diff options
author | Joel Brobecker <brobecker@gnat.com> | 2013-08-29 21:02:15 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2013-08-29 21:02:15 +0000 |
commit | 11cb8762fcacf259f9d7707201daba6670d1946a (patch) | |
tree | b42ebe0da0768020210a909b42d70c1b77bc70fe | |
parent | 489d4f4d01d74ffd193587ae23bb7e9bedc687d4 (diff) | |
download | gdb-11cb8762fcacf259f9d7707201daba6670d1946a.zip gdb-11cb8762fcacf259f9d7707201daba6670d1946a.tar.gz gdb-11cb8762fcacf259f9d7707201daba6670d1946a.tar.bz2 |
thread support broken on ppc-aix.
Thread support got broken when adding 64bit support on ppc-aix.
Upon digging further, I found that the following patch...
| * gdb_ptrace.h: Use ptrace64 instead of ptrace if HAVE_PTRACE64
| is defined.
| * rs6000-nat.c: Check for __ld_info64_ if compiling 64 BIT gdb.
| (rs6000_ptrace32): Call ptrace64 instead of ptrace if present.
| (rs6000_ptrace64): Call ptace64 instead of ptracex if present.
| * configure.ac: Check for ptrace64.
| * configure, config.in: Regenerate.
... is responsible for this regression:
(gdb) x /x &__n_pthreads
0xf06a8258 <__n_pthreads>: Cannot access memory at address 0xf06a8258
Prior to the patch, we have:
(gdb) x /x &__n_pthreads
0xf06a8258 <__n_pthreads>: 0x00000003
The problem occurs inside rs6000_ptrace32, while calling ptrace64.
The address is given to rs6000_ptrace32 as an "int *", while
ptrace64 takes a "long long". The cast causes the address to be
sign-extended, which results in GDB trying to read the wrong address.
This patch fixes the issue by casting the address to a "uintptr_t"
instead, and letting the compiler do the implicit conversion to
"long long" in the function call.
gdb/ChangeLog:
* rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
instead of "long long" in call to ptrace64.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/rs6000-nat.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7c2647e..f676c3f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2013-08-29 Joel Brobecker <brobecker@adacore.com> + + * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t" + instead of "long long" in call to ptrace64. + 2013-08-29 Andrew Burgess <aburgess@broadcom.com> * mi/mi-interp.c (mi_command_loop): Change signature to match diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 804b316..374976e 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -132,7 +132,7 @@ static int rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf) { #ifdef HAVE_PTRACE64 - int ret = ptrace64 (req, id, (long long) addr, data, buf); + int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf); #else int ret = ptrace (req, id, (int *)addr, data, buf); #endif |