Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* tcbhead_t gdb access for nonthreaded, gdb for longjmp()
@ 2006-09-08 10:29 Jan Kratochvil
  2006-09-10 14:27 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2006-09-08 10:29 UTC (permalink / raw)
  To: gdb

Hi,

crossposted to gdb+glibc as the patches closely correlate:

currently gdb/glibc cannot access TLS of debugged processes if compiled without
libpthread (nonthreaded).  Command line `print errno' produces one of:
	Cannot find thread-local variables on this target
	Cannot access memory at address 0x8
	[ gdb-20060908-tls-0.patch: gdb.threads/tls-print.exp ]

It also affects stepping over longjmp() as gdb calculates target address which
is PTR_MANGLE()d through TLS-based `pointer_guard' magic, as `next' will now:
	Cannot insert breakpoint -12.
	Error accessing memory address 0xb9227d3b: Input/output error.
	[ gdb-20060908-tls-0.patch: gdb.threads/tls-longjmp.exp ]

I would like to get approval of this design acceptance to finish the details.

glibc part:

 * Provide some access to the `tcbhead_t.pointer_guard' field for gdb.
   Currently implemented by `td_thr_getxregs' providing only `pointer_guard'.
   New non-Solaris `td_thr_*' function could be provided instead.

 * All the `libthread_db' functions accessing inferior's `_thread_db*' symbols
   of `libpthread' fallback to the new `_local_db*' symbols in `libthread_db'
   itself. `libthread_db'<=>`libpthread' versions must match anyway.
   I admit I do not know how may `libthread_db' and `libpthread' as there is
   already required in `td_ta_new' their versions match.  Anyway it should be
   enough for 99% of cases - as the fallback option.

gdb part:

 * `longjmp' decoder attempts to use `td_thr_getxregs', otherwise fallbacks
   to get the TLS base by `ps_get_thread_area' and the offset value
   `offsetof (tcbhead_t, pointer_guard)' from debuginfo, otherwise fallbacks
   to internal constant offset.

 * `SEC_THREAD_LOCAL' symbols are processed as a new expression data type.

 * TLS variables access uses legacy `thread_db_get_thread_local_address'
   as it depends on the `_local_db*' fallback implementation for nonthreaded
   processes missing `libthread_db' with the legacy `_thread_db*' symbols.


`longjmp' decoder can cope without glibc support by using debuginfo instead.
I would rather like to drop this workaround and rely on the glibc support.

TLS access needs the attached glibc patch for the nonthreaded processes.
I could provide gdb decoding without glibc support but I do not like it.

It works now only on i386, x86_64 to be debugged if it is accepted this way.
Patches still contain several FIXMEs; their fixes should not change the design.
glibc part should be arch-dependent, it will now fail to compile on arches
without existing `pointer_guard'.

Behavior changes depending on:
 * Application linked with libpthread or without libpthread.
 * glibc original/patched by this TLS extension.
 * -ggdb3 (overriding the TLS `errno' resolving just by the macro text).
 * Debuginfo availability for libpthread (for `longjmp').
Unfortunately the system changes cannot be tested just by the gdb testsuite.


Thanks,
Jan

Patches at: http://www.jankratochvil.net/priv/tls/


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-13 18:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-08 10:29 tcbhead_t gdb access for nonthreaded, gdb for longjmp() Jan Kratochvil
2006-09-10 14:27 ` Daniel Jacobowitz
2006-09-13 13:05   ` Jan Kratochvil
2006-09-13 13:20     ` Daniel Jacobowitz
2006-09-13 18:37       ` Jan Kratochvil
2006-09-13 18:49         ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox