This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] ia64-linux-nat.c: Make HW watchpoint support work again
- To: gdb-patches at sources dot redhat dot com
- Subject: [PATCH] ia64-linux-nat.c: Make HW watchpoint support work again
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Sat, 31 Mar 2001 15:29:47 -0700
The patch below, which I have just committed, makes hardware
watchpoint support work again for Linux/IA-64. At some undetermined
point in the past, the TRAP_HWBKPT constant was changed, but
ia64-linux-nat.c had not been updated to reflect this change.
There *is* a header file, <asm/siginfo.h>, which defines this constant
and it would be nice to just include it so that we don't have to
hard code the value in GDB. I see two problems with this though:
1) It appears that struct siginfo doesn't exactly match between
<asm/siginfo.h> and <bits/siginfo.h>. This latter file is the
glibc version of things and if I try to include the kernel
version, the definitions will conflict. (There's probably a
lot of other stuff which would conflict too.)
To be very precise, the glibc version of struct siginfo
has a member __pad0 which comes immediately after si_code.
The Linux kernel version does not have this member, but rather
relies on the ABI's alignment requirements to implicitly insert
the padding.
There may be other differences too, but this is the one that
I noticed.
2) Even if I were able to somehow avoid the above problem, the
kernel header defines TRAP_HWBKPT differently depending upon
whether or not __KERNEL_ is defined. If __KERNEL__ is defined,
TRAP_HWBKPT will have the value 0x30004. If __KERNEL__ is
not defined, TRAP_HWBKPT will be 4. It doesn't seem like a
good idea to me to define __KERNEL__ in non-kernel code (i.e.
GDB).
I'll also note that the glibc header <bits/siginfo.h> will
define TRAP_HWBKPT to be 4 only when __USE_GNU is defined.
Clearly this won't match the kernel headers even if I were
to define __USE_GNU.
So, I conclude that it is easier (and safer) to just hard code this
constant in GDB. If someone has a better suggestion, I'm willing
to listen...
* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Change
TRAP_HWBKPT constant to match that in the kernel headers for
Linux/IA-64.
Index: ia64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-linux-nat.c,v
retrieving revision 1.8
diff -u -p -r1.8 ia64-linux-nat.c
--- ia64-linux-nat.c 2001/03/01 01:39:21 1.8
+++ ia64-linux-nat.c 2001/03/31 21:48:28
@@ -630,7 +630,7 @@ ia64_linux_stopped_by_watchpoint (int pi
errno = 0;
ptrace (PTRACE_GETSIGINFO, tid, (PTRACE_ARG3_TYPE) 0, &siginfo);
- if (errno != 0 || siginfo.si_code != 4 /* TRAP_HWBKPT */)
+ if (errno != 0 || siginfo.si_code != 0x30004 /* TRAP_HWBKPT */)
return 0;
psr = read_register_pid (IA64_PSR_REGNUM, pid);