From b5ee5a50d440d75556fbe9154e501331f9e1d3c7 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 30 Oct 2013 15:07:07 +0000 Subject: [PATCH] Fix gdb.threads/stepi-random-signal.exp on software single-step targets. Currently on software single-step Linux targets we get: (gdb) PASS: gdb.threads/stepi-random-signal.exp: before stepi: get hexadecimal valueof "$pc" stepi infrun: clear_proceed_status_thread (Thread 0x7ffff7fca700 (LWP 7073)) infrun: clear_proceed_status_thread (Thread 0x7ffff7fcb740 (LWP 7069)) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT, step=1) infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 7069)] at 0x400700 infrun: wait_for_inferior () infrun: target_wait (-1, status) = infrun: 7069 [Thread 0x7ffff7fcb740 (LWP 7069)], infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x400704 infrun: software single step trap for Thread 0x7ffff7fcb740 (LWP 7069) infrun: stepi/nexti infrun: stop_stepping 44 while (counter != 0) (gdb) FAIL: gdb.threads/stepi-random-signal.exp: stepi (no random signal) Vs hardware-step targets: (gdb) PASS: gdb.threads/stepi-random-signal.exp: before stepi: get hexadecimal valueof "$pc" stepi infrun: clear_proceed_status_thread (Thread 0x7ffff7fca700 (LWP 9565)) infrun: clear_proceed_status_thread (Thread 0x7ffff7fcb740 (LWP 9561)) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT, step=1) infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 9561)] at 0x400700 infrun: wait_for_inferior () infrun: target_wait (-1, status) = infrun: 9561 [Thread 0x7ffff7fcb740 (LWP 9561)], infrun: status->kind = stopped, signal = GDB_SIGNAL_CHLD infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x400700 infrun: random signal (GDB_SIGNAL_CHLD) infrun: random signal, keep going infrun: resume (step=1, signal=GDB_SIGNAL_CHLD), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 9561)] at 0x400700 infrun: prepare_to_wait infrun: target_wait (-1, status) = infrun: 9561 [Thread 0x7ffff7fcb740 (LWP 9561)], infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x400704 infrun: stepi/nexti infrun: stop_stepping 44 while (counter != 0) (gdb) PASS: gdb.threads/stepi-random-signal.exp: stepi The test turns on infrun debug, does a stepi while a SIGCHLD is pending, and checks whether the "random signal" paths in infrun.c are taken. On the software single-step variant above, those paths were not taken. This is a test bug. The Linux backend short-circuits reporting signals that are set to pass/nostop/noprint. But _only_ if the thread is _not_ single-stepping. So on hardware-step targets, even though the signal is set to pass/nostop/noprint by default, the thread is indeed told to single-step, and so the core sees the signal. On the other hand, on software single-step architectures, the backend never actually gets a single-step request (steps are emulated by setting a breakpoint at the next pc, and then the target told to continue, not step). So the short-circuiting code triggers and the core doesn't see the signal. The fix is to make the test be sure the target doesn't bypass reporting the signal to the core. Tested on x86_64 Fedora 17, both with and without a series that implements software single-step for x86_64. gdb/testsuite/ 2014-02-07 Pedro Alves * gdb.threads/stepi-random-signal.exp: Set SIGCHLD to print. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.threads/stepi-random-signal.exp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 13ccaf30df..89f879b459 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-02-07 Pedro Alves + + * gdb.threads/stepi-random-signal.exp: Set SIGCHLD to print. + 2014-02-06 Jan Kratochvil Fix i386-sse-stack-align.exp regression since GDB_PARALLEL. diff --git a/gdb/testsuite/gdb.threads/stepi-random-signal.exp b/gdb/testsuite/gdb.threads/stepi-random-signal.exp index d099c91be0..168b226ec8 100644 --- a/gdb/testsuite/gdb.threads/stepi-random-signal.exp +++ b/gdb/testsuite/gdb.threads/stepi-random-signal.exp @@ -56,6 +56,11 @@ delete_breakpoints # really dequeued and that GDB sees it. gdb_test_no_output "set debug infrun 1" +# Make sure the target backend reports the signal to GDB core. Some +# backends (like Linux) skip reporting a signal if set to +# pass/nostop/noprint, resuming the thread immediately instead. +gdb_test "handle SIGCHLD print" + # Helper to extract the current PC. PREFIX is used to make each call # have its own unique test name.