how to view __thread variables in gdb on riscv architecture

153 views
Skip to first unread message

Anitha Quest

unread,
May 28, 2022, 1:53:53 PM5/28/22
to RISC-V SW Dev
Hi All, 
I am trying to use Thread Local Storage in my application, noticed when i declare variables with __thread prefix as expected in the objdump i see the offsets bring mentioned as opposed to absolute address like in the case of normal globals 

Example
2 TLS variables : 

__thread tls_var1;

__thread tls_var2 = 0xDECA;

 from Objdump 

00000000000010d4 g       .tbss  0000000000000004 tls_var1

0000000000000000 g       .tdata 0000000000000004 tls_var2


I am able to use tls_var1 and tls_var2, to view the variables via gdb i have to add $tp + <Offset>. see the expected data. 


Question : 

How can i view the variable in gdb using just the symbol i.e
gdb > p/x tls_var1 

"Cannot find thread-local variables on this target"  

it will help debug better if GDB can be made aware of TLS. Please let me know if i am missing anything my compiler or GDB setup ? 

Compiler 

clang version 13.0.0 (https://github.com/llvm/llvm-project.git

Target: riscv64-unknown-unknown-elf

Thread model: posix

GDB 

GNU gdb (GDB) 11.0.50.20210206-git

Thanks,

Anitha 

Reply all
Reply to author
Forward
0 new messages