RISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)

Message ID mvmo9fc532j.fsf@suse.de
State New
Headers show
Series
  • RISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)
Related show

Commit Message

Andreas Schwab July 12, 2018, 7:24 a.m.
Since RISC-V stores the thread pointer in a general register libthread_db
can just ask the debugger for the register contents instead of trying to
call ps_get_thread_area.  This enables thread debugging in gdb.

	* sysdeps/riscv/nptl/tls.h (DB_THREAD_SELF): Use REGISTER instead
	of CONST_THREAD_AREA.
---
 sysdeps/riscv/nptl/tls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jim Wilson July 12, 2018, 10:02 p.m. | #1
On Thu, Jul 12, 2018 at 12:24 AM, Andreas Schwab <schwab@suse.de> wrote:
> Since RISC-V stores the thread pointer in a general register libthread_db
> can just ask the debugger for the register contents instead of trying to
> call ps_get_thread_area.  This enables thread debugging in gdb.
>
>         * sysdeps/riscv/nptl/tls.h (DB_THREAD_SELF): Use REGISTER instead
>         of CONST_THREAD_AREA.

This looks good to me, just comparing with other glibc ports that have
tp in a register.  I'm not listed as one of the RISC-V port
maintainers though, but not sure if that matters.  Unfortunately, I
wasn't expecting to need glibc patches as part of my gdb porting
effort, so I don't have an easy way to test this myself at the moment.
I will have to extend my gdb testing setup to include support for
glibc patches.

Jim

Patch

diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
index 7745d59044..9fa43f2708 100644
--- a/sysdeps/riscv/nptl/tls.h
+++ b/sysdeps/riscv/nptl/tls.h
@@ -101,7 +101,7 @@  typedef struct
 
 /* Magic for libthread_db to know how to do THREAD_SELF.  */
 # define DB_THREAD_SELF \
-  CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+  REGISTER (64, 64, 4 * 8, - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
 
 /* Access to data in the thread descriptor is easy.  */
 # define THREAD_GETMEM(descr, member) \