Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: Ignore TLS symbols for non-TLS programs
Date: Fri, 25 Aug 2006 16:43:00 -0000	[thread overview]
Message-ID: <20060825034301.GA24479@nevyn.them.org> (raw)
In-Reply-To: <20060825021311.GB30225@host0.dyn.jankratochvil.net>

First a general note: please include changelogs with patches.  Also in
the minor feedback area, updates to included files need to be reflected
in Makefile.in, and URLs to Red Hat's bugzilla are not appropriate for
the FSF GDB; if you want to describe the problem, just do so.

On Fri, Aug 25, 2006 at 04:13:11AM +0200, Jan Kratochvil wrote:
> * with -ggdb2 and less "errno" in fact does not exist anywhere as it was
>   compiled to "(*__errno_location ())" and the macro definition is not present.
>   Unfortunately gdb will find the TLS symbol and it will try to access it but
>   as the program has been compiled without -lpthread the TLS base register
>   (%gs on i386) is not setup and it will result in:
>   	Cannot access memory at address 0x8

That can't be correct.  Every program using glibc references errno.
If the program can access it, then GDB ought to be able to also.
In this case, libc.so.6 exports a dynamic TLS symbol named errno.

Did you try this with the patch you posted earlier to access TLS
without debug info?

> --- gdb/minsyms.c	19 Jul 2006 02:17:23 -0000	1.46
> +++ gdb/minsyms.c	25 Aug 2006 01:42:27 -0000
> @@ -50,6 +50,7 @@
>  #include "demangle.h"
>  #include "value.h"
>  #include "cp-abi.h"
> +#include "target.h"

This violates the abstraction layers.  We're reading the symbols from
a file.  Why should it matter what target we're connected to?  In fact,
we probably aren't connected to a target yet.  Decisions about what we
can access should only be made when we want to access it.

> +/* Test accessing TLS based variable without -lpthread / TLS setup.  */
> +
> +#include <pthread.h>
> +
> +__thread int thread_local = 42;
> +
> +int main(void)
> +{
> +  return 0;
> +}

It would be legal for main to return the value of thread_local, even
though it is not linked to pthread.c.

Oh, and you don't actually need <pthread.h> for this.

> +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {

Did you try this?  [] should give you a TCL syntax error.

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2006-08-25  3:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-25 13:43 Jan Kratochvil
2006-08-25 16:43 ` Daniel Jacobowitz [this message]
2006-08-26 11:56   ` Daniel Jacobowitz
2006-08-25 13:48     ` RFC: Access TLS symbols without DWARF debuginfo Jan Kratochvil
2006-08-25 20:02       ` Daniel Jacobowitz
2006-08-28 18:27         ` RFC: Access TLS symbols without DWARF debuginfo v2 Jan Kratochvil
2006-08-28 21:02           ` Jim Blandy
2006-08-29 11:41             ` Daniel Jacobowitz
2006-10-09 20:20               ` Daniel Jacobowitz
2006-10-10  3:22         ` RFC: Access TLS symbols without DWARF debuginfo Daniel Jacobowitz
2006-10-10  4:25           ` Eli Zaretskii
2006-10-17 21:03             ` Daniel Jacobowitz
2006-10-17 22:03               ` Jan Kratochvil
2006-10-18 15:29                 ` Daniel Jacobowitz
2006-10-18  4:27               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060825034301.GA24479@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox