23#define DEBUG_TYPE "Reader"
29 using LVDuplicateEntry = std::tuple<LVElement *, LVScope *, LVScope *>;
30 using LVDuplicate = std::vector<LVDuplicateEntry>;
31 LVDuplicate Duplicate;
33 using LVIntegrity = std::map<LVElement *, LVScope *>;
38 LVIntegrity::iterator Iter =
Integrity.find(Element);
43 Duplicate.emplace_back(Element, Scope, Iter->second);
47 std::function<void(
LVScope * Parent)> TraverseScope = [&](
LVScope *Parent) {
48 auto Traverse = [&](
const auto *Set) {
50 for (
const auto &Entry : *Set)
51 AddElement(Entry, Parent);
55 AddElement(Scope, Parent);
66 bool PassIntegrity =
true;
67 if (Duplicate.size()) {
69 return std::get<0>(l)->getID() < std::get<0>(r)->getID();
72 auto PrintIndex = [](
unsigned Index) {
78 auto PrintElement = [&](
LVElement *Element,
unsigned Index = 0) {
80 std::string ElementName(Element->
getName());
82 Element->
getID(), ElementName.c_str());
85 std::string RootName(Root->
getName());
87 dbgs() <<
format(
"Root: '%s'\nDuplicated elements: %d\n", RootName.c_str(),
92 for (
const LVDuplicateEntry &Entry : Duplicate) {
96 std::tie(Element,
First, Second) = Entry;
98 PrintElement(Element, ++Index);
100 PrintElement(Second);
103 PassIntegrity =
false;
105 return PassIntegrity;
115 Location = std::string(Where);
118 size_t Pos = Location.find_last_of(
'/');
119 if (Location.length() != Pos + 1)
120 Location.append(
"/");
132 assert(OutputFile ==
nullptr &&
"OutputFile already set.");
136 Name.append(Extension);
138 if (!Location.empty())
139 Name.insert(0, Location);
148 return std::error_code();
155 outs() <<
"Invalid instance reader.\n";
160Error LVReader::createSplitFolder() {
164 if (
options().getOutputFolder().empty())
168 SplitFolder =
options().getOutputFolder();
175 OS <<
"\nSplit View Location: '" << SplitContext.
getLocation() <<
"'\n";
186 if (CompileUnits.size()) {
188 LVCompileUnits::const_iterator Iter =
189 std::prev(CompileUnits.lower_bound(Object->getOffset()));
190 if (Iter != CompileUnits.end())
191 return Iter->second->getFilename(Index);
205 ScopesWithRanges->
addEntry(Scope, LowerAddress, UpperAddress);
210 LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
211 if (IterSection == SectionRanges.end())
213 SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
228 if (!
options().getPrintSymbols()) {
233 case dwarf::DW_TAG_formal_parameter:
234 case dwarf::DW_TAG_unspecified_parameters:
235 case dwarf::DW_TAG_member:
236 case dwarf::DW_TAG_variable:
237 case dwarf::DW_TAG_inheritance:
238 case dwarf::DW_TAG_constant:
239 case dwarf::DW_TAG_call_site_parameter:
240 case dwarf::DW_TAG_GNU_call_site_parameter:
249 case dwarf::DW_TAG_base_type:
252 if (
options().getAttributeBase())
255 case dwarf::DW_TAG_const_type:
260 case dwarf::DW_TAG_enumerator:
263 case dwarf::DW_TAG_imported_declaration:
267 case dwarf::DW_TAG_imported_module:
271 case dwarf::DW_TAG_pointer_type:
276 case dwarf::DW_TAG_ptr_to_member_type:
281 case dwarf::DW_TAG_reference_type:
286 case dwarf::DW_TAG_restrict_type:
291 case dwarf::DW_TAG_rvalue_reference_type:
296 case dwarf::DW_TAG_subrange_type:
299 case dwarf::DW_TAG_template_value_parameter:
303 case dwarf::DW_TAG_template_type_parameter:
307 case dwarf::DW_TAG_GNU_template_template_param:
311 case dwarf::DW_TAG_typedef:
314 case dwarf::DW_TAG_unspecified_type:
318 case dwarf::DW_TAG_volatile_type:
325 case dwarf::DW_TAG_formal_parameter:
329 case dwarf::DW_TAG_unspecified_parameters:
334 case dwarf::DW_TAG_member:
338 case dwarf::DW_TAG_variable:
342 case dwarf::DW_TAG_inheritance:
346 case dwarf::DW_TAG_call_site_parameter:
347 case dwarf::DW_TAG_GNU_call_site_parameter:
351 case dwarf::DW_TAG_constant:
357 case dwarf::DW_TAG_catch_block:
361 case dwarf::DW_TAG_lexical_block:
365 case dwarf::DW_TAG_try_block:
369 case dwarf::DW_TAG_compile_unit:
370 case dwarf::DW_TAG_skeleton_unit:
374 case dwarf::DW_TAG_inlined_subroutine:
377 case dwarf::DW_TAG_namespace:
380 case dwarf::DW_TAG_template_alias:
383 case dwarf::DW_TAG_array_type:
386 case dwarf::DW_TAG_call_site:
387 case dwarf::DW_TAG_GNU_call_site:
391 case dwarf::DW_TAG_entry_point:
395 case dwarf::DW_TAG_subprogram:
399 case dwarf::DW_TAG_subroutine_type:
402 case dwarf::DW_TAG_label:
406 case dwarf::DW_TAG_class_type:
410 case dwarf::DW_TAG_structure_type:
414 case dwarf::DW_TAG_union_type:
418 case dwarf::DW_TAG_enumeration_type:
421 case dwarf::DW_TAG_GNU_formal_parameter_pack:
424 case dwarf::DW_TAG_GNU_template_parameter_pack:
427 case dwarf::DW_TAG_module:
485 return llvm::make_error<StringError>(
"Duplicated elements in Scopes Tree",
506 if (
options().getReportExecute()) {
512 if (
options().getReportChildren() && !
options().getReportParents())
529 if (
Error Err = createSplitFolder())
533 bool DoMatch =
options().getSelectGenericPattern() ||
534 options().getSelectGenericKind() ||
535 options().getSelectOffsetPattern();
543 if (
Error Err = createSplitFolder())
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
bool checkIntegrityScopesTree(LVScope *Root)
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...
StringRef - Represent a constant reference to a string, i.e.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
void setName(StringRef ElementName) override
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)
StringRef getFilename() const
static LVReader & getInstance()
static void setInstance(LVReader *Reader)
void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope)
virtual Error printMatchedElements(bool UseMatchedElements)
virtual Error printScopes()
virtual Error createScopes()
void processRangeInformation()
Error doPrintMatches(bool Split, raw_ostream &OS, bool UseMatchedElements) const
const LVLines * getLines() const
const LVScopes * getScopes() const
const LVSymbols * getSymbols() const
const LVTypes * getTypes() const
Error doPrint(bool Split, bool Match, bool Print, raw_ostream &OS, bool Full=true) const override
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.
LLVM_ABI std::string flattenedFilePath(StringRef Path)
LLVM_ABI void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute 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.
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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
support::detail::RepeatAdapter< T > fmt_repeat(T &&Item, size_t Count)