This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: thread local storage (__thread) variables aren't working in gdb 6.5/6.6?

Hi Ajit,

[ ]

On Mon, 13 Apr 2009 16:35:30 +0200, ajit nayak wrote:
> Below  are the details. I did try with gdb-6.8 (after compining both with
> g++), but no luck..ran into the same problem.

if you try CVS HEAD it should work:
	cvs -d co gdb

> However if I compile with gcc with a ".c" file  (NOT .cpp) extension (gcc -g
> tls.cpp  -o tls -lpthread), everyting works fine, i can access teh thread
> local variable from gdb.  But my requirement is to compile .cpp files with
> g++ .

Checked the difference, both g++-4.3 and gcc-4.1 use more simple format as
read by `readelf -wi':
 <1><88>: Abbrev Number: 7 (DW_TAG_variable)
    <89>   DW_AT_name        : i	
    <91>   DW_AT_external    : 1	
    <92>   DW_AT_location    : 10 byte block: 3 0 0 0 0 0 0 0 0 e0 	(DW_OP_addr: 0; DW_OP_GNU_push_tls_address or DW_OP_HP_unknown)

while g++-4.1 uses:
 <2><d2>: Abbrev Number: 7 (DW_TAG_variable)
     DW_AT_name        : i	
     DW_AT_external    : 1	
     DW_AT_declaration : 1	
 <1><de>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_specification: <d2>	
     DW_AT_location    : 10 byte block: 3 0 0 0 0 0 0 0 0 e0 	(DW_OP_addr: 0; DW_OP_GNU_push_tls_address)

Which is perfectly valid DWARF but current GDB cannot cope with it.

It starts working in post-6.8 FSF GDB because it gets resolved as an external
TLS reference.  External TLS references did not work before.  It is not
completely correct but in practice it works.  Fixed by this patch:

> [nz@TT4-A022 thread]$ cat /etc/redhat-release
> Red Hat Enterprise Linux Server release 5.2 (Tikanga)
> *[nz@TT4-A022 thread]$  g++ -g tls.cpp -o tls -lpthread*

=> Also using g++43 (bare g++ is 4.1 on RHEL-5.2) would workaround GDB.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]