@@ -48,10 +48,16 @@ load_lib mi-support.exp
# GDB is started. Note nothing is needed for gdb_exit, since
# gdbserver is started with --once, causing it to exit once GDB
# disconnects.
-proc gdb_start { } {
+proc gdb_start { {stop_mode "all-stop"} } {
# Spawn GDB.
default_gdb_start
+ # Non-stop mode must be set before connecting to gdbserver for it
+ # to be enabled in gdbserver, so we set non-stop here.
+ if { $stop_mode == "non-stop" } then {
+ gdb_test_no_output "set non-stop on" "enable non-stop mode"
+ }
+
# And then GDBserver, ready for extended-remote mode.
gdbserver_start_multi
@@ -68,6 +68,13 @@ proc zap_session {} {
-re ".*$gdb_prompt $" {}
timeout { fail "killing inferior (timeout)" ; return }
}
+
+ # For remote targets the 'file' command doesn't change the exec-file,
+ # as it does for native targets. In the remote case we must also use
+ # 'set remote exec-file'.
+ if [gdb_is_target_remote] then {
+ gdb_test_no_output "set remote exec-file $binfile" "reset remote exec-file to original file"
+ }
}
proc do_exec_tests {} {
@@ -16,6 +16,9 @@
# The problem was due to amd64_skip_prologue attempting to access inferior
# memory before the PIE (Position Independent Executable) gets relocated.
+global inferior_spawn_id
+global gdb_spawn_id
+
if ![istarget *-linux*] {
continue
}
@@ -67,6 +70,7 @@ gdb_test_multiple "p/x &pie_execl_marker" $test {
verbose -log "addr1 is $addr1"
set test "continue"
+set matches_found 0
gdb_test_multiple $test $test {
-re "Error in re-setting breakpoint" {
fail $test
@@ -74,8 +78,24 @@ gdb_test_multiple $test $test {
-re "Cannot access memory" {
fail $test
}
- -re "pie-execl: re-exec.*executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" {
- pass $test
+ -i "$inferior_spawn_id" -re "pie-execl: re-exec" {
+ # output from inferior
+ incr matches_found
+ if { $matches_found == 2 } {
+ pass $test
+ } else {
+ exp_continue
+ }
+ }
+ -i "$gdb_spawn_id"
+ -re "executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" {
+ # output from gdb
+ incr matches_found
+ if { $matches_found == 2 } {
+ pass $test
+ } else {
+ exp_continue
+ }
}
}
@@ -28,11 +28,11 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-proc do_test { lock_sched } {
- with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+ with_test_prefix "lock-sched$lock_sched,$stop_mode" {
global executable
- clean_restart ${executable}
+ clean_restart ${executable} $stop_mode
if ![runto_main] {
return -1
@@ -48,11 +48,17 @@ proc do_test { lock_sched } {
gdb_test_no_output "set scheduler-locking on"
}
+ if { $stop_mode == "non-stop" } {
+ gdb_test "thread 2" "Switching.*"
+ }
+
gdb_test "continue" \
".*is executing new program.*Breakpoint 1, main.* at .*" \
"continue over exec"
}
}
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
@@ -29,18 +29,26 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-proc do_test { lock_sched } {
- with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+ with_test_prefix "lock-sched$lock_sched,$stop_mode" {
global executable
- clean_restart ${executable}
+ clean_restart ${executable} $stop_mode
if ![runto_main] {
return -1
}
gdb_breakpoint [gdb_get_line_number "break-here"]
- gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+ gdb_test_multiple "continue" "continue to breakpoint" {
+ -re ".*Breakpoint.*break-here.*" {
+ pass "continue to breakpoint"
+ }
+ }
+
+ if { $stop_mode == "non-stop" } {
+ gdb_test "thread 2" "Switching.*"
+ }
gdb_test "info threads" \
"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
@@ -59,5 +67,7 @@ proc do_test { lock_sched } {
}
}
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
@@ -31,18 +31,22 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-proc do_test { lock_sched } {
- with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+ with_test_prefix "lock-sched$lock_sched,$stop_mode" {
global executable
- clean_restart ${executable}
+ clean_restart ${executable} $stop_mode
if ![runto_main] {
return -1
}
gdb_breakpoint [gdb_get_line_number "break-here"]
- gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+ gdb_test_multiple "continue" "continue to breakpoint" {
+ -re ".*Breakpoint.*break-here.*" {
+ pass "continue to breakpoint"
+ }
+ }
# Also test with sched-lock to make sure we can follow the
# non-leader thread execing even though the main thread wasn't
@@ -51,11 +55,17 @@ proc do_test { lock_sched } {
gdb_test_no_output "set scheduler-locking on"
}
+ if { $stop_mode == "non-stop" } {
+ gdb_test "thread 2" "Switching.*"
+ }
+
gdb_test "continue" \
".*is executing new program.*Breakpoint 1, main.* at .*" \
"continue over exec"
}
}
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
@@ -30,11 +30,11 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-proc do_test { lock_sched } {
- with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+ with_test_prefix "lock-sched$lock_sched,$stop_mode" {
global executable
- clean_restart ${executable}
+ clean_restart ${executable} $stop_mode
if ![runto_main] {
return -1
@@ -50,11 +50,17 @@ proc do_test { lock_sched } {
gdb_test_no_output "set scheduler-locking on"
}
+ if { $stop_mode == "non-stop" } {
+ gdb_test "thread 2" "Switching.*"
+ }
+
gdb_test "continue" \
".*is executing new program.*Breakpoint 1, main.* at .*" \
"continue over exec"
}
}
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
@@ -3694,8 +3694,11 @@ proc gdb_spawn_with_cmdline_opts { cmdline_flags } {
# Overridable function -- you can override this function in your
# baseboard file.
-proc gdb_start { } {
+proc gdb_start { {stop_mode "all-stop"} } {
default_gdb_start
+ if { $stop_mode == "non-stop" } {
+ gdb_test_no_output "set non-stop on" "enable non-stop mode"
+ }
}
proc gdb_exit { } {
@@ -4963,23 +4966,19 @@ proc build_executable { testname executable {sources ""} {options {debug}} } {
}
# Starts fresh GDB binary and loads an optional executable into GDB.
-# Usage: clean_restart [executable]
+# Usage: clean_restart [executable [mode]]
# EXECUTABLE is the basename of the binary.
+# If MODE is "non-stop", then non-stop mode will be enabled.
-proc clean_restart { args } {
+proc clean_restart { {executable ""} {stop_mode "all-stop"} } {
global srcdir
global subdir
- if { [llength $args] > 1 } {
- error "bad number of args: [llength $args]"
- }
-
gdb_exit
- gdb_start
+ gdb_start $stop_mode
gdb_reinitialize_dir $srcdir/$subdir
- if { [llength $args] >= 1 } {
- set executable [lindex $args 0]
+ if { $executable != "" } {
set binfile [standard_output_file ${executable}]
gdb_load ${binfile}
}