1 From cb411520cb7cd5e6e25966911ca55feb5de779e0 Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <mh@glandium.org>
3 Date: Fri, 4 Nov 2022 14:51:38 +0900
4 Subject: [PATCH] Revert "[symbolizer] Parse DW_TAG_variable DIs to show line
7 This reverts commit cead4eceb01b935fae07bf4a7e91911b344d2fec for causing
8 yet unidentified problems on some webrtc tests under TSan (bug 1798613).
10 llvm/include/llvm/DebugInfo/DIContext.h | 4 -
11 .../llvm/DebugInfo/DWARF/DWARFContext.h | 2 -
12 llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h | 7 -
13 llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h | 14 -
14 llvm/include/llvm/DebugInfo/PDB/PDBContext.h | 2 -
15 llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 97 ++--
16 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 60 ---
17 llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 97 ----
18 llvm/lib/DebugInfo/PDB/PDBContext.cpp | 7 -
19 llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp | 4 -
20 .../Symbolize/SymbolizableObjectFile.cpp | 8 -
21 .../Symbolize/ELF/data-command-symtab.yaml | 3 -
22 .../tools/llvm-symbolizer/data-location.yaml | 450 ------------------
23 llvm/test/tools/llvm-symbolizer/data.s | 3 -
24 14 files changed, 61 insertions(+), 697 deletions(-)
25 delete mode 100644 llvm/test/tools/llvm-symbolizer/data-location.yaml
27 diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
28 index 9b278b696073..a9f98588cf2d 100644
29 --- a/llvm/include/llvm/DebugInfo/DIContext.h
30 +++ b/llvm/include/llvm/DebugInfo/DIContext.h
31 @@ -114,8 +114,6 @@ struct DIGlobal {
35 - std::string DeclFile;
36 - uint64_t DeclLine = 0;
38 DIGlobal() : Name(DILineInfo::BadString) {}
40 @@ -241,8 +239,6 @@ public:
41 virtual DILineInfo getLineInfoForAddress(
42 object::SectionedAddress Address,
43 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
45 - getLineInfoForDataAddress(object::SectionedAddress Address) = 0;
46 virtual DILineInfoTable getLineInfoForAddressRange(
47 object::SectionedAddress Address, uint64_t Size,
48 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
49 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
50 index bf591ed554c6..3365ef8d8ee3 100644
51 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
52 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
53 @@ -364,8 +364,6 @@ public:
54 DILineInfo getLineInfoForAddress(
55 object::SectionedAddress Address,
56 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
58 - getLineInfoForDataAddress(object::SectionedAddress Address) override;
59 DILineInfoTable getLineInfoForAddressRange(
60 object::SectionedAddress Address, uint64_t Size,
61 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
62 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
63 index 149c5ef4e493..4a4d105a2b23 100644
64 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
65 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
66 @@ -280,13 +280,6 @@ public:
67 /// \returns an iterator range for the attributes of the current DIE.
68 iterator_range<attribute_iterator> attributes() const;
70 - /// Gets the type size (in bytes) for this DIE.
72 - /// \param PointerSize the pointer size of the containing CU.
73 - /// \returns if this is a type DIE, or this DIE contains a DW_AT_type, returns
74 - /// the size of the type.
75 - std::optional<uint64_t> getTypeSize(uint64_t PointerSize);
79 iterator begin() const;
80 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
81 index 9188865b4d77..0341344bc7b8 100644
82 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
83 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
85 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
86 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
88 -#include "llvm/ADT/DenseSet.h"
89 #include "llvm/ADT/STLExtras.h"
90 #include "llvm/ADT/SmallVector.h"
91 #include "llvm/ADT/StringRef.h"
100 @@ -242,11 +240,6 @@ class DWARFUnit {
101 /// std::map::upper_bound for address range lookup.
102 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
104 - /// Map from the location (interpreted DW_AT_location) of a DW_TAG_variable,
105 - /// to the end address and the corresponding DIE.
106 - std::map<uint64_t, std::pair<uint64_t, DWARFDie>> VariableDieMap;
107 - DenseSet<uint64_t> RootsParsedForVariables;
109 using die_iterator_range =
110 iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
112 @@ -329,9 +322,6 @@ public:
113 /// Recursively update address to Die map.
114 void updateAddressDieMap(DWARFDie Die);
116 - /// Recursively update address to variable Die map.
117 - void updateVariableDieMap(DWARFDie Die);
119 void setRangesSection(const DWARFSection *RS, uint64_t Base) {
121 RangeSectionBase = Base;
122 @@ -446,10 +436,6 @@ public:
124 DWARFDie getSubroutineForAddress(uint64_t Address);
126 - /// Returns variable DIE for the address provided. The pointer is alive as
127 - /// long as parsed compile unit DIEs are not cleared.
128 - DWARFDie getVariableForAddress(uint64_t Address);
130 /// getInlinedChainForAddress - fetches inlined chain for a given address.
131 /// Returns empty chain if there is no subprogram containing address. The
132 /// chain is valid as long as parsed compile unit DIEs are not cleared.
133 diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBContext.h b/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
134 index 3163c0a1dae0..7b6793f0a639 100644
135 --- a/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
136 +++ b/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
137 @@ -45,8 +45,6 @@ namespace pdb {
138 DILineInfo getLineInfoForAddress(
139 object::SectionedAddress Address,
140 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
142 - getLineInfoForDataAddress(object::SectionedAddress Address) override;
143 DILineInfoTable getLineInfoForAddressRange(
144 object::SectionedAddress Address, uint64_t Size,
145 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
146 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
147 index 19d7d659a86a..1bcfdecfd588 100644
148 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
149 +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
150 @@ -1053,25 +1053,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
151 // First, get the offset of the compile unit.
152 uint64_t CUOffset = getDebugAranges()->findAddress(Address);
153 // Retrieve the compile unit.
154 - if (DWARFCompileUnit *OffsetCU = getCompileUnitForOffset(CUOffset))
157 - // Global variables are often not found by the above search, for one of two
159 - // 1. .debug_aranges may not include global variables. On clang, it seems we
160 - // put the globals in the aranges, but this isn't true for gcc.
161 - // 2. Even if the global variable is in a .debug_arange, global variables
162 - // may not be captured in the [start, end) addresses described by the
163 - // parent compile unit.
165 - // So, we walk the CU's and their child DI's manually, looking for the
166 - // specific global variable.
167 - for (std::unique_ptr<DWARFUnit> &CU : compile_units()) {
168 - if (DWARFDie Die = CU->getVariableForAddress(Address)) {
169 - return static_cast<DWARFCompileUnit *>(CU.get());
173 + return getCompileUnitForOffset(CUOffset);
176 DWARFContext::DIEsForAddress DWARFContext::getDIEsForAddress(uint64_t Address) {
177 @@ -1141,6 +1123,64 @@ static bool getFunctionNameAndStartLineForAddress(
181 +static std::optional<uint64_t> getTypeSize(DWARFDie Type, uint64_t PointerSize) {
182 + if (auto SizeAttr = Type.find(DW_AT_byte_size))
183 + if (std::optional<uint64_t> Size = SizeAttr->getAsUnsignedConstant())
186 + switch (Type.getTag()) {
187 + case DW_TAG_pointer_type:
188 + case DW_TAG_reference_type:
189 + case DW_TAG_rvalue_reference_type:
190 + return PointerSize;
191 + case DW_TAG_ptr_to_member_type: {
192 + if (DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type))
193 + if (BaseType.getTag() == DW_TAG_subroutine_type)
194 + return 2 * PointerSize;
195 + return PointerSize;
197 + case DW_TAG_const_type:
198 + case DW_TAG_immutable_type:
199 + case DW_TAG_volatile_type:
200 + case DW_TAG_restrict_type:
201 + case DW_TAG_typedef: {
202 + if (DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type))
203 + return getTypeSize(BaseType, PointerSize);
206 + case DW_TAG_array_type: {
207 + DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type);
209 + return std::optional<uint64_t>();
210 + std::optional<uint64_t> BaseSize = getTypeSize(BaseType, PointerSize);
212 + return std::optional<uint64_t>();
213 + uint64_t Size = *BaseSize;
214 + for (DWARFDie Child : Type) {
215 + if (Child.getTag() != DW_TAG_subrange_type)
218 + if (auto ElemCountAttr = Child.find(DW_AT_count))
219 + if (std::optional<uint64_t> ElemCount =
220 + ElemCountAttr->getAsUnsignedConstant())
221 + Size *= *ElemCount;
222 + if (auto UpperBoundAttr = Child.find(DW_AT_upper_bound))
223 + if (std::optional<int64_t> UpperBound =
224 + UpperBoundAttr->getAsSignedConstant()) {
225 + int64_t LowerBound = 0;
226 + if (auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
227 + LowerBound = LowerBoundAttr->getAsSignedConstant().value_or(0);
228 + Size *= *UpperBound - LowerBound + 1;
236 + return std::optional<uint64_t>();
239 static std::optional<int64_t>
240 getExpressionFrameOffset(ArrayRef<uint8_t> Expr,
241 std::optional<unsigned> FrameBaseReg) {
242 @@ -1201,7 +1241,7 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
243 if (std::optional<const char *> Name = dwarf::toString(*NameAttr))
245 if (auto Type = Die.getAttributeValueAsReferencedDie(DW_AT_type))
246 - Local.Size = Type.getTypeSize(getCUAddrSize());
247 + Local.Size = getTypeSize(Type, getCUAddrSize());
248 if (auto DeclFileAttr = Die.find(DW_AT_decl_file)) {
249 if (const auto *LT = CU->getContext().getLineTableForUnit(CU))
250 LT->getFileNameByIndex(
251 @@ -1242,6 +1282,7 @@ DWARFContext::getLocalsForAddress(object::SectionedAddress Address) {
252 DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
253 DILineInfoSpecifier Spec) {
256 DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
259 @@ -1256,22 +1297,6 @@ DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
260 Spec.FLIKind, Result);
268 -DWARFContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
270 - DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
274 - if (DWARFDie Die = CU->getVariableForAddress(Address.Address)) {
275 - Result.FileName = Die.getDeclFile(FileLineInfoKind::AbsoluteFilePath);
276 - Result.Line = Die.getDeclLine();
282 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
283 index 15a2d23c4fd2..9bf15c30f714 100644
284 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
285 +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
286 @@ -492,66 +492,6 @@ void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
287 CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
290 -std::optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
291 - if (auto SizeAttr = find(DW_AT_byte_size))
292 - if (std::optional<uint64_t> Size = SizeAttr->getAsUnsignedConstant())
295 - switch (getTag()) {
296 - case DW_TAG_pointer_type:
297 - case DW_TAG_reference_type:
298 - case DW_TAG_rvalue_reference_type:
299 - return PointerSize;
300 - case DW_TAG_ptr_to_member_type: {
301 - if (DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type))
302 - if (BaseType.getTag() == DW_TAG_subroutine_type)
303 - return 2 * PointerSize;
304 - return PointerSize;
306 - case DW_TAG_const_type:
307 - case DW_TAG_immutable_type:
308 - case DW_TAG_volatile_type:
309 - case DW_TAG_restrict_type:
310 - case DW_TAG_typedef: {
311 - if (DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type))
312 - return BaseType.getTypeSize(PointerSize);
315 - case DW_TAG_array_type: {
316 - DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type);
318 - return std::nullopt;
319 - std::optional<uint64_t> BaseSize = BaseType.getTypeSize(PointerSize);
321 - return std::nullopt;
322 - uint64_t Size = *BaseSize;
323 - for (DWARFDie Child : *this) {
324 - if (Child.getTag() != DW_TAG_subrange_type)
327 - if (auto ElemCountAttr = Child.find(DW_AT_count))
328 - if (std::optional<uint64_t> ElemCount =
329 - ElemCountAttr->getAsUnsignedConstant())
330 - Size *= *ElemCount;
331 - if (auto UpperBoundAttr = Child.find(DW_AT_upper_bound))
332 - if (std::optional<int64_t> UpperBound =
333 - UpperBoundAttr->getAsSignedConstant()) {
334 - int64_t LowerBound = 0;
335 - if (auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
336 - LowerBound = LowerBoundAttr->getAsSignedConstant().value_or(0);
337 - Size *= *UpperBound - LowerBound + 1;
343 - if (DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type))
344 - return BaseType.getTypeSize(PointerSize);
347 - return std::nullopt;
350 /// Helper to dump a DIE with all of its parents, but no siblings.
351 static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent,
352 DIDumpOptions DumpOpts, unsigned Depth = 0) {
353 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
354 index 74667fcb92bc..148711f0246f 100644
355 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
356 +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
358 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
359 #include "llvm/ADT/SmallString.h"
360 #include "llvm/ADT/StringRef.h"
361 -#include "llvm/BinaryFormat/Dwarf.h"
362 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
363 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
364 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
366 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
367 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
368 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
369 -#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
370 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
371 #include "llvm/DebugInfo/DWARF/DWARFListTable.h"
372 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
373 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
374 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
375 -#include "llvm/Object/ObjectFile.h"
376 #include "llvm/Support/DataExtractor.h"
377 #include "llvm/Support/Errc.h"
378 #include "llvm/Support/Path.h"
379 @@ -752,100 +749,6 @@ DWARFDie DWARFUnit::getSubroutineForAddress(uint64_t Address) {
380 return R->second.second;
383 -void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
384 - for (DWARFDie Child : Die) {
385 - if (isType(Child.getTag()))
387 - updateVariableDieMap(Child);
390 - if (Die.getTag() != DW_TAG_variable)
393 - Expected<DWARFLocationExpressionsVector> Locations =
394 - Die.getLocations(DW_AT_location);
396 - // Missing DW_AT_location is fine here.
397 - consumeError(Locations.takeError());
401 - uint64_t Address = UINT64_MAX;
403 - for (const DWARFLocationExpression &Location : *Locations) {
404 - uint8_t AddressSize = getAddressByteSize();
405 - DataExtractor Data(Location.Expr, /*IsLittleEndian=*/true, AddressSize);
406 - DWARFExpression Expr(Data, AddressSize);
407 - auto It = Expr.begin();
408 - if (It == Expr.end())
411 - // Match exactly the main sequence used to describe global variables:
412 - // `DW_OP_addr[x] [+ DW_OP_plus_uconst]`. Currently, this is the sequence
413 - // that LLVM produces for DILocalVariables and DIGlobalVariables. If, in
414 - // future, the DWARF producer (`DwarfCompileUnit::addLocationAttribute()` is
415 - // a good starting point) is extended to use further expressions, this code
416 - // needs to be updated.
417 - uint64_t LocationAddr;
418 - if (It->getCode() == dwarf::DW_OP_addr) {
419 - LocationAddr = It->getRawOperand(0);
420 - } else if (It->getCode() == dwarf::DW_OP_addrx) {
421 - uint64_t DebugAddrOffset = It->getRawOperand(0);
422 - if (auto Pointer = getAddrOffsetSectionItem(DebugAddrOffset)) {
423 - LocationAddr = Pointer->Address;
429 - // Read the optional 2nd operand, a DW_OP_plus_uconst.
430 - if (++It != Expr.end()) {
431 - if (It->getCode() != dwarf::DW_OP_plus_uconst)
434 - LocationAddr += It->getRawOperand(0);
436 - // Probe for a 3rd operand, if it exists, bail.
437 - if (++It != Expr.end())
441 - Address = LocationAddr;
445 - // Get the size of the global variable. If all else fails (i.e. the global has
446 - // no type), then we use a size of one to still allow symbolization of the
448 - uint64_t GVSize = 1;
449 - if (DWARFDie BaseType = Die.getAttributeValueAsReferencedDie(DW_AT_type))
450 - if (std::optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
453 - if (Address != UINT64_MAX)
454 - VariableDieMap[Address] = {Address + GVSize, Die};
457 -DWARFDie DWARFUnit::getVariableForAddress(uint64_t Address) {
458 - extractDIEsIfNeeded(false);
460 - auto RootDie = getUnitDIE();
462 - auto RootLookup = RootsParsedForVariables.insert(RootDie.getOffset());
463 - if (RootLookup.second)
464 - updateVariableDieMap(RootDie);
466 - auto R = VariableDieMap.upper_bound(Address);
467 - if (R == VariableDieMap.begin())
470 - // upper_bound's previous item contains Address.
472 - if (Address >= R->second.first)
474 - return R->second.second;
478 DWARFUnit::getInlinedChainForAddress(uint64_t Address,
479 SmallVectorImpl<DWARFDie> &InlinedChain) {
480 diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
481 index e600fb7385f1..0444093d7622 100644
482 --- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp
483 +++ b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
484 @@ -64,13 +64,6 @@ DILineInfo PDBContext::getLineInfoForAddress(object::SectionedAddress Address,
489 -PDBContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
490 - // Unimplemented. S_GDATA and S_LDATA in CodeView (used to describe global
491 - // variables) aren't capable of carrying line information.
492 - return DILineInfo();
496 PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,
498 diff --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
499 index 877380213f21..496c8149782e 100644
500 --- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
501 +++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
502 @@ -206,10 +206,6 @@ void PlainPrinterBase::print(const Request &Request, const DIGlobal &Global) {
503 Name = DILineInfo::Addr2LineBadString;
505 OS << Global.Start << " " << Global.Size << "\n";
506 - if (Global.DeclFile.empty())
509 - OS << Global.DeclFile << ":" << Global.DeclLine << "\n";
513 diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
514 index d8ee9264b64f..fcff531895a2 100644
515 --- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
516 +++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
517 @@ -327,14 +327,6 @@ DIGlobal SymbolizableObjectFile::symbolizeData(
518 std::string FileName;
519 getNameFromSymbolTable(ModuleOffset.Address, Res.Name, Res.Start, Res.Size,
521 - Res.DeclFile = FileName;
523 - // Try and get a better filename:lineno pair from the debuginfo, if present.
524 - DILineInfo DL = DebugInfoContext->getLineInfoForDataAddress(ModuleOffset);
525 - if (DL.Line != 0) {
526 - Res.DeclFile = DL.FileName;
527 - Res.DeclLine = DL.Line;
532 diff --git a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
533 index 83af3111c5dd..984e444b2fda 100644
534 --- a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
535 +++ b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
552 diff --git a/llvm/test/tools/llvm-symbolizer/data-location.yaml b/llvm/test/tools/llvm-symbolizer/data-location.yaml
553 deleted file mode 100644
554 index 54f7d9be44a1..000000000000
555 --- a/llvm/test/tools/llvm-symbolizer/data-location.yaml
558 -## Show that when "DATA" is used with an address, it forces the found location
559 -## to be symbolized as data, including the source information.
561 -# RUN: yaml2obj %s -o %t.so
563 -# RUN: llvm-symbolizer 'DATA 0x304d0' 'DATA 0x304d1' 'DATA 0x304d3' \
564 -# RUN: 'DATA 0x304c0' 'DATA 0x304c8' 'DATA 0x304d4' 'DATA 0x304dc' \
565 -# RUN: 'DATA 0x304d8' --obj=%t.so | FileCheck %s
568 -# CHECK-NEXT: {{[0-9]+}} 4
569 -# CHECK-NEXT: /tmp/file.cpp:1
572 -## Check that lookups in the middle of the symbol are also resolved correctly.
574 -# CHECK-NEXT: {{[0-9]+}} 4
575 -# CHECK-NEXT: /tmp/file.cpp:1
578 -# CHECK-NEXT: {{[0-9]+}} 4
579 -# CHECK-NEXT: /tmp/file.cpp:1
582 -## Now, the remainder of the symbols.
583 -# CHECK-NEXT: data_global
584 -# CHECK-NEXT: {{[0-9]+}} 4
585 -# CHECK-NEXT: /tmp/file.cpp:2
588 -# CHECK-NEXT: {{[0-9]+}} 8
589 -# CHECK-NEXT: /tmp/file.cpp:4
591 -# CHECK-NEXT: f()::function_global
592 -# CHECK-NEXT: {{[0-9]+}} 4
593 -# CHECK-NEXT: /tmp/file.cpp:8
596 -## Including the one that includes an addend.
598 -# CHECK-NEXT: {{[0-9]+}} 4
599 -# CHECK-NEXT: /tmp/file.cpp:12
602 -# CHECK-NEXT: {{[0-9]+}} 4
603 -# CHECK-NEXT: /tmp/file.cpp:13
606 -## Ensure there's still a global that's offset-based.
607 -# RUN: llvm-dwarfdump --debug-info %t.so | FileCheck %s --check-prefix=OFFSET
609 -# OFFSET: DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)
611 -################################################################################
612 -## File below was generated using:
614 -## $ clang++ -g -O3 /tmp/file.cpp -shared -fuse-ld=lld -nostdlib \
615 -## -target aarch64-linux-gnuabi -mllvm -global-merge-ignore-single-use \
618 -## With /tmp/file.cpp as:
619 -## 1: int bss_global;
620 -## 2: int data_global = 2;
622 -## 4: const char* str =
626 -## 8: static int function_global;
627 -## 9: return &function_global;
630 -## 12: static int alpha;
631 -## 13: static int beta;
632 -## 14: int *f(bool b) { return beta ? &alpha : β }
635 -## ... then, one can get the offsets using `nm`, like:
636 -## $ nm out.so | grep bss_global
637 -## 00000000000038fc B bss_global
639 -## Note the use of the aarch64 target (with -nostdlib in order to allow linkage
640 -## without libraries for cross-compilation) as well as -O3 and
641 -## -global-merge-ignore-single-use. This is a specific combination that makes
642 -## the compiler emit the `alpha` global variable with a more complex
643 -## DW_AT_location than just a DW_OP_addr/DW_OP_addrx. In this instance, it
644 -## outputs a `DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)`.
646 -## Ideally, this would be tested by invoking clang directly on a C source file,
647 -## but unfortunately there's no way to do that for LLVM tests. The other option
648 -## is to compile IR to an objfile, but llvm-symbolizer doesn't understand that
649 -## two symbols can have the same address in different sections. In the code
650 -## above, for example, we'd have bss_global at .bss+0x0, and data_global at
651 -## .data+0x0, and so the symbolizer would only print one of them. Hence, we have
652 -## the ugly dso-to-yaml blob below.
654 -## For now, constant strings don't have a debuginfo entry, and so can't be
655 -## symbolized correctly. In future (if D123534 gets merged), this can be updated
656 -## to include a check that llvm-symbolizer can also symbolize constant strings,
657 -## like `str` above (basically that &"12345678" should be symbolizable)
658 -## to the specific line. Then, you can find the address of the constant string
659 -## from the relocation:
661 -## $ nm out.so | grep str
662 -## 00000000000038c0 D str
663 -## $ llvm-objdump -R out.so | grep 38c0
664 -## 00000000000038c0 R_X86_64_RELATIVE *ABS*+0x4f8 # <-- 0x4f8
665 -################################################################################
672 - Machine: EM_AARCH64
684 - Flags: [ PF_X, PF_R ]
690 - Flags: [ PF_W, PF_R ]
696 - Flags: [ PF_W, PF_R ]
702 - Flags: [ PF_W, PF_R ]
707 - - Type: PT_GNU_RELRO
712 - - Type: PT_GNU_EH_FRAME
714 - FirstSec: .eh_frame_hdr
715 - LastSec: .eh_frame_hdr
718 - - Type: PT_GNU_STACK
719 - Flags: [ PF_W, PF_R ]
724 - Flags: [ SHF_ALLOC ]
730 - Flags: [ SHF_ALLOC ]
737 - BloomFilter: [ 0x400188002180000C ]
738 - HashBuckets: [ 0x1 ]
739 - HashValues: [ 0xEE8502A, 0xEE85016, 0xC033991C, 0x61F7372E, 0xB88AB7F ]
742 - Flags: [ SHF_ALLOC ]
746 - Bucket: [ 5, 0, 4, 0, 3, 0 ]
747 - Chain: [ 0, 0, 0, 1, 2, 0 ]
750 - Flags: [ SHF_ALLOC ]
755 - Flags: [ SHF_ALLOC ]
761 - Type: R_AARCH64_RELATIVE
765 - Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
769 - Content: '313233343536373800'
770 - - Name: .eh_frame_hdr
772 - Flags: [ SHF_ALLOC ]
775 - Content: 011B033B18000000020000006800010034000000740001004C000000
778 - Flags: [ SHF_ALLOC ]
781 - Content: 1400000000000000017A5200017C1E011B0C1F0000000000140000001C0000002C0001000C00000000000000000000001400000034000000200001001C000000000000000000000000000000
784 - Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
787 - Content: 0001009000501391C0035FD60801009008611391E90308AA2A4540B85F0100710001899AC0035FD6
790 - Flags: [ SHF_WRITE, SHF_ALLOC ]
801 - - Tag: DT_RELACOUNT
819 - Flags: [ SHF_WRITE, SHF_ALLOC ]
822 - Content: '02000000000000000000000000000000'
825 - Flags: [ SHF_WRITE, SHF_ALLOC ]
829 - - Name: .debug_abbrev
832 - Content: 011101252513050325721710171B25111B120673170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000040F004913000005260049130000062E01111B120640187A196E2503253A0B3B0B49133F190000073400032549133A0B3B0B02180000083400032549133A0B3B0B02186E25000009050003253A0B3B0B4913000000
833 - - Name: .debug_info
836 - Content: AB0000000500010800000000010021000108000000000000000205280000000800000002032E000000000102A1000304050402052E000000000202A101020648000000000402A102044D00000005520000000307080106050C000000016F0D0E0007A500000007082E000000000802A1030008092E000000000D02A1040A080B2E000000000C04A10423040C06061C000000016F0F0E000EA50000000910000EAA00000000042E0000000311020100
837 - - Name: .debug_str_offsets
840 - Content: 4C00000005000000A2000000000000002C00000059000000280000001C00000072000000640000008C0000008700000069000000140000007B0000009C0000001A0000000E0000008500000076000000
843 - Flags: [ SHF_MERGE, SHF_STRINGS ]
846 - Content: 4C696E6B65723A204C4C442031352E302E300000636C616E672076657273696F6E2031352E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420306462616566363162353666306566306162306366333865613932666663316633356265653366662900
847 - - Name: .debug_line
850 - Content: 620000000500080037000000010101FB0E0D00010101010000000100000101011F010E00000003011F020F051E0100000000006C97BBE59F7DC6A9EA956633431DA63E0400000902E4030100000000001805030A140500BF05190A0105120608740204000101
851 - - Name: .debug_line_str
853 - Flags: [ SHF_MERGE, SHF_STRINGS ]
856 - Content: 2F746D702F66696C652E637070002F7573722F6C6F63616C2F676F6F676C652F686F6D652F6D69746368702F6C6C766D2D6275696C642F6F707400
864 - - Name: _ZZ1fvE15function_global
879 - Section: .debug_abbrev
881 - Section: .debug_info
883 - Section: .debug_str_offsets
885 - Section: .debug_str
888 - Section: .debug_addr
906 - Section: .debug_line
908 - Section: .debug_line_str
913 - Other: [ STV_HIDDEN ]
917 - Binding: STB_GLOBAL
923 - Binding: STB_GLOBAL
929 - Binding: STB_GLOBAL
932 - - Name: data_global
935 - Binding: STB_GLOBAL
941 - Binding: STB_GLOBAL
948 - Binding: STB_GLOBAL
954 - Binding: STB_GLOBAL
960 - Binding: STB_GLOBAL
963 - - Name: data_global
966 - Binding: STB_GLOBAL
972 - Binding: STB_GLOBAL
983 - - '/usr/local/google/home/mitchp/llvm-build/opt'
994 - - 'clang version 15.0.0 (https://github.com/llvm/llvm-project.git 0dbaef61b56f0ef0ab0cf38ea92ffc1f35bee3ff)'
1000 - - Address: 0x304D0
1001 - - Address: 0x304C0
1002 - - Address: 0x304C8
1003 - - Address: 0x304D4
1004 - - Address: 0x304D8
1005 - - Address: 0x103E4
1006 - - Address: 0x103F0
1008 diff --git a/llvm/test/tools/llvm-symbolizer/data.s b/llvm/test/tools/llvm-symbolizer/data.s
1009 index cc9503c59141..e8039f146dbd 100644
1010 --- a/llvm/test/tools/llvm-symbolizer/data.s
1011 +++ b/llvm/test/tools/llvm-symbolizer/data.s
1024 .quad 0x1122334455667788
1026 2.38.1.1.g6d9df9d320