diff options
-rw-r--r-- | gdb/testsuite/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/testsuite/gdb.threads/multiple-step-overs.c | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.threads/multiple-step-overs.exp | 80 |
3 files changed, 88 insertions, 14 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 234a0b0..c671c2f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,20 @@ 2015-04-08 Pedro Alves <palves@redhat.com> + PR gdb/18214 + PR gdb/18216 + * gdb.threads/multiple-step-overs.c (sigusr1_handler): New + function. + (main): Install it as SIGUSR1 handler. + * gdb.threads/multiple-step-overs.exp (setup): Remove 'prefix' + parameter. Always use "setup" as prefix. Toggle "set + displaced-stepping" off/on depending on global. Don't switch to + thread 1 here. + (top level): Add displaced stepping "off/on" test axis. Update + "setup" calls. Wrap each subtest with with_test_prefix. Test + continuing with a queued signal in each thread. + +2015-04-08 Pedro Alves <palves@redhat.com> + * gdb.trace/actions.exp: Use gdb_load before gdb_run_cmd. * gdb.trace/infotrace.exp: Use gdb_load before gdb_run_cmd. Use gdb_breakpoint instead of gdb_test that doesn't expect anything. diff --git a/gdb/testsuite/gdb.threads/multiple-step-overs.c b/gdb/testsuite/gdb.threads/multiple-step-overs.c index 87d292f5e..3a0142d 100644 --- a/gdb/testsuite/gdb.threads/multiple-step-overs.c +++ b/gdb/testsuite/gdb.threads/multiple-step-overs.c @@ -26,6 +26,11 @@ pthread_barrier_t barrier; pthread_t child_thread_2, child_thread_3; void +sigusr1_handler (int signo) +{ +} + +void callme (void) { } @@ -76,6 +81,8 @@ main () int res; long i; + signal (SIGUSR1, sigusr1_handler); + /* Call these early so that PLTs for these are resolved soon, instead of in the threads. RTLD_NOW should work as well. */ usleep (0); diff --git a/gdb/testsuite/gdb.threads/multiple-step-overs.exp b/gdb/testsuite/gdb.threads/multiple-step-overs.exp index 3d54ac2..bfa4ad1 100644 --- a/gdb/testsuite/gdb.threads/multiple-step-overs.exp +++ b/gdb/testsuite/gdb.threads/multiple-step-overs.exp @@ -29,19 +29,21 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -# Prepare environment for test. PREFIX is used as prefix in test -# messages. +# Prepare environment for test. -proc setup { prefix } { +proc setup {} { global executable + global displaced - with_test_prefix $prefix { + with_test_prefix "setup" { clean_restart $executable if ![runto_main] { return -1 } + gdb_test_no_output "set displaced-stepping $displaced" + gdb_breakpoint [gdb_get_line_number "set wait-threads breakpoint here"] gdb_continue_to_breakpoint "run to breakpoint" gdb_test "info threads" "3 .* 2 .*\\\* 1.*" "info threads shows all threads" @@ -59,8 +61,7 @@ proc setup { prefix } { gdb_continue_to_breakpoint "run to breakpoint in thread 2" gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 2" - # Switch back to thread 1 and disable scheduler locking. - gdb_test "thread 1" "Switching.*" + # Disable scheduler locking. gdb_test_no_output "set scheduler-locking off" # Now all 3 threads are stopped for a breakpoint that needs to @@ -68,13 +69,64 @@ proc setup { prefix } { } } -setup "step" -gdb_test "step" "in wait_threads .*" +foreach displaced { "off" "on" } { + with_test_prefix "displaced=$displaced" { + with_test_prefix "step" { + setup + gdb_test "thread 1" "Switching.*" + gdb_test "step" "in wait_threads .*" + } + + with_test_prefix "next" { + setup + gdb_test "thread 1" "Switching.*" + gdb_test "next" "pthread_join.*" + } -setup "next" -gdb_test "set debug infrun 1" ".*" -gdb_test "next" "pthread_join.*" + with_test_prefix "continue" { + setup + gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"] + gdb_test "thread 1" "Switching.*" + gdb_test "continue" "EXIT_SUCCESS.*" + } -setup "continue" -gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"] -gdb_test "continue" "EXIT_SUCCESS.*" + # Try continuing with a queued signal in each of the threads + # (one at a time). Should stop at the signal handler, instead + # of re-trapping the breakpoint the threads were already + # stopped at. + foreach thread {1 2 3} { + with_test_prefix "signal thr$thread" { + setup + + # Queue a signal in THREAD. + gdb_test "thread $thread" "Switching.*" + gdb_test_no_output "queue-signal SIGUSR1" + + # Switch back to thread 1, and continue. + gdb_test "thread 1" "Switching.*" "switch back to thread 1" + gdb_breakpoint "sigusr1_handler" "set break at sigusr1_handler" + + set msg "continue to sigusr1_handler" + gdb_test_multiple "continue" $msg { + -re "Breakpoint .* sigusr1_handler .*$gdb_prompt $" { + pass $msg + } + -re "Breakpoint .*$gdb_prompt $" { + if {![can_single_step_to_signal_handler] + && $thread != 1 && $displaced == "off"} { + setup_kfail "gdb/18214" "*-*-*" + } + fail $msg + } + eof { + if {[can_single_step_to_signal_handler] + && $displaced == "on"} { + setup_kfail "gdb/18216" "*-*-*" + } + fail $msg + } + } + } + } + } +} |