From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27842 invoked by alias); 8 Sep 2006 10:29:43 -0000 Received: (qmail 27816 invoked by uid 22791); 8 Sep 2006 10:29:43 -0000 X-Spam-Check-By: sourceware.org Received: from ip-160-218-140-228.eurotel.cz (HELO host0.dyn.jankratochvil.net) (160.218.140.228) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Sep 2006 10:29:40 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.8/8.13.8) with ESMTP id k88ATZLY025419 for ; Fri, 8 Sep 2006 12:29:35 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.13.8/8.13.8/Submit) id k88ATZpZ025418 for gdb@sourceware.org; Fri, 8 Sep 2006 12:29:35 +0200 Resent-Message-Id: <200609081029.k88ATZpZ025418@host0.dyn.jankratochvil.net> Date: Fri, 08 Sep 2006 10:29:00 -0000 From: Jan Kratochvil To: gdb@sourceware.org Subject: tcbhead_t gdb access for nonthreaded, gdb for longjmp() Message-ID: <20060908102235.GA31335@host0.dyn.jankratochvil.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Resent-From: jan.kratochvil@redhat.com Resent-Date: Fri, 8 Sep 2006 12:29:35 +0200 Resent-To: gdb@sourceware.org X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00056.txt.bz2 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/