This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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  <palves@redhat.com>

	* 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 13ccaf3..89f879b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-02-07  Pedro Alves  <palves@redhat.com>
+
+	* gdb.threads/stepi-random-signal.exp: Set SIGCHLD to print.
+
 2014-02-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	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 d099c91..168b226 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.
 
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]