global gdb_prompt
global binfile
- # The --pid option is used to attach to a process using the native target.
- # Start GDB and run to main just to see what the execution target is, skip
- # if it's not the native target.
- clean_restart $binfile
-
- if { ![runto_main] } {
- return
- }
-
- if { ![gdb_is_target_native] } {
+ # The --pid option is used to attach to a process using the native
+ # target.
+ if { ![gdb_protocol_is_native] } {
unsupported "commandline attach run test"
return
}
return
}
- set target_is_native [gdb_is_target_native]
-
# Set the follow-exec mode.
#
gdb_test_no_output "set follow-exec-mode $mode"
# process target, which was automatically pushed when running, was
# automatically unpushed from inferior 1 on exec. Use a
# different regexp that verifies the Connection field is empty.
- if { $target_is_native } {
+ if { [gdb_protocol_is_native] } {
set expected_re " 1.*<null> +[string_to_regexp $binfile].*\r\n\\* 2.*process.*$testfile2 .*"
} else {
set expected_re " 1.*null.*$testfile.*\r\n\\* 2.*process.*$testfile2 .*"
standard_testfile
+if [gdb_protocol_is_native] {
+ unsupported "the native target does not support the load command"
+ return
+}
+
# Disable generation of position independent executable (PIE). Otherwise, we
# would have to manually specify an offset to load.
return -1
}
-# The native target does not support the load command.
-if [gdb_is_target_native] {
- unsupported "the native target does not support the load command"
- return
-}
-
# Manually change the value of the_variable.
gdb_test "print/x the_variable" " = 0x1234" "check initial value of the_variable"
gdb_test_no_output "set the_variable = 0x5555" "manually change the_variable"
# Test that in all-stop mode with multiple inferiors, GDB stops all
# threads upon receiving an exit event from one of the inferiors.
+# This is a test specific for a native target, where we use the
+# "-exec" argument to "add-inferior" and we explicitly don't do
+# "maint set target-non-stop on".
+if {![gdb_protocol_is_native]} {
+ untested "the test is aimed at a native target"
+ return 0
+}
+
standard_testfile
if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-# This is a test specific for a native target, where we use the
-# "-exec" argument to "add-inferior" and we explicitly don't do
-# "maint set target-non-stop on".
-if {![gdb_is_target_native]} {
- untested "the test is aimed at a native target"
- return 0
-}
-
# Add a second inferior that will sleep longer.
gdb_test "add-inferior -exec $binfile" "Added inferior 2.*" \
"add the second inferior"
gdb_test "py print (gdb.selected_inferior().connection.num)" "1" \
"first inferior's connection number, though connection object"
# Figure out if inf 1 has a native target.
- set inf_1_is_native [gdb_is_target_native]
+ set inf_1_is_native [gdb_protocol_is_native]
set num [add_inferior "-no-connection"]
gdb_test "inferior $num" ".*" "switch to inferior $num"
# leader detection racy") this isn't always thread 1.1.
set cur_thr [get_integer_valueof "\$_thread" 0]
- if {[istarget *-*-linux*] && [gdb_is_target_native]} {
+ if {[istarget *-*-linux*] && [gdb_protocol_is_native]} {
# Confirm there's only one LWP in the list as well, and that
# it is bound to the existing GDB thread.
set inf_pid [get_inferior_pid]
# Check whether we're testing with the remote or extended-remote
# targets.
#
+# This is meant to be used on testcases that connect to targets
+# different from the default board protocol. For most tests, you can
+# check whether gdb_protocol is "remote" or "extended-remote" instead.
+#
# NOTE: GDB must be running BEFORE this procedure is called!
proc gdb_is_target_remote { } {
# Check whether we're testing with the native target.
#
+# This is meant to be used on testcases that connect to targets
+# different from the default board protocol. For most tests, you can
+# check whether gdb_protocol is the empty string instead.
+#
# NOTE: GDB must be running BEFORE this procedure is called!
proc gdb_is_target_native { } {
return [gdb_is_target_1 "native" ".*native \\(Native process\\).*" "$gdb_prompt $"]
}
+# Returns true if gdb_protocol is empty, indicating use of the native
+# target.
+
+proc gdb_protocol_is_native { } {
+ return [expr {[target_info gdb_protocol] == ""}]
+}
+
# Like istarget, but checks a list of targets.
proc is_any_target {args} {
foreach targ $args {