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]

Re: [patch 1/4]#3 Pedro's fix: compat_siginfo_from_siginfo (PR 11842)


On Tuesday 21 September 2010 23:49:10, Jan Kratochvil wrote:

> compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
> http://sourceware.org/bugzilla/show_bug.cgi?id=11842

I've applied this patch, which in addition swaps the SI_TIMER
branches over the si_code < 0 ones, because SI_TIMER is < 0, as
mentioned on the PR.  Mainly pedantic, as the effect ends up the
same.

> I guess the fix is not complete and that (at least; but maybe only) si_utime
> and si_stime may be lost during the conversion already in Linux kernel.
> Just I failed to get any meaningful value for non-converting x86_64-x86_64
> testcase.  I also could not google out any code using si_utime / si_stime.
> This patch is at least an incremental non-regressing fix.

It would be much saner if the kernel had PTRACE_GETSIGINFO/PTRACE_SETSIGINFO
variants that exposed the siginfo in the layout of the inferior (in the same
vein of PTRACE_GETREGSET), instead of gdb having to try to duplicate what
the compat layer of the kernel does...

-- 
Pedro Alves

2010-09-24  Pedro Alves  <pedro@codesourcery.com>

	PR gdb/11842

	gdb/
	* amd64-linux-nat.c (compat_siginfo_from_siginfo)
	(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
	si_code is < 0.  Check for si_code == SI_TIMER before checking for
	si_code < 0.

	gdb/gdbserver/
	* linux-x86-low.c (compat_siginfo_from_siginfo)
	(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
	si_code is < 0.  Check for si_code == SI_TIMER before checking for
	si_code < 0.

---
 gdb/amd64-linux-nat.c         |   20 ++++++++++++--------
 gdb/gdbserver/linux-x86-low.c |   20 ++++++++++++--------
 2 files changed, 24 insertions(+), 16 deletions(-)

Index: src/gdb/amd64-linux-nat.c
===================================================================
--- src.orig/gdb/amd64-linux-nat.c	2010-09-24 13:02:58.000000000 +0100
+++ src/gdb/amd64-linux-nat.c	2010-09-24 14:37:26.000000000 +0100
@@ -574,8 +574,10 @@ compat_siginfo_from_siginfo (compat_sigi
   to->si_errno = from->si_errno;
   to->si_code = from->si_code;
 
-  if (to->si_code < 0)
+  if (to->si_code == SI_TIMER)
     {
+      to->cpt_si_timerid = from->si_timerid;
+      to->cpt_si_overrun = from->si_overrun;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -583,10 +585,10 @@ compat_siginfo_from_siginfo (compat_sigi
       to->cpt_si_pid = from->si_pid;
       to->cpt_si_uid = from->si_uid;
     }
-  else if (to->si_code == SI_TIMER)
+  else if (to->si_code < 0)
     {
-      to->cpt_si_timerid = from->si_timerid;
-      to->cpt_si_overrun = from->si_overrun;
+      to->cpt_si_pid = from->si_pid;
+      to->cpt_si_uid = from->si_uid;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else
@@ -628,8 +630,10 @@ siginfo_from_compat_siginfo (siginfo_t *
   to->si_errno = from->si_errno;
   to->si_code = from->si_code;
 
-  if (to->si_code < 0)
+  if (to->si_code == SI_TIMER)
     {
+      to->si_timerid = from->cpt_si_timerid;
+      to->si_overrun = from->cpt_si_overrun;
       to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -637,10 +641,10 @@ siginfo_from_compat_siginfo (siginfo_t *
       to->si_pid = from->cpt_si_pid;
       to->si_uid = from->cpt_si_uid;
     }
-  else if (to->si_code == SI_TIMER)
+  if (to->si_code < 0)
     {
-      to->si_timerid = from->cpt_si_timerid;
-      to->si_overrun = from->cpt_si_overrun;
+      to->si_pid = from->cpt_si_pid;
+      to->si_uid = from->cpt_si_uid;
       to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
     }
   else
Index: src/gdb/gdbserver/linux-x86-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-x86-low.c	2010-09-24 13:02:58.000000000 +0100
+++ src/gdb/gdbserver/linux-x86-low.c	2010-09-24 14:37:41.000000000 +0100
@@ -792,8 +792,10 @@ compat_siginfo_from_siginfo (compat_sigi
   to->si_errno = from->si_errno;
   to->si_code = from->si_code;
 
-  if (to->si_code < 0)
+  if (to->si_code == SI_TIMER)
     {
+      to->cpt_si_timerid = from->si_timerid;
+      to->cpt_si_overrun = from->si_overrun;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -801,10 +803,10 @@ compat_siginfo_from_siginfo (compat_sigi
       to->cpt_si_pid = from->si_pid;
       to->cpt_si_uid = from->si_uid;
     }
-  else if (to->si_code == SI_TIMER)
+  else if (to->si_code < 0)
     {
-      to->cpt_si_timerid = from->si_timerid;
-      to->cpt_si_overrun = from->si_overrun;
+      to->cpt_si_pid = from->si_pid;
+      to->cpt_si_uid = from->si_uid;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else
@@ -846,8 +848,10 @@ siginfo_from_compat_siginfo (siginfo_t *
   to->si_errno = from->si_errno;
   to->si_code = from->si_code;
 
-  if (to->si_code < 0)
+  if (to->si_code == SI_TIMER)
     {
+      to->si_timerid = from->cpt_si_timerid;
+      to->si_overrun = from->cpt_si_overrun;
       to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -855,10 +859,10 @@ siginfo_from_compat_siginfo (siginfo_t *
       to->si_pid = from->cpt_si_pid;
       to->si_uid = from->cpt_si_uid;
     }
-  else if (to->si_code == SI_TIMER)
+  else if (to->si_code < 0)
     {
-      to->si_timerid = from->cpt_si_timerid;
-      to->si_overrun = from->cpt_si_overrun;
+      to->si_pid = from->cpt_si_pid;
+      to->si_uid = from->cpt_si_uid;
       to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
     }
   else


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