|
Lines 88-93
struct buffer;
Link Here
|
| 88 |
#define __WALL 0x40000000 /* Wait for any child. */ |
88 |
#define __WALL 0x40000000 /* Wait for any child. */ |
| 89 |
#endif |
89 |
#endif |
| 90 |
|
90 |
|
|
|
91 |
/* True if whether a breakpoint/watchpoint triggered can be determined |
| 92 |
from the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT). |
| 93 |
That is, if the kernel can tell us whether the thread executed a |
| 94 |
software breakpoint, we trust it. The kernel will be determining |
| 95 |
that from the hardware (e.g., from which exception was raised in |
| 96 |
the CPU). Relying on whether a breakpoint is planted in memory at |
| 97 |
the time the SIGTRAP is processed to determine whether the thread |
| 98 |
stopped for a software breakpoint can be too late. E.g., the |
| 99 |
breakpoint could have been removed since. Or the thread could have |
| 100 |
stepped an instruction the size of a breakpoint instruction, and |
| 101 |
before the stop is processed a breakpoint is inserted at its |
| 102 |
address. Getting these wrong is disastrous on decr_pc_after_break |
| 103 |
architectures. The moribund location mechanism helps with that |
| 104 |
somewhat but it is an heuristic, and can well fail. Getting that |
| 105 |
information out of the kernel and ultimately out of the CPU is the |
| 106 |
way to go. That said, some architecture may get the si_code wrong, |
| 107 |
and as such we're leaving fallback code in place. We'll remove |
| 108 |
this after a while if no problem is reported. */ |
| 109 |
#define USE_SIGTRAP_SIGINFO 1 |
| 110 |
|
| 111 |
/* The x86 kernel gets some of the si_code values backwards, like |
| 112 |
this: |
| 113 |
|
| 114 |
| what | si_code | |
| 115 |
|------------------------------------------+------------| |
| 116 |
| software breakpoints (int3) | SI_KERNEL | |
| 117 |
| single-steps | TRAP_TRACE | |
| 118 |
| single-stepping a syscall | TRAP_BRKPT | |
| 119 |
| user sent SIGTRAP | 0 | |
| 120 |
| exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0 | |
| 121 |
| hardware breakpoints/watchpoints | TRAP_HWBPT | |
| 122 |
|
| 123 |
That is, it reports SI_KERNEL for software breakpoints (and only |
| 124 |
for those), and TRAP_BRKPT for single-stepping a syscall... If the |
| 125 |
kernel is ever fixed, we'll just have to detect it like we detect |
| 126 |
optional ptrace features: by forking and debugging ourselves, |
| 127 |
running to a breakpoint and checking what comes out of |
| 128 |
siginfo->si_code. |
| 129 |
|
| 130 |
The generic Linux target code should use GDB_ARCH_TRAP_BRKPT |
| 131 |
instead of TRAP_BRKPT to abstract out this x86 peculiarity. */ |
| 132 |
#if defined __i386__ || defined __x86_64__ |
| 133 |
# define GDB_ARCH_TRAP_BRKPT SI_KERNEL |
| 134 |
#else |
| 135 |
# define GDB_ARCH_TRAP_BRKPT TRAP_BRKPT |
| 136 |
#endif |
| 137 |
|
| 138 |
#ifndef TRAP_HWBKPT |
| 139 |
# define TRAP_HWBKPT 4 |
| 140 |
#endif |
| 141 |
|
| 91 |
extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer); |
142 |
extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer); |