This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Correct libthreadb register access for 64-bit sparc.
- From: David Miller <davem at davemloft dot net>
- To: libc-alpha at sourceware dot org
- Cc: ilmalakhov at yandex dot ru
- Date: Sat, 06 Oct 2012 01:07:02 -0400 (EDT)
- Subject: [PATCH] Correct libthreadb register access for 64-bit sparc.
The REG_G7 index is only correct for 32-bit, and there simply does not
exist an appropriate index defined in ucontext.h for the 64-bit ptrace
offsets.
So just use constants throughout, and get it right.
This also deals with a 64-bit debugger debugging a 32-bit process. We
use __WORDSIZE for the second argument of REGISTER () in this case,
just like s390, but unlike s390 we're big endian so we have to adjust
the offset of the register value by 4 bytes in this case as well.
Much thanks to Il'ya Malakhov for his excellent and accurate analysis
of the bug.
Committed to master.
[BZ #14568]
* sysdeps/sparc/tls.h (DB_THREAD_SELF_INCLUDE): Delete.
(DB_THREAD_SELF): Use constants for the register offsets. Correct
the case of a 64-bit debugger with a 32-bit inferior.
---
NEWS | 14 +++++++-------
nptl/ChangeLog | 7 +++++++
nptl/sysdeps/sparc/tls.h | 4 ++--
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/NEWS b/NEWS
index ce3e360..811a1f1 100644
--- a/NEWS
+++ b/NEWS
@@ -9,13 +9,13 @@ Version 2.17
* The following bugs are resolved with this release:
- 1349, 3479, 5044, 5298, 5400, 6530, 6778, 6808, 9685, 9914, 10014,
- 10038, 10631, 11438, 11607, 13412, 13542, 13629, 13679, 13696, 13717,
- 13741, 13939, 13966, 14042, 14090, 14150, 14151, 14154, 14157, 14166,
- 14173, 14195, 14237, 14251, 14252, 14283, 14298, 14303, 14307, 14328,
- 14331, 14336, 14337, 14347, 14349, 14376, 14417, 14459, 14476, 14477,
- 14505, 14510, 14516, 14518, 14519, 14530, 14532, 14538, 14543, 14544,
- 14545, 14557, 14562, 14576, 14579, 14583, 14587, 14621, 14638, 14645,
+ 1349, 3479, 5044, 5298, 5400, 6530, 6778, 6808, 9685, 9914, 10014, 10038,
+ 10631, 11438, 11607, 13412, 13542, 13629, 13679, 13696, 13717, 13741,
+ 13939, 13966, 14042, 14090, 14150, 14151, 14154, 14157, 14166, 14173,
+ 14195, 14237, 14251, 14252, 14283, 14298, 14303, 14307, 14328, 14331,
+ 14336, 14337, 14347, 14349, 14376, 14417, 14459, 14476, 14477, 14505,
+ 14510, 14516, 14518, 14519, 14530, 14532, 14538, 14543, 14544, 14545,
+ 14557, 14562, 14568, 14576, 14579, 14583, 14587, 14621, 14638, 14645,
14648.
* Support for STT_GNU_IFUNC symbols added for s390 and s390x.
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 78b1b93..17a36e8 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-05 David S. Miller <davem@davemloft.net>
+
+ [BZ #14568]
+ * sysdeps/sparc/tls.h (DB_THREAD_SELF_INCLUDE): Delete.
+ (DB_THREAD_SELF): Use constants for the register offsets. Correct
+ the case of a 64-bit debugger with a 32-bit inferior.
+
2012-10-05 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14557]
diff --git a/nptl/sysdeps/sparc/tls.h b/nptl/sysdeps/sparc/tls.h
index 61cb09f..cfc9d96 100644
--- a/nptl/sysdeps/sparc/tls.h
+++ b/nptl/sysdeps/sparc/tls.h
@@ -117,9 +117,9 @@ register struct pthread *__thread_self __asm__("%g7");
#define THREAD_SELF __thread_self
/* Magic for libthread_db to know how to do THREAD_SELF. */
-# define DB_THREAD_SELF_INCLUDE <sys/ucontext.h>
# define DB_THREAD_SELF \
- REGISTER (32, 32, REG_G7 * 4, 0) REGISTER (64, 64, REG_G7 * 8, 0)
+ REGISTER (32, 32, 10 * 4, 0) \
+ REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)
/* Access to data in the thread descriptor is easy. */
#define THREAD_GETMEM(descr, member) \
--
1.7.10.4