D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21153 - DWARF: DMD emits the mangled name for DW_AT_name
Summary: DWARF: DMD emits the mangled name for DW_AT_name
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P1 trivial
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-08-13 13:19 UTC by LucienPe
Modified: 2020-08-20 11:19 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description LucienPe 2020-08-13 13:19:04 UTC
Consider the following program:

---
module bar;

int x = 9;

void main(string[] args)
{
    int i = 5;
    bar(i);
}

void bar(int i)
{
    i = x;
    x += i;
}
---

DMD will emit this:

---
.debug_info contents:
0x00000000: Compile Unit: length = 0x000001ee version = 0x0003 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x000001f2)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer	("Digital Mars D v2.093.0\n")
              DW_AT_language	(DW_LANG_D)
              DW_AT_name	("src/main.d")
              DW_AT_comp_dir	("/home/lucien/Documents/Programmation/D/b9800")
              DW_AT_low_pc	(0x0000000000000000)
              DW_AT_entry_pc	(0x0000000000000000)
              DW_AT_ranges	(0x00000000
                 [0x000000000003f69c, 0x000000000003f6bf)
                 [0x000000000003f6c0, 0x000000000003f6fb)
                 [0x000000000003f6fc, 0x000000000003f720))
              DW_AT_stmt_list	(0x00000000)

0x00000076:   DW_TAG_module
                DW_AT_name	("bar")

0x0000007b:   DW_TAG_base_type
                DW_AT_name	("int")
                DW_AT_byte_size	(0x04)
                DW_AT_encoding	(DW_ATE_signed)

0x00000082:   DW_TAG_variable
                DW_AT_name	("_D3bar1xi")
                DW_AT_type	(0x0000007b "int")
                DW_AT_external	(0x01)
                DW_AT_location	(DW_OP_const8u 0x0, DW_OP_GNU_push_tls_address)

0x0000009d:   DW_TAG_base_type
                DW_AT_name	("uint long")
                DW_AT_byte_size	(0x04)
                DW_AT_encoding	(DW_ATE_unsigned)

0x000000aa:   DW_TAG_base_type
                DW_AT_name	("char")
                DW_AT_byte_size	(0x01)
                DW_AT_encoding	(DW_ATE_unsigned_char)

0x000000b2:   DW_TAG_pointer_type
                DW_AT_type	(0x000000aa "char")

0x000000b7:   DW_TAG_structure_type
                DW_AT_name	("_Array_char")
                DW_AT_byte_size	(0x10)

0x000000c5:     DW_TAG_member
                  DW_AT_name	("length")
                  DW_AT_type	(0x0000009d "uint long")
                  DW_AT_data_member_location	(DW_OP_plus_uconst 0x0)

0x000000d4:     DW_TAG_member
                  DW_AT_name	("ptr")
                  DW_AT_type	(0x000000b2 "char*")
                  DW_AT_data_member_location	(DW_OP_plus_uconst 0x8)

0x000000e0:     NULL

0x000000e1:   DW_TAG_pointer_type
                DW_AT_type	(0x000000b7 "_Array_char")

0x000000e6:   DW_TAG_structure_type
                DW_AT_name	("_Array_ucent")
                DW_AT_byte_size	(0x10)

0x000000f5:     DW_TAG_member
                  DW_AT_name	("length")
                  DW_AT_type	(0x0000009d "uint long")
                  DW_AT_data_member_location	(DW_OP_plus_uconst 0x0)

0x00000104:     DW_TAG_member
                  DW_AT_name	("ptr")
                  DW_AT_type	(0x000000e1 "_Array_char*")
                  DW_AT_data_member_location	(DW_OP_plus_uconst 0x8)

0x00000110:     NULL

0x00000111:   DW_TAG_subprogram
                DW_AT_sibling	(0x00000156)
                DW_AT_name	("D main")
                DW_AT_MIPS_linkage_name	("_Dmain")
                DW_AT_decl_file	("src/main.d")
                DW_AT_decl_line	(5)
                DW_AT_external	(0x01)
                DW_AT_low_pc	(0x000000000003f69c)
                DW_AT_high_pc	(0x000000000003f6bf)
                DW_AT_frame_base	(0x00000000: 
                   [0x000000000003f69c, 0x000000000003f69d): DW_OP_breg7 RSP+8
                   [0x000000000003f69d, 0x000000000003f69f): DW_OP_breg7 RSP+16
                   [0x000000000003f69f, 0x000000000003f6bf): DW_OP_breg6 RBP+16)

