public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* RFC: change needs_frame_tls_address
@ 2010-07-23 22:33 Tom Tromey
  2010-07-24  1:04 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-07-23 22:33 UTC (permalink / raw)
  To: gdb-patches

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;
 }
 

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

end of thread, other threads:[~2010-07-26 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 22:33 RFC: change needs_frame_tls_address Tom Tromey
2010-07-24  1:04 ` Pedro Alves
2010-07-26 13:36   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).