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 4/9]#2 Pedro's fix: compat_siginfo_from_siginfo (PR 11842)


Hi,

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

So far GDB always kept siginfo_t in the host format.  That is on native amd64
box running i386 inferior GDB operated with siginfo_t in the amd64 format. The
conversion is being done by kernel during PTRACE_GETSIGINFO and
PTRACE_SETSIGINFO.

Now GDB always keeps siginfo in the target format (that is in i386 format on
amd64 native host running i386 inferior).  I find it more clear in the generic
(infrun.c etc.) code to always have siginfo in the target format, no matter if
it comes from a local inferior or a remote one (which may be handled
simultaneously in the future).

But that also means GDB has to convert now siginfo_t back and forth during all
the operations of amd64 host gdb and i386 inferior.  As the GDB-side
conversion had a bug before it affected some $_siginfo accesses but now it
breaks the normal inferior run.

If siginfo_fixup is not supported by specific *-nat.c architecture it works as
it is (incorrectly) kept always in the host format.


Thanks,
Jan


gdb/
2010-08-06  Pedro Alves  <pedro@codesourcery.com>

	* amd64-linux-nat.c (compat_siginfo_from_siginfo)
	(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
	si_code is < 0.

gdb/gdbserver/
2010-08-06  Pedro Alves  <pedro@codesourcery.com>

	* linux-x86-low.c (compat_siginfo_from_siginfo)
	(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
	si_code is < 0.

--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -576,6 +576,8 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
 
   if (to->si_code < 0)
     {
+      to->cpt_si_pid = from->si_pid;
+      to->cpt_si_uid = from->si_uid;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -630,6 +632,8 @@ siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
 
   if (to->si_code < 0)
     {
+      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 if (to->si_code == SI_USER)
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -794,6 +794,8 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
 
   if (to->si_code < 0)
     {
+      to->cpt_si_pid = from->si_pid;
+      to->cpt_si_uid = from->si_uid;
       to->cpt_si_ptr = (intptr_t) from->si_ptr;
     }
   else if (to->si_code == SI_USER)
@@ -848,6 +850,8 @@ siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
 
   if (to->si_code < 0)
     {
+      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 if (to->si_code == SI_USER)


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