LLVM  6.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"
26 #include "llvm/Object/MachO.h"
28 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/Errc.h"
34 #include "llvm/Support/Path.h"
35 #include <algorithm>
36 #include <cassert>
37 #include <cstdlib>
38 #include <cstring>
39 
40 #if defined(_MSC_VER)
41 #include <Windows.h>
42 
43 // This must be included after windows.h.
44 #include <DbgHelp.h>
45 #pragma comment(lib, "dbghelp.lib")
46 
47 // Windows.h conflicts with our COFF header definitions.
48 #ifdef IMAGE_FILE_MACHINE_I386
49 #undef IMAGE_FILE_MACHINE_I386
50 #endif
51 #endif
52 
53 namespace llvm {
54 namespace symbolize {
55 
56 Expected<DILineInfo>
57 LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
58  uint64_t ModuleOffset, StringRef DWPName) {
59  SymbolizableModule *Info;
60  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
61  Info = InfoOrErr.get();
62  else
63  return InfoOrErr.takeError();
64 
65  // A null module means an error has already been reported. Return an empty
66  // result.
67  if (!Info)
68  return DILineInfo();
69 
70  // If the user is giving us relative addresses, add the preferred base of the
71  // object to the offset before we do the query. It's what DIContext expects.
72  if (Opts.RelativeAddresses)
73  ModuleOffset += Info->getModulePreferredBase();
74 
75  DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,
76  Opts.UseSymbolTable);
77  if (Opts.Demangle)
78  LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info);
79  return LineInfo;
80 }
81 
83 LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,
84  uint64_t ModuleOffset, StringRef DWPName) {
85  SymbolizableModule *Info;
86  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
87  Info = InfoOrErr.get();
88  else
89  return InfoOrErr.takeError();
90 
91  // A null module means an error has already been reported. Return an empty
92  // result.
93  if (!Info)
94  return DIInliningInfo();
95 
96  // If the user is giving us relative addresses, add the preferred base of the
97  // object to the offset before we do the query. It's what DIContext expects.
98  if (Opts.RelativeAddresses)
99  ModuleOffset += Info->getModulePreferredBase();
100 
101  DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(
102  ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);
103  if (Opts.Demangle) {
104  for (int i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {
105  auto *Frame = InlinedContext.getMutableFrame(i);
106  Frame->FunctionName = DemangleName(Frame->FunctionName, Info);
107  }
108  }
109  return InlinedContext;
110 }
111 
112 Expected<DIGlobal> LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
113  uint64_t ModuleOffset) {
114  SymbolizableModule *Info;
115  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
116  Info = InfoOrErr.get();
117  else
118  return InfoOrErr.takeError();
119 
120  // A null module means an error has already been reported. Return an empty
121  // result.
122  if (!Info)
123  return DIGlobal();
124 
125  // If the user is giving us relative addresses, add the preferred base of
126  // the object to the offset before we do the query. It's what DIContext
127  // expects.
128  if (Opts.RelativeAddresses)
129  ModuleOffset += Info->getModulePreferredBase();
130 
131  DIGlobal Global = Info->symbolizeData(ModuleOffset);
132  if (Opts.Demangle)
133  Global.Name = DemangleName(Global.Name, Info);
134  return Global;
135 }
136 
138  ObjectForUBPathAndArch.clear();
139  BinaryForPath.clear();
140  ObjectPairForPathArch.clear();
141  Modules.clear();
142 }
143 
144 namespace {
145 
146 // For Path="/path/to/foo" and Basename="foo" assume that debug info is in
147 // /path/to/foo.dSYM/Contents/Resources/DWARF/foo.
148 // For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in
149 // /path/to/bar.dSYM/Contents/Resources/DWARF/foo.
150 std::string getDarwinDWARFResourceForPath(
151  const std::string &Path, const std::string &Basename) {
152  SmallString<16> ResourceName = StringRef(Path);
153  if (sys::path::extension(Path) != ".dSYM") {
154  ResourceName += ".dSYM";
155  }
156  sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
157  sys::path::append(ResourceName, Basename);
158  return ResourceName.str();
159 }
160 
161 bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
164  if (!MB)
165  return false;
166  return !zlib::isAvailable() || CRCHash == zlib::crc32(MB.get()->getBuffer());
167 }
168 
169 bool findDebugBinary(const std::string &OrigPath,
170  const std::string &DebuglinkName, uint32_t CRCHash,
171  std::string &Result) {
172  std::string OrigRealPath = OrigPath;
173 #if defined(HAVE_REALPATH)
174  if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
175  OrigRealPath = RP;
176  free(RP);
177  }
178 #endif
179  SmallString<16> OrigDir(OrigRealPath);
181  SmallString<16> DebugPath = OrigDir;
182  // Try /path/to/original_binary/debuglink_name
183  llvm::sys::path::append(DebugPath, DebuglinkName);
184  if (checkFileCRC(DebugPath, CRCHash)) {
185  Result = DebugPath.str();
186  return true;
187  }
188  // Try /path/to/original_binary/.debug/debuglink_name
189  DebugPath = OrigRealPath;
190  llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
191  if (checkFileCRC(DebugPath, CRCHash)) {
192  Result = DebugPath.str();
193  return true;
194  }
195  // Try /usr/lib/debug/path/to/original_binary/debuglink_name
196  DebugPath = "/usr/lib/debug";
198  DebuglinkName);
199  if (checkFileCRC(DebugPath, CRCHash)) {
200  Result = DebugPath.str();
201  return true;
202  }
203  return false;
204 }
205 
206 bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
207  uint32_t &CRCHash) {
208  if (!Obj)
209  return false;
210  for (const SectionRef &Section : Obj->sections()) {
211  StringRef Name;
212  Section.getName(Name);
213  Name = Name.substr(Name.find_first_not_of("._"));
214  if (Name == "gnu_debuglink") {
215  StringRef Data;
216  Section.getContents(Data);
217  DataExtractor DE(Data, Obj->isLittleEndian(), 0);
218  uint32_t Offset = 0;
219  if (const char *DebugNameStr = DE.getCStr(&Offset)) {
220  // 4-byte align the offset.
221  Offset = (Offset + 3) & ~0x3;
222  if (DE.isValidOffsetForDataOfSize(Offset, 4)) {
223  DebugName = DebugNameStr;
224  CRCHash = DE.getU32(&Offset);
225  return true;
226  }
227  }
228  break;
229  }
230  }
231  return false;
232 }
233 
234 bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,
235  const MachOObjectFile *Obj) {
236  ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid();
237  ArrayRef<uint8_t> bin_uuid = Obj->getUuid();
238  if (dbg_uuid.empty() || bin_uuid.empty())
239  return false;
240  return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size());
241 }
242 
243 } // end anonymous namespace
244 
245 ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
246  const MachOObjectFile *MachExeObj, const std::string &ArchName) {
247  // On Darwin we may find DWARF in separate object file in
248  // resource directory.
249  std::vector<std::string> DsymPaths;
250  StringRef Filename = sys::path::filename(ExePath);
251  DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename));
252  for (const auto &Path : Opts.DsymHints) {
253  DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename));
254  }
255  for (const auto &Path : DsymPaths) {
256  auto DbgObjOrErr = getOrCreateObject(Path, ArchName);
257  if (!DbgObjOrErr) {
258  // Ignore errors, the file might not exist.
259  consumeError(DbgObjOrErr.takeError());
260  continue;
261  }
262  ObjectFile *DbgObj = DbgObjOrErr.get();
263  if (!DbgObj)
264  continue;
265  const MachOObjectFile *MachDbgObj = dyn_cast<const MachOObjectFile>(DbgObj);
266  if (!MachDbgObj)
267  continue;
268  if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj))
269  return DbgObj;
270  }
271  return nullptr;
272 }
273 
274 ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path,
275  const ObjectFile *Obj,
276  const std::string &ArchName) {
277  std::string DebuglinkName;
278  uint32_t CRCHash;
279  std::string DebugBinaryPath;
280  if (!getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash))
281  return nullptr;
282  if (!findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath))
283  return nullptr;
284  auto DbgObjOrErr = getOrCreateObject(DebugBinaryPath, ArchName);
285  if (!DbgObjOrErr) {
286  // Ignore errors, the file might not exist.
287  consumeError(DbgObjOrErr.takeError());
288  return nullptr;
289  }
290  return DbgObjOrErr.get();
291 }
292 
294 LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
295  const std::string &ArchName) {
296  const auto &I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName));
297  if (I != ObjectPairForPathArch.end()) {
298  return I->second;
299  }
300 
301  auto ObjOrErr = getOrCreateObject(Path, ArchName);
302  if (!ObjOrErr) {
303  ObjectPairForPathArch.insert(std::make_pair(std::make_pair(Path, ArchName),
304  ObjectPair(nullptr, nullptr)));
305  return ObjOrErr.takeError();
306  }
307 
308  ObjectFile *Obj = ObjOrErr.get();
309  assert(Obj != nullptr);
310  ObjectFile *DbgObj = nullptr;
311 
312  if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj))
313  DbgObj = lookUpDsymFile(Path, MachObj, ArchName);
314  if (!DbgObj)
315  DbgObj = lookUpDebuglinkObject(Path, Obj, ArchName);
316  if (!DbgObj)
317  DbgObj = Obj;
318  ObjectPair Res = std::make_pair(Obj, DbgObj);
319  ObjectPairForPathArch.insert(
320  std::make_pair(std::make_pair(Path, ArchName), Res));
321  return Res;
322 }
323 
325 LLVMSymbolizer::getOrCreateObject(const std::string &Path,
326  const std::string &ArchName) {
327  const auto &I = BinaryForPath.find(Path);
328  Binary *Bin = nullptr;
329  if (I == BinaryForPath.end()) {
331  if (!BinOrErr) {
332  BinaryForPath.insert(std::make_pair(Path, OwningBinary<Binary>()));
333  return BinOrErr.takeError();
334  }
335  Bin = BinOrErr->getBinary();
336  BinaryForPath.insert(std::make_pair(Path, std::move(BinOrErr.get())));
337  } else {
338  Bin = I->second.getBinary();
339  }
340 
341  if (!Bin)
342  return static_cast<ObjectFile *>(nullptr);
343 
344  if (MachOUniversalBinary *UB = dyn_cast_or_null<MachOUniversalBinary>(Bin)) {
345  const auto &I = ObjectForUBPathAndArch.find(std::make_pair(Path, ArchName));
346  if (I != ObjectForUBPathAndArch.end()) {
347  return I->second.get();
348  }
350  UB->getObjectForArch(ArchName);
351  if (!ObjOrErr) {
352  ObjectForUBPathAndArch.insert(std::make_pair(
353  std::make_pair(Path, ArchName), std::unique_ptr<ObjectFile>()));
354  return ObjOrErr.takeError();
355  }
356  ObjectFile *Res = ObjOrErr->get();
357  ObjectForUBPathAndArch.insert(std::make_pair(std::make_pair(Path, ArchName),
358  std::move(ObjOrErr.get())));
359  return Res;
360  }
361  if (Bin->isObject()) {
362  return cast<ObjectFile>(Bin);
363  }
364  return errorCodeToError(object_error::arch_not_found);
365 }
366 
368 LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName,
369  StringRef DWPName) {
370  const auto &I = Modules.find(ModuleName);
371  if (I != Modules.end()) {
372  return I->second.get();
373  }
374  std::string BinaryName = ModuleName;
375  std::string ArchName = Opts.DefaultArch;
376  size_t ColonPos = ModuleName.find_last_of(':');
377  // Verify that substring after colon form a valid arch name.
378  if (ColonPos != std::string::npos) {
379  std::string ArchStr = ModuleName.substr(ColonPos + 1);
380  if (Triple(ArchStr).getArch() != Triple::UnknownArch) {
381  BinaryName = ModuleName.substr(0, ColonPos);
382  ArchName = ArchStr;
383  }
384  }
385  auto ObjectsOrErr = getOrCreateObjectPair(BinaryName, ArchName);
386  if (!ObjectsOrErr) {
387  // Failed to find valid object file.
388  Modules.insert(
389  std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>()));
390  return ObjectsOrErr.takeError();
391  }
392  ObjectPair Objects = ObjectsOrErr.get();
393 
394  std::unique_ptr<DIContext> Context;
395  // If this is a COFF object containing PDB info, use a PDBContext to
396  // symbolize. Otherwise, use DWARF.
397  if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) {
398  const codeview::DebugInfo *DebugInfo;
399  StringRef PDBFileName;
400  auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName);
401  if (!EC && DebugInfo != nullptr && !PDBFileName.empty()) {
402  using namespace pdb;
403  std::unique_ptr<IPDBSession> Session;
404  if (auto Err = loadDataForEXE(PDB_ReaderType::DIA,
405  Objects.first->getFileName(), Session)) {
406  Modules.insert(
407  std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>()));
408  return std::move(Err);
409  }
410  Context.reset(new PDBContext(*CoffObject, std::move(Session)));
411  }
412  }
413  if (!Context)
414  Context = DWARFContext::create(*Objects.second, nullptr,
416  assert(Context);
417  auto InfoOrErr =
418  SymbolizableObjectFile::create(Objects.first, std::move(Context));
419  std::unique_ptr<SymbolizableModule> SymMod;
420  if (InfoOrErr)
421  SymMod = std::move(InfoOrErr.get());
422  auto InsertResult =
423  Modules.insert(std::make_pair(ModuleName, std::move(SymMod)));
424  assert(InsertResult.second);
425  if (auto EC = InfoOrErr.getError())
426  return errorCodeToError(EC);
427  return InsertResult.first->second.get();
428 }
429 
430 namespace {
431 
432 // Undo these various manglings for Win32 extern "C" functions:
433 // cdecl - _foo
434 // stdcall - _foo@12
435 // fastcall - @foo@12
436 // vectorcall - foo@@12
437 // These are all different linkage names for 'foo'.
438 StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
439  // Remove any '_' or '@' prefix.
440  char Front = SymbolName.empty() ? '\0' : SymbolName[0];
441  if (Front == '_' || Front == '@')
442  SymbolName = SymbolName.drop_front();
443 
444  // Remove any '@[0-9]+' suffix.
445  if (Front != '?') {
446  size_t AtPos = SymbolName.rfind('@');
447  if (AtPos != StringRef::npos &&
448  std::all_of(SymbolName.begin() + AtPos + 1, SymbolName.end(),
449  [](char C) { return C >= '0' && C <= '9'; })) {
450  SymbolName = SymbolName.substr(0, AtPos);
451  }
452  }
453 
454  // Remove any ending '@' for vectorcall.
455  if (SymbolName.endswith("@"))
456  SymbolName = SymbolName.drop_back();
457 
458  return SymbolName;
459 }
460 
461 } // end anonymous namespace
462 
463 #if !defined(_MSC_VER)
464 // Assume that __cxa_demangle is provided by libcxxabi (except for Windows).
465 extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
466  size_t *length, int *status);
467 #endif
468 
469 std::string
471  const SymbolizableModule *DbiModuleDescriptor) {
472 #if !defined(_MSC_VER)
473  // We can spoil names of symbols with C linkage, so use an heuristic
474  // approach to check if the name should be demangled.
475  if (Name.substr(0, 2) == "_Z") {
476  int status = 0;
477  char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status);
478  if (status != 0)
479  return Name;
480  std::string Result = DemangledName;
481  free(DemangledName);
482  return Result;
483  }
484 #else
485  if (!Name.empty() && Name.front() == '?') {
486  // Only do MSVC C++ demangling on symbols starting with '?'.
487  char DemangledName[1024] = {0};
488  DWORD result = ::UnDecorateSymbolName(
489  Name.c_str(), DemangledName, 1023,
490  UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
491  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc
492  UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
493  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers
494  UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords
495  UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types
496  return (result == 0) ? Name : std::string(DemangledName);
497  }
498 #endif
499  if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module())
500  return std::string(demanglePE32ExternCFunc(Name));
501  return Name;
502 }
503 
504 } // namespace symbolize
505 } // 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:484
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:189
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:813
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:465
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:273
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:265
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:57
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:470
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:649
static const size_t npos
Definition: StringRef.h:51
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:575
#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:83
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
Definition: Path.cpp:422
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:112
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:80
StringRef extension(StringRef path, Style style=Style::native)
Get extension.
Definition: Path.cpp:590