no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / build / build-clang / revert-llvmorg-15-init-11205-gcead4eceb01b_clang_16.patch
blob93c7e7d7673b82239b0279ee90633f5e1805bbe3
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
5 info for globals"
7 This reverts commit cead4eceb01b935fae07bf4a7e91911b344d2fec for causing
8 yet unidentified problems on some webrtc tests under TSan (bug 1798613).
9 ---
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 {
32 std::string Name;
33 uint64_t Start = 0;
34 uint64_t Size = 0;
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;
44 - virtual DILineInfo
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;
57 - DILineInfo
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.
71 - ///
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);
77 class iterator;
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
84 @@ -9,7 +9,6 @@
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"
92 @@ -28,7 +27,6 @@
93 #include <cstdint>
94 #include <map>
95 #include <memory>
96 -#include <set>
97 #include <utility>
98 #include <vector>
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) {
120 RangeSection = RS;
121 RangeSectionBase = Base;
122 @@ -446,10 +436,6 @@ public:
123 /// cleared.
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;
141 - DILineInfo
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))
155 - return OffsetCU;
157 - // Global variables are often not found by the above search, for one of two
158 - // reasons:
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.
164 - //
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());
172 - return nullptr;
173 + return getCompileUnitForOffset(CUOffset);
176 DWARFContext::DIEsForAddress DWARFContext::getDIEsForAddress(uint64_t Address) {
177 @@ -1141,6 +1123,64 @@ static bool getFunctionNameAndStartLineForAddress(
178 return FoundResult;
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())
184 + return Size;
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);
204 + break;
206 + case DW_TAG_array_type: {
207 + DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type);
208 + if (!BaseType)
209 + return std::optional<uint64_t>();
210 + std::optional<uint64_t> BaseSize = getTypeSize(BaseType, PointerSize);
211 + if (!BaseSize)
212 + return std::optional<uint64_t>();
213 + uint64_t Size = *BaseSize;
214 + for (DWARFDie Child : Type) {
215 + if (Child.getTag() != DW_TAG_subrange_type)
216 + continue;
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;
231 + return Size;
233 + default:
234 + break;
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))
244 Local.Name = *Name;
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) {
254 DILineInfo Result;
256 DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
257 if (!CU)
258 return Result;
259 @@ -1256,22 +1297,6 @@ DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
260 Spec.FLIKind, Result);
264 - return Result;
267 -DILineInfo
268 -DWARFContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
269 - DILineInfo Result;
270 - DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
271 - if (!CU)
272 - return Result;
274 - if (DWARFDie Die = CU->getVariableForAddress(Address.Address)) {
275 - Result.FileName = Die.getDeclFile(FileLineInfoKind::AbsoluteFilePath);
276 - Result.Line = Die.getDeclLine();
279 return Result;
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())
293 - return Size;
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);
313 - break;
315 - case DW_TAG_array_type: {
316 - DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type);
317 - if (!BaseType)
318 - return std::nullopt;
319 - std::optional<uint64_t> BaseSize = BaseType.getTypeSize(PointerSize);
320 - if (!BaseSize)
321 - return std::nullopt;
322 - uint64_t Size = *BaseSize;
323 - for (DWARFDie Child : *this) {
324 - if (Child.getTag() != DW_TAG_subrange_type)
325 - continue;
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;
340 - return Size;
342 - default:
343 - if (DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type))
344 - return BaseType.getTypeSize(PointerSize);
345 - break;
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
357 @@ -9,7 +9,6 @@
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"
365 @@ -19,13 +18,11 @@
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()))
386 - continue;
387 - updateVariableDieMap(Child);
390 - if (Die.getTag() != DW_TAG_variable)
391 - return;
393 - Expected<DWARFLocationExpressionsVector> Locations =
394 - Die.getLocations(DW_AT_location);
395 - if (!Locations) {
396 - // Missing DW_AT_location is fine here.
397 - consumeError(Locations.takeError());
398 - return;
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())
409 - continue;
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;
425 - } else {
426 - continue;
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)
432 - continue;
434 - LocationAddr += It->getRawOperand(0);
436 - // Probe for a 3rd operand, if it exists, bail.
437 - if (++It != Expr.end())
438 - continue;
441 - Address = LocationAddr;
442 - break;
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
447 - // exact address.
448 - uint64_t GVSize = 1;
449 - if (DWARFDie BaseType = Die.getAttributeValueAsReferencedDie(DW_AT_type))
450 - if (std::optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
451 - GVSize = *Size;
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())
468 - return DWARFDie();
470 - // upper_bound's previous item contains Address.
471 - --R;
472 - if (Address >= R->second.first)
473 - return DWARFDie();
474 - return R->second.second;
477 void
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,
485 return Result;
488 -DILineInfo
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();
495 DILineInfoTable
496 PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,
497 uint64_t Size,
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;
504 OS << Name << "\n";
505 OS << Global.Start << " " << Global.Size << "\n";
506 - if (Global.DeclFile.empty())
507 - OS << "??:?\n";
508 - else
509 - OS << Global.DeclFile << ":" << Global.DeclLine << "\n";
510 printFooter();
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,
520 FileName);
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;
529 return Res;
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
536 @@ -7,15 +7,12 @@
538 # CHECK: func
539 # CHECK-NEXT: 4096 1
540 -# CHECK-NEXT: ??:?
541 # CHECK-EMPTY:
542 # CHECK-NEXT: data
543 # CHECK-NEXT: 8192 2
544 -# CHECK-NEXT: ??:?
545 # CHECK-EMPTY:
546 # CHECK-NEXT: notype
547 # CHECK-NEXT: 8194 3
548 -# CHECK-NEXT: ??:?
549 # CHECK-EMPTY:
551 --- !ELF
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
556 +++ /dev/null
557 @@ -1,450 +0,0 @@
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
567 -# CHECK: bss_global
568 -# CHECK-NEXT: {{[0-9]+}} 4
569 -# CHECK-NEXT: /tmp/file.cpp:1
570 -# CHECK-EMPTY:
572 -## Check that lookups in the middle of the symbol are also resolved correctly.
573 -# CHECK: bss_global
574 -# CHECK-NEXT: {{[0-9]+}} 4
575 -# CHECK-NEXT: /tmp/file.cpp:1
576 -# CHECK-EMPTY:
577 -# CHECK: bss_global
578 -# CHECK-NEXT: {{[0-9]+}} 4
579 -# CHECK-NEXT: /tmp/file.cpp:1
580 -# CHECK-EMPTY:
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
586 -# CHECK-EMPTY:
587 -# CHECK-NEXT: str
588 -# CHECK-NEXT: {{[0-9]+}} 8
589 -# CHECK-NEXT: /tmp/file.cpp:4
590 -# CHECK-EMPTY:
591 -# CHECK-NEXT: f()::function_global
592 -# CHECK-NEXT: {{[0-9]+}} 4
593 -# CHECK-NEXT: /tmp/file.cpp:8
594 -# CHECK-EMPTY:
596 -## Including the one that includes an addend.
597 -# CHECK-NEXT: alpha
598 -# CHECK-NEXT: {{[0-9]+}} 4
599 -# CHECK-NEXT: /tmp/file.cpp:12
600 -# CHECK-EMPTY:
601 -# CHECK-NEXT: beta
602 -# CHECK-NEXT: {{[0-9]+}} 4
603 -# CHECK-NEXT: /tmp/file.cpp:13
604 -# CHECK-EMPTY:
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 \
616 -## -o /tmp/file.so
618 -## With /tmp/file.cpp as:
619 -## 1: int bss_global;
620 -## 2: int data_global = 2;
621 -## 3:
622 -## 4: const char* str =
623 -## 5: "12345678";
624 -## 6:
625 -## 7: int* f() {
626 -## 8: static int function_global;
627 -## 9: return &function_global;
628 -## 10: }
629 -## 11:
630 -## 12: static int alpha;
631 -## 13: static int beta;
632 -## 14: int *f(bool b) { return beta ? &alpha : &beta; }
633 -## 15:
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 -################################################################################
667 ---- !ELF
668 -FileHeader:
669 - Class: ELFCLASS64
670 - Data: ELFDATA2LSB
671 - Type: ET_DYN
672 - Machine: EM_AARCH64
673 -ProgramHeaders:
674 - - Type: PT_PHDR
675 - Flags: [ PF_R ]
676 - VAddr: 0x40
677 - Align: 0x8
678 - - Type: PT_LOAD
679 - Flags: [ PF_R ]
680 - FirstSec: .dynsym
681 - LastSec: .eh_frame
682 - Align: 0x10000
683 - - Type: PT_LOAD
684 - Flags: [ PF_X, PF_R ]
685 - FirstSec: .text
686 - LastSec: .text
687 - VAddr: 0x103E4
688 - Align: 0x10000
689 - - Type: PT_LOAD
690 - Flags: [ PF_W, PF_R ]
691 - FirstSec: .dynamic
692 - LastSec: .dynamic
693 - VAddr: 0x20410
694 - Align: 0x10000
695 - - Type: PT_LOAD
696 - Flags: [ PF_W, PF_R ]
697 - FirstSec: .data
698 - LastSec: .bss
699 - VAddr: 0x304C0
700 - Align: 0x10000
701 - - Type: PT_DYNAMIC
702 - Flags: [ PF_W, PF_R ]
703 - FirstSec: .dynamic
704 - LastSec: .dynamic
705 - VAddr: 0x20410
706 - Align: 0x8
707 - - Type: PT_GNU_RELRO
708 - Flags: [ PF_R ]
709 - FirstSec: .dynamic
710 - LastSec: .dynamic
711 - VAddr: 0x20410
712 - - Type: PT_GNU_EH_FRAME
713 - Flags: [ PF_R ]
714 - FirstSec: .eh_frame_hdr
715 - LastSec: .eh_frame_hdr
716 - VAddr: 0x37C
717 - Align: 0x4
718 - - Type: PT_GNU_STACK
719 - Flags: [ PF_W, PF_R ]
720 - Align: 0x0
721 -Sections:
722 - - Name: .dynsym
723 - Type: SHT_DYNSYM
724 - Flags: [ SHF_ALLOC ]
725 - Address: 0x238
726 - Link: .dynstr
727 - AddressAlign: 0x8
728 - - Name: .gnu.hash
729 - Type: SHT_GNU_HASH
730 - Flags: [ SHF_ALLOC ]
731 - Address: 0x2C8
732 - Link: .dynsym
733 - AddressAlign: 0x8
734 - Header:
735 - SymNdx: 0x1
736 - Shift2: 0x1A
737 - BloomFilter: [ 0x400188002180000C ]
738 - HashBuckets: [ 0x1 ]
739 - HashValues: [ 0xEE8502A, 0xEE85016, 0xC033991C, 0x61F7372E, 0xB88AB7F ]
740 - - Name: .hash
741 - Type: SHT_HASH
742 - Flags: [ SHF_ALLOC ]
743 - Address: 0x2F8
744 - Link: .dynsym
745 - AddressAlign: 0x4
746 - Bucket: [ 5, 0, 4, 0, 3, 0 ]
747 - Chain: [ 0, 0, 0, 1, 2, 0 ]
748 - - Name: .dynstr
749 - Type: SHT_STRTAB
750 - Flags: [ SHF_ALLOC ]
751 - Address: 0x330
752 - AddressAlign: 0x1
753 - - Name: .rela.dyn
754 - Type: SHT_RELA
755 - Flags: [ SHF_ALLOC ]
756 - Address: 0x358
757 - Link: .dynsym
758 - AddressAlign: 0x8
759 - Relocations:
760 - - Offset: 0x304C8
761 - Type: R_AARCH64_RELATIVE
762 - Addend: 880
763 - - Name: .rodata
764 - Type: SHT_PROGBITS
765 - Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
766 - Address: 0x370
767 - AddressAlign: 0x1
768 - EntSize: 0x1
769 - Content: '313233343536373800'
770 - - Name: .eh_frame_hdr
771 - Type: SHT_PROGBITS
772 - Flags: [ SHF_ALLOC ]
773 - Address: 0x37C
774 - AddressAlign: 0x4
775 - Content: 011B033B18000000020000006800010034000000740001004C000000
776 - - Name: .eh_frame
777 - Type: SHT_PROGBITS
778 - Flags: [ SHF_ALLOC ]
779 - Address: 0x398
780 - AddressAlign: 0x8
781 - Content: 1400000000000000017A5200017C1E011B0C1F0000000000140000001C0000002C0001000C00000000000000000000001400000034000000200001001C000000000000000000000000000000
782 - - Name: .text
783 - Type: SHT_PROGBITS
784 - Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
785 - Address: 0x103E4
786 - AddressAlign: 0x4
787 - Content: 0001009000501391C0035FD60801009008611391E90308AA2A4540B85F0100710001899AC0035FD6
788 - - Name: .dynamic
789 - Type: SHT_DYNAMIC
790 - Flags: [ SHF_WRITE, SHF_ALLOC ]
791 - Address: 0x20410
792 - Link: .dynstr
793 - AddressAlign: 0x8
794 - Entries:
795 - - Tag: DT_RELA
796 - Value: 0x358
797 - - Tag: DT_RELASZ
798 - Value: 0x18
799 - - Tag: DT_RELAENT
800 - Value: 0x18
801 - - Tag: DT_RELACOUNT
802 - Value: 0x1
803 - - Tag: DT_SYMTAB
804 - Value: 0x238
805 - - Tag: DT_SYMENT
806 - Value: 0x18
807 - - Tag: DT_STRTAB
808 - Value: 0x330
809 - - Tag: DT_STRSZ
810 - Value: 0x28
811 - - Tag: DT_GNU_HASH
812 - Value: 0x2C8
813 - - Tag: DT_HASH
814 - Value: 0x2F8
815 - - Tag: DT_NULL
816 - Value: 0x0
817 - - Name: .data
818 - Type: SHT_PROGBITS
819 - Flags: [ SHF_WRITE, SHF_ALLOC ]
820 - Address: 0x304C0
821 - AddressAlign: 0x8
822 - Content: '02000000000000000000000000000000'
823 - - Name: .bss
824 - Type: SHT_NOBITS
825 - Flags: [ SHF_WRITE, SHF_ALLOC ]
826 - Address: 0x304D0
827 - AddressAlign: 0x4
828 - Size: 0x10
829 - - Name: .debug_abbrev
830 - Type: SHT_PROGBITS
831 - AddressAlign: 0x1
832 - Content: 011101252513050325721710171B25111B120673170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000040F004913000005260049130000062E01111B120640187A196E2503253A0B3B0B49133F190000073400032549133A0B3B0B02180000083400032549133A0B3B0B02186E25000009050003253A0B3B0B4913000000
833 - - Name: .debug_info
834 - Type: SHT_PROGBITS
835 - AddressAlign: 0x1
836 - Content: AB0000000500010800000000010021000108000000000000000205280000000800000002032E000000000102A1000304050402052E000000000202A101020648000000000402A102044D00000005520000000307080106050C000000016F0D0E0007A500000007082E000000000802A1030008092E000000000D02A1040A080B2E000000000C04A10423040C06061C000000016F0F0E000EA50000000910000EAA00000000042E0000000311020100
837 - - Name: .debug_str_offsets
838 - Type: SHT_PROGBITS
839 - AddressAlign: 0x1
840 - Content: 4C00000005000000A2000000000000002C00000059000000280000001C00000072000000640000008C0000008700000069000000140000007B0000009C0000001A0000000E0000008500000076000000
841 - - Name: .comment
842 - Type: SHT_PROGBITS
843 - Flags: [ SHF_MERGE, SHF_STRINGS ]
844 - AddressAlign: 0x1
845 - EntSize: 0x1
846 - Content: 4C696E6B65723A204C4C442031352E302E300000636C616E672076657273696F6E2031352E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420306462616566363162353666306566306162306366333865613932666663316633356265653366662900
847 - - Name: .debug_line
848 - Type: SHT_PROGBITS
849 - AddressAlign: 0x1
850 - Content: 620000000500080037000000010101FB0E0D00010101010000000100000101011F010E00000003011F020F051E0100000000006C97BBE59F7DC6A9EA956633431DA63E0400000902E4030100000000001805030A140500BF05190A0105120608740204000101
851 - - Name: .debug_line_str
852 - Type: SHT_PROGBITS
853 - Flags: [ SHF_MERGE, SHF_STRINGS ]
854 - AddressAlign: 0x1
855 - EntSize: 0x1
856 - Content: 2F746D702F66696C652E637070002F7573722F6C6F63616C2F676F6F676C652F686F6D652F6D69746368702F6C6C766D2D6275696C642F6F707400
857 -Symbols:
858 - - Name: file.cpp
859 - Type: STT_FILE
860 - Index: SHN_ABS
861 - - Name: '$x.0'
862 - Section: .text
863 - Value: 0x103E4
864 - - Name: _ZZ1fvE15function_global
865 - Type: STT_OBJECT
866 - Section: .bss
867 - Value: 0x304D4
868 - Size: 0x4
869 - - Name: '$d.1'
870 - Section: .bss
871 - Value: 0x304D0
872 - - Name: '$d.2'
873 - Section: .data
874 - Value: 0x304C0
875 - - Name: '$d.3'
876 - Section: .rodata
877 - Value: 0x370
878 - - Name: '$d.4'
879 - Section: .debug_abbrev
880 - - Name: '$d.5'
881 - Section: .debug_info
882 - - Name: '$d.6'
883 - Section: .debug_str_offsets
884 - - Name: '$d.7'
885 - Section: .debug_str
886 - Value: 0xA2
887 - - Name: '$d.8'
888 - Section: .debug_addr
889 - - Name: _ZL4beta
890 - Type: STT_OBJECT
891 - Section: .bss
892 - Value: 0x304D8
893 - Size: 0x4
894 - - Name: _ZL5alpha
895 - Type: STT_OBJECT
896 - Section: .bss
897 - Value: 0x304DC
898 - Size: 0x4
899 - - Name: '$d.9'
900 - Section: .comment
901 - Value: 0x13
902 - - Name: '$d.10'
903 - Section: .eh_frame
904 - Value: 0x398
905 - - Name: '$d.11'
906 - Section: .debug_line
907 - - Name: '$d.12'
908 - Section: .debug_line_str
909 - Value: 0xE
910 - - Name: _DYNAMIC
911 - Section: .dynamic
912 - Value: 0x20410
913 - Other: [ STV_HIDDEN ]
914 - - Name: _Z1fv
915 - Type: STT_FUNC
916 - Section: .text
917 - Binding: STB_GLOBAL
918 - Value: 0x103E4
919 - Size: 0xC
920 - - Name: _Z1fb
921 - Type: STT_FUNC
922 - Section: .text
923 - Binding: STB_GLOBAL
924 - Value: 0x103F0
925 - Size: 0x1C
926 - - Name: bss_global
927 - Type: STT_OBJECT
928 - Section: .bss
929 - Binding: STB_GLOBAL
930 - Value: 0x304D0
931 - Size: 0x4
932 - - Name: data_global
933 - Type: STT_OBJECT
934 - Section: .data
935 - Binding: STB_GLOBAL
936 - Value: 0x304C0
937 - Size: 0x4
938 - - Name: str
939 - Type: STT_OBJECT
940 - Section: .data
941 - Binding: STB_GLOBAL
942 - Value: 0x304C8
943 - Size: 0x8
944 -DynamicSymbols:
945 - - Name: _Z1fv
946 - Type: STT_FUNC
947 - Section: .text
948 - Binding: STB_GLOBAL
949 - Value: 0x103E4
950 - Size: 0xC
951 - - Name: _Z1fb
952 - Type: STT_FUNC
953 - Section: .text
954 - Binding: STB_GLOBAL
955 - Value: 0x103F0
956 - Size: 0x1C
957 - - Name: bss_global
958 - Type: STT_OBJECT
959 - Section: .bss
960 - Binding: STB_GLOBAL
961 - Value: 0x304D0
962 - Size: 0x4
963 - - Name: data_global
964 - Type: STT_OBJECT
965 - Section: .data
966 - Binding: STB_GLOBAL
967 - Value: 0x304C0
968 - Size: 0x4
969 - - Name: str
970 - Type: STT_OBJECT
971 - Section: .data
972 - Binding: STB_GLOBAL
973 - Value: 0x304C8
974 - Size: 0x8
975 -DWARF:
976 - debug_str:
977 - - '/tmp/file.cpp'
978 - - _Z1fb
979 - - alpha
980 - - f
981 - - data_global
982 - - int
983 - - '/usr/local/google/home/mitchp/llvm-build/opt'
984 - - bss_global
985 - - char
986 - - _ZL4beta
987 - - str
988 - - bool
989 - - _ZL5alpha
990 - - b
991 - - beta
992 - - function_global
993 - - _Z1fv
994 - - 'clang version 15.0.0 (https://github.com/llvm/llvm-project.git 0dbaef61b56f0ef0ab0cf38ea92ffc1f35bee3ff)'
995 - debug_addr:
996 - - Length: 0x3C
997 - Version: 0x5
998 - AddressSize: 0x8
999 - Entries:
1000 - - Address: 0x304D0
1001 - - Address: 0x304C0
1002 - - Address: 0x304C8
1003 - - Address: 0x304D4
1004 - - Address: 0x304D8
1005 - - Address: 0x103E4
1006 - - Address: 0x103F0
1007 -...
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
1012 @@ -7,12 +7,9 @@
1014 # CHECK: d1
1015 # CHECK-NEXT: 0 8
1016 -# CHECK-NEXT: ??:?
1017 # CHECK-EMPTY:
1018 # CHECK-NEXT: d2
1019 # CHECK-NEXT: 8 4
1020 -# CHECK-NEXT: ??:?
1021 -# CHECK-EMPTY:
1024 .quad 0x1122334455667788
1026 2.38.1.1.g6d9df9d320