Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFC: change needs_frame_tls_address
Date: Fri, 23 Jul 2010 22:33:00 -0000	[thread overview]
Message-ID: <m31vat3k2y.fsf@fleche.redhat.com> (raw)

I am curious to get reactions on this patch.

This fixes PR 11803, a gdb assertion resulting from trying to print the
TLS variable in this program:

    class A { public: static __thread int num; };
    __thread int A::num = 1;
    int main() { return 0; }

For this we get a warning from value_static_field, then things go
downhill and we hit an internal_error.  From the PR:

(gdb) print A::num
warning: static field's value depends on the current frame - bad debug info?
findvar.c:427: internal-error: read_var_value: Assertion `frame' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) 


After tracing through the TLS code for a bit, I have concluded that TLS
does not really need a frame, at least not in the gdb sense.  Instead, I
think it only needs registers -- a funny sort of distinction to make,
but nevertheless...

With this patch the behavior seems ok:

    (gdb) p A::num
    $1 = 1
    (gdb) kill
    Kill the program being debugged? (y or n) y
    (gdb) p A::num
    Cannot access memory at address 0xb7fdb6d8

If this seems acceptable I will write up a real test case.
If it is not acceptable, I would appreciate some enlightenment as to
what other approach I should take.

This built & regtested ok on x86-64 (compile farm).

Tom

2010-07-23  Tom Tromey  <tromey@redhat.com>

	PR exp/11803:
	* dwarf2loc.c (needs_frame_tls_address): Don't require a frame.

Index: dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.95
diff -u -r1.95 dwarf2loc.c
--- dwarf2loc.c	13 Jul 2010 15:09:03 -0000	1.95
+++ dwarf2loc.c	23 Jul 2010 22:25:56 -0000
@@ -1053,13 +1053,15 @@
   return 1;
 }
 
-/* Thread-local accesses do require a frame.  */
 static CORE_ADDR
 needs_frame_tls_address (void *baton, CORE_ADDR offset)
 {
   struct needs_frame_baton *nf_baton = baton;
 
-  nf_baton->needs_frame = 1;
+  /* Thread-local accesses require registers, but not an actual
+     frame.  This is a funny sort of distinction to make, but it lets
+     us avoid assertions elsewhere in gdb.  */
+  nf_baton->needs_frame = 0;
   return 1;
 }
 


             reply	other threads:[~2010-07-23 22:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-23 22:33 Tom Tromey [this message]
2010-07-24  1:04 ` Pedro Alves
2010-07-26 13:36   ` Daniel Jacobowitz

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=m31vat3k2y.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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