[Lldb-commits] [lldb] r347842 - [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.
George Rimar via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 29 00:16:07 PST 2018
Author: grimar
Date: Thu Nov 29 00:16:07 2018
New Revision: 347842
URL: http://llvm.org/viewvc/llvm-project?rev=347842&view=rev
Log:
[LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.
The issue happens because starting from DWARF v5
DW_AT_addr_base attribute should be used
instead of DW_AT_GNU_addr_base. LLDB does not do that and
we end up reading the .debug_addr header as section content
(as addresses) instead of skipping it and reading the real addresses.
Then LLDB is unable to match 2 similar locations and
thinks they are different.
Differential revision: https://reviews.llvm.org/D54751
Added:
lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
lldb/trunk/lit/Breakpoint/split-dwarf-5-addrbase.test
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Added: lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml?rev=347842&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml Thu Nov 29 00:16:07 2018
@@ -0,0 +1,35 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .debug_loc.dwo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_EXCLUDE ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .debug_str_offsets.dwo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_EXCLUDE ]
+ AddressAlign: 0x0000000000000001
+ Content: 200000000500000000000000090000002C000000340000003C0000004000000045000000
+ - Name: .debug_str.dwo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 746573742E64776F00636C616E672076657273696F6E20382E302E3020287472756E6B203334373239392900746573742E6363005F5A3362617A760062617A006D61696E00696E7400
+ - Name: .debug_info.dwo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_EXCLUDE ]
+ AddressAlign: 0x0000000000000001
+ Content: 360000000500050800000000E93484C441B7E84A01000104000202000600000001560304010103011C0000000156050104350000000406050400
+ - Name: .debug_abbrev.dwo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_EXCLUDE ]
+ AddressAlign: 0x0000000000000001
+ Content: 011101B042252525130503250000022E00111B120640186E2503253A0B3B0B3F190000032E00111B1206401803253A0B3B0B49133F19000004240003253E0B0B0B000000
+Symbols: {}
+DynamicSymbols: {}
+...
Added: lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml?rev=347842&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml Thu Nov 29 00:16:07 2018
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+ Entry: 0x0000000000400440
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Address: 0x0000000000400440
+ AddressAlign: 0x0000000000000010
+ Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000554889E55DC3662E0F1F840000000000554889E54883EC10C745FC00000000E8DCFFFFFF31C04883C4105DC30F1F4000415741564189FF415541544C8D25A618000055488D2DA6180000534989F64989D54C29E54883EC0848C1FD03E86FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3
+ - Name: .debug_str_offsets
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 0C000000050000000000000009000000
+ - Name: .debug_str
+ Type: SHT_PROGBITS
+ Flags: [ SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 746573742E64776F002F686F6D652F756D622F74657374735F323031382F3132322F69737375652F6477617266355F73706C69740062617A005F5A3362617A76006D61696E00696E7400
+ - Name: .debug_abbrev
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 01110010177217B042251B25B442197317111B1206000000
+ - Name: .debug_info
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 240000000500040800000000E93484C441B7E84A010000000008000000000108000000002C000000
+ - Name: .debug_macinfo
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: '00'
+ - Name: .debug_addr
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: '140000000500080020054000000000003005400000000000'
+ - Name: .debug_names
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000004
+ Content: A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000000000003000000000000003080880B64D103B5C260880B6A7F9A7C460000003900000035000000410000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E1A000000000000002E1A000000000000002E2600000000000000000000
+ - Name: .debug_gnu_pubnames
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 210000000200000000002800000026000000306D61696E001A0000003062617A0000000000
+ - Name: .debug_gnu_pubtypes
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: '17000000020000000000280000003500000090696E740000000000'
+ - Name: .debug_line
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 71000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E022C000000004B61BD987753AF9C38389263DC08E24F2C000000004B61BD987753AF9C38389263DC08E24F00090220054000000000000105010A4B0500BC05030AE5750206000101
+ - Name: .debug_line_str
+ Type: SHT_PROGBITS
+ Flags: [ SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 2F686F6D652F756D622F74657374735F323031382F3132322F69737375652F6477617266355F73706C697400746573742E636300
+
Added: lldb/trunk/lit/Breakpoint/split-dwarf-5-addrbase.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/split-dwarf-5-addrbase.test?rev=347842&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/split-dwarf-5-addrbase.test (added)
+++ lldb/trunk/lit/Breakpoint/split-dwarf-5-addrbase.test Thu Nov 29 00:16:07 2018
@@ -0,0 +1,30 @@
+# RUN: rm -rf %t.dir
+# RUN: mkdir %t.dir
+# RUN: cd %t.dir
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.dwo.yaml > %t.dir/test.dwo
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.yaml > %t.dir/test
+# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s
+
+# This test checks that source code location is shown correctly
+# when -gsplit-dwarf and DWARF 5 are used.
+#
+# split-dwarf-5-addrbase.dwo.yaml and split-dwarf-5-addrbase.yamlare
+# reduced yaml files produces from the dwo file and the corresponding executable.
+#
+# The following code was used initially:
+# void baz() {
+# }
+#
+# int main() {
+# baz();
+# return 0;
+# }
+#
+# Invocation used to produce outputs was:
+# clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf
+# clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf
+# clang version 8.0.0 (trunk 347299)
+
+b baz
+# CHECK-LABEL: b baz
+# CHECK: Address: {{.*}}baz() + 4 at test.cc:2:1
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp?rev=347842&r1=347841&r2=347842&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp Thu Nov 29 00:16:07 2018
@@ -307,8 +307,11 @@ void DWARFUnit::ExtractDIEsEndCheck(lldb
// 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));
+ dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
+ m_dwarf, this, DW_AT_addr_base, LLDB_INVALID_ADDRESS);
+ if (addr_base != LLDB_INVALID_ADDRESS)
+ SetAddrBase(addr_base);
+
SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
@@ -342,8 +345,15 @@ void DWARFUnit::AddUnitDIE(const DWARFDe
m_dwo_symbol_file = std::move(dwo_symbol_file);
- dw_addr_t addr_base =
- cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+ // Here for DWO CU we want to use the address base set in the skeleton unit
+ // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
+ // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
+ // attributes which were applicable to the DWO units. The corresponding
+ // DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
+ // unit in contrast.
+ if (addr_base == LLDB_INVALID_ADDRESS)
+ 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(
More information about the lldb-commits
mailing list