Bug 11616

Summary: DW_OP_form_tls_address is unimplemented
Product: gdb Reporter: Tom Tromey <tromey>
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: emaste, gbenson, gdb-prs, tromey
Priority: P2    
Version: 8.0   
Target Milestone: 7.1   
Host: Target:
Build: Last reconfirmed: 2010-07-07 15:59:41
Project(s) to access: ssh public key:

Description Tom Tromey 2010-05-20 19:52:44 UTC
gdb does not implement the DW_OP_form_tls_address opcode.
This is part of dwarf 4, and gcc can optionally emit it.
Comment 1 Tom Tromey 2010-07-07 15:59:41 UTC
GCC only emits it for emutls systems.
In this case the value on the stack is the address of the control variable.
See gcc/emutls.c for more info.
Note that this means that this operator is not equivalent to
DW_OP_GNU_push_tls_address.
Comment 2 emaste 2015-03-03 20:37:27 UTC
LLVM will likely start emitting this soon - see e.g.
http://reviews.llvm.org/D8018
Comment 3 Tom Tromey 2016-08-22 03:45:32 UTC
I now think it's probably fine to have gdb have to handle emultls
systems differently, and just gradually move the toolchain to using
the standard format.
Comment 4 Tom Tromey 2016-08-22 03:46:45 UTC
Suggested the change for gcc in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77315
Comment 5 Sourceware Commits 2016-09-02 18:29:25 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4aa4e28bdcf5f0d733def62b542fea11d5f219d5

commit 4aa4e28bdcf5f0d733def62b542fea11d5f219d5
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Aug 22 16:56:52 2016 -0600

    Handle DW_OP_form_tls_address
    
    Currently gdb supports DW_OP_GNU_push_tls_address, but not
    DW_OP_form_tls_address.  I think it would be better if the toolchain
    as a whole moved to using the standard opcode, and the prerequisite to
    this is getting gdb to recognize it.
    
    GCC can sometimes emit DW_OP_form_tls_address for emultls targets.  As
    far as I know, nobody has ever tried this with gdb (since it wouldn't
    work at all).
    
    I don't think there's a major drawback to using a single opcode for
    all targets, because computing the location of a thread-local is
    already target specific.
    
    This is PR gdb/11616.
    
    I don't know how to write a test case for this; though it's worth
    noting that there aren't explicit tests for DW_OP_GNU_push_tls_address
    either -- and if I change GCC, these paths will be tested to the same
    extent they are now.
    
    2016-09-02  Tom Tromey  <tom@tromey.com>
    
    	PR gdb/11616:
    	* dwarf2read.c (decode_locdesc): Handle DW_OP_form_tls_address.
    	* dwarf2loc.c (dwarf2_compile_expr_to_ax): Handle
    	DW_OP_form_tls_address.
    	(locexpr_describe_location_piece): Likewise.
    	* dwarf2expr.h (struct dwarf_expr_context_funcs): Update comment.
    	* dwarf2expr.c (execute_stack_op): Handle DW_OP_form_tls_address.
    	(ctx_no_get_tls_address): Mention DW_OP_form_tls_address.
    	* compile/compile-loc2c.c (struct insn_info): Update comment.
    	(compute_stack_depth_worker): Handle DW_OP_form_tls_address.
Comment 6 Tom Tromey 2016-09-02 18:32:28 UTC
Fixed.