https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128234
Kent Cheung <kent.cheung at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kent.cheung at linaro dot org
--- Comment #5 from Kent Cheung <kent.cheung at linaro dot org> ---
Inside the outlined OpenMP subprogram, the `array_1` variable is lacking
representation in a non-artificial DIE with an unmangled source identifier
DW_AT_name. Only a DIE for the artificial variable `array_1.0` is generated,
albeit without a `DW_AT_abstract_origin` entry to refer back to the enclosing
procedure's variable DIE containing the valid source identifier. As described
above, this hinders source-level debugging of non-main threads running the
OpenMP region. The following is an excerpt of the relevant DWARF info.
> <2><55>: Abbrev Number: 15 (DW_TAG_subprogram)
> <56> DW_AT_name : (strp) (offset: 0x162): populate_elements
> <5a> DW_AT_decl_file : (data1) 1
> <5b> DW_AT_decl_line : (data1) 10
> <5c> DW_AT_decl_column : (data1) 32
> <5d> DW_AT_low_pc : (addr) 0x11c9
> <65> DW_AT_high_pc : (data8) 0x12c
> <6d> DW_AT_frame_base : (exprloc) 1 byte block: 9c
> (DW_OP_call_frame_cfa)
> <6f> DW_AT_static_link : (exprloc) 7 byte block: 91 c8 7e 6 23 8 6
> (DW_OP_fbreg: -184; DW_OP_deref; DW_OP_plus_uconst: 8; DW_OP_deref)
> <77> DW_AT_call_all_tail_calls: (flag_present) 1
> <77> DW_AT_sibling : (ref4) <0x145>
> <3><7b>: Abbrev Number: 8 (DW_TAG_formal_parameter)
> <7c> DW_AT_name : (strp) (offset: 0x10): array_1
> <80> DW_AT_type : (ref4) <0x184>, real(kind=8)
> <84> DW_AT_artificial : (flag_present) 1
> <84> DW_AT_location : (exprloc) 4 byte block: 91 d8 7e 6
> (DW_OP_fbreg: -168; DW_OP_deref)
> <3><89>: Abbrev Number: 8 (DW_TAG_formal_parameter)
> <8a> DW_AT_name : (strp) (offset: 0x18): array_2
> <8e> DW_AT_type : (ref4) <0x1af>, real(kind=8)
> <92> DW_AT_artificial : (flag_present) 1
> <92> DW_AT_location : (exprloc) 4 byte block: 91 d0 7e 6
> (DW_OP_fbreg: -176; DW_OP_deref)
> <3><97>: Abbrev Number: 16 (DW_TAG_subprogram)
> <98> DW_AT_name : (strp) (offset: 0x17e):
> populate_elements.0._omp_fn.0
> <9c> DW_AT_artificial : (flag_present) 1
> <9c> DW_AT_low_pc : (addr) 0x158d
> <a4> DW_AT_high_pc : (data8) 0x20d
> <ac> DW_AT_frame_base : (exprloc) 1 byte block: 9c
> (DW_OP_call_frame_cfa)
> <ae> DW_AT_call_all_tail_calls: (flag_present) 1
> <ae> DW_AT_sibling : (ref4) <0x115>
> <4><b2>: Abbrev Number: 17 (DW_TAG_formal_parameter)
> <b3> DW_AT_type : (ref4) <0x236>, .omp_data_s.25
> <b7> DW_AT_artificial : (flag_present) 1
> <b7> DW_AT_location : (exprloc) 3 byte block: 91 d8 7e
> (DW_OP_fbreg: -168)
> <4><bb>: Abbrev Number: 6 (DW_TAG_variable)
> <bc> DW_AT_name : (strp) (offset: 0x174): array_1.0
> <c0> DW_AT_type : (ref4) <0x240>
> <c4> DW_AT_artificial : (flag_present) 1
> <c4> DW_AT_location : (exprloc) 4 byte block: 91 d8 7e 6
> (DW_OP_fbreg: -168; DW_OP_deref)
> <4><c9>: Abbrev Number: 6 (DW_TAG_variable)
> <ca> DW_AT_name : (strp) (offset: 0): ubound.0
> <ce> DW_AT_type : (ref4) <0x2f>, integer(kind=8)
> <d2> DW_AT_artificial : (flag_present) 1
> <d2> DW_AT_location : (exprloc) 3 byte block: 91 b0 7f
> (DW_OP_fbreg: -80)
> <4><d6>: Abbrev Number: 6 (DW_TAG_variable)
> <d7> DW_AT_name : (strp) (offset: 0x123): array_2.0
> <db> DW_AT_type : (ref4) <0x24a>
> <df> DW_AT_artificial : (flag_present) 1
> <df> DW_AT_location : (exprloc) 6 byte block: 91 d8 7e 6 23 20
> (DW_OP_fbreg: -168; DW_OP_deref; DW_OP_plus_uconst: 32)
> <4><e6>: Abbrev Number: 1 (DW_TAG_variable)
> <e7> DW_AT_name : (string) iv
> <ea> DW_AT_decl_file : (implicit_const) 1
> <ea> DW_AT_decl_line : (data1) 4
> <eb> DW_AT_decl_column : (data1) 17
> <ec> DW_AT_type : (ref4) <0x1d3>, integer(kind=4)
> <f0> DW_AT_location : (exprloc) 3 byte block: 91 b8 7f
> (DW_OP_fbreg: -72)
> <4><f4>: Abbrev Number: 18 (DW_TAG_lexical_block)
> <f5> DW_AT_low_pc : (addr) 0x16a2
> <fd> DW_AT_high_pc : (data8) 0xc6
> <5><105>: Abbrev Number: 1 (DW_TAG_variable)
> <106> DW_AT_name : (string) iv
> <109> DW_AT_decl_file : (implicit_const) 1
> <109> DW_AT_decl_line : (data1) 4
> <10a> DW_AT_decl_column : (data1) 17
> <10b> DW_AT_type : (ref4) <0x1d3>, integer(kind=4)
> <10f> DW_AT_location : (exprloc) 3 byte block: 91 bc 7f
> (DW_OP_fbreg: -68)
> <5><113>: Abbrev Number: 0
> <4><114>: Abbrev Number: 0
Compare with this small C example
> #include "omp.h"
>
> void foo(int n) {
> int array_1[n];
> #pragma omp parallel shared(array_1)
> {
> for (int i = 0; i<n; ++i)
> array_1[i] = i;
> }
> }
> int main() {
> foo(10);
> }
Which as shown below generates both a DIE with the non-mangled source
identifier, as well as the artificial variable DIE with the suffixed name. In
this case, source-level debugging works as expected within the OpenMP region,
including on non-main threads.
> <2><81>: Abbrev Number: 9 (DW_TAG_subprogram)
> <82> DW_AT_name : (strp) (offset: 0x2d): _Z3fooi._omp_fn.0
> <86> DW_AT_artificial : (flag_present) 1
> <86> DW_AT_low_pc : (addr) 0x128c
> <8e> DW_AT_high_pc : (data8) 0x4a
> <96> DW_AT_frame_base : (exprloc) 1 byte block: 9c
> (DW_OP_call_frame_cfa)
> <98> DW_AT_call_all_calls: (flag_present) 1
> <98> DW_AT_sibling : (ref4) <0xe8>
> <3><9c>: Abbrev Number: 10 (DW_TAG_formal_parameter)
> <9d> DW_AT_type : (ref4) <0x127>, .omp_data_s.3, typedef
> .omp_data_s.3 .omp_data_s.3, 13.omp_data_s.3
> <a1> DW_AT_artificial : (flag_present) 1
> <a1> DW_AT_location : (exprloc) 2 byte block: 91 58 (DW_OP_fbreg:
> -40)
> <3><a4>: Abbrev Number: 2 (DW_TAG_variable)
> <a5> DW_AT_name : (strp) (offset: 0): array_1
> <a9> DW_AT_decl_file : (implicit_const) 1
> <a9> DW_AT_decl_line : (implicit_const) 4
> <a9> DW_AT_decl_column : (implicit_const) 9
> <a9> DW_AT_type : (ref4) <0x12c>, int
> <ad> DW_AT_location : (exprloc) 3 byte block: 91 68 6 (DW_OP_fbreg:
> -24; DW_OP_deref)
> <3><b1>: Abbrev Number: 3 (DW_TAG_variable)
> <b2> DW_AT_name : (string) n
> <b4> DW_AT_decl_file : (implicit_const) 1
> <b4> DW_AT_decl_line : (data1) 3
> <b5> DW_AT_decl_column : (data1) 14
> <b6> DW_AT_type : (ref4) <0x4a>, int
> <ba> DW_AT_location : (exprloc) 2 byte block: 91 64 (DW_OP_fbreg:
> -28)
> <3><bd>: Abbrev Number: 11 (DW_TAG_variable)
> <be> DW_AT_name : (strp) (offset: 0x118): array_1.1
> <c2> DW_AT_type : (ref4) <0x13b>, int
> <c6> DW_AT_artificial : (flag_present) 1
> <c6> DW_AT_location : (exprloc) 2 byte block: 91 68 (DW_OP_fbreg:
> -24)
> <3><c9>: Abbrev Number: 12 (DW_TAG_lexical_block)
> <ca> DW_AT_low_pc : (addr) 0x12ad
> <d2> DW_AT_high_pc : (data8) 0x26
> <4><da>: Abbrev Number: 3 (DW_TAG_variable)
> <db> DW_AT_name : (string) i
> <dd> DW_AT_decl_file : (implicit_const) 1
> <dd> DW_AT_decl_line : (data1) 7
> <de> DW_AT_decl_column : (data1) 18
> <df> DW_AT_type : (ref4) <0x4a>, int
> <e3> DW_AT_location : (exprloc) 2 byte block: 91 60 (DW_OP_fbreg:
> -32)
> <4><e6>: Abbrev Number: 0
> <3><e7>: Abbrev Number: 0
Please let us know if more information is required for this issue to be
confirmed as a bug.