Index: lldb/trunk/lit/Breakpoint/Inputs/debug_addrx.yaml =================================================================== --- lldb/trunk/lit/Breakpoint/Inputs/debug_addrx.yaml +++ lldb/trunk/lit/Breakpoint/Inputs/debug_addrx.yaml @@ -0,0 +1,57 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C700112000E897010000F4CCCCCCCCCCCC55B810202000483D102020004889E57417B8000000004885C0740D5DBF10202000FFE00F1F4400005DC3660F1F440000BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF10202000FFE00F1F005DC3660F1F440000803D592F0000007517554889E5E87EFFFFFFC605472F0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89CCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC31C0C3CCCCCCCCCCCCCCCCCCCCCCCCCC415741564189FF415541544C8D25E61E000055488D2DE61E0000534989F64989D54C29E54883EC0848C1FD03E8430000004885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 44000000050000006B0000005F0000003A0000000E0000001A0000001E000000930000002E0000001600000067000000050000009A0000008E000000000000006900000095000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 74686973005F5A336261723141005F76707472244100666F6F00696E74005F5F7674626C5F7074725F74797065005F5A4E314133666F6F4576002F686F6D652F756D622F74657374735F323031382F3131326C6C64625F726C657461677300746573742E63630041006100636C616E672076657273696F6E20382E302E3020287472756E6B2033343438333429006D61696E0078006F626A410062617200 + - Name: .debug_loc + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: E010200000000000E010200000000000030011009FE010200000000000E1102000000000000500110023019F00000000000000000000000000000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B25731711015517741700000213011D13360B03250B0B3A0B3B0B0000030D0003254913380B34190000040D00032549133A0B3B0B380B0000052E016E2503253A0B3B0B4C0B4D183C193F191D130000060500491334190000070F0049130000080F00491303250000091500491300000A240003253E0B0B0B00000B2E01111B1206401864137A193B0B471300000C050003254913341900000D3400021703253A0B3B0B491300000E2E01111B120640187A196E2503253A0B3B0B3F1900000F050003253A0B3B0B49130000102E01111B120640187A1903253A0B3B0B49133F19000011340003253A0B3B0B4913000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: C8000000050001080000000001000400010800000000000000020800000000000000000000000C0000000C000000022E000000040910010303035C0000000004066C0000000104080507080105010210002E000000067000000000000761000000086700000005096C0000000A040504072E0000000B000100000001578600000008480000000C0DC60000000D000000000601096C000000000E010100000001570A0B010D0F0E010D2E0000000010020300000001570C01116C000000110F01122E00000000072E00000000 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 27000000050008000000000007E0102000000000000107F010200000000000010700112000000000000300 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 1C00000005000800E010200000000000F0102000000000000011200000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 97000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E02250000000066F622AD4EB40BCEA506478235D9D438250000000066F622AD4EB40BCEA506478235D9D438000902E0102000000000001905010A150201000101000902F010200000000000030C0105010A140201000101000902001120000000000003100105030A170203000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3131326C6C64625F726C657461677300746573742E636300 +Symbols: Index: lldb/trunk/lit/Breakpoint/debug_addrx.test =================================================================== --- lldb/trunk/lit/Breakpoint/debug_addrx.test +++ lldb/trunk/lit/Breakpoint/debug_addrx.test @@ -0,0 +1,30 @@ +# RUN: yaml2obj %p/Inputs/debug_addrx.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# The following code and invocation were used. +# clang -gdwarf-5 test.cc -o test_v5 -fuse-ld=lld -fno-rtti -O2 -ffunction-sections +# Then output was converted to yaml and reduced. +# +# struct A { +# void foo() {}; +# }; +# +# void bar(struct A a) { +# a.foo(); +# } +# +# int main() { +# A objA; +# bar(objA); +# +# return 0; +# } +# +# clang and LLD versions were 8.0.0 (trunk 344834) +# +# Output file contains DW_FORM_addrx forms. + +b bar + +# CHECK-LABEL: b bar +# CHECK: Address: {{.*}}`bar(A) at test.cc:15:1 Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -118,6 +118,7 @@ break; // 1 byte values + case DW_FORM_addrx1: case DW_FORM_data1: case DW_FORM_flag: case DW_FORM_ref1: @@ -126,17 +127,21 @@ break; // 2 byte values + case DW_FORM_addrx2: case DW_FORM_data2: case DW_FORM_ref2: case DW_FORM_strx2: form_size = 2; break; + // 3 byte values + case DW_FORM_addrx3: case DW_FORM_strx3: form_size = 3; break; // 4 byte values + case DW_FORM_addrx4: case DW_FORM_data4: case DW_FORM_ref4: case DW_FORM_strx4: @@ -151,6 +156,7 @@ break; // signed or unsigned LEB 128 values + case DW_FORM_addrx: case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -233,18 +233,23 @@ m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4); break; + case DW_FORM_addrx: case DW_FORM_strx: m_value.value.uval = data.GetULEB128(offset_ptr); break; + case DW_FORM_addrx1: case DW_FORM_strx1: m_value.value.uval = data.GetU8(offset_ptr); break; + case DW_FORM_addrx2: case DW_FORM_strx2: m_value.value.uval = data.GetU16(offset_ptr); break; + case DW_FORM_addrx3: case DW_FORM_strx3: m_value.value.uval = data.GetMaxU64(offset_ptr, 3); break; + case DW_FORM_addrx4: case DW_FORM_strx4: m_value.value.uval = data.GetU32(offset_ptr); break; @@ -376,6 +381,7 @@ return true; // 1 byte values + case DW_FORM_addrx1: case DW_FORM_data1: case DW_FORM_flag: case DW_FORM_ref1: @@ -384,6 +390,7 @@ return true; // 2 byte values + case DW_FORM_addrx2: case DW_FORM_data2: case DW_FORM_ref2: case DW_FORM_strx2: @@ -391,6 +398,7 @@ return true; // 3 byte values + case DW_FORM_addrx3: case DW_FORM_strx3: *offset_ptr += 3; return true; @@ -403,6 +411,7 @@ return true; // 4 byte values + case DW_FORM_addrx4: case DW_FORM_data4: case DW_FORM_ref4: case DW_FORM_strx4: @@ -417,6 +426,7 @@ return true; // signed or unsigned LEB 128 values + case DW_FORM_addrx: case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: @@ -625,7 +635,9 @@ return Unsigned(); assert(m_cu); - assert(m_form == DW_FORM_GNU_addr_index); + assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx || + m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 || + m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4); if (!symbol_file) return 0; @@ -798,6 +810,7 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) { switch (form) { case DW_FORM_addr: + case DW_FORM_addrx: case DW_FORM_block2: case DW_FORM_block4: case DW_FORM_data2: Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -111,8 +111,9 @@ dw_addr_t GetBaseAddress() const { return m_base_addr; } dw_addr_t GetAddrBase() const { return m_addr_base; } dw_addr_t GetRangesBase() const { return m_ranges_base; } - void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base, - dw_offset_t base_obj_offset); + void SetAddrBase(dw_addr_t addr_base); + void SetRangesBase(dw_addr_t ranges_base); + void SetBaseObjOffset(dw_offset_t base_obj_offset); void BuildAddressRangeTable(SymbolFileDWARF *dwarf, DWARFDebugAranges *debug_aranges); Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -307,6 +307,9 @@ // m_die_array_mutex must be already held as read/write. void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) { + SetAddrBase( + cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0)); + uint64_t base_addr = cu_die.GetAttributeValueAsAddress( m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (base_addr == LLDB_INVALID_ADDRESS) @@ -339,9 +342,13 @@ dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0); + dwo_cu->SetAddrBase(addr_base); + dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned( m_dwarf, this, DW_AT_GNU_ranges_base, 0); - dwo_cu->SetAddrBase(addr_base, ranges_base, m_offset); + dwo_cu->SetRangesBase(ranges_base); + + dwo_cu->SetBaseObjOffset(m_offset); } DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) { @@ -399,11 +406,13 @@ return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET; } -void DWARFUnit::SetAddrBase(dw_addr_t addr_base, - dw_addr_t ranges_base, - dw_offset_t base_obj_offset) { - m_addr_base = addr_base; +void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; } + +void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) { m_ranges_base = ranges_base; +} + +void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) { m_base_obj_offset = base_obj_offset; }