https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83010

            Bug ID: 83010
           Summary: DW_AT_location is not emitted for thread local
                    variable
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qiyao at gcc dot gnu.org
  Target Milestone: ---

$ cat 1.c
__thread int a_thread_local;

$ gcc -g -c 1.c -o 1.o

$ readelf -wi ./1.o
....
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : (indirect string, offset: 0x38): GNU C17
8.0.0 20171102 (experimental) -mlittle-endian -mabi=lp64 -g
    <10>   DW_AT_language    : 12 (ANSI C99)
    <11>   DW_AT_name        : 1.c
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x0): gdb
    <19>   DW_AT_stmt_list   : 0x0
<1><1d>: Abbrev Number: 2 (DW_TAG_variable)
    <1e>   DW_AT_name        : (indirect string, offset: 0x29): a_thread_local
    <22>   DW_AT_decl_file   : 1
    <23>   DW_AT_decl_line   : 1
    <24>   DW_AT_decl_column : 14
    <25>   DW_AT_type        : <0x29>
    <29>   DW_AT_external    : 1

DW_AT_location is missing, so GDB can't locate this variable.  However, on arm
and x86_64, DW_AT_location is emitted.

x86_64:
 <1><1d>: Abbrev Number: 2 (DW_TAG_variable)
    <1e>   DW_AT_name        : (indirect string, offset: 0x3e): a_thread_local
    <22>   DW_AT_decl_file   : 1
    <23>   DW_AT_decl_line   : 1
    <24>   DW_AT_type        : <0x33>
    <28>   DW_AT_external    : 1
    <28>   DW_AT_location    : 10 byte block: e 0 0 0 0 0 0 0 0 e0
(DW_OP_const8u: 0 0; DW_OP_GNU_push_tls_address or DW_OP_HP_unknown)

arm:
<1><1d>: Abbrev Number: 2 (DW_TAG_variable)
    <1e>   DW_AT_name        : (indirect string, offset: 0xa2): a_thread_local
    <22>   DW_AT_decl_file   : 1
    <23>   DW_AT_decl_line   : 1
    <24>   DW_AT_type        : <0x2f>
    <28>   DW_AT_external    : 1
    <28>   DW_AT_location    : 6 byte block: c 0 0 0 0 e0
(DW_OP_const4u: 0; DW_OP_GNU_push_tls_address or DW_OP_HP_unknown)

Reply via email to