LLVM  7.0.0svn
Symbolize.cpp
Go to the documentation of this file.
1 //===-- LLVMSymbolize.cpp -------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Implementation for LLVM symbolization library.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 
16 #include "SymbolizableObjectFile.h"
17 
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/BinaryFormat/COFF.h"
20 #include "llvm/Config/config.h"
22 #include "llvm/DebugInfo/PDB/PDB.h"
24 #include "llvm/Object/COFF.h"
25 #include "llvm/Object/MachO.h"
27 #include "llvm/Support/Casting.h"
30 #include "llvm/Support/Errc.h"
33 #include "llvm/Support/Path.h"
34 #include <algorithm>
35 #include <cassert>
36 #include <cstdlib>
37 #include <cstring>
38 
39 #if defined(_MSC_VER)
40 #include <Windows.h>
41 
42 // This must be included after windows.h.
43 #include <DbgHelp.h>
44 #pragma comment(lib, "dbghelp.lib")
45 
46 // Windows.h conflicts with our COFF header definitions.
47 #ifdef IMAGE_FILE_MACHINE_I386
48 #undef IMAGE_FILE_MACHINE_I386
49 #endif
50 #endif
51 
52 namespace llvm {
53 namespace symbolize {
54 
55 Expected<DILineInfo>
56 LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
57  uint64_t ModuleOffset, StringRef DWPName) {
58  SymbolizableModule *Info;
59  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
60  Info = InfoOrErr.get();
61  else
62  return InfoOrErr.takeError();
63 
64  // A null module means an error has already been reported. Return an empty
65  // result.
66  if (!Info)
67  return DILineInfo();
68 
69  // If the user is giving us relative addresses, add the preferred base of the
70  // object to the offset before we do the query. It's what DIContext expects.
71  if (Opts.RelativeAddresses)
72  ModuleOffset += Info->getModulePreferredBase();
73 
74  DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,
75  Opts.UseSymbolTable);
76  if (Opts.Demangle)
77  LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info);
78  return LineInfo;
79 }
80 
82 LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,
83  uint64_t ModuleOffset, StringRef DWPName) {
84  SymbolizableModule *Info;
85  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
86  Info = InfoOrErr.get();
87  else
88  return InfoOrErr.takeError();
89 
90  // A null module means an error has already been reported. Return an empty
91  // result.
92  if (!Info)
93  return DIInliningInfo();
94 
95  // If the user is giving us relative addresses, add the preferred base of the
96  // object to the offset before we do the query. It's what DIContext expects.
97  if (Opts.RelativeAddresses)
98  ModuleOffset += Info->getModulePreferredBase();
99 
100  DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(
101  ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);
102  if (Opts.Demangle) {
103  for (int i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {
104  auto *Frame = InlinedContext.getMutableFrame(i);
105  Frame->FunctionName = DemangleName(Frame->FunctionName, Info);
106  }
107  }
108  return InlinedContext;
109 }
110 
111 Expected<DIGlobal> LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
112  uint64_t ModuleOffset) {
113  SymbolizableModule *Info;
114  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
115  Info = InfoOrErr.get();
116  else
117  return InfoOrErr.takeError();
118 
119  // A null module means an error has already been reported. Return an empty
120  // result.
121  if (!Info)
122  return DIGlobal();
123 
124  // If the user is giving us relative addresses, add the preferred base of
125  // the object to the offset before we do the query. It's what DIContext
126  // expects.
127  if (Opts.RelativeAddresses)
128  ModuleOffset += Info->getModulePreferredBase();
129 
130  DIGlobal Global = Info->symbolizeData(ModuleOffset);
131  if (Opts.Demangle)
132  Global.Name = DemangleName(Global.Name, Info);
133  return Global;
134 }
135 
137  ObjectForUBPathAndArch.clear();
138  BinaryForPath.clear();
139  ObjectPairForPathArch.clear();
140  Modules.clear();
141 }
142 
143 namespace {
144 
145 // For Path="/path/to/foo" and Basename="foo" assume that debug info is in
146 // /path/to/foo.dSYM/Contents/Resources/DWARF/foo.
147 // For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in
148 // /path/to/bar.dSYM/Contents/Resources/DWARF/foo.
149 std::string getDarwinDWARFResourceForPath(
150  const std::string &Path, const std::string &Basename) {
151  SmallString<16> ResourceName = StringRef(Path);
152  if (sys::path::extension(Path) != ".dSYM") {
153  ResourceName += ".dSYM";
154  }
155  sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
156  sys::path::append(ResourceName, Basename);
157  return ResourceName.str();
158 }
159 
160 bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
163  if (!MB)
164  return false;
165  return !zlib::isAvailable() || CRCHash == zlib::crc32(MB.get()->getBuffer());
166 }
167 
168 bool findDebugBinary(const std::string &OrigPath,
169  const std::string &DebuglinkName, uint32_t CRCHash,
170  std::string &Result) {
171  std::string OrigRealPath = OrigPath;
172 #if defined(HAVE_REALPATH)
173  if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
174  OrigRealPath = RP;
175  free(RP);
176  }
177 #endif
178  SmallString<16> OrigDir(OrigRealPath);
180  SmallString<16> DebugPath = OrigDir;
181  // Try /path/to/original_binary/debuglink_name
182  llvm::sys::path::append(DebugPath, DebuglinkName);
183  if (checkFileCRC(DebugPath, CRCHash)) {
184  Result = DebugPath.str();
185  return true;
186  }
187  // Try /path/to/original_binary/.debug/debuglink_name
188  DebugPath = OrigRealPath;
189  llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
190  if (checkFileCRC(DebugPath, CRCHash)) {
191  Result = DebugPath.str();
192  return true;
193  }
194  // Try /usr/lib/debug/path/to/original_binary/debuglink_name
195  DebugPath = "/usr/lib/debug";
197  DebuglinkName);
198  if (checkFileCRC(DebugPath, CRCHash)) {
199  Result = DebugPath.str();
200  return true;
201  }
202  return false;
203 }
204 
205 bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
206  uint32_t &CRCHash) {
207  if (!Obj)
208  return false;
209  for (const SectionRef &Section : Obj->sections()) {
210  StringRef Name;
211  Section.getName(Name);
212  Name = Name.substr(Name.find_first_not_of("._"));
213  if (Name == "gnu_debuglink") {
214  StringRef Data;
215  Section.getContents(Data);
216  DataExtractor DE(Data, Obj->isLittleEndian(), 0);
217  uint32_t Offset = 0;
218  if (const char *DebugNameStr = DE.getCStr(&Offset)) {
219  // 4-byte align the offset.
220  Offset = (Offset + 3) & ~0x3;
221  if (DE.isValidOffsetForDataOfSize(Offset, 4)) {
222  DebugName = DebugNameStr;
223  CRCHash = DE.getU32(&Offset);
224  return true;
225  }
226  }
227  break;
228  }
229  }
230  return false;
231 }
232 
233 bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,
234  const MachOObjectFile *Obj) {
235  ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid();
236  ArrayRef<uint8_t> bin_uuid = Obj->getUuid();
237  if (dbg_uuid.empty() || bin_uuid.empty())
238  return false;
239  return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size());
240 }
241 
242 } // end anonymous namespace
243 
244 ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
245  const MachOObjectFile *MachExeObj, const std::string &ArchName) {
246  // On Darwin we may find DWARF in separate object file in
247  // resource directory.
248  std::vector<std::string> DsymPaths;
249  StringRef Filename = sys::path::filename(ExePath);
250  DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename));
251  for (const auto &Path : Opts.DsymHints) {
252  DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename));
253  }
254  for (const auto &Path : DsymPaths) {
255  auto DbgObjOrErr = getOrCreateObject(Path, ArchName);
256  if (!DbgObjOrErr) {
257  // Ignore errors, the file might not exist.
258  consumeError(DbgObjOrErr.takeError());
259  continue;
260  }
261  ObjectFile *DbgObj = DbgObjOrErr.get();
262  if (!DbgObj)
263  continue;
264  const MachOObjectFile *MachDbgObj = dyn_cast<const MachOObjectFile>(DbgObj);
265  if (!MachDbgObj)
266  continue;
267  if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj))
268  return DbgObj;
269  }
270  return nullptr;
271 }
272 
273 ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path,
274  const ObjectFile *Obj,
275  const std::string &ArchName) {
276  std::string DebuglinkName;
277  uint32_t CRCHash;
278  std::string DebugBinaryPath;
279  if (!getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash))
280  return nullptr;
281  if (!findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath))
282  return nullptr;
283  auto DbgObjOrErr = getOrCreateObject(DebugBinaryPath, ArchName);
284  if (!DbgObjOrErr) {
285  // Ignore errors, the file might not exist.
286  consumeError(DbgObjOrErr.takeError());
287  return nullptr;
288  }
289  return DbgObjOrErr.get();
290 }
291 
293 LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
294  const std::string &ArchName) {
295  const auto &I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName));
296  if (I != ObjectPairForPathArch.end()) {
297  return I->second;
298  }
299 
300  auto ObjOrErr = getOrCreateObject(Path, ArchName);
301  if (!ObjOrErr) {
302  ObjectPairForPathArch.insert(std::make_pair(std::make_pair(Path, ArchName),
303  ObjectPair(nullptr, nullptr)));
304  return ObjOrErr.takeError();
305  }
306 
307  ObjectFile *Obj = ObjOrErr.get();
308  assert(Obj != nullptr);
309  ObjectFile *DbgObj = nullptr;
310 
311  if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj))
312  DbgObj = lookUpDsymFile(Path, MachObj, ArchName);
313  if (!DbgObj)
314  DbgObj = lookUpDebuglinkObject(Path, Obj, ArchName);
315  if (!DbgObj)
316  DbgObj = Obj;
317  ObjectPair Res = std::make_pair(Obj, DbgObj);
318  ObjectPairForPathArch.insert(
319  std::make_pair(std::make_pair(Path, ArchName), Res));
320  return Res;
321 }
322 
324 LLVMSymbolizer::getOrCreateObject(const std::string &Path,
325  const std::string &ArchName) {
326  const auto &I = BinaryForPath.find(Path);
327  Binary *Bin = nullptr;
328  if (I == BinaryForPath.end()) {
330  if (!BinOrErr) {
331  BinaryForPath.insert(std::make_pair(Path, OwningBinary<Binary>()));
332  return BinOrErr.takeError();
333  }
334  Bin = BinOrErr->getBinary();
335  BinaryForPath.insert(std::make_pair(Path, std::move(BinOrErr.get())));
336  } else {
337  Bin = I->second.getBinary();
338  }
339 
340  if (!Bin)
341  return static_cast<ObjectFile *>(nullptr);
342 
343  if (MachOUniversalBinary *UB = dyn_cast_or_null<MachOUniversalBinary>(Bin)) {
344  const auto &I = ObjectForUBPathAndArch.find(std::make_pair(Path, ArchName));
345  if (I != ObjectForUBPathAndArch.end()) {
346  return I->second.get();
347  }
349  UB->getObjectForArch(ArchName);
350  if (!ObjOrErr) {
351  ObjectForUBPathAndArch.insert(std::make_pair(
352  std::make_pair(Path, ArchName), std::unique_ptr<ObjectFile>()));
353  return ObjOrErr.takeError();
354  }
355  ObjectFile *Res = ObjOrErr->get();
356  ObjectForUBPathAndArch.insert(std::make_pair(std::make_pair(Path, ArchName),
357  std::move(ObjOrErr.get())));
358  return Res;
359  }
360  if (Bin->isObject()) {
361  return cast<ObjectFile>(Bin);
362  }
363  return errorCodeToError(object_error::arch_not_found);
364 }
365 
367 LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName,
368  StringRef DWPName) {
369  const auto &I = Modules.find(ModuleName);
370  if (I != Modules.end()) {
371  return I->second.get();
372  }
373  std::string BinaryName = ModuleName;
374  std::string ArchName = Opts.DefaultArch;
375  size_t ColonPos = ModuleName.find_last_of(':');
376  // Verify that substring after colon form a valid arch name.
377  if (ColonPos != std::string::npos) {
378  std::string ArchStr = ModuleName.substr(ColonPos + 1);
379  if (Triple(ArchStr).getArch() != Triple::UnknownArch) {
380  BinaryName = ModuleName.substr(0, ColonPos);
381  ArchName = ArchStr;
382  }
383  }
384  auto ObjectsOrErr = getOrCreateObjectPair(BinaryName, ArchName);
385  if (!ObjectsOrErr) {
386  // Failed to find valid object file.
387  Modules.insert(
388  std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>()));
389  return ObjectsOrErr.takeError();
390  }
391  ObjectPair Objects = ObjectsOrErr.get();
392 
393  std::unique_ptr<DIContext> Context;
394  // If this is a COFF object containing PDB info, use a PDBContext to
395  // symbolize. Otherwise, use DWARF.
396  if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) {
397  const codeview::DebugInfo *DebugInfo;
398  StringRef PDBFileName;
399  auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName);
400  if (!EC && DebugInfo != nullptr && !PDBFileName.empty()) {
401  using namespace pdb;
402  std::unique_ptr<IPDBSession> Session;
403  if (auto Err = loadDataForEXE(PDB_ReaderType::DIA,
404  Objects.first->getFileName(), Session)) {
405  Modules.insert(
406  std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>()));
407  return std::move(Err);
408  }
409  Context.reset(new PDBContext(*CoffObject, std::move(Session)));
410  }
411  }
412  if (!Context)
413  Context = DWARFContext::create(*Objects.second, nullptr,
415  assert(Context);
416  auto InfoOrErr =
417  SymbolizableObjectFile::create(Objects.first, std::move(Context));
418  std::unique_ptr<SymbolizableModule> SymMod;
419  if (InfoOrErr)
420  SymMod = std::move(InfoOrErr.get());
421  auto InsertResult =
422  Modules.insert(std::make_pair(ModuleName, std::move(SymMod)));
423  assert(InsertResult.second);
424  if (auto EC = InfoOrErr.getError())
425  return errorCodeToError(EC);
426  return InsertResult.first->second.get();
427 }
428 
429 namespace {
430 
431 // Undo these various manglings for Win32 extern "C" functions:
432 // cdecl - _foo
433 // stdcall - _foo@12
434 // fastcall - @foo@12
435 // vectorcall - foo@@12
436 // These are all different linkage names for 'foo'.
437 StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
438  // Remove any '_' or '@' prefix.
439  char Front = SymbolName.empty() ? '\0' : SymbolName[0];
440  if (Front == '_' || Front == '@')
441  SymbolName = SymbolName.drop_front();
442 
443  // Remove any '@[0-9]+' suffix.
444  if (Front != '?') {
445  size_t AtPos = SymbolName.rfind('@');
446  if (AtPos != StringRef::npos &&
447  std::all_of(SymbolName.begin() + AtPos + 1, SymbolName.end(),
448  [](char C) { return C >= '0' && C <= '9'; })) {
449  SymbolName = SymbolName.substr(0, AtPos);
450  }
451  }
452 
453  // Remove any ending '@' for vectorcall.
454  if (SymbolName.endswith("@"))
455  SymbolName = SymbolName.drop_back();
456 
457  return SymbolName;
458 }
459 
460 } // end anonymous namespace
461 
462 #if !defined(_MSC_VER)
463 // Assume that __cxa_demangle is provided by libcxxabi (except for Windows).
464 extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
465  size_t *length, int *status);
466 #endif
467 
468 std::string
470  const SymbolizableModule *DbiModuleDescriptor) {
471 #if !defined(_MSC_VER)
472  // We can spoil names of symbols with C linkage, so use an heuristic
473  // approach to check if the name should be demangled.
474  if (Name.substr(0, 2) == "_Z") {
475  int status = 0;
476  char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status);
477  if (status != 0)
478  return Name;
479  std::string Result = DemangledName;
480  free(DemangledName);
481  return Result;
482  }
483 #else
484  if (!Name.empty() && Name.front() == '?') {
485  // Only do MSVC C++ demangling on symbols starting with '?'.
486  char DemangledName[1024] = {0};
487  DWORD result = ::UnDecorateSymbolName(
488  Name.c_str(), DemangledName, 1023,
489  UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
490  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc
491  UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
492  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers
493  UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords
494  UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types
495  return (result == 0) ? Name : std::string(DemangledName);
496  }
497 #endif
498  if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module())
499  return std::string(demanglePE32ExternCFunc(Name));
500  return Name;
501 }
502 
503 } // namespace symbolize
504 } // namespace llvm
uint64_t CallInst * C
Represents either an error or a value T.
Definition: ErrorOr.h:69
void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
Definition: Path.cpp:485
DILineInfo * getMutableFrame(unsigned Index)
Definition: DIContext.h:88
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
Definition: StringRef.h:360
virtual DIGlobal symbolizeData(uint64_t ModuleOffset) const =0
This class is the base class for all object file types.
Definition: ObjectFile.h:190
virtual DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const =0
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:814
Error takeError()
Take ownership of the stored error.
Definition: Error.h:537
virtual bool isWin32Module() const =0
A format-neutral container for source line information.
Definition: DIContext.h:31
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr)
Create a Binary from Source, autodetecting the file type.
Definition: Binary.cpp:45
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:279
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:466
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:267
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
section_iterator_range sections() const
Definition: ObjectFile.h:274
uint32_t getNumberOfFrames() const
Definition: DIContext.h:93
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:598
bool isAvailable()
Definition: Compression.cpp:58
Error loadDataForEXE(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
Definition: PDB.cpp:44
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
virtual DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const =0
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:78
A format-neutral container for inlined code description.
Definition: DIContext.h:77
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
Definition: StringRef.cpp:250
std::vector< std::string > DsymHints
Definition: Symbolize.h:44
static ErrorPolicy defaultErrorHandler(Error E)
Function used to handle default error reporting policy.
Expected< DILineInfo > symbolizeCode(const std::string &ModuleName, uint64_t ModuleOffset, StringRef DWPName="")
Definition: Symbolize.cpp:56
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:962
bool isLittleEndian() const
Definition: Binary.h:131
const T * data() const
Definition: ArrayRef.h:146
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back(size_t N=1) const
Return a StringRef equal to &#39;this&#39; but with the last N elements dropped.
Definition: StringRef.h:654
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, const LoadedObjectInfo *L=nullptr, function_ref< ErrorPolicy(Error)> HandleError=defaultErrorHandler, std::string DWPName="")
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to &#39;this&#39; but with the first N elements dropped.
Definition: StringRef.h:645
static std::string DemangleName(const std::string &Name, const SymbolizableModule *DbiModuleDescriptor)
Definition: Symbolize.cpp:469
ArrayRef< uint8_t > getUuid() const
std::string Name
Definition: DIContext.h:104
char * __cxa_demangle(const char *mangled_name, char *output_buffer, size_t *length, int *status)
std::string FunctionName
Definition: DIContext.h:33
reference get()
Returns a reference to the stored T value.
Definition: Error.h:517
bool isObject() const
Definition: Binary.h:95
uint32_t crc32(StringRef Buffer)
Definition: Compression.cpp:97
iterator begin() const
Definition: StringRef.h:106
virtual uint64_t getModulePreferredBase() const =0
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:652
static const size_t npos
Definition: StringRef.h:51
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:576
#define I(x, y, z)
Definition: MD5.cpp:58
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Expected< DIInliningInfo > symbolizeInlinedCode(const std::string &ModuleName, uint64_t ModuleOffset, StringRef DWPName="")
Definition: Symbolize.cpp:82
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
Definition: Path.cpp:423
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static ErrorOr< std::unique_ptr< SymbolizableObjectFile > > create(object::ObjectFile *Obj, std::unique_ptr< DIContext > DICtx)
iterator end() const
Definition: StringRef.h:108
Expected< DIGlobal > symbolizeData(const std::string &ModuleName, uint64_t ModuleOffset)
Definition: Symbolize.cpp:111
reference get()
Definition: ErrorOr.h:169
Container for description of a global variable.
Definition: DIContext.h:103
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:144
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:81
StringRef extension(StringRef path, Style style=Style::native)
Get extension.
Definition: Path.cpp:591