Bug 1806400 - Move the CancelTask call in HandleTouchEndEvent() into MaybeChangeActiv...
[gecko.git] / build / build-clang / revert-llvmorg-15-init-11205-gcead4eceb01b_clang_18.patch
blob908374789cd7f11cd4184f054e758308b2bf0759
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 (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 66492f7bf804..357b172bf99b 100644
284 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
285 +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
286 @@ -556,11 +556,6 @@ getTypeSizeImpl(DWARFDie Die, uint64_t PointerSize,
287 return std::nullopt;
290 -std::optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
291 - SmallPtrSet<const DWARFDebugInfoEntry *, 4> Visited;
292 - return getTypeSizeImpl(*this, PointerSize, Visited);
295 /// Helper to dump a DIE with all of its parents, but no siblings.
296 static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent,
297 DIDumpOptions DumpOpts, unsigned Depth = 0) {
298 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
299 index 74667fcb92bc..148711f0246f 100644
300 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
301 +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
302 @@ -9,7 +9,6 @@
303 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
304 #include "llvm/ADT/SmallString.h"
305 #include "llvm/ADT/StringRef.h"
306 -#include "llvm/BinaryFormat/Dwarf.h"
307 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
308 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
309 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
310 @@ -19,13 +18,11 @@
311 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
312 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
313 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
314 -#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
315 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
316 #include "llvm/DebugInfo/DWARF/DWARFListTable.h"
317 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
318 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
319 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
320 -#include "llvm/Object/ObjectFile.h"
321 #include "llvm/Support/DataExtractor.h"
322 #include "llvm/Support/Errc.h"
323 #include "llvm/Support/Path.h"
324 @@ -752,100 +749,6 @@ DWARFDie DWARFUnit::getSubroutineForAddress(uint64_t Address) {
325 return R->second.second;
328 -void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
329 - for (DWARFDie Child : Die) {
330 - if (isType(Child.getTag()))
331 - continue;
332 - updateVariableDieMap(Child);
335 - if (Die.getTag() != DW_TAG_variable)
336 - return;
338 - Expected<DWARFLocationExpressionsVector> Locations =
339 - Die.getLocations(DW_AT_location);
340 - if (!Locations) {
341 - // Missing DW_AT_location is fine here.
342 - consumeError(Locations.takeError());
343 - return;
346 - uint64_t Address = UINT64_MAX;
348 - for (const DWARFLocationExpression &Location : *Locations) {
349 - uint8_t AddressSize = getAddressByteSize();
350 - DataExtractor Data(Location.Expr, isLittleEndian(), AddressSize);
351 - DWARFExpression Expr(Data, AddressSize);
352 - auto It = Expr.begin();
353 - if (It == Expr.end())
354 - continue;
356 - // Match exactly the main sequence used to describe global variables:
357 - // `DW_OP_addr[x] [+ DW_OP_plus_uconst]`. Currently, this is the sequence
358 - // that LLVM produces for DILocalVariables and DIGlobalVariables. If, in
359 - // future, the DWARF producer (`DwarfCompileUnit::addLocationAttribute()` is
360 - // a good starting point) is extended to use further expressions, this code
361 - // needs to be updated.
362 - uint64_t LocationAddr;
363 - if (It->getCode() == dwarf::DW_OP_addr) {
364 - LocationAddr = It->getRawOperand(0);
365 - } else if (It->getCode() == dwarf::DW_OP_addrx) {
366 - uint64_t DebugAddrOffset = It->getRawOperand(0);
367 - if (auto Pointer = getAddrOffsetSectionItem(DebugAddrOffset)) {
368 - LocationAddr = Pointer->Address;
370 - } else {
371 - continue;
374 - // Read the optional 2nd operand, a DW_OP_plus_uconst.
375 - if (++It != Expr.end()) {
376 - if (It->getCode() != dwarf::DW_OP_plus_uconst)
377 - continue;
379 - LocationAddr += It->getRawOperand(0);
381 - // Probe for a 3rd operand, if it exists, bail.
382 - if (++It != Expr.end())
383 - continue;
386 - Address = LocationAddr;
387 - break;
390 - // Get the size of the global variable. If all else fails (i.e. the global has
391 - // no type), then we use a size of one to still allow symbolization of the
392 - // exact address.
393 - uint64_t GVSize = 1;
394 - if (Die.getAttributeValueAsReferencedDie(DW_AT_type))
395 - if (std::optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
396 - GVSize = *Size;
398 - if (Address != UINT64_MAX)
399 - VariableDieMap[Address] = {Address + GVSize, Die};
402 -DWARFDie DWARFUnit::getVariableForAddress(uint64_t Address) {
403 - extractDIEsIfNeeded(false);
405 - auto RootDie = getUnitDIE();
407 - auto RootLookup = RootsParsedForVariables.insert(RootDie.getOffset());
408 - if (RootLookup.second)
409 - updateVariableDieMap(RootDie);
411 - auto R = VariableDieMap.upper_bound(Address);
412 - if (R == VariableDieMap.begin())
413 - return DWARFDie();
415 - // upper_bound's previous item contains Address.
416 - --R;
417 - if (Address >= R->second.first)
418 - return DWARFDie();
419 - return R->second.second;
422 void
423 DWARFUnit::getInlinedChainForAddress(uint64_t Address,
424 SmallVectorImpl<DWARFDie> &InlinedChain) {
425 diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
426 index e600fb7385f1..0444093d7622 100644
427 --- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp
428 +++ b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
429 @@ -64,13 +64,6 @@ DILineInfo PDBContext::getLineInfoForAddress(object::SectionedAddress Address,
430 return Result;
433 -DILineInfo
434 -PDBContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
435 - // Unimplemented. S_GDATA and S_LDATA in CodeView (used to describe global
436 - // variables) aren't capable of carrying line information.
437 - return DILineInfo();
440 DILineInfoTable
441 PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,
442 uint64_t Size,
443 diff --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
444 index 877380213f21..496c8149782e 100644
445 --- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
446 +++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
447 @@ -206,10 +206,6 @@ void PlainPrinterBase::print(const Request &Request, const DIGlobal &Global) {
448 Name = DILineInfo::Addr2LineBadString;
449 OS << Name << "\n";
450 OS << Global.Start << " " << Global.Size << "\n";
451 - if (Global.DeclFile.empty())
452 - OS << "??:?\n";
453 - else
454 - OS << Global.DeclFile << ":" << Global.DeclLine << "\n";
455 printFooter();
458 diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
459 index d8ee9264b64f..fcff531895a2 100644
460 --- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
461 +++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
462 @@ -327,14 +327,6 @@ DIGlobal SymbolizableObjectFile::symbolizeData(
463 std::string FileName;
464 getNameFromSymbolTable(ModuleOffset.Address, Res.Name, Res.Start, Res.Size,
465 FileName);
466 - Res.DeclFile = FileName;
468 - // Try and get a better filename:lineno pair from the debuginfo, if present.
469 - DILineInfo DL = DebugInfoContext->getLineInfoForDataAddress(ModuleOffset);
470 - if (DL.Line != 0) {
471 - Res.DeclFile = DL.FileName;
472 - Res.DeclLine = DL.Line;
474 return Res;
477 diff --git a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
478 index 83af3111c5dd..984e444b2fda 100644
479 --- a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
480 +++ b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
481 @@ -7,15 +7,12 @@
483 # CHECK: func
484 # CHECK-NEXT: 4096 1
485 -# CHECK-NEXT: ??:?
486 # CHECK-EMPTY:
487 # CHECK-NEXT: data
488 # CHECK-NEXT: 8192 2
489 -# CHECK-NEXT: ??:?
490 # CHECK-EMPTY:
491 # CHECK-NEXT: notype
492 # CHECK-NEXT: 8194 3
493 -# CHECK-NEXT: ??:?
494 # CHECK-EMPTY:
496 --- !ELF
497 diff --git a/llvm/test/tools/llvm-symbolizer/data-location.yaml b/llvm/test/tools/llvm-symbolizer/data-location.yaml
498 deleted file mode 100644
499 index 54f7d9be44a1..000000000000
500 --- a/llvm/test/tools/llvm-symbolizer/data-location.yaml
501 +++ /dev/null
502 @@ -1,450 +0,0 @@
503 -## Show that when "DATA" is used with an address, it forces the found location
504 -## to be symbolized as data, including the source information.
506 -# RUN: yaml2obj %s -o %t.so
508 -# RUN: llvm-symbolizer 'DATA 0x304d0' 'DATA 0x304d1' 'DATA 0x304d3' \
509 -# RUN: 'DATA 0x304c0' 'DATA 0x304c8' 'DATA 0x304d4' 'DATA 0x304dc' \
510 -# RUN: 'DATA 0x304d8' --obj=%t.so | FileCheck %s
512 -# CHECK: bss_global
513 -# CHECK-NEXT: {{[0-9]+}} 4
514 -# CHECK-NEXT: /tmp/file.cpp:1
515 -# CHECK-EMPTY:
517 -## Check that lookups in the middle of the symbol are also resolved correctly.
518 -# CHECK: bss_global
519 -# CHECK-NEXT: {{[0-9]+}} 4
520 -# CHECK-NEXT: /tmp/file.cpp:1
521 -# CHECK-EMPTY:
522 -# CHECK: bss_global
523 -# CHECK-NEXT: {{[0-9]+}} 4
524 -# CHECK-NEXT: /tmp/file.cpp:1
525 -# CHECK-EMPTY:
527 -## Now, the remainder of the symbols.
528 -# CHECK-NEXT: data_global
529 -# CHECK-NEXT: {{[0-9]+}} 4
530 -# CHECK-NEXT: /tmp/file.cpp:2
531 -# CHECK-EMPTY:
532 -# CHECK-NEXT: str
533 -# CHECK-NEXT: {{[0-9]+}} 8
534 -# CHECK-NEXT: /tmp/file.cpp:4
535 -# CHECK-EMPTY:
536 -# CHECK-NEXT: f()::function_global
537 -# CHECK-NEXT: {{[0-9]+}} 4
538 -# CHECK-NEXT: /tmp/file.cpp:8
539 -# CHECK-EMPTY:
541 -## Including the one that includes an addend.
542 -# CHECK-NEXT: alpha
543 -# CHECK-NEXT: {{[0-9]+}} 4
544 -# CHECK-NEXT: /tmp/file.cpp:12
545 -# CHECK-EMPTY:
546 -# CHECK-NEXT: beta
547 -# CHECK-NEXT: {{[0-9]+}} 4
548 -# CHECK-NEXT: /tmp/file.cpp:13
549 -# CHECK-EMPTY:
551 -## Ensure there's still a global that's offset-based.
552 -# RUN: llvm-dwarfdump --debug-info %t.so | FileCheck %s --check-prefix=OFFSET
554 -# OFFSET: DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)
556 -################################################################################
557 -## File below was generated using:
559 -## $ clang++ -g -O3 /tmp/file.cpp -shared -fuse-ld=lld -nostdlib \
560 -## -target aarch64-linux-gnuabi -mllvm -global-merge-ignore-single-use \
561 -## -o /tmp/file.so
563 -## With /tmp/file.cpp as:
564 -## 1: int bss_global;
565 -## 2: int data_global = 2;
566 -## 3:
567 -## 4: const char* str =
568 -## 5: "12345678";
569 -## 6:
570 -## 7: int* f() {
571 -## 8: static int function_global;
572 -## 9: return &function_global;
573 -## 10: }
574 -## 11:
575 -## 12: static int alpha;
576 -## 13: static int beta;
577 -## 14: int *f(bool b) { return beta ? &alpha : &beta; }
578 -## 15:
580 -## ... then, one can get the offsets using `nm`, like:
581 -## $ nm out.so | grep bss_global
582 -## 00000000000038fc B bss_global
584 -## Note the use of the aarch64 target (with -nostdlib in order to allow linkage
585 -## without libraries for cross-compilation) as well as -O3 and
586 -## -global-merge-ignore-single-use. This is a specific combination that makes
587 -## the compiler emit the `alpha` global variable with a more complex
588 -## DW_AT_location than just a DW_OP_addr/DW_OP_addrx. In this instance, it
589 -## outputs a `DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)`.
591 -## Ideally, this would be tested by invoking clang directly on a C source file,
592 -## but unfortunately there's no way to do that for LLVM tests. The other option
593 -## is to compile IR to an objfile, but llvm-symbolizer doesn't understand that
594 -## two symbols can have the same address in different sections. In the code
595 -## above, for example, we'd have bss_global at .bss+0x0, and data_global at
596 -## .data+0x0, and so the symbolizer would only print one of them. Hence, we have
597 -## the ugly dso-to-yaml blob below.
599 -## For now, constant strings don't have a debuginfo entry, and so can't be
600 -## symbolized correctly. In future (if D123534 gets merged), this can be updated
601 -## to include a check that llvm-symbolizer can also symbolize constant strings,
602 -## like `str` above (basically that &"12345678" should be symbolizable)
603 -## to the specific line. Then, you can find the address of the constant string
604 -## from the relocation:
606 -## $ nm out.so | grep str
607 -## 00000000000038c0 D str
608 -## $ llvm-objdump -R out.so | grep 38c0
609 -## 00000000000038c0 R_X86_64_RELATIVE *ABS*+0x4f8 # <-- 0x4f8
610 -################################################################################
612 ---- !ELF
613 -FileHeader:
614 - Class: ELFCLASS64
615 - Data: ELFDATA2LSB
616 - Type: ET_DYN
617 - Machine: EM_AARCH64
618 -ProgramHeaders:
619 - - Type: PT_PHDR
620 - Flags: [ PF_R ]
621 - VAddr: 0x40
622 - Align: 0x8
623 - - Type: PT_LOAD
624 - Flags: [ PF_R ]
625 - FirstSec: .dynsym
626 - LastSec: .eh_frame
627 - Align: 0x10000
628 - - Type: PT_LOAD
629 - Flags: [ PF_X, PF_R ]
630 - FirstSec: .text
631 - LastSec: .text
632 - VAddr: 0x103E4
633 - Align: 0x10000
634 - - Type: PT_LOAD
635 - Flags: [ PF_W, PF_R ]
636 - FirstSec: .dynamic
637 - LastSec: .dynamic
638 - VAddr: 0x20410
639 - Align: 0x10000
640 - - Type: PT_LOAD
641 - Flags: [ PF_W, PF_R ]
642 - FirstSec: .data
643 - LastSec: .bss
644 - VAddr: 0x304C0
645 - Align: 0x10000
646 - - Type: PT_DYNAMIC
647 - Flags: [ PF_W, PF_R ]
648 - FirstSec: .dynamic
649 - LastSec: .dynamic
650 - VAddr: 0x20410
651 - Align: 0x8
652 - - Type: PT_GNU_RELRO
653 - Flags: [ PF_R ]
654 - FirstSec: .dynamic
655 - LastSec: .dynamic
656 - VAddr: 0x20410
657 - - Type: PT_GNU_EH_FRAME
658 - Flags: [ PF_R ]
659 - FirstSec: .eh_frame_hdr
660 - LastSec: .eh_frame_hdr
661 - VAddr: 0x37C
662 - Align: 0x4
663 - - Type: PT_GNU_STACK
664 - Flags: [ PF_W, PF_R ]
665 - Align: 0x0
666 -Sections:
667 - - Name: .dynsym
668 - Type: SHT_DYNSYM
669 - Flags: [ SHF_ALLOC ]
670 - Address: 0x238
671 - Link: .dynstr
672 - AddressAlign: 0x8
673 - - Name: .gnu.hash
674 - Type: SHT_GNU_HASH
675 - Flags: [ SHF_ALLOC ]
676 - Address: 0x2C8
677 - Link: .dynsym
678 - AddressAlign: 0x8
679 - Header:
680 - SymNdx: 0x1
681 - Shift2: 0x1A
682 - BloomFilter: [ 0x400188002180000C ]
683 - HashBuckets: [ 0x1 ]
684 - HashValues: [ 0xEE8502A, 0xEE85016, 0xC033991C, 0x61F7372E, 0xB88AB7F ]
685 - - Name: .hash
686 - Type: SHT_HASH
687 - Flags: [ SHF_ALLOC ]
688 - Address: 0x2F8
689 - Link: .dynsym
690 - AddressAlign: 0x4
691 - Bucket: [ 5, 0, 4, 0, 3, 0 ]
692 - Chain: [ 0, 0, 0, 1, 2, 0 ]
693 - - Name: .dynstr
694 - Type: SHT_STRTAB
695 - Flags: [ SHF_ALLOC ]
696 - Address: 0x330
697 - AddressAlign: 0x1
698 - - Name: .rela.dyn
699 - Type: SHT_RELA
700 - Flags: [ SHF_ALLOC ]
701 - Address: 0x358
702 - Link: .dynsym
703 - AddressAlign: 0x8
704 - Relocations:
705 - - Offset: 0x304C8
706 - Type: R_AARCH64_RELATIVE
707 - Addend: 880
708 - - Name: .rodata
709 - Type: SHT_PROGBITS
710 - Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
711 - Address: 0x370
712 - AddressAlign: 0x1
713 - EntSize: 0x1
714 - Content: '313233343536373800'
715 - - Name: .eh_frame_hdr
716 - Type: SHT_PROGBITS
717 - Flags: [ SHF_ALLOC ]
718 - Address: 0x37C
719 - AddressAlign: 0x4
720 - Content: 011B033B18000000020000006800010034000000740001004C000000
721 - - Name: .eh_frame
722 - Type: SHT_PROGBITS
723 - Flags: [ SHF_ALLOC ]
724 - Address: 0x398
725 - AddressAlign: 0x8
726 - Content: 1400000000000000017A5200017C1E011B0C1F0000000000140000001C0000002C0001000C00000000000000000000001400000034000000200001001C000000000000000000000000000000
727 - - Name: .text
728 - Type: SHT_PROGBITS
729 - Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
730 - Address: 0x103E4
731 - AddressAlign: 0x4
732 - Content: 0001009000501391C0035FD60801009008611391E90308AA2A4540B85F0100710001899AC0035FD6
733 - - Name: .dynamic
734 - Type: SHT_DYNAMIC
735 - Flags: [ SHF_WRITE, SHF_ALLOC ]
736 - Address: 0x20410
737 - Link: .dynstr
738 - AddressAlign: 0x8
739 - Entries:
740 - - Tag: DT_RELA
741 - Value: 0x358
742 - - Tag: DT_RELASZ
743 - Value: 0x18
744 - - Tag: DT_RELAENT
745 - Value: 0x18
746 - - Tag: DT_RELACOUNT
747 - Value: 0x1
748 - - Tag: DT_SYMTAB
749 - Value: 0x238
750 - - Tag: DT_SYMENT
751 - Value: 0x18
752 - - Tag: DT_STRTAB
753 - Value: 0x330
754 - - Tag: DT_STRSZ
755 - Value: 0x28
756 - - Tag: DT_GNU_HASH
757 - Value: 0x2C8
758 - - Tag: DT_HASH
759 - Value: 0x2F8
760 - - Tag: DT_NULL
761 - Value: 0x0
762 - - Name: .data
763 - Type: SHT_PROGBITS
764 - Flags: [ SHF_WRITE, SHF_ALLOC ]
765 - Address: 0x304C0
766 - AddressAlign: 0x8
767 - Content: '02000000000000000000000000000000'
768 - - Name: .bss
769 - Type: SHT_NOBITS
770 - Flags: [ SHF_WRITE, SHF_ALLOC ]
771 - Address: 0x304D0
772 - AddressAlign: 0x4
773 - Size: 0x10
774 - - Name: .debug_abbrev
775 - Type: SHT_PROGBITS
776 - AddressAlign: 0x1
777 - Content: 011101252513050325721710171B25111B120673170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000040F004913000005260049130000062E01111B120640187A196E2503253A0B3B0B49133F190000073400032549133A0B3B0B02180000083400032549133A0B3B0B02186E25000009050003253A0B3B0B4913000000
778 - - Name: .debug_info
779 - Type: SHT_PROGBITS
780 - AddressAlign: 0x1
781 - Content: AB0000000500010800000000010021000108000000000000000205280000000800000002032E000000000102A1000304050402052E000000000202A101020648000000000402A102044D00000005520000000307080106050C000000016F0D0E0007A500000007082E000000000802A1030008092E000000000D02A1040A080B2E000000000C04A10423040C06061C000000016F0F0E000EA50000000910000EAA00000000042E0000000311020100
782 - - Name: .debug_str_offsets
783 - Type: SHT_PROGBITS
784 - AddressAlign: 0x1
785 - Content: 4C00000005000000A2000000000000002C00000059000000280000001C00000072000000640000008C0000008700000069000000140000007B0000009C0000001A0000000E0000008500000076000000
786 - - Name: .comment
787 - Type: SHT_PROGBITS
788 - Flags: [ SHF_MERGE, SHF_STRINGS ]
789 - AddressAlign: 0x1
790 - EntSize: 0x1
791 - Content: 4C696E6B65723A204C4C442031352E302E300000636C616E672076657273696F6E2031352E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420306462616566363162353666306566306162306366333865613932666663316633356265653366662900
792 - - Name: .debug_line
793 - Type: SHT_PROGBITS
794 - AddressAlign: 0x1
795 - Content: 620000000500080037000000010101FB0E0D00010101010000000100000101011F010E00000003011F020F051E0100000000006C97BBE59F7DC6A9EA956633431DA63E0400000902E4030100000000001805030A140500BF05190A0105120608740204000101
796 - - Name: .debug_line_str
797 - Type: SHT_PROGBITS
798 - Flags: [ SHF_MERGE, SHF_STRINGS ]
799 - AddressAlign: 0x1
800 - EntSize: 0x1
801 - Content: 2F746D702F66696C652E637070002F7573722F6C6F63616C2F676F6F676C652F686F6D652F6D69746368702F6C6C766D2D6275696C642F6F707400
802 -Symbols:
803 - - Name: file.cpp
804 - Type: STT_FILE
805 - Index: SHN_ABS
806 - - Name: '$x.0'
807 - Section: .text
808 - Value: 0x103E4
809 - - Name: _ZZ1fvE15function_global
810 - Type: STT_OBJECT
811 - Section: .bss
812 - Value: 0x304D4
813 - Size: 0x4
814 - - Name: '$d.1'
815 - Section: .bss
816 - Value: 0x304D0
817 - - Name: '$d.2'
818 - Section: .data
819 - Value: 0x304C0
820 - - Name: '$d.3'
821 - Section: .rodata
822 - Value: 0x370
823 - - Name: '$d.4'
824 - Section: .debug_abbrev
825 - - Name: '$d.5'
826 - Section: .debug_info
827 - - Name: '$d.6'
828 - Section: .debug_str_offsets
829 - - Name: '$d.7'
830 - Section: .debug_str
831 - Value: 0xA2
832 - - Name: '$d.8'
833 - Section: .debug_addr
834 - - Name: _ZL4beta
835 - Type: STT_OBJECT
836 - Section: .bss
837 - Value: 0x304D8
838 - Size: 0x4
839 - - Name: _ZL5alpha
840 - Type: STT_OBJECT
841 - Section: .bss
842 - Value: 0x304DC
843 - Size: 0x4
844 - - Name: '$d.9'
845 - Section: .comment
846 - Value: 0x13
847 - - Name: '$d.10'
848 - Section: .eh_frame
849 - Value: 0x398
850 - - Name: '$d.11'
851 - Section: .debug_line
852 - - Name: '$d.12'
853 - Section: .debug_line_str
854 - Value: 0xE
855 - - Name: _DYNAMIC
856 - Section: .dynamic
857 - Value: 0x20410
858 - Other: [ STV_HIDDEN ]
859 - - Name: _Z1fv
860 - Type: STT_FUNC
861 - Section: .text
862 - Binding: STB_GLOBAL
863 - Value: 0x103E4
864 - Size: 0xC
865 - - Name: _Z1fb
866 - Type: STT_FUNC
867 - Section: .text
868 - Binding: STB_GLOBAL
869 - Value: 0x103F0
870 - Size: 0x1C
871 - - Name: bss_global
872 - Type: STT_OBJECT
873 - Section: .bss
874 - Binding: STB_GLOBAL
875 - Value: 0x304D0
876 - Size: 0x4
877 - - Name: data_global
878 - Type: STT_OBJECT
879 - Section: .data
880 - Binding: STB_GLOBAL
881 - Value: 0x304C0
882 - Size: 0x4
883 - - Name: str
884 - Type: STT_OBJECT
885 - Section: .data
886 - Binding: STB_GLOBAL
887 - Value: 0x304C8
888 - Size: 0x8
889 -DynamicSymbols:
890 - - Name: _Z1fv
891 - Type: STT_FUNC
892 - Section: .text
893 - Binding: STB_GLOBAL
894 - Value: 0x103E4
895 - Size: 0xC
896 - - Name: _Z1fb
897 - Type: STT_FUNC
898 - Section: .text
899 - Binding: STB_GLOBAL
900 - Value: 0x103F0
901 - Size: 0x1C
902 - - Name: bss_global
903 - Type: STT_OBJECT
904 - Section: .bss
905 - Binding: STB_GLOBAL
906 - Value: 0x304D0
907 - Size: 0x4
908 - - Name: data_global
909 - Type: STT_OBJECT
910 - Section: .data
911 - Binding: STB_GLOBAL
912 - Value: 0x304C0
913 - Size: 0x4
914 - - Name: str
915 - Type: STT_OBJECT
916 - Section: .data
917 - Binding: STB_GLOBAL
918 - Value: 0x304C8
919 - Size: 0x8
920 -DWARF:
921 - debug_str:
922 - - '/tmp/file.cpp'
923 - - _Z1fb
924 - - alpha
925 - - f
926 - - data_global
927 - - int
928 - - '/usr/local/google/home/mitchp/llvm-build/opt'
929 - - bss_global
930 - - char
931 - - _ZL4beta
932 - - str
933 - - bool
934 - - _ZL5alpha
935 - - b
936 - - beta
937 - - function_global
938 - - _Z1fv
939 - - 'clang version 15.0.0 (https://github.com/llvm/llvm-project.git 0dbaef61b56f0ef0ab0cf38ea92ffc1f35bee3ff)'
940 - debug_addr:
941 - - Length: 0x3C
942 - Version: 0x5
943 - AddressSize: 0x8
944 - Entries:
945 - - Address: 0x304D0
946 - - Address: 0x304C0
947 - - Address: 0x304C8
948 - - Address: 0x304D4
949 - - Address: 0x304D8
950 - - Address: 0x103E4
951 - - Address: 0x103F0
952 -...
953 diff --git a/llvm/test/tools/llvm-symbolizer/data.s b/llvm/test/tools/llvm-symbolizer/data.s
954 index cc9503c59141..e8039f146dbd 100644
955 --- a/llvm/test/tools/llvm-symbolizer/data.s
956 +++ b/llvm/test/tools/llvm-symbolizer/data.s
957 @@ -7,12 +7,9 @@
959 # CHECK: d1
960 # CHECK-NEXT: 0 8
961 -# CHECK-NEXT: ??:?
962 # CHECK-EMPTY:
963 # CHECK-NEXT: d2
964 # CHECK-NEXT: 8 4
965 -# CHECK-NEXT: ??:?
966 -# CHECK-EMPTY:
969 .quad 0x1122334455667788
971 2.38.1.1.g6d9df9d320