0x0000013c:     DW_TAG_formal_parameter
                  DW_AT_name	("args")
                  DW_AT_type	(0x000000e6 "_Array_ucent")
                  DW_AT_artificial	(0x00)
                  DW_AT_location	(DW_OP_fbreg -32)

0x0000014a:     DW_TAG_variable
                  DW_AT_name	("i")
                  DW_AT_type	(0x0000007b "int")
                  DW_AT_artificial	(0x00)
                  DW_AT_location	(DW_OP_fbreg -40)

0x00000155:     NULL

0x00000156:   DW_TAG_subprogram
                DW_AT_sibling	(0x00000194)
                DW_AT_name	("bar.bar")
                DW_AT_MIPS_linkage_name	("_D3barQeFiZv")
                DW_AT_decl_file	("src/main.d")
                DW_AT_decl_line	(11)
                DW_AT_external	(0x01)
                DW_AT_low_pc	(0x000000000003f6c0)
                DW_AT_high_pc	(0x000000000003f6fb)
                DW_AT_frame_base	(0x0000004c: 
                   [0x000000000003f6c0, 0x000000000003f6c1): DW_OP_breg7 RSP+8
                   [0x000000000003f6c1, 0x000000000003f6c3): DW_OP_breg7 RSP+16
                   [0x000000000003f6c3, 0x000000000003f6fb): DW_OP_breg6 RBP+16)

0x00000188:     DW_TAG_formal_parameter
                  DW_AT_name	("i")
                  DW_AT_type	(0x0000007b "int")
                  DW_AT_artificial	(0x00)
                  DW_AT_location	(DW_OP_fbreg -24)

0x00000193:     NULL

0x00000194:   DW_TAG_pointer_type
                DW_AT_type	(0x000000b2 "char*")

0x00000199:   DW_TAG_subprogram
                DW_AT_sibling	(0x000001f1)
                DW_AT_name	("bar._d_cmain!().main")
                DW_AT_MIPS_linkage_name	("main")
                DW_AT_decl_file	("/usr/include/dlang/dmd/core/internal/entrypoint.d")
                DW_AT_decl_line	(27)
                DW_AT_type	(0x0000007b "int")
                DW_AT_external	(0x01)
                DW_AT_low_pc	(0x000000000003f6fc)
                DW_AT_high_pc	(0x000000000003f720)
                DW_AT_frame_base	(0x00000098: 
                   [0x000000000003f6fc, 0x000000000003f6fd): DW_OP_breg7 RSP+8
                   [0x000000000003f6fd, 0x000000000003f6ff): DW_OP_breg7 RSP+16
                   [0x000000000003f6ff, 0x000000000003f720): DW_OP_breg6 RBP+16)

0x000001d4:     DW_TAG_formal_parameter
                  DW_AT_name	("argc")
                  DW_AT_type	(0x0000007b "int")
                  DW_AT_artificial	(0x00)
                  DW_AT_location	(DW_OP_fbreg -32)

0x000001e2:     DW_TAG_formal_parameter
                  DW_AT_name	("argv")
                  DW_AT_type	(0x00000194 "char**")
                  DW_AT_artificial	(0x00)
                  DW_AT_location	(DW_OP_fbreg -24)

0x000001f0:     NULL

0x000001f1:   NULL

.debug_pubnames contents:
length = 0x00000033 version = 0x0002 unit_offset = 0x00000000 unit_size = 0x000001f2
Offset     Name
0x00000111 "_Dmain"
0x00000156 "_D3barQeFiZv"
0x00000199 "main"
---

`DW_AT_name` should contain the plain variable name, because the mangled name is for the `DW_AT_linkage_name` attribute.
In `debug_pubnames`, the names should also be plain.

LDC emits correctly these names.
Comment 1 Dlang Bot 2020-08-13 19:50:03 UTC
@Luhrel updated dlang/dmd pull request #11540 "Fix issue 21153  - DWARF: DMD emits the mangled name for DW_AT_name" fixing this issue:

- Fix issue 21153 - DWARF: DMD emits the mangled name for DW_AT_name

https://github.com/dlang/dmd/pull/11540
Comment 2 Dlang Bot 2020-08-20 11:19:09 UTC
dlang/dmd pull request #11540 "Fix issue 21153  - DWARF: DMD emits the mangled name for DW_AT_name" was merged into master:

- 5dd37c4b98a6264bfafd0bcfaae8e952d2b72925 by Luhrel:
  Fix issue 21153 - DWARF: DMD emits the mangled name for DW_AT_name

- 2c4b2b439ba27dff17964c8fbb2a007a911a5e63 by Luhrel:
  Add tests for issue 21153

https://github.com/dlang/dmd/pull/11540