* [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo.
@ 2015-12-17 16:57 Walfred Tedeschi
2015-12-17 16:57 ` [PATCH V2 2/5] Preparation for new siginfo on Linux Walfred Tedeschi
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Walfred Tedeschi @ 2015-12-17 16:57 UTC (permalink / raw)
To: palves, brobecker; +Cc: gdb-patches, Walfred Tedeschi
The compatible siginfo handling from amd64-linux-nat.c and
gdbserver/linux-x86-low were extracted it into a new file
nat/amd64-linux-siginfo.c.
2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
* nat/amd64-linux-siginfo.c: New file.
* nat/amd64-linux-siginfo.h: New file.
* Makefile.in (HFILES_NO_SRCDIR): Add new header to
HFILES_NO_SRCDIR. Add native object files rule for
amd64-linux-siginfo.o
* config/i386/linux64.mh (NATDEPFILES): Add amd64-linux-siginfo.o.
* amd64-linux-nat.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo, compat_x32_siginfo_from_siginfo)
(siginfo_from_compat_x32_siginfo and collateral structures): Move
to nat/amd64-linux-siginfo.c.
gdbserver
* configure.srv (srv_tgtobj): Add amd64-linux-siginfo.o.
* linux-x86-low.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo, compat_x32_siginfo_from_siginfo)
(siginfo_from_compat_x32_siginfo and collateral structures): Move
to nat/amd64-linux-siginfo.c.
* Makefile.in (x86_64-*-linux*): Add amd64-linux-siginfo.o.
---
gdb/Makefile.in | 6 +-
gdb/amd64-linux-nat.c | 431 +-------------------------------------
gdb/config/i386/linux64.mh | 2 +-
gdb/gdbserver/Makefile.in | 3 +
gdb/gdbserver/configure.srv | 1 +
gdb/gdbserver/linux-x86-low.c | 423 +------------------------------------
gdb/nat/amd64-linux-siginfo.c | 469 ++++++++++++++++++++++++++++++++++++++++++
gdb/nat/amd64-linux-siginfo.h | 48 +++++
8 files changed, 540 insertions(+), 843 deletions(-)
create mode 100644 gdb/nat/amd64-linux-siginfo.c
create mode 100644 gdb/nat/amd64-linux-siginfo.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3eadbbc..21d74fb 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -985,7 +985,7 @@ i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
common/common-exceptions.h target/target.h common/symbol.h \
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
-common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h \
+common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h nat/amd64-linux-siginfo.h \
nat/linux-namespaces.h arch/arm.h common/gdb_sys_time.h arch/aarch64-insn.h
# Header files that already have srcdir in them, or which are in objdir.
@@ -2335,6 +2335,10 @@ x86-linux-dregs.o: ${srcdir}/nat/x86-linux-dregs.c
$(COMPILE) $(srcdir)/nat/x86-linux-dregs.c
$(POSTCOMPILE)
+amd64-linux-siginfo.o: ${srcdir}/nat/amd64-linux-siginfo.c
+ $(COMPILE) $(srcdir)/nat/amd64-linux-siginfo.c
+ $(POSTCOMPILE)
+
linux-namespaces.o: ${srcdir}/nat/linux-namespaces.c
$(COMPILE) $(srcdir)/nat/linux-namespaces.c
$(POSTCOMPILE)
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 397f664..11da12c 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -38,6 +38,7 @@
#include "x86-linux-nat.h"
#include "nat/linux-ptrace.h"
+#include "nat/amd64-linux-siginfo.h"
/* Mapping between the general-purpose registers in GNU/Linux x86-64
`struct user' format and GDB's register cache layout for GNU/Linux
@@ -320,409 +321,6 @@ ps_get_thread_area (const struct ps_prochandle *ph,
}
\f
-/* When GDB is built as a 64-bit application on linux, the
- PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
- debugging a 32-bit inferior with a 64-bit GDB should look the same
- as debugging it with a 32-bit GDB, we do the 32-bit <-> 64-bit
- conversion in-place ourselves. */
-
-/* These types below (compat_*) define a siginfo type that is layout
- compatible with the siginfo type exported by the 32-bit userspace
- support. */
-
-typedef int compat_int_t;
-typedef unsigned int compat_uptr_t;
-
-typedef int compat_time_t;
-typedef int compat_timer_t;
-typedef int compat_clock_t;
-
-struct compat_timeval
-{
- compat_time_t tv_sec;
- int tv_usec;
-};
-
-typedef union compat_sigval
-{
- compat_int_t sival_int;
- compat_uptr_t sival_ptr;
-} compat_sigval_t;
-
-typedef struct compat_siginfo
-{
- int si_signo;
- int si_errno;
- int si_code;
-
- union
- {
- int _pad[((128 / sizeof (int)) - 3)];
-
- /* kill() */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- } _kill;
-
- /* POSIX.1b timers */
- struct
- {
- compat_timer_t _tid;
- int _overrun;
- compat_sigval_t _sigval;
- } _timer;
-
- /* POSIX.1b signals */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- compat_sigval_t _sigval;
- } _rt;
-
- /* SIGCHLD */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- int _status;
- compat_clock_t _utime;
- compat_clock_t _stime;
- } _sigchld;
-
- /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
- struct
- {
- unsigned int _addr;
- } _sigfault;
-
- /* SIGPOLL */
- struct
- {
- int _band;
- int _fd;
- } _sigpoll;
- } _sifields;
-} compat_siginfo_t;
-
-/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
-typedef struct compat_x32_clock
-{
- int lower;
- int upper;
-} compat_x32_clock_t;
-
-typedef struct compat_x32_siginfo
-{
- int si_signo;
- int si_errno;
- int si_code;
-
- union
- {
- int _pad[((128 / sizeof (int)) - 3)];
-
- /* kill() */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- } _kill;
-
- /* POSIX.1b timers */
- struct
- {
- compat_timer_t _tid;
- int _overrun;
- compat_sigval_t _sigval;
- } _timer;
-
- /* POSIX.1b signals */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- compat_sigval_t _sigval;
- } _rt;
-
- /* SIGCHLD */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- int _status;
- compat_x32_clock_t _utime;
- compat_x32_clock_t _stime;
- } _sigchld;
-
- /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
- struct
- {
- unsigned int _addr;
- } _sigfault;
-
- /* SIGPOLL */
- struct
- {
- int _band;
- int _fd;
- } _sigpoll;
- } _sifields;
-} compat_x32_siginfo_t;
-
-#define cpt_si_pid _sifields._kill._pid
-#define cpt_si_uid _sifields._kill._uid
-#define cpt_si_timerid _sifields._timer._tid
-#define cpt_si_overrun _sifields._timer._overrun
-#define cpt_si_status _sifields._sigchld._status
-#define cpt_si_utime _sifields._sigchld._utime
-#define cpt_si_stime _sifields._sigchld._stime
-#define cpt_si_ptr _sifields._rt._sigval.sival_ptr
-#define cpt_si_addr _sifields._sigfault._addr
-#define cpt_si_band _sifields._sigpoll._band
-#define cpt_si_fd _sifields._sigpoll._fd
-
-/* glibc at least up to 2.3.2 doesn't have si_timerid, si_overrun.
- In their place is si_timer1,si_timer2. */
-#ifndef si_timerid
-#define si_timerid si_timer1
-#endif
-#ifndef si_overrun
-#define si_overrun si_timer2
-#endif
-
-static void
-compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- to->cpt_si_utime = from->si_utime;
- to->cpt_si_stime = from->si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
- break;
- case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
- break;
- default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
- break;
- }
- }
-}
-
-static void
-siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- }
- 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- to->si_utime = from->cpt_si_utime;
- to->si_stime = from->cpt_si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
- break;
- case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
- break;
- default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
- break;
- }
- }
-}
-
-static void
-compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
- siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- memcpy (&to->cpt_si_utime, &from->si_utime,
- sizeof (to->cpt_si_utime));
- memcpy (&to->cpt_si_stime, &from->si_stime,
- sizeof (to->cpt_si_stime));
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
- break;
- case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
- break;
- default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
- break;
- }
- }
-}
-
-static void
-siginfo_from_compat_x32_siginfo (siginfo_t *to,
- compat_x32_siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- }
- 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- memcpy (&to->si_utime, &from->cpt_si_utime,
- sizeof (to->si_utime));
- memcpy (&to->si_stime, &from->cpt_si_stime,
- sizeof (to->si_stime));
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
- break;
- case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
- break;
- default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
- break;
- }
- }
-}
-
/* Convert a native/host siginfo object, into/from the siginfo in the
layout of the inferiors' architecture. Returns true if any
conversion was done; false otherwise. If DIRECTION is 1, then copy
@@ -737,34 +335,15 @@ amd64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
/* Is the inferior 32-bit? If so, then do fixup the siginfo
object. */
if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
- {
- gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
-
- if (direction == 0)
- compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
- else
- siginfo_from_compat_siginfo (native, (struct compat_siginfo *) inf);
-
- return 1;
- }
+ return amd64_linux_siginfo_fixup_common (native, inf , direction,
+ FIXUP_32);
/* No fixup for native x32 GDB. */
else if (gdbarch_addr_bit (gdbarch) == 32 && sizeof (void *) == 8)
- {
- gdb_assert (sizeof (siginfo_t) == sizeof (compat_x32_siginfo_t));
-
- if (direction == 0)
- compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,
- native);
- else
- siginfo_from_compat_x32_siginfo (native,
- (struct compat_x32_siginfo *) inf);
-
- return 1;
- }
+ return amd64_linux_siginfo_fixup_common (native, inf , direction,
+ FIXUP_X32);
else
return 0;
}
-\f
/* Provide a prototype to silence -Wmissing-prototypes. */
void _initialize_amd64_linux_nat (void);
diff --git a/gdb/config/i386/linux64.mh b/gdb/config/i386/linux64.mh
index 04cbb95..42d8df5 100644
--- a/gdb/config/i386/linux64.mh
+++ b/gdb/config/i386/linux64.mh
@@ -6,7 +6,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
proc-service.o linux-thread-db.o linux-fork.o \
linux-procfs.o linux-ptrace.o linux-btrace.o \
linux-waitpid.o linux-personality.o x86-linux.o \
- x86-linux-dregs.o linux-namespaces.o
+ x86-linux-dregs.o amd64-linux-siginfo.o linux-namespaces.o
NAT_FILE= config/nm-linux.h
NAT_CDEPS = $(srcdir)/proc-service.list
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index f18243b..37365e4 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -595,6 +595,9 @@ arm.o: ../arch/arm.c
x86-dregs.o: ../nat/x86-dregs.c
$(COMPILE) $<
$(POSTCOMPILE)
+amd64-linux-siginfo.o: ../nat/amd64-linux-siginfo.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
linux-btrace.o: ../nat/linux-btrace.c
$(COMPILE) $<
$(POSTCOMPILE)
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index e854110..542d373 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -336,6 +336,7 @@ case "${target}" in
srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o"
+ srv_tgtobj="${srv_tgtobj} amd64-linux-siginfo.o"
srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
srv_linux_usrregs=yes # This is for i386 progs.
srv_linux_regsets=yes
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 18adf5e..6b3ed5f 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -27,6 +27,10 @@
#include "x86-xstate.h"
#include "nat/gdb_ptrace.h"
+#ifdef __x86_64__
+#include "nat/amd64-linux-siginfo.h"
+#endif
+
#include "gdb_proc_service.h"
/* Don't include elf/common.h if linux/elf.h got included by
gdb_proc_service.h. */
@@ -670,399 +674,6 @@ x86_debug_reg_state (pid_t pid)
as debugging it with a 32-bit GDBSERVER, we do the 32-bit <-> 64-bit
conversion in-place ourselves. */
-/* These types below (compat_*) define a siginfo type that is layout
- compatible with the siginfo type exported by the 32-bit userspace
- support. */
-
-#ifdef __x86_64__
-
-typedef int compat_int_t;
-typedef unsigned int compat_uptr_t;
-
-typedef int compat_time_t;
-typedef int compat_timer_t;
-typedef int compat_clock_t;
-
-struct compat_timeval
-{
- compat_time_t tv_sec;
- int tv_usec;
-};
-
-typedef union compat_sigval
-{
- compat_int_t sival_int;
- compat_uptr_t sival_ptr;
-} compat_sigval_t;
-
-typedef struct compat_siginfo
-{
- int si_signo;
- int si_errno;
- int si_code;
-
- union
- {
- int _pad[((128 / sizeof (int)) - 3)];
-
- /* kill() */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- } _kill;
-
- /* POSIX.1b timers */
- struct
- {
- compat_timer_t _tid;
- int _overrun;
- compat_sigval_t _sigval;
- } _timer;
-
- /* POSIX.1b signals */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- compat_sigval_t _sigval;
- } _rt;
-
- /* SIGCHLD */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- int _status;
- compat_clock_t _utime;
- compat_clock_t _stime;
- } _sigchld;
-
- /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
- struct
- {
- unsigned int _addr;
- } _sigfault;
-
- /* SIGPOLL */
- struct
- {
- int _band;
- int _fd;
- } _sigpoll;
- } _sifields;
-} compat_siginfo_t;
-
-/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
-
-typedef struct compat_x32_siginfo
-{
- int si_signo;
- int si_errno;
- int si_code;
-
- union
- {
- int _pad[((128 / sizeof (int)) - 3)];
-
- /* kill() */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- } _kill;
-
- /* POSIX.1b timers */
- struct
- {
- compat_timer_t _tid;
- int _overrun;
- compat_sigval_t _sigval;
- } _timer;
-
- /* POSIX.1b signals */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- compat_sigval_t _sigval;
- } _rt;
-
- /* SIGCHLD */
- struct
- {
- unsigned int _pid;
- unsigned int _uid;
- int _status;
- compat_x32_clock_t _utime;
- compat_x32_clock_t _stime;
- } _sigchld;
-
- /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
- struct
- {
- unsigned int _addr;
- } _sigfault;
-
- /* SIGPOLL */
- struct
- {
- int _band;
- int _fd;
- } _sigpoll;
- } _sifields;
-} compat_x32_siginfo_t __attribute__ ((__aligned__ (8)));
-
-#define cpt_si_pid _sifields._kill._pid
-#define cpt_si_uid _sifields._kill._uid
-#define cpt_si_timerid _sifields._timer._tid
-#define cpt_si_overrun _sifields._timer._overrun
-#define cpt_si_status _sifields._sigchld._status
-#define cpt_si_utime _sifields._sigchld._utime
-#define cpt_si_stime _sifields._sigchld._stime
-#define cpt_si_ptr _sifields._rt._sigval.sival_ptr
-#define cpt_si_addr _sifields._sigfault._addr
-#define cpt_si_band _sifields._sigpoll._band
-#define cpt_si_fd _sifields._sigpoll._fd
-
-/* glibc at least up to 2.3.2 doesn't have si_timerid, si_overrun.
- In their place is si_timer1,si_timer2. */
-#ifndef si_timerid
-#define si_timerid si_timer1
-#endif
-#ifndef si_overrun
-#define si_overrun si_timer2
-#endif
-
-static void
-compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- to->cpt_si_utime = from->si_utime;
- to->cpt_si_stime = from->si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
- break;
- case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
- break;
- default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
- break;
- }
- }
-}
-
-static void
-siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- to->si_utime = from->cpt_si_utime;
- to->si_stime = from->cpt_si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
- break;
- case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
- break;
- default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
- break;
- }
- }
-}
-
-static void
-compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
- siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- to->cpt_si_utime = from->si_utime;
- to->cpt_si_stime = from->si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
- break;
- case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
- break;
- default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
- break;
- }
- }
-}
-
-static void
-siginfo_from_compat_x32_siginfo (siginfo_t *to,
- compat_x32_siginfo_t *from)
-{
- memset (to, 0, sizeof (*to));
-
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
-
- 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)
- {
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- }
- else 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
- {
- switch (to->si_signo)
- {
- case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- to->si_utime = from->cpt_si_utime;
- to->si_stime = from->cpt_si_stime;
- break;
- case SIGILL:
- case SIGFPE:
- case SIGSEGV:
- case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
- break;
- case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
- break;
- default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
- break;
- }
- }
-}
-
-#endif /* __x86_64__ */
-
/* Convert a native/host siginfo object, into/from the siginfo in the
layout of the inferiors' architecture. Returns true if any
conversion was done; false otherwise. If DIRECTION is 1, then copy
@@ -1079,30 +690,12 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction)
/* Is the inferior 32-bit? If so, then fixup the siginfo object. */
if (!is_64bit_tdesc ())
- {
- gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
-
- if (direction == 0)
- compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
- else
- siginfo_from_compat_siginfo (native, (struct compat_siginfo *) inf);
-
- return 1;
- }
+ return amd64_linux_siginfo_fixup_common (native, inf , direction,
+ FIXUP_32);
/* No fixup for native x32 GDB. */
else if (!is_elf64 && sizeof (void *) == 8)
- {
- gdb_assert (sizeof (siginfo_t) == sizeof (compat_x32_siginfo_t));
-
- if (direction == 0)
- compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,
- native);
- else
- siginfo_from_compat_x32_siginfo (native,
- (struct compat_x32_siginfo *) inf);
-
- return 1;
- }
+ return amd64_linux_siginfo_fixup_common (native, inf , direction,
+ FIXUP_X32);
#endif
return 0;
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
new file mode 100644
index 0000000..22e3552
--- /dev/null
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -0,0 +1,469 @@
+/* Low-level siginfo manipulation for amd64.
+
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include "common-defs.h"
+#include "amd64-linux-siginfo.h"
+
+/* When GDB is built as a 64-bit application on linux, the
+ PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
+ debugging a 32-bit inferior with a 64-bit GDB should look the same
+ as debugging it with a 32-bit GDB, we do the 32-bit <-> 64-bit
+ conversion in-place ourselves. With the presence of possible different
+ fields for host and target we have to guarantee that we use the
+ Also, the first step is to make a copy from the original bits to the
+ internal structure which is the super set. */
+
+
+/* These types below (compat_*) define a siginfo type that is layout
+ compatible with the siginfo type exported by the 32-bit userspace
+ support. */
+
+typedef int compat_int_t;
+typedef unsigned int compat_uptr_t;
+
+typedef int compat_time_t;
+typedef int compat_timer_t;
+typedef int compat_clock_t;
+
+struct compat_timeval
+{
+ compat_time_t tv_sec;
+ int tv_usec;
+};
+
+typedef union compat_sigval
+{
+ compat_int_t sival_int;
+ compat_uptr_t sival_ptr;
+} compat_sigval_t;
+
+typedef struct compat_siginfo
+{
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union
+ {
+ int _pad[((128 / sizeof (int)) - 3)];
+
+ /* kill() */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ } _kill;
+
+ /* POSIX.1b timers */
+ struct
+ {
+ compat_timer_t _tid;
+ int _overrun;
+ compat_sigval_t _sigval;
+ } _timer;
+
+ /* POSIX.1b signals */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ compat_sigval_t _sigval;
+ } _rt;
+
+ /* SIGCHLD */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ int _status;
+ compat_clock_t _utime;
+ compat_clock_t _stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+ struct
+ {
+ unsigned int _addr;
+ } _sigfault;
+
+ /* SIGPOLL */
+ struct
+ {
+ int _band;
+ int _fd;
+ } _sigpoll;
+ } _sifields;
+} compat_siginfo_t;
+
+/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
+typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
+
+typedef struct compat_x32_siginfo
+{
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union
+ {
+ int _pad[((128 / sizeof (int)) - 3)];
+
+ /* kill() */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ } _kill;
+
+ /* POSIX.1b timers */
+ struct
+ {
+ compat_timer_t _tid;
+ int _overrun;
+ compat_sigval_t _sigval;
+ } _timer;
+
+ /* POSIX.1b signals */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ compat_sigval_t _sigval;
+ } _rt;
+
+ /* SIGCHLD */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ int _status;
+ compat_x32_clock_t _utime;
+ compat_x32_clock_t _stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+ struct
+ {
+ unsigned int _addr;
+ } _sigfault;
+
+ /* SIGPOLL */
+ struct
+ {
+ int _band;
+ int _fd;
+ } _sigpoll;
+ } _sifields;
+} compat_x32_siginfo_t __attribute__ ((__aligned__ (8)));
+
+/* To simplify usage of siginfo fields. */
+
+#define cpt_si_pid _sifields._kill._pid
+#define cpt_si_uid _sifields._kill._uid
+#define cpt_si_timerid _sifields._timer._tid
+#define cpt_si_overrun _sifields._timer._overrun
+#define cpt_si_status _sifields._sigchld._status
+#define cpt_si_utime _sifields._sigchld._utime
+#define cpt_si_stime _sifields._sigchld._stime
+#define cpt_si_ptr _sifields._rt._sigval.sival_ptr
+#define cpt_si_addr _sifields._sigfault._addr
+#define cpt_si_band _sifields._sigpoll._band
+#define cpt_si_fd _sifields._sigpoll._fd
+
+/* glibc at least up to 2.3.2 doesn't have si_timerid, si_overrun.
+ In their place is si_timer1,si_timer2. */
+#ifndef si_timerid
+#define si_timerid si_timer1
+#endif
+#ifndef si_overrun
+#define si_overrun si_timer2
+#endif
+
+/* Converts the system provided siginfo into compatible siginfo. */
+static void
+compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
+{
+ memset (to, 0, sizeof (*to));
+
+ to->si_signo = from->si_signo;
+ to->si_errno = from->si_errno;
+ to->si_code = from->si_code;
+
+ 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)
+ {
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ }
+ else 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
+ {
+ switch (to->si_signo)
+ {
+ case SIGCHLD:
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ to->cpt_si_status = from->si_status;
+ to->cpt_si_utime = from->si_utime;
+ to->cpt_si_stime = from->si_stime;
+ break;
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ to->cpt_si_addr = (intptr_t) from->si_addr;
+ break;
+ case SIGPOLL:
+ to->cpt_si_band = from->si_band;
+ to->cpt_si_fd = from->si_fd;
+ break;
+ default:
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ to->cpt_si_ptr = (intptr_t) from->si_ptr;
+ break;
+ }
+ }
+}
+
+/* Converts the compatible siginfo into system siginfo. */
+static void
+siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
+{
+ memset (to, 0, sizeof (*to));
+
+ to->si_signo = from->si_signo;
+ to->si_errno = from->si_errno;
+ to->si_code = from->si_code;
+
+ 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)
+ {
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ }
+ 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
+ {
+ switch (to->si_signo)
+ {
+ case SIGCHLD:
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ to->si_status = from->cpt_si_status;
+ to->si_utime = from->cpt_si_utime;
+ to->si_stime = from->cpt_si_stime;
+ break;
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
+ break;
+ case SIGPOLL:
+ to->si_band = from->cpt_si_band;
+ to->si_fd = from->cpt_si_fd;
+ break;
+ default:
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
+ break;
+ }
+ }
+}
+
+/* Converts the system provided siginfo into compatible x32 siginfo. */
+static void
+compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
+ siginfo_t *from)
+{
+ memset (to, 0, sizeof (*to));
+
+ to->si_signo = from->si_signo;
+ to->si_errno = from->si_errno;
+ to->si_code = from->si_code;
+
+ 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)
+ {
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ }
+ else 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
+ {
+ switch (to->si_signo)
+ {
+ case SIGCHLD:
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ to->cpt_si_status = from->si_status;
+ memcpy (&to->cpt_si_utime, &from->si_utime,
+ sizeof (to->cpt_si_utime));
+ memcpy (&to->cpt_si_stime, &from->si_stime,
+ sizeof (to->cpt_si_stime));
+ break;
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ to->cpt_si_addr = (intptr_t) from->si_addr;
+ break;
+ case SIGPOLL:
+ to->cpt_si_band = from->si_band;
+ to->cpt_si_fd = from->si_fd;
+ break;
+ default:
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
+ to->cpt_si_ptr = (intptr_t) from->si_ptr;
+ break;
+ }
+ }
+}
+
+/* Converts the compatible x32 siginfo into system siginfo. */
+static void
+siginfo_from_compat_x32_siginfo (siginfo_t *to,
+ compat_x32_siginfo_t *from)
+{
+ memset (to, 0, sizeof (*to));
+
+ to->si_signo = from->si_signo;
+ to->si_errno = from->si_errno;
+ to->si_code = from->si_code;
+
+ 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)
+ {
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ }
+ 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
+ {
+ switch (to->si_signo)
+ {
+ case SIGCHLD:
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ to->si_status = from->cpt_si_status;
+ memcpy (&to->si_utime, &from->cpt_si_utime,
+ sizeof (to->si_utime));
+ memcpy (&to->si_stime, &from->cpt_si_stime,
+ sizeof (to->si_stime));
+ break;
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
+ break;
+ case SIGPOLL:
+ to->si_band = from->cpt_si_band;
+ to->si_fd = from->cpt_si_fd;
+ break;
+ default:
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
+ to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
+ break;
+ }
+ }
+}
+
+/* Convert a native/host siginfo object, into/from the siginfo in the
+ layout of the inferiors' architecture. Returns true if any
+ conversion was done; false otherwise. If DIRECTION is 1, then copy
+ from INF to NATIVE. If DIRECTION is 0, then copy from NATIVE to INF. */
+
+int
+amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
+ int direction,
+ enum amd64_siginfo_fixup_mode mode)
+{
+
+ if (mode == FIXUP_32)
+ {
+ gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
+
+ if (direction == 0)
+ compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
+ else
+ siginfo_from_compat_siginfo (native, (struct compat_siginfo *) inf);
+
+ return 1;
+ }
+ else if (mode == FIXUP_X32)
+ {
+ gdb_assert (sizeof (siginfo_t) == sizeof (compat_x32_siginfo_t));
+
+ if (direction == 0)
+ compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,
+ native);
+ else
+ siginfo_from_compat_x32_siginfo (native,
+ (struct compat_x32_siginfo *) inf);
+
+ return 1;
+ }
+ return 0;
+}
diff --git a/gdb/nat/amd64-linux-siginfo.h b/gdb/nat/amd64-linux-siginfo.h
new file mode 100644
index 0000000..a906ead
--- /dev/null
+++ b/gdb/nat/amd64-linux-siginfo.h
@@ -0,0 +1,48 @@
+/* Low-level siginfo manipulation for amd64.
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef AMD64_LINUX_SIGINFO_H
+#define AMD64_LINUX_SIGINFO_H 1
+
+
+/* When GDB is built as a 64-bit application on linux, the
+ PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
+ debugging a 32-bit inferior with a 64-bit GDB should look the same
+ as debugging it with a 32-bit GDB, we do the 32-bit <-> 64-bit
+ conversion in-place ourselves. With the presence of possible different
+ fields for host and target we have to guarantee that we use the
+ Also, the first step is to make a copy from the original bits to the
+ internal structure which is the super set. */
+
+/* ENUM to determine the kind of siginfo fixup to be performed. */
+
+enum amd64_siginfo_fixup_mode
+{
+ FIXUP_32 = 1,
+ FIXUP_X32 = 2
+};
+
+/* Common code for performing the fixup of the siginfo. */
+
+int
+amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
+ int direction,
+ enum amd64_siginfo_fixup_mode mode);
+
+#endif
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 2/5] Preparation for new siginfo on Linux.
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
@ 2015-12-17 16:57 ` Walfred Tedeschi
2015-12-18 12:39 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86 Walfred Tedeschi
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Walfred Tedeschi @ 2015-12-17 16:57 UTC (permalink / raw)
To: palves, brobecker; +Cc: gdb-patches, Walfred Tedeschi
First add new structure and function to allow architecture customization
for the siginfo structure.
2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
* linux-tdep.h (linux_siginfo_extra_field_values): New enum values.
(linux_siginfo_extra_fields): New enum type.
* linux-tdep.c (linux_get_siginfo_type_with_fields): New function.
(linux_get_siginfo_type): Uses new function.
---
gdb/linux-tdep.c | 16 +++++++++++++---
gdb/linux-tdep.h | 9 +++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 000efc8..a7e85c5 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -243,11 +243,12 @@ get_linux_inferior_data (void)
return info;
}
-/* This function is suitable for architectures that don't
- extend/override the standard siginfo structure. */
+/* This function is suitable for architectures that
+ extend/override the standard siginfo in an specific way. */
static struct type *
-linux_get_siginfo_type (struct gdbarch *gdbarch)
+linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
+ linux_siginfo_extra_fields extra_fields)
{
struct linux_gdbarch_data *linux_gdbarch_data;
struct type *int_type, *uint_type, *long_type, *void_ptr_type;
@@ -364,6 +365,15 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
return siginfo_type;
}
+/* This function is suitable for architectures that don't
+ extend/override the standard siginfo structure. */
+
+static struct type *
+linux_get_siginfo_type (struct gdbarch *gdbarch)
+{
+ return linux_get_siginfo_type_with_fields (gdbarch, 0);
+}
+
/* Return true if the target is running on uClinux instead of normal
Linux kernel. */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 9beb6f6..c0c9d91 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -24,6 +24,15 @@
struct regcache;
+/* Enum used to define which kind of siginfo is used by the architecture. */
+enum linux_siginfo_extra_field_values
+{
+ LINUX_SIGINFO_FIELD_ADDR_BND = 1
+};
+
+/* Defines a type for the values defined in linux_siginfo_extra_field_values. */
+DEF_ENUM_FLAGS_TYPE (enum linux_siginfo_extra_field_values, linux_siginfo_extra_fields);
+
typedef char *(*linux_collect_thread_registers_ftype) (const struct regcache *,
ptid_t,
bfd *, char *, int *,
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 2/5] Preparation for new siginfo on Linux.
2015-12-17 16:57 ` [PATCH V2 2/5] Preparation for new siginfo on Linux Walfred Tedeschi
@ 2015-12-18 12:39 ` Pedro Alves
0 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-12-18 12:39 UTC (permalink / raw)
To: Walfred Tedeschi, brobecker; +Cc: gdb-patches
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> First add new structure and function to allow architecture customization
> for the siginfo structure.
>
> 2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * linux-tdep.h (linux_siginfo_extra_field_values): New enum values.
> (linux_siginfo_extra_fields): New enum type.
(linux_siginfo_extra_fields): New enum_flags type.
> * linux-tdep.c (linux_get_siginfo_type_with_fields): New function.
> (linux_get_siginfo_type): Uses new function.
* linux-tdep.c (linux_get_siginfo_type): Rename to ...
(linux_get_siginfo_type_with_fields): ... this. Add parameter.
(linux_get_siginfo_type): Reimplement as wrapper around
linux_get_siginfo_type_with_fields.
> diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
> index 9beb6f6..c0c9d91 100644
> --- a/gdb/linux-tdep.h
> +++ b/gdb/linux-tdep.h
> @@ -24,6 +24,15 @@
>
Should include common/enum-flags.h. (And mention it in ChangeLog.)
> struct regcache;
>
> +/* Enum used to define which kind of siginfo is used by the architecture. */
I'd suggest:
/* Flag values indicating the extra fields in an architecture's
siginfo_t type. */
> +enum linux_siginfo_extra_field_values
> +{
> + LINUX_SIGINFO_FIELD_ADDR_BND = 1
Please document the value.
> +};
> +
> +/* Defines a type for the values defined in linux_siginfo_extra_field_values. */
I think you can just say:
/* Define the corresponding enum_flags type. */
> +DEF_ENUM_FLAGS_TYPE (enum linux_siginfo_extra_field_values, linux_siginfo_extra_fields);
> +
> typedef char *(*linux_collect_thread_registers_ftype) (const struct regcache *,
> ptid_t,
> bfd *, char *, int *,
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86.
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
2015-12-17 16:57 ` [PATCH V2 2/5] Preparation for new siginfo on Linux Walfred Tedeschi
@ 2015-12-17 16:57 ` Walfred Tedeschi
2015-12-18 12:55 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 4/5] Add bound related fields to the siginfo structure Walfred Tedeschi
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Walfred Tedeschi @ 2015-12-17 16:57 UTC (permalink / raw)
To: palves, brobecker; +Cc: gdb-patches, Walfred Tedeschi
Using new functions introduced for siginfo for i386/amd64.
2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
* linux-tdep.h (linux_get_siginfo_type_with_fields): Making
function linux_get_siginfo_type_with_fields public.
* linux-tdep.c (linux_get_siginfo_type_with_fields): Making
function linux_get_siginfo_type_with_fields public.
* i386-linux-tdep.h (x86_get_siginfo_type_with_fields): New
function.
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Add
x86_get_siginfo_type_with_fields for the amd64 abi.
* i386-linux-tdep.c (x86_get_siginfo_type_with_fields): New
Function.
(i386_linux_init_abi): Add new function at the i386 ABI
initialization.
---
gdb/amd64-linux-tdep.c | 2 ++
gdb/i386-linux-tdep.c | 8 ++++++++
gdb/i386-linux-tdep.h | 3 +++
gdb/linux-tdep.c | 2 +-
gdb/linux-tdep.h | 5 +++++
5 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index ee21635..bde751f 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1838,6 +1838,8 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_process_record (gdbarch, i386_process_record);
set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
+
+ set_gdbarch_get_siginfo_type (gdbarch, x86_get_siginfo_type_with_fields);
}
static void
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 86fe09e..766f193 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -656,6 +656,12 @@ i386_linux_supply_xstateregset (const struct regset *regset,
i387_supply_xsave (regcache, regnum, xstateregs);
}
+struct type *
+x86_get_siginfo_type_with_fields (struct gdbarch *gdbarch)
+{
+ return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND);
+}
+
/* Similar to i386_collect_fpregset, but use XSAVE extended state. */
static void
@@ -994,6 +1000,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
set_gdbarch_get_syscall_number (gdbarch,
i386_linux_get_syscall_number);
+
+ set_gdbarch_get_siginfo_type (gdbarch, x86_get_siginfo_type_with_fields);
}
/* Provide a prototype to silence -Wmissing-prototypes. */
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5ac08d3..f42bf7a 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -72,4 +72,7 @@ extern struct target_desc *tdesc_i386_avx512_linux;
extern int i386_linux_gregset_reg_offset[];
+/* Returns x86 siginfo type with extra fields. */
+extern struct type *x86_get_siginfo_type_with_fields (struct gdbarch *gdbarch);
+
#endif /* i386-linux-tdep.h */
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index a7e85c5..e41b6f4 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -246,7 +246,7 @@ get_linux_inferior_data (void)
/* This function is suitable for architectures that
extend/override the standard siginfo in an specific way. */
-static struct type *
+struct type *
linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
linux_siginfo_extra_fields extra_fields)
{
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index c0c9d91..7592259 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -33,6 +33,11 @@ enum linux_siginfo_extra_field_values
/* Defines a type for the values defined in linux_siginfo_extra_field_values. */
DEF_ENUM_FLAGS_TYPE (enum linux_siginfo_extra_field_values, linux_siginfo_extra_fields);
+/* Return the siginfo type with additional fields. */
+struct type *
+linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
+ linux_siginfo_extra_fields);
+
typedef char *(*linux_collect_thread_registers_ftype) (const struct regcache *,
ptid_t,
bfd *, char *, int *,
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86.
2015-12-17 16:57 ` [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86 Walfred Tedeschi
@ 2015-12-18 12:55 ` Pedro Alves
0 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-12-18 12:55 UTC (permalink / raw)
To: Walfred Tedeschi, brobecker; +Cc: gdb-patches
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> Using new functions introduced for siginfo for i386/amd64.
>
>
> 2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * linux-tdep.h (linux_get_siginfo_type_with_fields): Making
> function linux_get_siginfo_type_with_fields public.
> * linux-tdep.c (linux_get_siginfo_type_with_fields): Making
> function linux_get_siginfo_type_with_fields public.
Use imperative: "Use", "Make" (here and elsewhere, including subject
line of patch #1. Drop periods in subject lines while at it).
s/public/extern/.
> * i386-linux-tdep.h (x86_get_siginfo_type_with_fields): New
> function.
> * amd64-linux-tdep.c (amd64_linux_init_abi_common): Add
> x86_get_siginfo_type_with_fields for the amd64 abi.
(amd64_linux_init_abi_common): Register as gdbarch_get_siginfo_type
method.
> * i386-linux-tdep.c (x86_get_siginfo_type_with_fields): New
> Function.
lowercase "function".
> (i386_linux_init_abi): Add new function at the i386 ABI
> initialization.
(i386_linux_init_abi): Register as gdbarch_get_siginfo_type
method.
>
> ---
> gdb/amd64-linux-tdep.c | 2 ++
> gdb/i386-linux-tdep.c | 8 ++++++++
> gdb/i386-linux-tdep.h | 3 +++
> gdb/linux-tdep.c | 2 +-
> gdb/linux-tdep.h | 5 +++++
> 5 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index ee21635..bde751f 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -1838,6 +1838,8 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
>
> set_gdbarch_process_record (gdbarch, i386_process_record);
> set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
> +
> + set_gdbarch_get_siginfo_type (gdbarch, x86_get_siginfo_type_with_fields);
> }
>
> static void
> diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
> index 86fe09e..766f193 100644
> --- a/gdb/i386-linux-tdep.c
> +++ b/gdb/i386-linux-tdep.c
> @@ -656,6 +656,12 @@ i386_linux_supply_xstateregset (const struct regset *regset,
> i387_supply_xsave (regcache, regnum, xstateregs);
> }
>
> +struct type *
> +x86_get_siginfo_type_with_fields (struct gdbarch *gdbarch)
"with_fields" is implementation detail. I'd rather just:
struct type *
x86_get_siginfo_type (struct gdbarch *gdbarch)
> +{
> + return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND);
> +}
> +
> /* Similar to i386_collect_fpregset, but use XSAVE extended state. */
>
> static void
> @@ -994,6 +1000,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
> set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
> set_gdbarch_get_syscall_number (gdbarch,
> i386_linux_get_syscall_number);
> +
> + set_gdbarch_get_siginfo_type (gdbarch, x86_get_siginfo_type_with_fields);
> }
>
> /* Provide a prototype to silence -Wmissing-prototypes. */
> diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
> index 5ac08d3..f42bf7a 100644
> --- a/gdb/i386-linux-tdep.h
> +++ b/gdb/i386-linux-tdep.h
> @@ -72,4 +72,7 @@ extern struct target_desc *tdesc_i386_avx512_linux;
>
> extern int i386_linux_gregset_reg_offset[];
>
> +/* Returns x86 siginfo type with extra fields. */
/* Return the x86 siginfo type. */
> +extern struct type *x86_get_siginfo_type_with_fields (struct gdbarch *gdbarch);
> +
> #endif /* i386-linux-tdep.h */
> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
> index a7e85c5..e41b6f4 100644
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -246,7 +246,7 @@ get_linux_inferior_data (void)
> /* This function is suitable for architectures that
> extend/override the standard siginfo in an specific way. */
>
Update comment:
/* See linux-tdep.h. */
> -static struct type *
> +struct type *
> linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
> linux_siginfo_extra_fields extra_fields)
> {
> diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
> index c0c9d91..7592259 100644
> --- a/gdb/linux-tdep.h
> +++ b/gdb/linux-tdep.h
> @@ -33,6 +33,11 @@ enum linux_siginfo_extra_field_values
> /* Defines a type for the values defined in linux_siginfo_extra_field_values. */
> DEF_ENUM_FLAGS_TYPE (enum linux_siginfo_extra_field_values, linux_siginfo_extra_fields);
>
> +/* Return the siginfo type with additional fields. */
> +struct type *
> +linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
> + linux_siginfo_extra_fields fields);
> +
/* Return a new siginfo type with additional fields specified by
FIELDS. */
struct type *linux_get_siginfo_type_with_fields
(struct gdbarch *gdbarch,
linux_siginfo_extra_fields fields);
> typedef char *(*linux_collect_thread_registers_ftype) (const struct regcache *,
> ptid_t,
> bfd *, char *, int *,
>
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V2 4/5] Add bound related fields to the siginfo structure.
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
2015-12-17 16:57 ` [PATCH V2 2/5] Preparation for new siginfo on Linux Walfred Tedeschi
2015-12-17 16:57 ` [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86 Walfred Tedeschi
@ 2015-12-17 16:57 ` Walfred Tedeschi
2015-12-18 13:11 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields Walfred Tedeschi
2015-12-18 12:25 ` [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Pedro Alves
4 siblings, 1 reply; 11+ messages in thread
From: Walfred Tedeschi @ 2015-12-17 16:57 UTC (permalink / raw)
To: palves, brobecker; +Cc: gdb-patches, Walfred Tedeschi
New kernel and glibc patches have introduced fields in the
segmentation fault fields. New fields will be conditional and requested
on demand by the customers.
Kernel patch:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=ee1b58d36aa1b5a79eaba11f5c3633c88231da83
Glibc patch:
http://repo.or.cz/w/glibc.git/commit/d4358b51c26a634eb885955aea06cad26af6f696
2015-12-08 Walfred Tedeschi <walfred.tedeschi@intel.com>
* linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
structure to the siginfo conditionally if extra_fields is
LINUX_SIGINFO_FIELD_ADDR_BND.
---
gdb/linux-tdep.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index e41b6f4..73c70cb 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -251,7 +251,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
linux_siginfo_extra_fields extra_fields)
{
struct linux_gdbarch_data *linux_gdbarch_data;
- struct type *int_type, *uint_type, *long_type, *void_ptr_type;
+ struct type *int_type, *uint_type, *long_type, *void_ptr_type, *short_type;
struct type *uid_type, *pid_type;
struct type *sigval_type, *clock_type;
struct type *siginfo_type, *sifields_type;
@@ -267,6 +267,8 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
1, "unsigned int");
long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
0, "long");
+ short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ 0, "short");
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
/* sival_t */
@@ -344,6 +346,18 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
append_composite_type_field (type, "si_addr", void_ptr_type);
append_composite_type_field (sifields_type, "_sigfault", type);
+ if (extra_fields == LINUX_SIGINFO_FIELD_ADDR_BND)
+ {
+ struct type *sigfault_bnd_fields;
+
+ append_composite_type_field (type, "_addr_lsb", short_type);
+ sigfault_bnd_fields = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (sigfault_bnd_fields, "_lower", void_ptr_type);
+ append_composite_type_field (sigfault_bnd_fields, "_upper", void_ptr_type);
+ append_composite_type_field (type, "_addr_bnd", sigfault_bnd_fields);
+ append_composite_type_field (sifields_type, "_sigfault", type);
+ }
+
/* _sigpoll */
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
append_composite_type_field (type, "si_band", long_type);
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 4/5] Add bound related fields to the siginfo structure.
2015-12-17 16:57 ` [PATCH V2 4/5] Add bound related fields to the siginfo structure Walfred Tedeschi
@ 2015-12-18 13:11 ` Pedro Alves
0 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-12-18 13:11 UTC (permalink / raw)
To: Walfred Tedeschi, brobecker; +Cc: gdb-patches
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> New kernel and glibc patches have introduced fields in the
> segmentation fault fields. New fields will be conditional and requested
> on demand by the customers.
I think that by "customers" you mean that the patch adds them
to x86 only, right? "API client" is more usual than "API customer",
which otherwise sounds like you're talking about Intel's
customers. :-) I'd suggest writing:
Both Linux and glibc have introduced bound related fields
in the segmentation fault fields of the siginfo_t type. Add the
new fields to our x86's siginfo_t type too.
>
> Kernel patch:
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=ee1b58d36aa1b5a79eaba11f5c3633c88231da83
>
> Glibc patch:
> http://repo.or.cz/w/glibc.git/commit/d4358b51c26a634eb885955aea06cad26af6f696
>
> 2015-12-08 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
> structure to the siginfo conditionally if extra_fields is
> LINUX_SIGINFO_FIELD_ADDR_BND.
"conditionally" is redundant with if. Should be "contains" rather than
"is". When talking about a variable's value, use uppercase:
* linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
structure to the siginfo type if EXTRA_FIELDS contains
LINUX_SIGINFO_FIELD_ADDR_BND.
>
> ---
> gdb/linux-tdep.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
> index e41b6f4..73c70cb 100644
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -251,7 +251,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
> linux_siginfo_extra_fields extra_fields)
> {
> struct linux_gdbarch_data *linux_gdbarch_data;
> - struct type *int_type, *uint_type, *long_type, *void_ptr_type;
> + struct type *int_type, *uint_type, *long_type, *void_ptr_type, *short_type;
> struct type *uid_type, *pid_type;
> struct type *sigval_type, *clock_type;
> struct type *siginfo_type, *sifields_type;
> @@ -267,6 +267,8 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
> 1, "unsigned int");
> long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
> 0, "long");
> + short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
> + 0, "short");
> void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
>
> /* sival_t */
> @@ -344,6 +346,18 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
> append_composite_type_field (type, "si_addr", void_ptr_type);
> append_composite_type_field (sifields_type, "_sigfault", type);
>
> + if (extra_fields == LINUX_SIGINFO_FIELD_ADDR_BND)
This is a bit flags type so that other fields can be added in the future.
Write:
if ((extra_fields & LINUX_SIGINFO_FIELD_ADDR_BND) != 0)
> + {
> + struct type *sigfault_bnd_fields;
> +
> + append_composite_type_field (type, "_addr_lsb", short_type);
> + sigfault_bnd_fields = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
> + append_composite_type_field (sigfault_bnd_fields, "_lower", void_ptr_type);
> + append_composite_type_field (sigfault_bnd_fields, "_upper", void_ptr_type);
> + append_composite_type_field (type, "_addr_bnd", sigfault_bnd_fields);
> + append_composite_type_field (sifields_type, "_sigfault", type);
We add "_sigfault" twice?
> + }
> +
> /* _sigpoll */
> type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
> append_composite_type_field (type, "si_band", long_type);
>
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields.
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
` (2 preceding siblings ...)
2015-12-17 16:57 ` [PATCH V2 4/5] Add bound related fields to the siginfo structure Walfred Tedeschi
@ 2015-12-17 16:57 ` Walfred Tedeschi
2015-12-18 14:43 ` Pedro Alves
2015-12-18 12:25 ` [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Pedro Alves
4 siblings, 1 reply; 11+ messages in thread
From: Walfred Tedeschi @ 2015-12-17 16:57 UTC (permalink / raw)
To: palves, brobecker; +Cc: gdb-patches, Walfred Tedeschi
New bnds fields will be always present for x86 architecture.
Fixup for compatibility layer 32bits has to be fixed.
It was added the nat_siginfo to serving as intermediate step
between kernel provided siginfo and the fix up routine.
When executing compat_siginfo_from_siginfo or
compat_x32_siginfo_from_siginfo first the buffer read from the kernel are
converted into the nat_signfo for homogenization, then the fields of
nat_siginfo are use to set the compat and compat_x32 siginfo structures.
When executing siginfo_from_compat_siginfo or
siginfo_from_compat_x32_siginfo the process happens in oposite order.
In doing this the fixups become more independent of the system underneath.
Caveat: No support for MPX on x32.
2015-12-08 Walfred Tedeschi <walfred.tedeschi@intel.com>
* amd64-linux-siginfo.c (nat_siginfo_t, nat_sigval_t, nat_timeval):
New types.
(compat_siginfo): New bnd fields added.
(compat_x32_siginfo): New field added.
(cpt_si_addr_lsb): New define.
(compat_siginfo_from_siginfo): Use nat_siginfo.
(siginfo_from_compat_siginfo): Use nat_siginfo.
(compat_x32_siginfo_from_siginfo): Likewise.
(siginfo_from_compat_x32_siginfo): Likewise.
---
gdb/nat/amd64-linux-siginfo.c | 311 ++++++++++++++++++++++++++++--------------
1 file changed, 211 insertions(+), 100 deletions(-)
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 22e3552..8f0f486 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -30,6 +30,92 @@
Also, the first step is to make a copy from the original bits to the
internal structure which is the super set. */
+/* These types below (native_*) define a siginfo type that is layout
+ the most complete siginfo available for the architecture. */
+
+typedef int nat_int_t;
+typedef void* nat_uptr_t;
+
+typedef int nat_time_t;
+typedef int nat_timer_t;
+
+/* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes. */
+typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;
+
+struct nat_timeval
+{
+ nat_time_t tv_sec;
+ int tv_usec;
+};
+
+typedef union nat_sigval
+{
+ nat_int_t sival_int;
+ nat_uptr_t sival_ptr;
+} nat_sigval_t;
+
+typedef struct nat_siginfo
+{
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union
+ {
+ int _pad[((128 / sizeof (int)) - 4)];
+ /* kill() */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ } _kill;
+
+ /* POSIX.1b timers */
+ struct
+ {
+ nat_timer_t _tid;
+ int _overrun;
+ nat_sigval_t _sigval;
+ } _timer;
+
+ /* POSIX.1b signals */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ nat_sigval_t _sigval;
+ } _rt;
+
+ /* SIGCHLD */
+ struct
+ {
+ unsigned int _pid;
+ unsigned int _uid;
+ int _status;
+ nat_clock_t _utime;
+ nat_clock_t _stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+ struct
+ {
+ nat_uptr_t _addr;
+ short int _addr_lsb;
+ struct
+ {
+ nat_uptr_t _lower;
+ nat_uptr_t _upper;
+ } si_addr_bnd;
+ } _sigfault;
+
+ /* SIGPOLL */
+ struct
+ {
+ int _band;
+ int _fd;
+ } _sigpoll;
+ } _sifields;
+} nat_siginfo_t __attribute__ ((__aligned__ (8)));
/* These types below (compat_*) define a siginfo type that is layout
compatible with the siginfo type exported by the 32-bit userspace
@@ -101,6 +187,12 @@ typedef struct compat_siginfo
struct
{
unsigned int _addr;
+ short int _addr_lsb;
+ struct
+ {
+ unsigned int _lower;
+ unsigned int _upper;
+ } si_addr_bnd;
} _sigfault;
/* SIGPOLL */
@@ -162,6 +254,7 @@ typedef struct compat_x32_siginfo
struct
{
unsigned int _addr;
+ unsigned int _addr_lsb;
} _sigfault;
/* SIGPOLL */
@@ -184,6 +277,7 @@ typedef struct compat_x32_siginfo
#define cpt_si_stime _sifields._sigchld._stime
#define cpt_si_ptr _sifields._rt._sigval.sival_ptr
#define cpt_si_addr _sifields._sigfault._addr
+#define cpt_si_addr_lsb _sifields._sigfault._addr_lsb
#define cpt_si_band _sifields._sigpoll._band
#define cpt_si_fd _sifields._sigpoll._fd
@@ -200,54 +294,58 @@ typedef struct compat_x32_siginfo
static void
compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
{
+ nat_siginfo_t from_nat;
+
+ gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
+ memcpy (&from_nat, from, sizeof (from_nat));
memset (to, 0, sizeof (*to));
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
+ to->si_signo = from_nat.si_signo;
+ to->si_errno = from_nat.si_errno;
+ to->si_code = from_nat.si_code;
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;
+ to->cpt_si_timerid = from_nat.cpt_si_timerid;
+ to->cpt_si_overrun = from_nat.cpt_si_overrun;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
}
else if (to->si_code == SI_USER)
{
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
}
else 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;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
}
else
{
switch (to->si_signo)
{
case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- to->cpt_si_utime = from->si_utime;
- to->cpt_si_stime = from->si_stime;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_status = from_nat.cpt_si_status;
+ to->cpt_si_utime = from_nat.cpt_si_utime;
+ to->cpt_si_stime = from_nat.cpt_si_stime;
break;
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
+ to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
break;
case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
+ to->cpt_si_band = from_nat.cpt_si_band;
+ to->cpt_si_fd = from_nat.cpt_si_fd;
break;
default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
break;
}
}
@@ -257,57 +355,62 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
static void
siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
{
- memset (to, 0, sizeof (*to));
+ nat_siginfo_t to_nat;
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
+ gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
+ memset (&to_nat, 0, sizeof (to_nat));
- if (to->si_code == SI_TIMER)
+ to_nat.si_signo = from->si_signo;
+ to_nat.si_errno = from->si_errno;
+ to_nat.si_code = from->si_code;
+
+ if (to_nat.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;
+ to_nat.cpt_si_timerid = from->cpt_si_timerid;
+ to_nat.cpt_si_overrun = from->cpt_si_overrun;
+ to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
- else if (to->si_code == SI_USER)
+ else if (to_nat.si_code == SI_USER)
{
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
}
- if (to->si_code < 0)
+ if (to_nat.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;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
else
{
- switch (to->si_signo)
+ switch (to_nat.si_signo)
{
case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- to->si_utime = from->cpt_si_utime;
- to->si_stime = from->cpt_si_stime;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_status = from->cpt_si_status;
+ to_nat.cpt_si_utime = from->cpt_si_utime;
+ to_nat.cpt_si_stime = from->cpt_si_stime;
break;
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
+ to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
+ to_nat.cpt_si_addr_lsb = (short) from->cpt_si_addr_lsb;
break;
case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
+ to_nat.cpt_si_band = from->cpt_si_band;
+ to_nat.cpt_si_fd = from->cpt_si_fd;
break;
default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
break;
}
}
+ memcpy (to, &to_nat, sizeof (to_nat));
}
/* Converts the system provided siginfo into compatible x32 siginfo. */
@@ -315,56 +418,60 @@ static void
compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
siginfo_t *from)
{
+ nat_siginfo_t from_nat;
+
+ gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
+ memcpy (&from_nat, from, sizeof (from_nat));
memset (to, 0, sizeof (*to));
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
+ to->si_signo = from_nat.si_signo;
+ to->si_errno = from_nat.si_errno;
+ to->si_code = from_nat.si_code;
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;
+ to->cpt_si_timerid = from_nat.cpt_si_timerid;
+ to->cpt_si_overrun = from_nat.cpt_si_overrun;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
}
else if (to->si_code == SI_USER)
{
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
}
else 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;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
}
else
{
switch (to->si_signo)
{
case SIGCHLD:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_status = from->si_status;
- memcpy (&to->cpt_si_utime, &from->si_utime,
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_status = from_nat.cpt_si_status;
+ memcpy (&to->cpt_si_utime, &from_nat.cpt_si_utime,
sizeof (to->cpt_si_utime));
- memcpy (&to->cpt_si_stime, &from->si_stime,
+ memcpy (&to->cpt_si_stime, &from_nat.cpt_si_stime,
sizeof (to->cpt_si_stime));
break;
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGBUS:
- to->cpt_si_addr = (intptr_t) from->si_addr;
+ to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
break;
case SIGPOLL:
- to->cpt_si_band = from->si_band;
- to->cpt_si_fd = from->si_fd;
+ to->cpt_si_band = from_nat.cpt_si_band;
+ to->cpt_si_fd = from_nat.cpt_si_fd;
break;
default:
- to->cpt_si_pid = from->si_pid;
- to->cpt_si_uid = from->si_uid;
- to->cpt_si_ptr = (intptr_t) from->si_ptr;
+ to->cpt_si_pid = from_nat.cpt_si_pid;
+ to->cpt_si_uid = from_nat.cpt_si_uid;
+ to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
break;
}
}
@@ -375,59 +482,63 @@ static void
siginfo_from_compat_x32_siginfo (siginfo_t *to,
compat_x32_siginfo_t *from)
{
- memset (to, 0, sizeof (*to));
+ nat_siginfo_t to_nat;
- to->si_signo = from->si_signo;
- to->si_errno = from->si_errno;
- to->si_code = from->si_code;
+ gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
+ memset (&to_nat, 0, sizeof (to_nat));
- if (to->si_code == SI_TIMER)
+ to_nat.si_signo = from->si_signo;
+ to_nat.si_errno = from->si_errno;
+ to_nat.si_code = from->si_code;
+
+ if (to_nat.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;
+ to_nat.cpt_si_timerid = from->cpt_si_timerid;
+ to_nat.cpt_si_overrun = from->cpt_si_overrun;
+ to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
- else if (to->si_code == SI_USER)
+ else if (to_nat.si_code == SI_USER)
{
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
}
- if (to->si_code < 0)
+ if (to_nat.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;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
else
{
- switch (to->si_signo)
+ switch (to_nat.si_signo)
{
case SIGCHLD:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_status = from->cpt_si_status;
- memcpy (&to->si_utime, &from->cpt_si_utime,
- sizeof (to->si_utime));
- memcpy (&to->si_stime, &from->cpt_si_stime,
- sizeof (to->si_stime));
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_status = from->cpt_si_status;
+ memcpy (&to_nat.cpt_si_utime, &from->cpt_si_utime,
+ sizeof (to_nat.cpt_si_utime));
+ memcpy (&to_nat.cpt_si_stime, &from->cpt_si_stime,
+ sizeof (to_nat.cpt_si_stime));
break;
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGBUS:
- to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
+ to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
break;
case SIGPOLL:
- to->si_band = from->cpt_si_band;
- to->si_fd = from->cpt_si_fd;
+ to_nat.cpt_si_band = from->cpt_si_band;
+ to_nat.cpt_si_fd = from->cpt_si_fd;
break;
default:
- to->si_pid = from->cpt_si_pid;
- to->si_uid = from->cpt_si_uid;
- to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
+ to_nat.cpt_si_pid = from->cpt_si_pid;
+ to_nat.cpt_si_uid = from->cpt_si_uid;
+ to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
break;
}
}
+ memcpy (to, &to_nat, sizeof (to_nat));
}
/* Convert a native/host siginfo object, into/from the siginfo in the
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields.
2015-12-17 16:57 ` [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields Walfred Tedeschi
@ 2015-12-18 14:43 ` Pedro Alves
2015-12-18 14:53 ` Tedeschi, Walfred
0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2015-12-18 14:43 UTC (permalink / raw)
To: Walfred Tedeschi, brobecker; +Cc: gdb-patches
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> New bnds fields will be always present for x86 architecture.
> Fixup for compatibility layer 32bits has to be fixed.
>
> It was added the nat_siginfo to serving as intermediate step
> between kernel provided siginfo and the fix up routine.
>
> When executing compat_siginfo_from_siginfo or
> compat_x32_siginfo_from_siginfo first the buffer read from the kernel are
> converted into the nat_signfo for homogenization, then the fields of
> nat_siginfo are use to set the compat and compat_x32 siginfo structures.
>
> When executing siginfo_from_compat_siginfo or
> siginfo_from_compat_x32_siginfo the process happens in oposite order.
>
> In doing this the fixups become more independent of the system underneath.
Can you expand on the rationale? AFAICS, there's no intermediate step
conversion, in the sense of a field-by-field conversion.
It's a straight memcpy to/from the host's siginfo_t.
So is the reason for this new type so that we don't rely on the siginfo_t
host's type at all? So that we can access the new fields even if gdb is not
compiled on a system with the updated glibc yet?
Thanks,
Pedro Alves
>
> Caveat: No support for MPX on x32.
>
> 2015-12-08 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * amd64-linux-siginfo.c (nat_siginfo_t, nat_sigval_t, nat_timeval):
> New types.
> (compat_siginfo): New bnd fields added.
> (compat_x32_siginfo): New field added.
> (cpt_si_addr_lsb): New define.
> (compat_siginfo_from_siginfo): Use nat_siginfo.
> (siginfo_from_compat_siginfo): Use nat_siginfo.
> (compat_x32_siginfo_from_siginfo): Likewise.
> (siginfo_from_compat_x32_siginfo): Likewise.
>
> ---
> gdb/nat/amd64-linux-siginfo.c | 311 ++++++++++++++++++++++++++++--------------
> 1 file changed, 211 insertions(+), 100 deletions(-)
>
> diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
> index 22e3552..8f0f486 100644
> --- a/gdb/nat/amd64-linux-siginfo.c
> +++ b/gdb/nat/amd64-linux-siginfo.c
> @@ -30,6 +30,92 @@
> Also, the first step is to make a copy from the original bits to the
> internal structure which is the super set. */
>
> +/* These types below (native_*) define a siginfo type that is layout
> + the most complete siginfo available for the architecture. */
> +
> +typedef int nat_int_t;
> +typedef void* nat_uptr_t;
> +
> +typedef int nat_time_t;
> +typedef int nat_timer_t;
> +
> +/* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes. */
> +typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;
> +
> +struct nat_timeval
> +{
> + nat_time_t tv_sec;
> + int tv_usec;
> +};
> +
> +typedef union nat_sigval
> +{
> + nat_int_t sival_int;
> + nat_uptr_t sival_ptr;
> +} nat_sigval_t;
> +
> +typedef struct nat_siginfo
> +{
> + int si_signo;
> + int si_errno;
> + int si_code;
> +
> + union
> + {
> + int _pad[((128 / sizeof (int)) - 4)];
> + /* kill() */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + } _kill;
> +
> + /* POSIX.1b timers */
> + struct
> + {
> + nat_timer_t _tid;
> + int _overrun;
> + nat_sigval_t _sigval;
> + } _timer;
> +
> + /* POSIX.1b signals */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + nat_sigval_t _sigval;
> + } _rt;
> +
> + /* SIGCHLD */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + int _status;
> + nat_clock_t _utime;
> + nat_clock_t _stime;
> + } _sigchld;
> +
> + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
> + struct
> + {
> + nat_uptr_t _addr;
> + short int _addr_lsb;
> + struct
> + {
> + nat_uptr_t _lower;
> + nat_uptr_t _upper;
> + } si_addr_bnd;
> + } _sigfault;
> +
> + /* SIGPOLL */
> + struct
> + {
> + int _band;
> + int _fd;
> + } _sigpoll;
> + } _sifields;
> +} nat_siginfo_t __attribute__ ((__aligned__ (8)));
>
> /* These types below (compat_*) define a siginfo type that is layout
> compatible with the siginfo type exported by the 32-bit userspace
> @@ -101,6 +187,12 @@ typedef struct compat_siginfo
> struct
> {
> unsigned int _addr;
> + short int _addr_lsb;
> + struct
> + {
> + unsigned int _lower;
> + unsigned int _upper;
> + } si_addr_bnd;
> } _sigfault;
>
> /* SIGPOLL */
> @@ -162,6 +254,7 @@ typedef struct compat_x32_siginfo
> struct
> {
> unsigned int _addr;
> + unsigned int _addr_lsb;
> } _sigfault;
>
> /* SIGPOLL */
> @@ -184,6 +277,7 @@ typedef struct compat_x32_siginfo
> #define cpt_si_stime _sifields._sigchld._stime
> #define cpt_si_ptr _sifields._rt._sigval.sival_ptr
> #define cpt_si_addr _sifields._sigfault._addr
> +#define cpt_si_addr_lsb _sifields._sigfault._addr_lsb
> #define cpt_si_band _sifields._sigpoll._band
> #define cpt_si_fd _sifields._sigpoll._fd
>
> @@ -200,54 +294,58 @@ typedef struct compat_x32_siginfo
> static void
> compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
> {
> + nat_siginfo_t from_nat;
> +
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
> + memcpy (&from_nat, from, sizeof (from_nat));
> memset (to, 0, sizeof (*to));
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + to->si_signo = from_nat.si_signo;
> + to->si_errno = from_nat.si_errno;
> + to->si_code = from_nat.si_code;
>
> 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;
> + to->cpt_si_timerid = from_nat.cpt_si_timerid;
> + to->cpt_si_overrun = from_nat.cpt_si_overrun;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else if (to->si_code == SI_USER)
> {
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> }
> else 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;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else
> {
> switch (to->si_signo)
> {
> case SIGCHLD:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_status = from->si_status;
> - to->cpt_si_utime = from->si_utime;
> - to->cpt_si_stime = from->si_stime;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_status = from_nat.cpt_si_status;
> + to->cpt_si_utime = from_nat.cpt_si_utime;
> + to->cpt_si_stime = from_nat.cpt_si_stime;
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->cpt_si_addr = (intptr_t) from->si_addr;
> + to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
> break;
> case SIGPOLL:
> - to->cpt_si_band = from->si_band;
> - to->cpt_si_fd = from->si_fd;
> + to->cpt_si_band = from_nat.cpt_si_band;
> + to->cpt_si_fd = from_nat.cpt_si_fd;
> break;
> default:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_ptr = (intptr_t) from->si_ptr;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> break;
> }
> }
> @@ -257,57 +355,62 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
> static void
> siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
> {
> - memset (to, 0, sizeof (*to));
> + nat_siginfo_t to_nat;
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
> + memset (&to_nat, 0, sizeof (to_nat));
>
> - if (to->si_code == SI_TIMER)
> + to_nat.si_signo = from->si_signo;
> + to_nat.si_errno = from->si_errno;
> + to_nat.si_code = from->si_code;
> +
> + if (to_nat.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;
> + to_nat.cpt_si_timerid = from->cpt_si_timerid;
> + to_nat.cpt_si_overrun = from->cpt_si_overrun;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> - else if (to->si_code == SI_USER)
> + else if (to_nat.si_code == SI_USER)
> {
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> }
> - if (to->si_code < 0)
> + if (to_nat.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;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> else
> {
> - switch (to->si_signo)
> + switch (to_nat.si_signo)
> {
> case SIGCHLD:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_status = from->cpt_si_status;
> - to->si_utime = from->cpt_si_utime;
> - to->si_stime = from->cpt_si_stime;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_status = from->cpt_si_status;
> + to_nat.cpt_si_utime = from->cpt_si_utime;
> + to_nat.cpt_si_stime = from->cpt_si_stime;
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr_lsb = (short) from->cpt_si_addr_lsb;
> break;
> case SIGPOLL:
> - to->si_band = from->cpt_si_band;
> - to->si_fd = from->cpt_si_fd;
> + to_nat.cpt_si_band = from->cpt_si_band;
> + to_nat.cpt_si_fd = from->cpt_si_fd;
> break;
> default:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> break;
> }
> }
> + memcpy (to, &to_nat, sizeof (to_nat));
> }
>
> /* Converts the system provided siginfo into compatible x32 siginfo. */
> @@ -315,56 +418,60 @@ static void
> compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
> siginfo_t *from)
> {
> + nat_siginfo_t from_nat;
> +
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
> + memcpy (&from_nat, from, sizeof (from_nat));
> memset (to, 0, sizeof (*to));
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + to->si_signo = from_nat.si_signo;
> + to->si_errno = from_nat.si_errno;
> + to->si_code = from_nat.si_code;
>
> 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;
> + to->cpt_si_timerid = from_nat.cpt_si_timerid;
> + to->cpt_si_overrun = from_nat.cpt_si_overrun;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else if (to->si_code == SI_USER)
> {
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> }
> else 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;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else
> {
> switch (to->si_signo)
> {
> case SIGCHLD:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_status = from->si_status;
> - memcpy (&to->cpt_si_utime, &from->si_utime,
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_status = from_nat.cpt_si_status;
> + memcpy (&to->cpt_si_utime, &from_nat.cpt_si_utime,
> sizeof (to->cpt_si_utime));
> - memcpy (&to->cpt_si_stime, &from->si_stime,
> + memcpy (&to->cpt_si_stime, &from_nat.cpt_si_stime,
> sizeof (to->cpt_si_stime));
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->cpt_si_addr = (intptr_t) from->si_addr;
> + to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
> break;
> case SIGPOLL:
> - to->cpt_si_band = from->si_band;
> - to->cpt_si_fd = from->si_fd;
> + to->cpt_si_band = from_nat.cpt_si_band;
> + to->cpt_si_fd = from_nat.cpt_si_fd;
> break;
> default:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_ptr = (intptr_t) from->si_ptr;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> break;
> }
> }
> @@ -375,59 +482,63 @@ static void
> siginfo_from_compat_x32_siginfo (siginfo_t *to,
> compat_x32_siginfo_t *from)
> {
> - memset (to, 0, sizeof (*to));
> + nat_siginfo_t to_nat;
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
> + memset (&to_nat, 0, sizeof (to_nat));
>
> - if (to->si_code == SI_TIMER)
> + to_nat.si_signo = from->si_signo;
> + to_nat.si_errno = from->si_errno;
> + to_nat.si_code = from->si_code;
> +
> + if (to_nat.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;
> + to_nat.cpt_si_timerid = from->cpt_si_timerid;
> + to_nat.cpt_si_overrun = from->cpt_si_overrun;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> - else if (to->si_code == SI_USER)
> + else if (to_nat.si_code == SI_USER)
> {
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> }
> - if (to->si_code < 0)
> + if (to_nat.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;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> else
> {
> - switch (to->si_signo)
> + switch (to_nat.si_signo)
> {
> case SIGCHLD:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_status = from->cpt_si_status;
> - memcpy (&to->si_utime, &from->cpt_si_utime,
> - sizeof (to->si_utime));
> - memcpy (&to->si_stime, &from->cpt_si_stime,
> - sizeof (to->si_stime));
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_status = from->cpt_si_status;
> + memcpy (&to_nat.cpt_si_utime, &from->cpt_si_utime,
> + sizeof (to_nat.cpt_si_utime));
> + memcpy (&to_nat.cpt_si_stime, &from->cpt_si_stime,
> + sizeof (to_nat.cpt_si_stime));
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
> break;
> case SIGPOLL:
> - to->si_band = from->cpt_si_band;
> - to->si_fd = from->cpt_si_fd;
> + to_nat.cpt_si_band = from->cpt_si_band;
> + to_nat.cpt_si_fd = from->cpt_si_fd;
> break;
> default:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> break;
> }
> }
> + memcpy (to, &to_nat, sizeof (to_nat));
> }
>
> /* Convert a native/host siginfo object, into/from the siginfo in the
>
^ permalink raw reply [flat|nested] 11+ messages in thread* RE: [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields.
2015-12-18 14:43 ` Pedro Alves
@ 2015-12-18 14:53 ` Tedeschi, Walfred
0 siblings, 0 replies; 11+ messages in thread
From: Tedeschi, Walfred @ 2015-12-18 14:53 UTC (permalink / raw)
To: Pedro Alves, brobecker; +Cc: gdb-patches
Pedro,
Yes, This way we don't need to rely on the systems where gdb/gdbserver was compiled.
I understood as an intermediate step in that the siginfo buffer from the system is memcopied to the internal structure and then to compat and vice versa.
I.e.:
buffer -> nat-> compat (x32).
Or
Compat (x32) -> nat -> buffer.
Thanks for your reviews!
Regards,
-Fred
-----Original Message-----
From: Pedro Alves [mailto:palves@redhat.com]
Sent: Friday, December 18, 2015 3:43 PM
To: Tedeschi, Walfred; brobecker@adacore.com
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields.
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> New bnds fields will be always present for x86 architecture.
> Fixup for compatibility layer 32bits has to be fixed.
>
> It was added the nat_siginfo to serving as intermediate step between
> kernel provided siginfo and the fix up routine.
>
> When executing compat_siginfo_from_siginfo or
> compat_x32_siginfo_from_siginfo first the buffer read from the kernel
> are converted into the nat_signfo for homogenization, then the fields
> of nat_siginfo are use to set the compat and compat_x32 siginfo structures.
>
> When executing siginfo_from_compat_siginfo or
> siginfo_from_compat_x32_siginfo the process happens in oposite order.
>
> In doing this the fixups become more independent of the system underneath.
Can you expand on the rationale? AFAICS, there's no intermediate step conversion, in the sense of a field-by-field conversion.
It's a straight memcpy to/from the host's siginfo_t.
So is the reason for this new type so that we don't rely on the siginfo_t host's type at all? So that we can access the new fields even if gdb is not compiled on a system with the updated glibc yet?
Thanks,
Pedro Alves
>
> Caveat: No support for MPX on x32.
>
> 2015-12-08 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * amd64-linux-siginfo.c (nat_siginfo_t, nat_sigval_t, nat_timeval):
> New types.
> (compat_siginfo): New bnd fields added.
> (compat_x32_siginfo): New field added.
> (cpt_si_addr_lsb): New define.
> (compat_siginfo_from_siginfo): Use nat_siginfo.
> (siginfo_from_compat_siginfo): Use nat_siginfo.
> (compat_x32_siginfo_from_siginfo): Likewise.
> (siginfo_from_compat_x32_siginfo): Likewise.
>
> ---
> gdb/nat/amd64-linux-siginfo.c | 311
> ++++++++++++++++++++++++++++--------------
> 1 file changed, 211 insertions(+), 100 deletions(-)
>
> diff --git a/gdb/nat/amd64-linux-siginfo.c
> b/gdb/nat/amd64-linux-siginfo.c index 22e3552..8f0f486 100644
> --- a/gdb/nat/amd64-linux-siginfo.c
> +++ b/gdb/nat/amd64-linux-siginfo.c
> @@ -30,6 +30,92 @@
> Also, the first step is to make a copy from the original bits to the
> internal structure which is the super set. */
>
> +/* These types below (native_*) define a siginfo type that is layout
> + the most complete siginfo available for the architecture. */
> +
> +typedef int nat_int_t;
> +typedef void* nat_uptr_t;
> +
> +typedef int nat_time_t;
> +typedef int nat_timer_t;
> +
> +/* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4
> +bytes. */ typedef long __attribute__ ((__aligned__ (4)))
> +nat_clock_t;
> +
> +struct nat_timeval
> +{
> + nat_time_t tv_sec;
> + int tv_usec;
> +};
> +
> +typedef union nat_sigval
> +{
> + nat_int_t sival_int;
> + nat_uptr_t sival_ptr;
> +} nat_sigval_t;
> +
> +typedef struct nat_siginfo
> +{
> + int si_signo;
> + int si_errno;
> + int si_code;
> +
> + union
> + {
> + int _pad[((128 / sizeof (int)) - 4)];
> + /* kill() */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + } _kill;
> +
> + /* POSIX.1b timers */
> + struct
> + {
> + nat_timer_t _tid;
> + int _overrun;
> + nat_sigval_t _sigval;
> + } _timer;
> +
> + /* POSIX.1b signals */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + nat_sigval_t _sigval;
> + } _rt;
> +
> + /* SIGCHLD */
> + struct
> + {
> + unsigned int _pid;
> + unsigned int _uid;
> + int _status;
> + nat_clock_t _utime;
> + nat_clock_t _stime;
> + } _sigchld;
> +
> + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
> + struct
> + {
> + nat_uptr_t _addr;
> + short int _addr_lsb;
> + struct
> + {
> + nat_uptr_t _lower;
> + nat_uptr_t _upper;
> + } si_addr_bnd;
> + } _sigfault;
> +
> + /* SIGPOLL */
> + struct
> + {
> + int _band;
> + int _fd;
> + } _sigpoll;
> + } _sifields;
> +} nat_siginfo_t __attribute__ ((__aligned__ (8)));
>
> /* These types below (compat_*) define a siginfo type that is layout
> compatible with the siginfo type exported by the 32-bit userspace
> @@ -101,6 +187,12 @@ typedef struct compat_siginfo
> struct
> {
> unsigned int _addr;
> + short int _addr_lsb;
> + struct
> + {
> + unsigned int _lower;
> + unsigned int _upper;
> + } si_addr_bnd;
> } _sigfault;
>
> /* SIGPOLL */
> @@ -162,6 +254,7 @@ typedef struct compat_x32_siginfo
> struct
> {
> unsigned int _addr;
> + unsigned int _addr_lsb;
> } _sigfault;
>
> /* SIGPOLL */
> @@ -184,6 +277,7 @@ typedef struct compat_x32_siginfo #define
> cpt_si_stime _sifields._sigchld._stime #define cpt_si_ptr
> _sifields._rt._sigval.sival_ptr #define cpt_si_addr
> _sifields._sigfault._addr
> +#define cpt_si_addr_lsb _sifields._sigfault._addr_lsb
> #define cpt_si_band _sifields._sigpoll._band #define cpt_si_fd
> _sifields._sigpoll._fd
>
> @@ -200,54 +294,58 @@ typedef struct compat_x32_siginfo static void
> compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from) {
> + nat_siginfo_t from_nat;
> +
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t)); memcpy
> + (&from_nat, from, sizeof (from_nat));
> memset (to, 0, sizeof (*to));
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + to->si_signo = from_nat.si_signo;
> + to->si_errno = from_nat.si_errno;
> + to->si_code = from_nat.si_code;
>
> 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;
> + to->cpt_si_timerid = from_nat.cpt_si_timerid;
> + to->cpt_si_overrun = from_nat.cpt_si_overrun;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else if (to->si_code == SI_USER)
> {
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> }
> else 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;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else
> {
> switch (to->si_signo)
> {
> case SIGCHLD:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_status = from->si_status;
> - to->cpt_si_utime = from->si_utime;
> - to->cpt_si_stime = from->si_stime;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_status = from_nat.cpt_si_status;
> + to->cpt_si_utime = from_nat.cpt_si_utime;
> + to->cpt_si_stime = from_nat.cpt_si_stime;
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->cpt_si_addr = (intptr_t) from->si_addr;
> + to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
> break;
> case SIGPOLL:
> - to->cpt_si_band = from->si_band;
> - to->cpt_si_fd = from->si_fd;
> + to->cpt_si_band = from_nat.cpt_si_band;
> + to->cpt_si_fd = from_nat.cpt_si_fd;
> break;
> default:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_ptr = (intptr_t) from->si_ptr;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> break;
> }
> }
> @@ -257,57 +355,62 @@ compat_siginfo_from_siginfo (compat_siginfo_t
> *to, siginfo_t *from) static void siginfo_from_compat_siginfo
> (siginfo_t *to, compat_siginfo_t *from) {
> - memset (to, 0, sizeof (*to));
> + nat_siginfo_t to_nat;
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t)); memset
> + (&to_nat, 0, sizeof (to_nat));
>
> - if (to->si_code == SI_TIMER)
> + to_nat.si_signo = from->si_signo;
> + to_nat.si_errno = from->si_errno;
> + to_nat.si_code = from->si_code;
> +
> + if (to_nat.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;
> + to_nat.cpt_si_timerid = from->cpt_si_timerid;
> + to_nat.cpt_si_overrun = from->cpt_si_overrun;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> - else if (to->si_code == SI_USER)
> + else if (to_nat.si_code == SI_USER)
> {
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> }
> - if (to->si_code < 0)
> + if (to_nat.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;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> else
> {
> - switch (to->si_signo)
> + switch (to_nat.si_signo)
> {
> case SIGCHLD:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_status = from->cpt_si_status;
> - to->si_utime = from->cpt_si_utime;
> - to->si_stime = from->cpt_si_stime;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_status = from->cpt_si_status;
> + to_nat.cpt_si_utime = from->cpt_si_utime;
> + to_nat.cpt_si_stime = from->cpt_si_stime;
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr_lsb = (short) from->cpt_si_addr_lsb;
> break;
> case SIGPOLL:
> - to->si_band = from->cpt_si_band;
> - to->si_fd = from->cpt_si_fd;
> + to_nat.cpt_si_band = from->cpt_si_band;
> + to_nat.cpt_si_fd = from->cpt_si_fd;
> break;
> default:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> break;
> }
> }
> + memcpy (to, &to_nat, sizeof (to_nat));
> }
>
> /* Converts the system provided siginfo into compatible x32 siginfo.
> */ @@ -315,56 +418,60 @@ static void compat_x32_siginfo_from_siginfo
> (compat_x32_siginfo_t *to,
> siginfo_t *from)
> {
> + nat_siginfo_t from_nat;
> +
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t)); memcpy
> + (&from_nat, from, sizeof (from_nat));
> memset (to, 0, sizeof (*to));
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + to->si_signo = from_nat.si_signo;
> + to->si_errno = from_nat.si_errno;
> + to->si_code = from_nat.si_code;
>
> 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;
> + to->cpt_si_timerid = from_nat.cpt_si_timerid;
> + to->cpt_si_overrun = from_nat.cpt_si_overrun;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else if (to->si_code == SI_USER)
> {
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> }
> else 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;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> }
> else
> {
> switch (to->si_signo)
> {
> case SIGCHLD:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_status = from->si_status;
> - memcpy (&to->cpt_si_utime, &from->si_utime,
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_status = from_nat.cpt_si_status;
> + memcpy (&to->cpt_si_utime, &from_nat.cpt_si_utime,
> sizeof (to->cpt_si_utime));
> - memcpy (&to->cpt_si_stime, &from->si_stime,
> + memcpy (&to->cpt_si_stime, &from_nat.cpt_si_stime,
> sizeof (to->cpt_si_stime));
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->cpt_si_addr = (intptr_t) from->si_addr;
> + to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
> break;
> case SIGPOLL:
> - to->cpt_si_band = from->si_band;
> - to->cpt_si_fd = from->si_fd;
> + to->cpt_si_band = from_nat.cpt_si_band;
> + to->cpt_si_fd = from_nat.cpt_si_fd;
> break;
> default:
> - to->cpt_si_pid = from->si_pid;
> - to->cpt_si_uid = from->si_uid;
> - to->cpt_si_ptr = (intptr_t) from->si_ptr;
> + to->cpt_si_pid = from_nat.cpt_si_pid;
> + to->cpt_si_uid = from_nat.cpt_si_uid;
> + to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
> break;
> }
> }
> @@ -375,59 +482,63 @@ static void
> siginfo_from_compat_x32_siginfo (siginfo_t *to,
> compat_x32_siginfo_t *from)
> {
> - memset (to, 0, sizeof (*to));
> + nat_siginfo_t to_nat;
>
> - to->si_signo = from->si_signo;
> - to->si_errno = from->si_errno;
> - to->si_code = from->si_code;
> + gdb_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t)); memset
> + (&to_nat, 0, sizeof (to_nat));
>
> - if (to->si_code == SI_TIMER)
> + to_nat.si_signo = from->si_signo;
> + to_nat.si_errno = from->si_errno;
> + to_nat.si_code = from->si_code;
> +
> + if (to_nat.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;
> + to_nat.cpt_si_timerid = from->cpt_si_timerid;
> + to_nat.cpt_si_overrun = from->cpt_si_overrun;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> - else if (to->si_code == SI_USER)
> + else if (to_nat.si_code == SI_USER)
> {
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> }
> - if (to->si_code < 0)
> + if (to_nat.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;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
> }
> else
> {
> - switch (to->si_signo)
> + switch (to_nat.si_signo)
> {
> case SIGCHLD:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_status = from->cpt_si_status;
> - memcpy (&to->si_utime, &from->cpt_si_utime,
> - sizeof (to->si_utime));
> - memcpy (&to->si_stime, &from->cpt_si_stime,
> - sizeof (to->si_stime));
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_status = from->cpt_si_status;
> + memcpy (&to_nat.cpt_si_utime, &from->cpt_si_utime,
> + sizeof (to_nat.cpt_si_utime));
> + memcpy (&to_nat.cpt_si_stime, &from->cpt_si_stime,
> + sizeof (to_nat.cpt_si_stime));
> break;
> case SIGILL:
> case SIGFPE:
> case SIGSEGV:
> case SIGBUS:
> - to->si_addr = (void *) (intptr_t) from->cpt_si_addr;
> + to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
> break;
> case SIGPOLL:
> - to->si_band = from->cpt_si_band;
> - to->si_fd = from->cpt_si_fd;
> + to_nat.cpt_si_band = from->cpt_si_band;
> + to_nat.cpt_si_fd = from->cpt_si_fd;
> break;
> default:
> - to->si_pid = from->cpt_si_pid;
> - to->si_uid = from->cpt_si_uid;
> - to->si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> + to_nat.cpt_si_pid = from->cpt_si_pid;
> + to_nat.cpt_si_uid = from->cpt_si_uid;
> + to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
> break;
> }
> }
> + memcpy (to, &to_nat, sizeof (to_nat));
> }
>
> /* Convert a native/host siginfo object, into/from the siginfo in the
>
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo.
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
` (3 preceding siblings ...)
2015-12-17 16:57 ` [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields Walfred Tedeschi
@ 2015-12-18 12:25 ` Pedro Alves
4 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2015-12-18 12:25 UTC (permalink / raw)
To: Walfred Tedeschi, brobecker; +Cc: gdb-patches
On 12/17/2015 04:56 PM, Walfred Tedeschi wrote:
> The compatible siginfo handling from amd64-linux-nat.c and
> gdbserver/linux-x86-low were extracted it into a new file
> nat/amd64-linux-siginfo.c.
>
>
> 2015-12-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> * nat/amd64-linux-siginfo.c: New file.
> * nat/amd64-linux-siginfo.h: New file.
> * Makefile.in (HFILES_NO_SRCDIR): Add new header to
> HFILES_NO_SRCDIR. Add native object files rule for
> amd64-linux-siginfo.o
"HFILES_NO_SRCDIR" is already the specified context. Specify the rules
as context:
* Makefile.in (HFILES_NO_SRCDIR): Add nat/amd64-linux-siginfo.h.
Add native object files rule for
(amd64-linux-siginfo.o:): New rule.
> * config/i386/linux64.mh (NATDEPFILES): Add amd64-linux-siginfo.o.
> * amd64-linux-nat.c (compat_siginfo_from_siginfo)
Mention the header inclusion:
* amd64-linux-nat.c: Include "nat/amd64-linux-siginfo.h".
(compat_siginfo_from_siginfo) ...
>
> gdbserver
>
> * configure.srv (srv_tgtobj): Add amd64-linux-siginfo.o.
Should be:
* configure.srv (x86_64-*-linux*): Add amd64-linux-siginfo.o to srv_tgtobj.
I think you also need to add this here in the gdb_cv_i386_is_x86_64 case:
i[34567]86-*-linux*) srv_regobj="$srv_i386_linux_regobj"
srv_xmlfiles="$srv_i386_linux_xmlfiles"
if test "$gdb_cv_i386_is_x86_64" = yes ; then
srv_regobj="$srv_regobj $srv_amd64_linux_regobj"
srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
fi
> * linux-x86-low.c (compat_siginfo_from_siginfo)
Mention the include:
* linux-x86-low.c [__x86_64__]: Include "nat/amd64-linux-siginfo.h".
...
> (siginfo_from_compat_siginfo, compat_x32_siginfo_from_siginfo)
> (siginfo_from_compat_x32_siginfo and collateral structures): Move
> to nat/amd64-linux-siginfo.c.
> * Makefile.in (x86_64-*-linux*): Add amd64-linux-siginfo.o.
The last entry doesn't make sense. Seems like it was talking about the
configure.src change. You want:
* Makefile.in (amd64-linux-siginfo.o:): New rule.
> @@ -737,34 +335,15 @@ amd64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
> /* Is the inferior 32-bit? If so, then do fixup the siginfo
> object. */
> if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
> - {
> - gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
> -
> - if (direction == 0)
> - compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
> - else
> - siginfo_from_compat_siginfo (native, (struct compat_siginfo *) inf);
> -
> - return 1;
> - }
> + return amd64_linux_siginfo_fixup_common (native, inf , direction,
> + FIXUP_32);
Spurious space after "inf". Looks like that ended up in all
amd64_linux_siginfo_fixup_common calls.
> +++ b/gdb/nat/amd64-linux-siginfo.c
> +#include <signal.h>
> +#include "common-defs.h"
> +#include "amd64-linux-siginfo.h"
> +
> +/* When GDB is built as a 64-bit application on linux, the
> + PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
> + debugging a 32-bit inferior with a 64-bit GDB should look the same
> + as debugging it with a 32-bit GDB, we do the 32-bit <-> 64-bit
> + conversion in-place ourselves. With the presence of possible different
> + fields for host and target we have to guarantee that we use the
This sentence is incomplete.
> + Also, the first step is to make a copy from the original bits to the
> + internal structure which is the super set. */
> +
???
> +}
> +
> +/* Converts the compatible siginfo into system siginfo. */
> +static void
> +siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
There should be an empty line between intro comment and function.
Here and elsewhere.
> +
> +/* Convert a native/host siginfo object, into/from the siginfo in the
> + layout of the inferiors' architecture. Returns true if any
> + conversion was done; false otherwise. If DIRECTION is 1, then copy
> + from INF to NATIVE. If DIRECTION is 0, then copy from NATIVE to INF. */
This should be already documented in the header. Here say:
/* See whatever.h. */
> +
> +int
> +amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
> + int direction,
> + enum amd64_siginfo_fixup_mode mode)
> +{
> +
> + if (mode == FIXUP_32)
Spurious empty line.
> +#ifndef AMD64_LINUX_SIGINFO_H
> +#define AMD64_LINUX_SIGINFO_H 1
> +
> +
> +/* When GDB is built as a 64-bit application on linux, the
> + PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
> + debugging a 32-bit inferior with a 64-bit GDB should look the same
> + as debugging it with a 32-bit GDB, we do the 32-bit <-> 64-bit
> + conversion in-place ourselves. With the presence of possible different
> + fields for host and target we have to guarantee that we use the
> + Also, the first step is to make a copy from the original bits to the
> + internal structure which is the super set. */
Duplicate comment. There should only be one copy, and it should probably
be in the header file.
> +
> +/* ENUM to determine the kind of siginfo fixup to be performed. */
No need to say it's an enum:
/* The kind of siginfo fixup to be performed. */
> +
> +enum amd64_siginfo_fixup_mode
> +{
> + FIXUP_32 = 1,
> + FIXUP_X32 = 2
Please document each mode.
> +};
> +
> +/* Common code for performing the fixup of the siginfo. */
> +
> +int
> +amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
Function name only goes at column 0 in definitions, never in declarations.
> + int direction,
> + enum amd64_siginfo_fixup_mode mode);
> +
> +#endif
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-12-18 14:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-17 16:57 [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Walfred Tedeschi
2015-12-17 16:57 ` [PATCH V2 2/5] Preparation for new siginfo on Linux Walfred Tedeschi
2015-12-18 12:39 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 3/5] Use linux_get_siginfo_type_with_fields for x86 Walfred Tedeschi
2015-12-18 12:55 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 4/5] Add bound related fields to the siginfo structure Walfred Tedeschi
2015-12-18 13:11 ` Pedro Alves
2015-12-17 16:57 ` [PATCH V2 5/5] Adapt siginfo fixup for the new bnd fields Walfred Tedeschi
2015-12-18 14:43 ` Pedro Alves
2015-12-18 14:53 ` Tedeschi, Walfred
2015-12-18 12:25 ` [PATCH V2 1/5] Merges gdb and gdbserver implementation for siginfo Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox