23#define DEBUG_TYPE "Reader"
27 std::function<void(
LVScope * Parent)> TraverseScope = [&](
LVScope *Parent) {
29 auto Print = [&](
const auto &Set) {
31 for (
const auto &Entry : *Set)
32 Entry->printCommon(
dbgs());
36 Element->print(
dbgs());
45 dbgs() <<
"\n** Collected logical elements **\n";
54 using LVDuplicateEntry = std::tuple<LVElement *, LVScope *, LVScope *>;
55 using LVDuplicate = std::vector<LVDuplicateEntry>;
56 LVDuplicate Duplicate;
58 using LVIntegrity = std::map<LVElement *, LVScope *>;
63 LVIntegrity::iterator Iter =
Integrity.find(Element);
68 Duplicate.emplace_back(Element, Scope, Iter->second);
72 std::function<void(
LVScope * Parent)> TraverseScope = [&](
LVScope *Parent) {
73 auto Traverse = [&](
const auto *Set) {
75 for (
const auto &Entry : *Set)
76 AddElement(Entry, Parent);
79 for (
LVScope *Scope : *Scopes) {
80 AddElement(Scope, Parent);
94 bool PassIntegrity =
true;
95 if (Duplicate.size()) {
97 return std::get<0>(l)->getID() < std::get<0>(r)->getID();
100 auto PrintIndex = [](
unsigned Index) {
106 auto PrintElement = [&](
LVElement *Element,
unsigned Index = 0) {
108 std::string ElementName(Element->
getName());
110 Element->
getID(), ElementName);
113 std::string RootName(
Root->getName());
115 dbgs() <<
formatv(
"Root: '{0}'\nDuplicated elements: {1}\n", RootName,
120 for (
const LVDuplicateEntry &Entry : Duplicate) {
124 std::tie(Element,
First, Second) = Entry;
126 PrintElement(Element, ++Index);
128 PrintElement(Second);
131 PassIntegrity =
false;
133 return PassIntegrity;
143 Location = std::string(Where);
146 size_t Pos = Location.find_last_of(
'/');
147 if (Location.length() != Pos + 1)
148 Location.append(
"/");
160 assert(OutputFile ==
nullptr &&
"OutputFile already set.");
164 Name.append(Extension);
166 if (!Location.empty())
167 Name.insert(0, Location);
176 return std::error_code();
183 outs() <<
"Invalid instance reader.\n";
188Error LVReader::createSplitFolder() {
192 if (
options().getOutputFolder().empty())
196 SplitFolder =
options().getOutputFolder();
203 OS <<
"\nSplit View Location: '" << SplitContext.
getLocation() <<
"'\n";
214 if (CompileUnits.size()) {
216 LVCompileUnits::const_iterator Iter =
217 std::prev(CompileUnits.lower_bound(Object->getOffset()));
218 if (Iter != CompileUnits.end())
219 return Iter->second->getFilename(Index);
233 ScopesWithRanges->
addEntry(Scope, LowerAddress, UpperAddress);
238 LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
239 if (IterSection == SectionRanges.end())
241 SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
256 if (!
options().getPrintSymbols()) {
261 case dwarf::DW_TAG_formal_parameter:
262 case dwarf::DW_TAG_unspecified_parameters:
263 case dwarf::DW_TAG_member:
264 case dwarf::DW_TAG_variable:
265 case dwarf::DW_TAG_inheritance:
266 case dwarf::DW_TAG_constant:
267 case dwarf::DW_TAG_call_site_parameter:
268 case dwarf::DW_TAG_GNU_call_site_parameter:
277 case dwarf::DW_TAG_base_type:
280 if (
options().getAttributeBase())
283 case dwarf::DW_TAG_const_type:
288 case dwarf::DW_TAG_enumerator:
291 case dwarf::DW_TAG_imported_declaration:
295 case dwarf::DW_TAG_imported_module:
299 case dwarf::DW_TAG_pointer_type:
304 case dwarf::DW_TAG_ptr_to_member_type:
309 case dwarf::DW_TAG_reference_type:
314 case dwarf::DW_TAG_restrict_type:
319 case dwarf::DW_TAG_rvalue_reference_type:
324 case dwarf::DW_TAG_subrange_type:
327 case dwarf::DW_TAG_template_value_parameter:
331 case dwarf::DW_TAG_template_type_parameter:
335 case dwarf::DW_TAG_GNU_template_template_param:
339 case dwarf::DW_TAG_typedef:
342 case dwarf::DW_TAG_unspecified_type:
346 case dwarf::DW_TAG_volatile_type:
353 case dwarf::DW_TAG_formal_parameter:
357 case dwarf::DW_TAG_unspecified_parameters:
362 case dwarf::DW_TAG_member:
366 case dwarf::DW_TAG_variable:
370 case dwarf::DW_TAG_inheritance:
374 case dwarf::DW_TAG_call_site_parameter:
375 case dwarf::DW_TAG_GNU_call_site_parameter:
379 case dwarf::DW_TAG_constant:
385 case dwarf::DW_TAG_catch_block:
389 case dwarf::DW_TAG_lexical_block:
393 case dwarf::DW_TAG_try_block:
397 case dwarf::DW_TAG_compile_unit:
398 case dwarf::DW_TAG_skeleton_unit:
402 case dwarf::DW_TAG_inlined_subroutine:
405 case dwarf::DW_TAG_namespace:
408 case dwarf::DW_TAG_template_alias:
411 case dwarf::DW_TAG_array_type:
414 case dwarf::DW_TAG_call_site:
415 case dwarf::DW_TAG_GNU_call_site:
419 case dwarf::DW_TAG_entry_point:
423 case dwarf::DW_TAG_subprogram:
427 case dwarf::DW_TAG_subroutine_type:
430 case dwarf::DW_TAG_label:
434 case dwarf::DW_TAG_class_type:
438 case dwarf::DW_TAG_structure_type:
442 case dwarf::DW_TAG_union_type:
446 case dwarf::DW_TAG_enumeration_type:
449 case dwarf::DW_TAG_GNU_formal_parameter_pack:
452 case dwarf::DW_TAG_GNU_template_parameter_pack:
455 case dwarf::DW_TAG_module:
517 Root->processRangeInformation();
522 Root->resolveElements();
534 if (
options().getReportExecute()) {
540 if (
options().getReportChildren() && !
options().getReportParents())
557 if (
Error Err = createSplitFolder())
561 bool DoMatch =
options().getSelectGenericPattern() ||
562 options().getSelectGenericKind() ||
563 options().getSelectOffsetPattern();
564 return Root->doPrint(OutputSplit, DoMatch, DoPrint,
OS);
571 if (
Error Err = createSplitFolder())
574 return Root->doPrintMatches(OutputSplit,
OS, UseMatchedElements);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
static LVReader * CurrentReader
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Represent a constant reference to a string, i.e.
StringRef getName() const override
virtual const char * kind() const
LLVM_ABI void addGenericPatterns(StringSet<> &Patterns)
LLVM_ABI void updateReportOptions()
LLVM_ABI void addOffsetPatterns(const LVOffsetSet &Patterns)
void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress)
The logical reader owns of all the logical elements created during the debug information parsing.
virtual void sortScopes()
LVRange * getSectionRanges(LVSectionIndex SectionIndex)
void print(raw_ostream &OS) const
std::vector< LVAddressRange > CurrentRanges
LVElement * createElement(dwarf::Tag Tag)
void printCollectedElements(LVScope *Root)
StringRef getFilename() const
static LVReader & getInstance()
LVScopeCompileUnit * CompileUnit
static void setInstance(LVReader *Reader)
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope)
virtual Error printMatchedElements(bool UseMatchedElements)
bool checkIntegrityScopesTree(LVScope *Root)
virtual Error printScopes()
virtual Error createScopes()
const LVLines * getLines() const
const LVScopes * getScopes() const
LVElementsView getChildren() const
const LVSymbols * getSymbols() const
const LVTypes * getTypes() const
const LVLocations * getRanges() const
std::string getLocation() const
LLVM_ABI Error createSplitFolder(StringRef Where)
LLVM_ABI std::error_code open(std::string Name, std::string Extension, raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef TagString(unsigned Tag)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SmallVector< LVScope *, 8 > LVScopes
LLVM_ABI std::string flattenedFilePath(StringRef Path)
LLVM_ABI std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
LLVM_ABI std::error_code make_absolute(SmallVectorImpl< char > &path)
Make path an absolute path.
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
support::detail::RepeatAdapter< T > fmt_repeat(T &&Item, size_t Count)