aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-02-24 22:52:06 +0000
committerPedro Alves <palves@redhat.com>2016-02-24 22:52:06 +0000
commite7ad2f145c05bc60b1cd2796c8f3b72f02e3e730 (patch)
treeb977a7b52d8dbb2c626494ded7fabab6b1c0c729 /gdb/nat
parent338435ef105ff51e967571ad073830ec1eb5a4ab (diff)
downloadgdb-e7ad2f145c05bc60b1cd2796c8f3b72f02e3e730.zip
gdb-e7ad2f145c05bc60b1cd2796c8f3b72f02e3e730.tar.gz
gdb-e7ad2f145c05bc60b1cd2796c8f3b72f02e3e730.tar.bz2
Handle MIPS Linux SIGTRAP siginfo.si_code values
This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/linux-ptrace.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index ba58717..b9123c9 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -119,14 +119,14 @@ struct buffer;
/* The x86 kernel gets some of the si_code values backwards, like
this:
- | what | si_code |
- |------------------------------------------+------------|
- | software breakpoints (int3) | SI_KERNEL |
- | single-steps | TRAP_TRACE |
- | single-stepping a syscall | TRAP_BRKPT |
- | user sent SIGTRAP | 0 |
- | exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0 |
- | hardware breakpoints/watchpoints | TRAP_HWBPT |
+ | what | si_code |
+ |------------------------------------------+-------------|
+ | software breakpoints (int3) | SI_KERNEL |
+ | single-steps | TRAP_TRACE |
+ | single-stepping a syscall | TRAP_BRKPT |
+ | user sent SIGTRAP | 0 |
+ | exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0 |
+ | hardware breakpoints/watchpoints | TRAP_HWBKPT |
That is, it reports SI_KERNEL for software breakpoints (and only
for those), and TRAP_BRKPT for single-stepping a syscall... If the
@@ -140,14 +140,32 @@ struct buffer;
in SPU code on a Cell/B.E. However, SI_KERNEL is never seen
on a SIGTRAP for any other reason.
- The generic Linux target code should use GDB_ARCH_IS_TRAP_BRKPT
- instead of TRAP_BRKPT to abstract out these peculiarities. */
+ The MIPS kernel uses SI_KERNEL for all kernel generated traps.
+ Since:
+
+ - MIPS doesn't do hardware single-step.
+ - We don't need to care about exec SIGTRAPs --- we assume
+ PTRACE_EVENT_EXEC is available.
+ - The MIPS kernel doesn't support hardware breakpoints.
+
+ on MIPS, all we need to care about is distinguishing between
+ software breakpoints and hardware watchpoints, which can be done by
+ peeking the debug registers.
+
+ The generic Linux target code should use GDB_ARCH_IS_TRAP_* instead
+ of TRAP_* to abstract out these peculiarities. */
#if defined __i386__ || defined __x86_64__
# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)
#elif defined __powerpc__
# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)
+#elif defined __mips__
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL)
#else
# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)
#endif
#ifndef TRAP_HWBKPT