27 auto findBuildID = [&Obj](
const auto &ShdrOrPhdr,
28 uint64_t Alignment) -> std::optional<BuildIDRef> {
30 for (
auto N : Obj.
notes(ShdrOrPhdr, Err))
33 return N.getDesc(Alignment);
39 for (
const auto &S : Sections) {
42 if (std::optional<BuildIDRef> ShdrRes = findBuildID(S, S.sh_addralign))
43 return ShdrRes.value();
50 for (
const auto &
P : *PhdrsOrErr) {
53 if (std::optional<BuildIDRef> PhdrRes = findBuildID(
P,
P.p_align))
54 return PhdrRes.value();
72 return ::getBuildID(O->getELFFile());
74 return ::getBuildID(O->getELFFile());
76 return ::getBuildID(O->getELFFile());
78 return ::getBuildID(O->getELFFile());
83 auto GetDebugPath = [&](
StringRef Directory) {
91 if (DebugFileDirectories.empty()) {
93#
if defined(__NetBSD__)
102 return std::string(Path);
104 for (
const auto &Directory : DebugFileDirectories) {
108 return std::string(Path);
This file declares a library for handling Build IDs and using them to find debug info.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
virtual std::optional< std::string > fetch(BuildIDRef BuildID) const
Returns the path to the debug file with the given build ID.
iterator_range< Elf_Note_Iterator > notes(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator range over notes of a program header.
Expected< Elf_Phdr_Range > program_headers() const
Iterate over program header table.
Expected< Elf_Shdr_Range > sections() const
This class is the base class for all object file types.
constexpr const char * ELF_NOTE_GNU
SmallVector< uint8_t, 10 > BuildID
A build ID in binary form.
LLVM_ABI BuildIDRef getBuildID(const ObjectFile *Obj)
Returns the build ID, if any, contained in the given object file.
LLVM_ABI BuildID parseBuildID(StringRef Str)
Parses a build ID from a hex string.
ArrayRef< uint8_t > BuildIDRef
A reference to a BuildID in binary form.
LLVM_ABI bool exists(const basic_file_status &status)
Does file exist?
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool tryGetFromHex(StringRef Input, std::string &Output)
Convert hexadecimal string Input to its binary representation and store the result in Output....
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
void consumeError(Error Err)
Consume a Error without doing anything.