[RFC] mask off is-syscall bit for TRAP_IS_SYSCALL

Doug Evans dje@google.com
Mon Sep 28 19:39:00 GMT 2009


Hi.

On one system I use (bi-arch ubuntu-hardy clone),
i386-disp-step.exp is failing because the wait status
value linux_nat_wait_1 gets when hitting a system call is 0857f
which gets passed to the upper layers which then get confused
by a signal of 0x85 (== 0x80 | SIGTRAP).

This patch fixes things by masking off the 0x80 bit before
passing the signal number to up the call chain.

Ok to check in?

2009-09-28  Doug Evans  <dje@google.com>

	* linux-nat.c (TRAP_REMOVE_SYSCALL_FLAG): New macro.
	(linux_nat_wait_1): Mask off is-syscall bit in wait status for
	TRAP_IS_SYSCALL before passing value to caller.

Index: linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.148
diff -u -p -r1.148 linux-nat.c
--- linux-nat.c	28 Sep 2009 18:39:29 -0000	1.148
+++ linux-nat.c	28 Sep 2009 19:29:21 -0000
@@ -70,6 +70,7 @@
 /* To be used when one needs to know wether a
    WSTOPSIG (status) is a syscall */
 #define TRAP_IS_SYSCALL (SIGTRAP | 0x80)
+#define TRAP_REMOVE_SYSCALL_FLAG(status) ((status) & ~(0x80 << 8))
 
 /* This comment documents high-level logic of this file. 
 
@@ -3012,6 +3013,12 @@ retry:
 
 	  lp = linux_nat_filter_event (lwpid, status, options);
 
+	  /* If this was a syscall trap, we no longer need or want
+	     the 0x80 flag, remove it.  */
+	  if (WIFSTOPPED (status)
+	      && WSTOPSIG (status) == TRAP_IS_SYSCALL)
+	    status = TRAP_REMOVE_SYSCALL_FLAG (status);
+
 	  if (lp
 	      && ptid_is_pid (ptid)
 	      && ptid_get_pid (lp->ptid) != ptid_get_pid (ptid))



More information about the Gdb-patches mailing list