Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
LVBinaryReader.cpp
Go to the documentation of this file.
1//===-- LVBinaryReader.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This implements the LVBinaryReader class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h"
14#include "llvm/Support/Errc.h"
15#include "llvm/Support/FormatAdapters.h"
16#include "llvm/Support/FormatVariadic.h"
17
18using namespacellvm;
19using namespacellvm::logicalview;
20
21#define DEBUG_TYPE "BinaryReader"
22
23// Function names extracted from the object symbol table.
24voidLVSymbolTable::add(StringRefName,LVScope *Function,
25LVSectionIndex SectionIndex) {
26 std::string SymbolName(Name);
27if (SymbolNames.find(SymbolName) == SymbolNames.end()) {
28 SymbolNames.emplace(
29 std::piecewise_construct, std::forward_as_tuple(SymbolName),
30 std::forward_as_tuple(Function, 0, SectionIndex,false));
31 }else {
32// Update a recorded entry with its logical scope and section index.
33 SymbolNames[SymbolName].Scope =Function;
34if (SectionIndex)
35 SymbolNames[SymbolName].SectionIndex = SectionIndex;
36 }
37
38if (Function && SymbolNames[SymbolName].IsComdat)
39Function->setIsComdat();
40
41LLVM_DEBUG({print(dbgs()); });
42}
43
44voidLVSymbolTable::add(StringRefName,LVAddressAddress,
45LVSectionIndex SectionIndex,bool IsComdat) {
46 std::string SymbolName(Name);
47if (SymbolNames.find(SymbolName) == SymbolNames.end())
48 SymbolNames.emplace(
49 std::piecewise_construct, std::forward_as_tuple(SymbolName),
50 std::forward_as_tuple(nullptr,Address, SectionIndex, IsComdat));
51else
52// Update a recorded symbol name with its logical scope.
53 SymbolNames[SymbolName].Address =Address;
54
55LVScope *Function = SymbolNames[SymbolName].Scope;
56if (Function && IsComdat)
57Function->setIsComdat();
58LLVM_DEBUG({print(dbgs()); });
59}
60
61LVSectionIndexLVSymbolTable::update(LVScope *Function) {
62LVSectionIndex SectionIndex =getReader().getDotTextSectionIndex();
63StringRefName =Function->getLinkageName();
64if (Name.empty())
65Name =Function->getName();
66 std::string SymbolName(Name);
67
68if (SymbolName.empty() || (SymbolNames.find(SymbolName) == SymbolNames.end()))
69return SectionIndex;
70
71// Update a recorded entry with its logical scope, only if the scope has
72// ranges. That is the case when in DWARF there are 2 DIEs connected via
73// the DW_AT_specification.
74if (Function->getHasRanges()) {
75 SymbolNames[SymbolName].Scope =Function;
76 SectionIndex = SymbolNames[SymbolName].SectionIndex;
77 }else {
78 SectionIndex =UndefinedSectionIndex;
79 }
80
81if (SymbolNames[SymbolName].IsComdat)
82Function->setIsComdat();
83
84LLVM_DEBUG({print(dbgs()); });
85return SectionIndex;
86}
87
88constLVSymbolTableEntry &LVSymbolTable::getEntry(StringRefName) {
89staticLVSymbolTableEntry Empty =LVSymbolTableEntry();
90 LVSymbolNames::iterator Iter = SymbolNames.find(Name);
91return Iter != SymbolNames.end() ? Iter->second : Empty;
92}
93LVAddressLVSymbolTable::getAddress(StringRefName) {
94 LVSymbolNames::iterator Iter = SymbolNames.find(Name);
95return Iter != SymbolNames.end() ? Iter->second.Address : 0;
96}
97LVSectionIndexLVSymbolTable::getIndex(StringRefName) {
98 LVSymbolNames::iterator Iter = SymbolNames.find(Name);
99return Iter != SymbolNames.end() ? Iter->second.SectionIndex
100 :getReader().getDotTextSectionIndex();
101}
102boolLVSymbolTable::getIsComdat(StringRefName) {
103 LVSymbolNames::iterator Iter = SymbolNames.find(Name);
104return Iter != SymbolNames.end() ? Iter->second.IsComdat :false;
105}
106
107voidLVSymbolTable::print(raw_ostream &OS) {
108OS <<"Symbol Table\n";
109for (LVSymbolNames::reference Entry : SymbolNames) {
110LVSymbolTableEntry &SymbolName = Entry.second;
111LVScope *Scope = SymbolName.Scope;
112LVOffsetOffset = Scope ? Scope->getOffset() : 0;
113OS <<"Index: " <<hexValue(SymbolName.SectionIndex, 5)
114 <<" Comdat: " << (SymbolName.IsComdat ?"Y" :"N")
115 <<" Scope: " <<hexValue(Offset)
116 <<" Address: " <<hexValue(SymbolName.Address)
117 <<" Name: " << Entry.first <<"\n";
118 }
119}
120
121voidLVBinaryReader::addToSymbolTable(StringRefName,LVScope *Function,
122LVSectionIndex SectionIndex) {
123 SymbolTable.add(Name,Function, SectionIndex);
124}
125voidLVBinaryReader::addToSymbolTable(StringRefName,LVAddressAddress,
126LVSectionIndex SectionIndex,
127bool IsComdat) {
128 SymbolTable.add(Name,Address, SectionIndex, IsComdat);
129}
130LVSectionIndexLVBinaryReader::updateSymbolTable(LVScope *Function) {
131return SymbolTable.update(Function);
132}
133
134constLVSymbolTableEntry &LVBinaryReader::getSymbolTableEntry(StringRefName) {
135return SymbolTable.getEntry(Name);
136}
137LVAddressLVBinaryReader::getSymbolTableAddress(StringRefName) {
138return SymbolTable.getAddress(Name);
139}
140LVSectionIndexLVBinaryReader::getSymbolTableIndex(StringRefName) {
141return SymbolTable.getIndex(Name);
142}
143boolLVBinaryReader::getSymbolTableIsComdat(StringRefName) {
144return SymbolTable.getIsComdat(Name);
145}
146
147voidLVBinaryReader::mapVirtualAddress(constobject::ObjectFile &Obj) {
148for (constobject::SectionRef &Section : Obj.sections()) {
149LLVM_DEBUG({
150Expected<StringRef> SectionNameOrErr = Section.getName();
151StringRefName;
152if (!SectionNameOrErr)
153consumeError(SectionNameOrErr.takeError());
154else
155Name = *SectionNameOrErr;
156dbgs() <<"Index: " <<format_decimal(Section.getIndex(), 3) <<", "
157 <<"Address: " <<hexValue(Section.getAddress()) <<", "
158 <<"Size: " <<hexValue(Section.getSize()) <<", "
159 <<"Name: " <<Name <<"\n";
160dbgs() <<"isCompressed: " << Section.isCompressed() <<", "
161 <<"isText: " << Section.isText() <<", "
162 <<"isData: " << Section.isData() <<", "
163 <<"isBSS: " << Section.isBSS() <<", "
164 <<"isVirtual: " << Section.isVirtual() <<"\n";
165dbgs() <<"isBitcode: " << Section.isBitcode() <<", "
166 <<"isStripped: " << Section.isStripped() <<", "
167 <<"isBerkeleyText: " << Section.isBerkeleyText() <<", "
168 <<"isBerkeleyData: " << Section.isBerkeleyData() <<", "
169 <<"isDebugSection: " << Section.isDebugSection() <<"\n";
170dbgs() <<"\n";
171 });
172
173if (!Section.isText() || Section.isVirtual() || !Section.getSize())
174continue;
175
176// Record section information required for symbol resolution.
177// Note: The section index returned by 'getIndex()' is one based.
178 Sections.emplace(Section.getIndex(), Section);
179 addSectionAddress(Section);
180
181// Identify the ".text" section.
182Expected<StringRef> SectionNameOrErr = Section.getName();
183if (!SectionNameOrErr) {
184consumeError(SectionNameOrErr.takeError());
185continue;
186 }
187if (*SectionNameOrErr ==".text" || *SectionNameOrErr =="CODE" ||
188 *SectionNameOrErr ==".code") {
189DotTextSectionIndex = Section.getIndex();
190// If the object is WebAssembly, update the address offset that
191// will be added to DWARF DW_AT_* attributes.
192if (Obj.isWasm())
193WasmCodeSectionOffset = Section.getAddress();
194 }
195 }
196
197// Process the symbol table.
198mapRangeAddress(Obj);
199
200LLVM_DEBUG({
201dbgs() <<"\nSections Information:\n";
202for (LVSections::reference Entry : Sections) {
203LVSectionIndex SectionIndex = Entry.first;
204constobject::SectionRef Section = Entry.second;
205Expected<StringRef> SectionNameOrErr = Section.getName();
206if (!SectionNameOrErr)
207consumeError(SectionNameOrErr.takeError());
208dbgs() <<"\nIndex: " <<format_decimal(SectionIndex, 3)
209 <<" Name: " << *SectionNameOrErr <<"\n"
210 <<"Size: " <<hexValue(Section.getSize()) <<"\n"
211 <<"VirtualAddress: " <<hexValue(VirtualAddress) <<"\n"
212 <<"SectionAddress: " <<hexValue(Section.getAddress()) <<"\n";
213 }
214dbgs() <<"\nObject Section Information:\n";
215for (LVSectionAddresses::const_reference Entry : SectionAddresses)
216dbgs() <<"[" <<hexValue(Entry.first) <<":"
217 <<hexValue(Entry.first + Entry.second.getSize())
218 <<"] Size: " <<hexValue(Entry.second.getSize()) <<"\n";
219 });
220}
221
222voidLVBinaryReader::mapVirtualAddress(constobject::COFFObjectFile &COFFObj) {
223ErrorOr<uint64_t> ImageBase = COFFObj.getImageBase();
224if (ImageBase)
225 ImageBaseAddress = ImageBase.get();
226
227LLVM_DEBUG({
228dbgs() <<"ImageBaseAddress: " <<hexValue(ImageBaseAddress) <<"\n";
229 });
230
231uint32_t Flags =COFF::IMAGE_SCN_CNT_CODE |COFF::IMAGE_SCN_LNK_COMDAT;
232
233for (constobject::SectionRef &Section : COFFObj.sections()) {
234if (!Section.isText() || Section.isVirtual() || !Section.getSize())
235continue;
236
237constobject::coff_section *COFFSection = COFFObj.getCOFFSection(Section);
238 VirtualAddress = COFFSection->VirtualAddress;
239bool IsComdat = (COFFSection->Characteristics & Flags) == Flags;
240
241// Record section information required for symbol resolution.
242// Note: The section index returned by 'getIndex()' is zero based.
243 Sections.emplace(Section.getIndex() + 1, Section);
244 addSectionAddress(Section);
245
246// Additional initialization on the specific object format.
247mapRangeAddress(COFFObj, Section, IsComdat);
248 }
249
250LLVM_DEBUG({
251dbgs() <<"\nSections Information:\n";
252for (LVSections::reference Entry : Sections) {
253LVSectionIndex SectionIndex = Entry.first;
254constobject::SectionRef Section = Entry.second;
255constobject::coff_section *COFFSection = COFFObj.getCOFFSection(Section);
256Expected<StringRef> SectionNameOrErr = Section.getName();
257if (!SectionNameOrErr)
258consumeError(SectionNameOrErr.takeError());
259dbgs() <<"\nIndex: " <<format_decimal(SectionIndex, 3)
260 <<" Name: " << *SectionNameOrErr <<"\n"
261 <<"Size: " <<hexValue(Section.getSize()) <<"\n"
262 <<"VirtualAddress: " <<hexValue(VirtualAddress) <<"\n"
263 <<"SectionAddress: " <<hexValue(Section.getAddress()) <<"\n"
264 <<"PointerToRawData: " <<hexValue(COFFSection->PointerToRawData)
265 <<"\n"
266 <<"SizeOfRawData: " <<hexValue(COFFSection->SizeOfRawData)
267 <<"\n";
268 }
269dbgs() <<"\nObject Section Information:\n";
270for (LVSectionAddresses::const_reference Entry : SectionAddresses)
271dbgs() <<"[" <<hexValue(Entry.first) <<":"
272 <<hexValue(Entry.first + Entry.second.getSize())
273 <<"] Size: " <<hexValue(Entry.second.getSize()) <<"\n";
274 });
275}
276
277ErrorLVBinaryReader::loadGenericTargetInfo(StringRef TheTriple,
278StringRef TheFeatures) {
279 std::string TargetLookupError;
280constTarget *TheTarget =
281TargetRegistry::lookupTarget(std::string(TheTriple), TargetLookupError);
282if (!TheTarget)
283returncreateStringError(errc::invalid_argument, TargetLookupError.c_str());
284
285// Register information.
286MCRegisterInfo *RegisterInfo = TheTarget->createMCRegInfo(TheTriple);
287if (!RegisterInfo)
288returncreateStringError(errc::invalid_argument,
289"no register info for target " + TheTriple);
290MRI.reset(RegisterInfo);
291
292// Assembler properties and features.
293MCTargetOptions MCOptions;
294MCAsmInfo *AsmInfo(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions));
295if (!AsmInfo)
296returncreateStringError(errc::invalid_argument,
297"no assembly info for target " + TheTriple);
298MAI.reset(AsmInfo);
299
300// Target subtargets.
301StringRef CPU;
302MCSubtargetInfo *SubtargetInfo(
303 TheTarget->createMCSubtargetInfo(TheTriple, CPU, TheFeatures));
304if (!SubtargetInfo)
305returncreateStringError(errc::invalid_argument,
306"no subtarget info for target " + TheTriple);
307STI.reset(SubtargetInfo);
308
309// Instructions Info.
310MCInstrInfo *InstructionInfo(TheTarget->createMCInstrInfo());
311if (!InstructionInfo)
312returncreateStringError(errc::invalid_argument,
313"no instruction info for target " + TheTriple);
314MII.reset(InstructionInfo);
315
316MC = std::make_unique<MCContext>(Triple(TheTriple),MAI.get(),MRI.get(),
317STI.get());
318
319// Assembler.
320MCDisassembler *DisAsm(TheTarget->createMCDisassembler(*STI, *MC));
321if (!DisAsm)
322returncreateStringError(errc::invalid_argument,
323"no disassembler for target " + TheTriple);
324MD.reset(DisAsm);
325
326MCInstPrinter *InstructionPrinter(TheTarget->createMCInstPrinter(
327Triple(TheTriple), AsmInfo->getAssemblerDialect(), *MAI, *MII, *MRI));
328if (!InstructionPrinter)
329returncreateStringError(errc::invalid_argument,
330"no target assembly language printer for target " +
331 TheTriple);
332MIP.reset(InstructionPrinter);
333 InstructionPrinter->setPrintImmHex(true);
334
335returnError::success();
336}
337
338Expected<std::pair<uint64_t, object::SectionRef>>
339LVBinaryReader::getSection(LVScope *Scope,LVAddressAddress,
340LVSectionIndex SectionIndex) {
341// Return the 'text' section with the code for this logical scope.
342// COFF: SectionIndex is zero. Use 'SectionAddresses' data.
343// ELF: SectionIndex is the section index in the file.
344if (SectionIndex) {
345 LVSections::iterator Iter = Sections.find(SectionIndex);
346if (Iter == Sections.end()) {
347returncreateStringError(errc::invalid_argument,
348"invalid section index for: '%s'",
349 Scope->getName().str().c_str());
350 }
351constobject::SectionRef Section = Iter->second;
352return std::make_pair(Section.getAddress(), Section);
353 }
354
355// Ensure a valid starting address for the public names.
356 LVSectionAddresses::const_iterator Iter =
357 SectionAddresses.upper_bound(Address);
358if (Iter == SectionAddresses.begin())
359returncreateStringError(errc::invalid_argument,
360"invalid section address for: '%s'",
361 Scope->getName().str().c_str());
362
363// Get section that contains the code for this function.
364 Iter = SectionAddresses.lower_bound(Address);
365if (Iter != SectionAddresses.begin())
366 --Iter;
367return std::make_pair(Iter->first, Iter->second);
368}
369
370voidLVBinaryReader::addSectionRange(LVSectionIndex SectionIndex,
371LVScope *Scope) {
372LVRange *ScopesWithRanges =getSectionRanges(SectionIndex);
373 ScopesWithRanges->addEntry(Scope);
374}
375
376voidLVBinaryReader::addSectionRange(LVSectionIndex SectionIndex,
377LVScope *Scope,LVAddress LowerAddress,
378LVAddress UpperAddress) {
379LVRange *ScopesWithRanges =getSectionRanges(SectionIndex);
380 ScopesWithRanges->addEntry(Scope, LowerAddress, UpperAddress);
381}
382
383LVRange *LVBinaryReader::getSectionRanges(LVSectionIndex SectionIndex) {
384// Check if we already have a mapping for this section index.
385 LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
386if (IterSection == SectionRanges.end())
387 IterSection =
388 SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
389LVRange *Range = IterSection->second.get();
390assert(Range &&"Range is null.");
391returnRange;
392}
393
394ErrorLVBinaryReader::createInstructions(LVScope *Scope,
395LVSectionIndex SectionIndex,
396constLVNameInfo &NameInfo) {
397assert(Scope &&"Scope is null.");
398
399// Skip stripped functions.
400if (Scope->getIsDiscarded())
401returnError::success();
402
403// Find associated address and size for the given function entry point.
404LVAddressAddress = NameInfo.first;
405uint64_tSize = NameInfo.second;
406
407LLVM_DEBUG({
408dbgs() <<"\nPublic Name instructions: '" << Scope->getName() <<"' / '"
409 << Scope->getLinkageName() <<"'\n"
410 <<"DIE Offset: " <<hexValue(Scope->getOffset()) <<" Range: ["
411 <<hexValue(Address) <<":" <<hexValue(Address +Size) <<"]\n";
412 });
413
414Expected<std::pair<uint64_t, const object::SectionRef>> SectionOrErr =
415getSection(Scope,Address, SectionIndex);
416if (!SectionOrErr)
417return SectionOrErr.takeError();
418constobject::SectionRef Section = (*SectionOrErr).second;
419uint64_t SectionAddress = (*SectionOrErr).first;
420
421Expected<StringRef> SectionContentsOrErr = Section.getContents();
422if (!SectionContentsOrErr)
423return SectionOrErr.takeError();
424
425// There are cases where the section size is smaller than the [LowPC,HighPC]
426// range; it causes us to decode invalid addresses. The recorded size in the
427// logical scope is one less than the real size.
428LLVM_DEBUG({
429dbgs() <<" Size: " <<hexValue(Size)
430 <<", Section Size: " <<hexValue(Section.getSize()) <<"\n";
431 });
432Size = std::min(Size + 1, Section.getSize());
433
434ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(*SectionContentsOrErr);
435uint64_tOffset =Address - SectionAddress;
436uint8_tconst *Begin = Bytes.data() +Offset;
437uint8_tconst *End = Bytes.data() +Offset +Size;
438
439LLVM_DEBUG({
440Expected<StringRef> SectionNameOrErr = Section.getName();
441if (!SectionNameOrErr)
442consumeError(SectionNameOrErr.takeError());
443else
444dbgs() <<"Section Index: " <<hexValue(Section.getIndex()) <<" ["
445 <<hexValue((uint64_t)Section.getAddress()) <<":"
446 <<hexValue((uint64_t)Section.getAddress() + Section.getSize(), 10)
447 <<"] Name: '" << *SectionNameOrErr <<"'\n"
448 <<"Begin: " <<hexValue((uint64_t)Begin)
449 <<", End: " <<hexValue((uint64_t)End) <<"\n";
450 });
451
452// Address for first instruction line.
453LVAddress FirstAddress =Address;
454auto InstructionsSP = std::make_unique<LVLines>();
455LVLines &Instructions = *InstructionsSP;
456 DiscoveredLines.emplace_back(std::move(InstructionsSP));
457
458while (Begin <End) {
459MCInstInstruction;
460uint64_t BytesConsumed = 0;
461SmallVector<char, 64> InsnStr;
462raw_svector_ostreamAnnotations(InsnStr);
463MCDisassembler::DecodeStatusconst S =
464MD->getInstruction(Instruction, BytesConsumed,
465ArrayRef<uint8_t>(Begin,End),Address,outs());
466switch (S) {
467caseMCDisassembler::Fail:
468LLVM_DEBUG({dbgs() <<"Invalid instruction\n"; });
469if (BytesConsumed == 0)
470// Skip invalid bytes
471 BytesConsumed = 1;
472break;
473caseMCDisassembler::SoftFail:
474LLVM_DEBUG({dbgs() <<"Potentially undefined instruction:"; });
475 [[fallthrough]];
476caseMCDisassembler::Success: {
477 std::string Buffer;
478raw_string_ostream Stream(Buffer);
479StringRef AnnotationsStr =Annotations.str();
480MIP->printInst(&Instruction,Address, AnnotationsStr, *STI, Stream);
481LLVM_DEBUG({
482 std::string BufferCodes;
483raw_string_ostream StreamCodes(BufferCodes);
484 StreamCodes <<format_bytes(
485ArrayRef<uint8_t>(Begin, Begin + BytesConsumed), std::nullopt, 16,
486 16);
487dbgs() <<"[" <<hexValue((uint64_t)Begin) <<"] "
488 <<"Size: " <<format_decimal(BytesConsumed, 2) <<" ("
489 <<formatv("{0}",
490fmt_align(StreamCodes.str(),AlignStyle::Left, 32))
491 <<") " <<hexValue((uint64_t)Address) <<": " << Stream.str()
492 <<"\n";
493 });
494// Here we add logical lines to the Instructions. Later on,
495// the 'processLines()' function will move each created logical line
496// to its enclosing logical scope, using the debug ranges information
497// and they will be released when its scope parent is deleted.
498LVLineAssembler *Line = createLineAssembler();
499Line->setAddress(Address);
500Line->setName(StringRef(Stream.str()).trim());
501Instructions.push_back(Line);
502break;
503 }
504 }
505Address += BytesConsumed;
506 Begin += BytesConsumed;
507 }
508
509LLVM_DEBUG({
510size_t Index = 0;
511dbgs() <<"\nSectionIndex: " <<format_decimal(SectionIndex, 3)
512 <<" Scope DIE: " <<hexValue(Scope->getOffset()) <<"\n"
513 <<"Address: " <<hexValue(FirstAddress)
514 <<format(" - Collected instructions lines: %d\n",
515Instructions.size());
516for (constLVLine *Line :Instructions)
517dbgs() <<format_decimal(++Index, 5) <<": "
518 <<hexValue(Line->getOffset()) <<", (" <<Line->getName()
519 <<")\n";
520 });
521
522// The scope in the assembler names is linked to its own instructions.
523 ScopeInstructions.add(SectionIndex, Scope, &Instructions);
524 AssemblerMappings.add(SectionIndex, FirstAddress, Scope);
525
526returnError::success();
527}
528
529ErrorLVBinaryReader::createInstructions(LVScope *Function,
530LVSectionIndex SectionIndex) {
531if (!options().getPrintInstructions())
532returnError::success();
533
534LVNameInfoName =CompileUnit->findPublicName(Function);
535if (Name.first !=LVAddress(UINT64_MAX))
536returncreateInstructions(Function, SectionIndex,Name);
537
538returnError::success();
539}
540
541ErrorLVBinaryReader::createInstructions() {
542if (!options().getPrintInstructions())
543returnError::success();
544
545LLVM_DEBUG({
546size_t Index = 1;
547dbgs() <<"\nPublic Names (Scope):\n";
548for (LVPublicNames::const_referenceName :CompileUnit->getPublicNames()) {
549LVScope *Scope =Name.first;
550constLVNameInfo &NameInfo =Name.second;
551LVAddressAddress = NameInfo.first;
552uint64_tSize = NameInfo.second;
553dbgs() <<format_decimal(Index++, 5) <<": "
554 <<"DIE Offset: " <<hexValue(Scope->getOffset()) <<" Range: ["
555 <<hexValue(Address) <<":" <<hexValue(Address +Size) <<"] "
556 <<"Name: '" << Scope->getName() <<"' / '"
557 << Scope->getLinkageName() <<"'\n";
558 }
559 });
560
561// For each public name in the current compile unit, create the line
562// records that represent the executable instructions.
563for (LVPublicNames::const_referenceName :CompileUnit->getPublicNames()) {
564LVScope *Scope =Name.first;
565// The symbol table extracted from the object file always contains a
566// non-empty name (linkage name). However, the logical scope does not
567// guarantee to have a name for the linkage name (main is one case).
568// For those cases, set the linkage name the same as the name.
569if (!Scope->getLinkageNameIndex())
570 Scope->setLinkageName(Scope->getName());
571LVSectionIndex SectionIndex =getSymbolTableIndex(Scope->getLinkageName());
572if (Error Err =createInstructions(Scope, SectionIndex,Name.second))
573return Err;
574 }
575
576returnError::success();
577}
578
579// During the traversal of the debug information sections, we created the
580// logical lines representing the disassembled instructions from the text
581// section and the logical lines representing the line records from the
582// debug line section. Using the ranges associated with the logical scopes,
583// we will allocate those logical lines to their logical scopes.
584voidLVBinaryReader::processLines(LVLines *DebugLines,
585LVSectionIndex SectionIndex,
586LVScope *Function) {
587assert(DebugLines &&"DebugLines is null.");
588
589// Just return if this compilation unit does not have any line records
590// and no instruction lines were created.
591if (DebugLines->empty() && !options().getPrintInstructions())
592return;
593
594// Merge the debug lines and instruction lines using their text address;
595// the logical line representing the debug line record is followed by the
596// line(s) representing the disassembled instructions, whose addresses are
597// equal or greater that the line address and less than the address of the
598// next debug line record.
599LLVM_DEBUG({
600size_t Index = 1;
601size_t PerLine = 4;
602dbgs() <<format("\nProcess debug lines: %d\n", DebugLines->size());
603for (constLVLine *Line : *DebugLines) {
604dbgs() <<format_decimal(Index, 5) <<": " <<hexValue(Line->getOffset())
605 <<", (" <<Line->getLineNumber() <<")"
606 << ((Index % PerLine) ?" " :"\n");
607 ++Index;
608 }
609dbgs() << ((Index % PerLine) ?"\n" :"");
610 });
611
612bool TraverseLines =true;
613LVLines::iterator Iter = DebugLines->begin();
614while (TraverseLines && Iter != DebugLines->end()) {
615uint64_t DebugAddress = (*Iter)->getAddress();
616
617// Get the function with an entry point that matches this line and
618// its associated assembler entries. In the case of COMDAT, the input
619// 'Function' is not null. Use it to find its address ranges.
620LVScope *Scope =Function;
621if (!Function) {
622 Scope = AssemblerMappings.find(SectionIndex, DebugAddress);
623if (!Scope) {
624 ++Iter;
625continue;
626 }
627 }
628
629// Get the associated instructions for the found 'Scope'.
630LVLines InstructionLines;
631LVLines *Lines = ScopeInstructions.find(SectionIndex, Scope);
632if (Lines)
633 InstructionLines = std::move(*Lines);
634
635LLVM_DEBUG({
636size_t Index = 0;
637dbgs() <<"\nSectionIndex: " <<format_decimal(SectionIndex, 3)
638 <<" Scope DIE: " <<hexValue(Scope->getOffset()) <<"\n"
639 <<format("Process instruction lines: %d\n",
640 InstructionLines.size());
641for (constLVLine *Line : InstructionLines)
642dbgs() <<format_decimal(++Index, 5) <<": "
643 <<hexValue(Line->getOffset()) <<", (" <<Line->getName()
644 <<")\n";
645 });
646
647// Continue with next debug line if there are not instructions lines.
648if (InstructionLines.empty()) {
649 ++Iter;
650continue;
651 }
652
653for (LVLine *InstructionLine : InstructionLines) {
654uint64_t InstructionAddress = InstructionLine->getAddress();
655LLVM_DEBUG({
656dbgs() <<"Instruction address: " <<hexValue(InstructionAddress)
657 <<"\n";
658 });
659if (TraverseLines) {
660while (Iter != DebugLines->end()) {
661 DebugAddress = (*Iter)->getAddress();
662LLVM_DEBUG({
663bool IsDebug = (*Iter)->getIsLineDebug();
664dbgs() <<"Line " << (IsDebug ?"dbg:" :"ins:") <<" ["
665 <<hexValue(DebugAddress) <<"]";
666if (IsDebug)
667dbgs() <<format(" %d", (*Iter)->getLineNumber());
668dbgs() <<"\n";
669 });
670// Instruction address before debug line.
671if (InstructionAddress < DebugAddress) {
672LLVM_DEBUG({
673dbgs() <<"Inserted instruction address: "
674 <<hexValue(InstructionAddress) <<" before line: "
675 <<format("%d", (*Iter)->getLineNumber()) <<" ["
676 <<hexValue(DebugAddress) <<"]\n";
677 });
678 Iter = DebugLines->insert(Iter, InstructionLine);
679// The returned iterator points to the inserted instruction.
680// Skip it and point to the line acting as reference.
681 ++Iter;
682break;
683 }
684 ++Iter;
685 }
686if (Iter == DebugLines->end()) {
687// We have reached the end of the source lines and the current
688// instruction line address is greater than the last source line.
689 TraverseLines =false;
690 DebugLines->push_back(InstructionLine);
691 }
692 }else {
693 DebugLines->push_back(InstructionLine);
694 }
695 }
696 }
697
698LLVM_DEBUG({
699dbgs() <<format("Lines after merge: %d\n", DebugLines->size());
700size_t Index = 0;
701for (constLVLine *Line : *DebugLines) {
702dbgs() <<format_decimal(++Index, 5) <<": "
703 <<hexValue(Line->getOffset()) <<", ("
704 << ((Line->getIsLineDebug())
705 ?Line->lineNumberAsStringStripped(/*ShowZero=*/true)
706 :Line->getName())
707 <<")\n";
708 }
709 });
710
711// If this compilation unit does not have line records, traverse its scopes
712// and take any collected instruction lines as the working set in order
713// to move them to their associated scope.
714if (DebugLines->empty()) {
715if (constLVScopes *Scopes =CompileUnit->getScopes())
716for (LVScope *Scope : *Scopes) {
717LVLines *Lines = ScopeInstructions.find(Scope);
718if (Lines) {
719
720LLVM_DEBUG({
721size_t Index = 0;
722dbgs() <<"\nSectionIndex: " <<format_decimal(SectionIndex, 3)
723 <<" Scope DIE: " <<hexValue(Scope->getOffset()) <<"\n"
724 <<format("Instruction lines: %d\n",Lines->size());
725for (constLVLine *Line : *Lines)
726dbgs() <<format_decimal(++Index, 5) <<": "
727 <<hexValue(Line->getOffset()) <<", (" <<Line->getName()
728 <<")\n";
729 });
730
731if (Scope->getIsArtificial()) {
732// Add the instruction lines to their artificial scope.
733for (LVLine *Line : *Lines)
734 Scope->addElement(Line);
735 }else {
736 DebugLines->append(*Lines);
737 }
738Lines->clear();
739 }
740 }
741 }
742
743LVRange *ScopesWithRanges =getSectionRanges(SectionIndex);
744 ScopesWithRanges->startSearch();
745
746// Process collected lines.
747LVScope *Scope;
748for (LVLine *Line : *DebugLines) {
749// Using the current line address, get its associated lexical scope and
750// add the line information to it.
751 Scope = ScopesWithRanges->getEntry(Line->getAddress());
752if (!Scope) {
753// If missing scope, use the compile unit.
754 Scope =CompileUnit;
755LLVM_DEBUG({
756dbgs() <<"Adding line to CU: " <<hexValue(Line->getOffset()) <<", ("
757 << ((Line->getIsLineDebug())
758 ?Line->lineNumberAsStringStripped(/*ShowZero=*/true)
759 :Line->getName())
760 <<")\n";
761 });
762 }
763
764// Add line object to scope.
765 Scope->addElement(Line);
766
767// Report any line zero.
768if (options().getWarningLines() &&Line->getIsLineDebug() &&
769 !Line->getLineNumber())
770CompileUnit->addLineZero(Line);
771
772// Some compilers generate ranges in the compile unit; other compilers
773// only DW_AT_low_pc/DW_AT_high_pc. In order to correctly map global
774// variables, we need to generate the map ranges for the compile unit.
775// If we use the ranges stored at the scope level, there are cases where
776// the address referenced by a symbol location, is not in the enclosing
777// scope, but in an outer one. By using the ranges stored in the compile
778// unit, we can catch all those addresses.
779if (Line->getIsLineDebug())
780CompileUnit->addMapping(Line, SectionIndex);
781
782// Resolve any given pattern.
783patterns().resolvePatternMatch(Line);
784 }
785
786 ScopesWithRanges->endSearch();
787}
788
789voidLVBinaryReader::processLines(LVLines *DebugLines,
790LVSectionIndex SectionIndex) {
791assert(DebugLines &&"DebugLines is null.");
792if (DebugLines->empty() && !ScopeInstructions.findMap(SectionIndex))
793return;
794
795// If the Compile Unit does not contain comdat functions, use the whole
796// set of debug lines, as the addresses don't have conflicts.
797if (!CompileUnit->getHasComdatScopes()) {
798processLines(DebugLines, SectionIndex,nullptr);
799return;
800 }
801
802// Find the indexes for the lines whose address is zero.
803 std::vector<size_t> AddressZero;
804LVLines::iterator It =
805 std::find_if(std::begin(*DebugLines), std::end(*DebugLines),
806 [](LVLine *Line) {return !Line->getAddress(); });
807while (It != std::end(*DebugLines)) {
808 AddressZero.emplace_back(std::distance(std::begin(*DebugLines), It));
809 It = std::find_if(std::next(It), std::end(*DebugLines),
810 [](LVLine *Line) {return !Line->getAddress(); });
811 }
812
813// If the set of debug lines does not contain any line with address zero,
814// use the whole set. It means we are dealing with an initialization
815// section from a fully linked binary.
816if (AddressZero.empty()) {
817processLines(DebugLines, SectionIndex,nullptr);
818return;
819 }
820
821// The Compile unit contains comdat functions. Traverse the collected
822// debug lines and identify logical groups based on their start and
823// address. Each group starts with a zero address.
824// Begin, End, Address, IsDone.
825usingLVBucket = std::tuple<size_t, size_t, LVAddress, bool>;
826 std::vector<LVBucket> Buckets;
827
828LVAddressAddress;
829size_t Begin = 0;
830size_tEnd = 0;
831size_t Index = 0;
832for (Index = 0; Index < AddressZero.size() - 1; ++Index) {
833 Begin = AddressZero[Index];
834End = AddressZero[Index + 1] - 1;
835Address = (*DebugLines)[End]->getAddress();
836 Buckets.emplace_back(Begin,End,Address,false);
837 }
838
839// Add the last bucket.
840if (Index) {
841 Begin = AddressZero[Index];
842End = DebugLines->size() - 1;
843Address = (*DebugLines)[End]->getAddress();
844 Buckets.emplace_back(Begin,End,Address,false);
845 }
846
847LLVM_DEBUG({
848dbgs() <<"\nDebug Lines buckets: " << Buckets.size() <<"\n";
849for (LVBucket &Bucket : Buckets) {
850dbgs() <<"Begin: " <<format_decimal(std::get<0>(Bucket), 5) <<", "
851 <<"End: " <<format_decimal(std::get<1>(Bucket), 5) <<", "
852 <<"Address: " <<hexValue(std::get<2>(Bucket)) <<"\n";
853 }
854 });
855
856// Traverse the sections and buckets looking for matches on the section
857// sizes. In the unlikely event of different buckets with the same size
858// process them in order and mark them as done.
859LVLines Group;
860for (LVSections::reference Entry : Sections) {
861LVSectionIndex SectionIndex = Entry.first;
862constobject::SectionRef Section = Entry.second;
863uint64_tSize = Section.getSize();
864LLVM_DEBUG({
865dbgs() <<"\nSection Index: " <<format_decimal(SectionIndex, 3)
866 <<" , Section Size: " <<hexValue(Section.getSize())
867 <<" , Section Address: " <<hexValue(Section.getAddress())
868 <<"\n";
869 });
870
871for (LVBucket &Bucket : Buckets) {
872if (std::get<3>(Bucket))
873// Already done for previous section.
874continue;
875if (Size == std::get<2>(Bucket)) {
876// We have a match on the section size.
877 Group.clear();
878LVLines::iterator IterStart = DebugLines->begin() + std::get<0>(Bucket);
879LVLines::iterator IterEnd =
880 DebugLines->begin() + std::get<1>(Bucket) + 1;
881for (LVLines::iterator Iter = IterStart; Iter < IterEnd; ++Iter)
882 Group.push_back(*Iter);
883processLines(&Group, SectionIndex,/*Function=*/nullptr);
884 std::get<3>(Bucket) =true;
885break;
886 }
887 }
888 }
889}
890
891// Traverse the scopes for the given 'Function' looking for any inlined
892// scopes with inlined lines, which are found in 'CUInlineeLines'.
893voidLVBinaryReader::includeInlineeLines(LVSectionIndex SectionIndex,
894LVScope *Function) {
895SmallVector<LVInlineeLine::iterator> InlineeIters;
896 std::function<void(LVScope * Parent)> FindInlinedScopes =
897 [&](LVScope *Parent) {
898if (constLVScopes *Scopes = Parent->getScopes())
899for (LVScope *Scope : *Scopes) {
900 LVInlineeLine::iterator Iter = CUInlineeLines.find(Scope);
901if (Iter != CUInlineeLines.end())
902 InlineeIters.push_back(Iter);
903 FindInlinedScopes(Scope);
904 }
905 };
906
907// Find all inlined scopes for the given 'Function'.
908 FindInlinedScopes(Function);
909for (LVInlineeLine::iterator InlineeIter : InlineeIters) {
910LVScope *Scope = InlineeIter->first;
911addToSymbolTable(Scope->getLinkageName(), Scope, SectionIndex);
912
913// TODO: Convert this into a reference.
914LVLines *InlineeLines = InlineeIter->second.get();
915LLVM_DEBUG({
916dbgs() <<"Inlined lines for: " << Scope->getName() <<"\n";
917for (constLVLine *Line : *InlineeLines)
918dbgs() <<"[" <<hexValue(Line->getAddress()) <<"] "
919 <<Line->getLineNumber() <<"\n";
920dbgs() <<format("Debug lines: %d\n",CULines.size());
921for (constLVLine *Line :CULines)
922dbgs() <<"Line address: " <<hexValue(Line->getOffset()) <<", ("
923 <<Line->getLineNumber() <<")\n";
924 ;
925 });
926
927// The inlined lines must be merged using its address, in order to keep
928// the real order of the instructions. The inlined lines are mixed with
929// the other non-inlined lines.
930if (InlineeLines->size()) {
931// First address of inlinee code.
932uint64_t InlineeStart = (InlineeLines->front())->getAddress();
933LVLines::iterator Iter = std::find_if(
934CULines.begin(),CULines.end(), [&](LVLine *Item) ->bool {
935 return Item->getAddress() == InlineeStart;
936 });
937if (Iter !=CULines.end()) {
938// 'Iter' points to the line where the inlined function is called.
939// Emulate the DW_AT_call_line attribute.
940 Scope->setCallLineNumber((*Iter)->getLineNumber());
941// Mark the referenced line as the start of the inlined function.
942// Skip the first line during the insertion, as the address and
943// line number as the same. Otherwise we have to erase and insert.
944 (*Iter)->setLineNumber((*InlineeLines->begin())->getLineNumber());
945 ++Iter;
946CULines.insert(Iter,InlineeLines->begin() + 1,InlineeLines->end());
947 }
948 }
949
950// Remove this set of lines from the container; each inlined function
951// creates an unique set of lines. Remove only the created container.
952 CUInlineeLines.erase(InlineeIter);
953InlineeLines->clear();
954 }
955LLVM_DEBUG({
956dbgs() <<"Merged Inlined lines for: " <<Function->getName() <<"\n";
957dbgs() <<format("Debug lines: %d\n",CULines.size());
958for (constLVLine *Line :CULines)
959dbgs() <<"Line address: " <<hexValue(Line->getOffset()) <<", ("
960 <<Line->getLineNumber() <<")\n";
961 ;
962 });
963}
964
965voidLVBinaryReader::print(raw_ostream &OS) const{
966OS <<"LVBinaryReader\n";
967LLVM_DEBUG(dbgs() <<"PrintReader\n");
968}
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
End
bool End
Definition:ELF_riscv.cpp:480
Errc.h
FormatAdapters.h
FormatVariadic.h
LVBinaryReader.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
getAddress
const Value * getAddress(const DbgVariableIntrinsic *DVI)
Definition:SROA.cpp:5023
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
T
llvm::Annotations
Annotations lets you mark points and ranges inside source code, for tests:
Definition:Annotations.h:53
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::data
const T * data() const
Definition:ArrayRef.h:165
llvm::ErrorOr
Represents either an error or a value T.
Definition:ErrorOr.h:56
llvm::ErrorOr::get
reference get()
Definition:ErrorOr.h:149
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:Error.h:160
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition:Error.h:337
llvm::Expected
Tagged union holding either a T or a Error.
Definition:Error.h:481
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition:Error.h:608
llvm::Function
Definition:Function.h:63
llvm::Instruction
Definition:Instruction.h:68
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition:MCAsmInfo.h:56
llvm::MCAsmInfo::getAssemblerDialect
unsigned getAssemblerDialect() const
Definition:MCAsmInfo.h:567
llvm::MCDisassembler
Superclass for all disassemblers.
Definition:MCDisassembler.h:84
llvm::MCDisassembler::DecodeStatus
DecodeStatus
Ternary decode status.
Definition:MCDisassembler.h:108
llvm::MCDisassembler::Fail
@ Fail
Definition:MCDisassembler.h:109
llvm::MCDisassembler::SoftFail
@ SoftFail
Definition:MCDisassembler.h:110
llvm::MCDisassembler::Success
@ Success
Definition:MCDisassembler.h:111
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition:MCInstPrinter.h:46
llvm::MCInstPrinter::setPrintImmHex
void setPrintImmHex(bool Value)
Definition:MCInstPrinter.h:163
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition:MCInst.h:185
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition:MCInstrInfo.h:26
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition:MCRegisterInfo.h:149
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition:MCSubtargetInfo.h:76
llvm::MCTargetOptions
Definition:MCTargetOptions.h:39
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition:SmallVector.h:683
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition:SmallVector.h:805
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVector< LVLine *, 8 >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::trim
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
Definition:StringRef.h:815
llvm::Target
Target - Wrapper for Target specific information.
Definition:TargetRegistry.h:144
llvm::Target::createMCSubtargetInfo
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
Definition:TargetRegistry.h:441
llvm::Target::createMCRegInfo
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
Definition:TargetRegistry.h:426
llvm::Target::createMCDisassembler
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
Definition:TargetRegistry.h:497
llvm::Target::createMCAsmInfo
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
Definition:TargetRegistry.h:388
llvm::Target::createMCInstPrinter
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
Definition:TargetRegistry.h:504
llvm::Target::createMCInstrInfo
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Definition:TargetRegistry.h:410
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
llvm::codeview::Line
Definition:Line.h:90
llvm::dwarf_linker::classic::CompileUnit
Stores all information relating to a compile unit, be it in its original instance in the object file ...
Definition:DWARFLinkerCompileUnit.h:63
llvm::logicalview::LVBinaryReader::getSymbolTableEntry
const LVSymbolTableEntry & getSymbolTableEntry(StringRef Name)
Definition:LVBinaryReader.cpp:134
llvm::logicalview::LVBinaryReader::updateSymbolTable
LVSectionIndex updateSymbolTable(LVScope *Function)
Definition:LVBinaryReader.cpp:130
llvm::logicalview::LVBinaryReader::getSection
Expected< std::pair< LVSectionIndex, object::SectionRef > > getSection(LVScope *Scope, LVAddress Address, LVSectionIndex SectionIndex)
Definition:LVBinaryReader.cpp:339
llvm::logicalview::LVBinaryReader::MC
std::unique_ptr< MCContext > MC
Definition:LVBinaryReader.h:122
llvm::logicalview::LVBinaryReader::includeInlineeLines
void includeInlineeLines(LVSectionIndex SectionIndex, LVScope *Function)
Definition:LVBinaryReader.cpp:893
llvm::logicalview::LVBinaryReader::MII
std::unique_ptr< const MCInstrInfo > MII
Definition:LVBinaryReader.h:120
llvm::logicalview::LVBinaryReader::getSymbolTableAddress
LVAddress getSymbolTableAddress(StringRef Name)
Definition:LVBinaryReader.cpp:137
llvm::logicalview::LVBinaryReader::print
void print(raw_ostream &OS) const
Definition:LVBinaryReader.cpp:965
llvm::logicalview::LVBinaryReader::STI
std::unique_ptr< const MCSubtargetInfo > STI
Definition:LVBinaryReader.h:119
llvm::logicalview::LVBinaryReader::CULines
LVLines CULines
Definition:LVBinaryReader.h:115
llvm::logicalview::LVBinaryReader::addToSymbolTable
void addToSymbolTable(StringRef Name, LVScope *Function, LVSectionIndex SectionIndex=0)
Definition:LVBinaryReader.cpp:121
llvm::logicalview::LVBinaryReader::mapRangeAddress
virtual void mapRangeAddress(const object::ObjectFile &Obj)
Definition:LVBinaryReader.h:170
llvm::logicalview::LVBinaryReader::processLines
void processLines(LVLines *DebugLines, LVSectionIndex SectionIndex)
Definition:LVBinaryReader.cpp:789
llvm::logicalview::LVBinaryReader::mapVirtualAddress
void mapVirtualAddress(const object::ObjectFile &Obj)
Definition:LVBinaryReader.cpp:147
llvm::logicalview::LVBinaryReader::MAI
std::unique_ptr< const MCAsmInfo > MAI
Definition:LVBinaryReader.h:118
llvm::logicalview::LVBinaryReader::getSymbolTableIndex
LVSectionIndex getSymbolTableIndex(StringRef Name)
Definition:LVBinaryReader.cpp:140
llvm::logicalview::LVBinaryReader::getSymbolTableIsComdat
bool getSymbolTableIsComdat(StringRef Name)
Definition:LVBinaryReader.cpp:143
llvm::logicalview::LVBinaryReader::MRI
std::unique_ptr< const MCRegisterInfo > MRI
Definition:LVBinaryReader.h:117
llvm::logicalview::LVBinaryReader::MD
std::unique_ptr< const MCDisassembler > MD
Definition:LVBinaryReader.h:121
llvm::logicalview::LVBinaryReader::getSectionRanges
LVRange * getSectionRanges(LVSectionIndex SectionIndex)
Definition:LVBinaryReader.cpp:383
llvm::logicalview::LVBinaryReader::loadGenericTargetInfo
Error loadGenericTargetInfo(StringRef TheTriple, StringRef TheFeatures)
Definition:LVBinaryReader.cpp:277
llvm::logicalview::LVBinaryReader::addSectionRange
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope)
Definition:LVBinaryReader.cpp:370
llvm::logicalview::LVBinaryReader::createInstructions
Error createInstructions()
Definition:LVBinaryReader.cpp:541
llvm::logicalview::LVBinaryReader::MIP
std::unique_ptr< MCInstPrinter > MIP
Definition:LVBinaryReader.h:123
llvm::logicalview::LVBinaryReader::WasmCodeSectionOffset
LVAddress WasmCodeSectionOffset
Definition:LVBinaryReader.h:165
llvm::logicalview::LVLineAssembler
Definition:LVLine.h:143
llvm::logicalview::LVLine
Definition:LVLine.h:40
llvm::logicalview::LVPatterns::resolvePatternMatch
void resolvePatternMatch(LVLine *Line)
Definition:LVOptions.h:606
llvm::logicalview::LVRange
Definition:LVRange.h:49
llvm::logicalview::LVRange::getEntry
LVScope * getEntry(LVAddress Address) const
Definition:LVRange.cpp:83
llvm::logicalview::LVRange::startSearch
void startSearch()
Definition:LVRange.cpp:22
llvm::logicalview::LVRange::addEntry
void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress)
Definition:LVRange.cpp:52
llvm::logicalview::LVRange::endSearch
void endSearch()
Definition:LVRange.h:85
llvm::logicalview::LVReader::getDotTextSectionIndex
LVSectionIndex getDotTextSectionIndex() const
Definition:LVReader.h:270
llvm::logicalview::LVReader::CompileUnit
LVScopeCompileUnit * CompileUnit
Definition:LVReader.h:130
llvm::logicalview::LVReader::DotTextSectionIndex
LVSectionIndex DotTextSectionIndex
Definition:LVReader.h:133
llvm::logicalview::LVReader::OS
raw_ostream & OS
Definition:LVReader.h:129
llvm::logicalview::LVScope
Definition:LVScope.h:73
llvm::logicalview::LVScope::getScopes
const LVScopes * getScopes() const
Definition:LVScope.h:207
llvm::logicalview::LVSymbolTable::getIndex
LVSectionIndex getIndex(StringRef Name)
Definition:LVBinaryReader.cpp:97
llvm::logicalview::LVSymbolTable::getIsComdat
bool getIsComdat(StringRef Name)
Definition:LVBinaryReader.cpp:102
llvm::logicalview::LVSymbolTable::print
void print(raw_ostream &OS)
Definition:LVBinaryReader.cpp:107
llvm::logicalview::LVSymbolTable::getAddress
LVAddress getAddress(StringRef Name)
Definition:LVBinaryReader.cpp:93
llvm::logicalview::LVSymbolTable::add
void add(StringRef Name, LVScope *Function, LVSectionIndex SectionIndex=0)
Definition:LVBinaryReader.cpp:24
llvm::logicalview::LVSymbolTable::update
LVSectionIndex update(LVScope *Function)
Definition:LVBinaryReader.cpp:61
llvm::logicalview::LVSymbolTable::getEntry
const LVSymbolTableEntry & getEntry(StringRef Name)
Definition:LVBinaryReader.cpp:88
llvm::object::Binary::isWasm
bool isWasm() const
Definition:Binary.h:137
llvm::object::COFFObjectFile
Definition:COFF.h:879
llvm::object::COFFObjectFile::getImageBase
uint64_t getImageBase() const
Definition:COFFObjectFile.cpp:454
llvm::object::COFFObjectFile::getCOFFSection
const coff_section * getCOFFSection(const SectionRef &Section) const
Definition:COFFObjectFile.cpp:1350
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition:ObjectFile.h:229
llvm::object::ObjectFile::sections
section_iterator_range sections() const
Definition:ObjectFile.h:329
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition:ObjectFile.h:81
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition:raw_ostream.h:661
llvm::raw_string_ostream::str
std::string & str()
Returns the string's reference.
Definition:raw_ostream.h:679
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition:raw_ostream.h:691
uint32_t
uint64_t
uint8_t
UINT64_MAX
#define UINT64_MAX
Definition:DataTypes.h:77
llvm::COFF::IMAGE_SCN_CNT_CODE
@ IMAGE_SCN_CNT_CODE
Definition:COFF.h:302
llvm::COFF::IMAGE_SCN_LNK_COMDAT
@ IMAGE_SCN_LNK_COMDAT
Definition:COFF.h:308
llvm::codeview::DebugSubsectionKind::InlineeLines
@ InlineeLines
llvm::codeview::DebugSubsectionKind::Lines
@ Lines
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::logicalview
Definition:LVCompare.h:20
llvm::logicalview::hexValue
FormattedNumber hexValue(uint64_t N, unsigned Width=HEX_WIDTH, bool Upper=false)
Definition:LVSupport.h:103
llvm::logicalview::getReader
LVReader & getReader()
Definition:LVReader.h:333
llvm::logicalview::LVNameInfo
std::pair< LVAddress, uint64_t > LVNameInfo
Definition:LVScope.h:29
llvm::logicalview::patterns
LVPatterns & patterns()
Definition:LVOptions.h:642
llvm::logicalview::UndefinedSectionIndex
constexpr LVSectionIndex UndefinedSectionIndex
Definition:LVReader.h:28
llvm::logicalview::LVPrintKind::Instructions
@ Instructions
llvm::logicalview::LVCompareKind::Scopes
@ Scopes
llvm::logicalview::LVAttributeKind::Range
@ Range
llvm::logicalview::LVAttributeKind::Offset
@ Offset
llvm::logicalview::options
LVOptions & options()
Definition:LVOptions.h:445
llvm::logicalview::LVSortMode::Name
@ Name
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::format_decimal
FormattedNumber format_decimal(int64_t N, unsigned Width)
format_decimal - Output N as a right justified, fixed-width decimal.
Definition:Format.h:212
llvm::AlignStyle::Left
@ Left
llvm::outs
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Definition:raw_ostream.cpp:895
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition:Error.h:1291
llvm::errc::invalid_argument
@ invalid_argument
llvm::formatv
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
Definition:FormatVariadic.h:252
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::CaptureComponents::Address
@ Address
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition:Format.h:125
llvm::fmt_align
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
Definition:FormatAdapters.h:89
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition:Error.h:1069
llvm::format_bytes
FormattedBytes format_bytes(ArrayRef< uint8_t > Bytes, std::optional< uint64_t > FirstByteOffset=std::nullopt, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition:Format.h:241
llvm::TargetRegistry::lookupTarget
static const Target * lookupTarget(StringRef Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Definition:TargetRegistry.cpp:154
llvm::logicalview::LVSymbolTableEntry
Definition:LVBinaryReader.h:36
llvm::object::coff_section
Definition:COFF.h:448
llvm::object::coff_section::PointerToRawData
support::ulittle32_t PointerToRawData
Definition:COFF.h:453
llvm::object::coff_section::Characteristics
support::ulittle32_t Characteristics
Definition:COFF.h:458
llvm::object::coff_section::SizeOfRawData
support::ulittle32_t SizeOfRawData
Definition:COFF.h:452
llvm::object::coff_section::VirtualAddress
support::ulittle32_t VirtualAddress
Definition:COFF.h:451

Generated on Sun Jul 20 2025 09:13:32 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp