LLVM  9.0.0svn
Symbolize.cpp
Go to the documentation of this file.
1 //===-- LLVMSymbolize.cpp -------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implementation for LLVM symbolization library.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 
15 #include "SymbolizableObjectFile.h"
16 
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/BinaryFormat/COFF.h"
20 #include "llvm/DebugInfo/PDB/PDB.h"
22 #include "llvm/Demangle/Demangle.h"
23 #include "llvm/Object/COFF.h"
24 #include "llvm/Object/MachO.h"
26 #include "llvm/Support/CRC.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 <cstring>
37 
38 #if defined(_MSC_VER)
39 #include <Windows.h>
40 
41 // This must be included after windows.h.
42 #include <DbgHelp.h>
43 #pragma comment(lib, "dbghelp.lib")
44 
45 // Windows.h conflicts with our COFF header definitions.
46 #ifdef IMAGE_FILE_MACHINE_I386
47 #undef IMAGE_FILE_MACHINE_I386
48 #endif
49 #endif
50 
51 namespace llvm {
52 namespace symbolize {
53 
54 Expected<DILineInfo>
55 LLVMSymbolizer::symbolizeCodeCommon(SymbolizableModule *Info,
56  object::SectionedAddress ModuleOffset) {
57  // A null module means an error has already been reported. Return an empty
58  // result.
59  if (!Info)
60  return DILineInfo();
61 
62  // If the user is giving us relative addresses, add the preferred base of the
63  // object to the offset before we do the query. It's what DIContext expects.
64  if (Opts.RelativeAddresses)
65  ModuleOffset.Address += Info->getModulePreferredBase();
66 
67  DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,
68  Opts.UseSymbolTable);
69  if (Opts.Demangle)
70  LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info);
71  return LineInfo;
72 }
73 
74 Expected<DILineInfo>
76  object::SectionedAddress ModuleOffset) {
77  StringRef ModuleName = Obj.getFileName();
78  auto I = Modules.find(ModuleName);
79  if (I != Modules.end())
80  return symbolizeCodeCommon(I->second.get(), ModuleOffset);
81 
82  std::unique_ptr<DIContext> Context =
85  createModuleInfo(&Obj, std::move(Context), ModuleName);
86  if (!InfoOrErr)
87  return InfoOrErr.takeError();
88  return symbolizeCodeCommon(*InfoOrErr, ModuleOffset);
89 }
90 
92 LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
93  object::SectionedAddress ModuleOffset) {
94  Expected<SymbolizableModule *> InfoOrErr = getOrCreateModuleInfo(ModuleName);
95  if (!InfoOrErr)
96  return InfoOrErr.takeError();
97  return symbolizeCodeCommon(*InfoOrErr, ModuleOffset);
98 }
99 
101 LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,
102  object::SectionedAddress ModuleOffset) {
104  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
105  Info = InfoOrErr.get();
106  else
107  return InfoOrErr.takeError();
108 
109  // A null module means an error has already been reported. Return an empty
110  // result.
111  if (!Info)
112  return DIInliningInfo();
113 
114  // If the user is giving us relative addresses, add the preferred base of the
115  // object to the offset before we do the query. It's what DIContext expects.
116  if (Opts.RelativeAddresses)
117  ModuleOffset.Address += Info->getModulePreferredBase();
118 
119  DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(
120  ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);
121  if (Opts.Demangle) {
122  for (int i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {
123  auto *Frame = InlinedContext.getMutableFrame(i);
124  Frame->FunctionName = DemangleName(Frame->FunctionName, Info);
125  }
126  }
127  return InlinedContext;
128 }
129 
131 LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
132  object::SectionedAddress ModuleOffset) {
134  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
135  Info = InfoOrErr.get();
136  else
137  return InfoOrErr.takeError();
138 
139  // A null module means an error has already been reported. Return an empty
140  // result.
141  if (!Info)
142  return DIGlobal();
143 
144  // If the user is giving us relative addresses, add the preferred base of
145  // the object to the offset before we do the query. It's what DIContext
146  // expects.
147  if (Opts.RelativeAddresses)
148  ModuleOffset.Address += Info->getModulePreferredBase();
149 
150  DIGlobal Global = Info->symbolizeData(ModuleOffset);
151  if (Opts.Demangle)
152  Global.Name = DemangleName(Global.Name, Info);
153  return Global;
154 }
155 
157 LLVMSymbolizer::symbolizeFrame(const std::string &ModuleName,
158  object::SectionedAddress ModuleOffset) {
160  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
161  Info = InfoOrErr.get();
162  else
163  return InfoOrErr.takeError();
164 
165  // A null module means an error has already been reported. Return an empty
166  // result.
167  if (!Info)
168  return std::vector<DILocal>();
169 
170  // If the user is giving us relative addresses, add the preferred base of
171  // the object to the offset before we do the query. It's what DIContext
172  // expects.
173  if (Opts.RelativeAddresses)
174  ModuleOffset.Address += Info->getModulePreferredBase();
175 
176  return Info->symbolizeFrame(ModuleOffset);
177 }
178 
180  ObjectForUBPathAndArch.clear();
181  BinaryForPath.clear();
182  ObjectPairForPathArch.clear();
183  Modules.clear();
184 }
185 
186 namespace {
187 
188 // For Path="/path/to/foo" and Basename="foo" assume that debug info is in
189 // /path/to/foo.dSYM/Contents/Resources/DWARF/foo.
190 // For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in
191 // /path/to/bar.dSYM/Contents/Resources/DWARF/foo.
192 std::string getDarwinDWARFResourceForPath(
193  const std::string &Path, const std::string &Basename) {
194  SmallString<16> ResourceName = StringRef(Path);
195  if (sys::path::extension(Path) != ".dSYM") {
196  ResourceName += ".dSYM";
197  }
198  sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
199  sys::path::append(ResourceName, Basename);
200  return ResourceName.str();
201 }
202 
203 bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
206  if (!MB)
207  return false;
208  return CRCHash == llvm::crc32(0, MB.get()->getBuffer());
209 }
210 
211 bool findDebugBinary(const std::string &OrigPath,
212  const std::string &DebuglinkName, uint32_t CRCHash,
213  const std::string &FallbackDebugPath,
214  std::string &Result) {
215  SmallString<16> OrigDir(OrigPath);
217  SmallString<16> DebugPath = OrigDir;
218  // Try relative/path/to/original_binary/debuglink_name
219  llvm::sys::path::append(DebugPath, DebuglinkName);
220  if (checkFileCRC(DebugPath, CRCHash)) {
221  Result = DebugPath.str();
222  return true;
223  }
224  // Try relative/path/to/original_binary/.debug/debuglink_name
225  DebugPath = OrigDir;
226  llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
227  if (checkFileCRC(DebugPath, CRCHash)) {
228  Result = DebugPath.str();
229  return true;
230  }
231  // Make the path absolute so that lookups will go to
232  // "/usr/lib/debug/full/path/to/debug", not
233  // "/usr/lib/debug/to/debug"
235  if (!FallbackDebugPath.empty()) {
236  // Try <FallbackDebugPath>/absolute/path/to/original_binary/debuglink_name
237  DebugPath = FallbackDebugPath;
238  } else {
239 #if defined(__NetBSD__)
240  // Try /usr/libdata/debug/absolute/path/to/original_binary/debuglink_name
241  DebugPath = "/usr/libdata/debug";
242 #else
243  // Try /usr/lib/debug/absolute/path/to/original_binary/debuglink_name
244  DebugPath = "/usr/lib/debug";
245 #endif
246  }
248  DebuglinkName);
249  if (checkFileCRC(DebugPath, CRCHash)) {
250  Result = DebugPath.str();
251  return true;
252  }
253  return false;
254 }
255 
256 bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
257  uint32_t &CRCHash) {
258  if (!Obj)
259  return false;
260  for (const SectionRef &Section : Obj->sections()) {
261  StringRef Name;
262  Section.getName(Name);
263  Name = Name.substr(Name.find_first_not_of("._"));
264  if (Name == "gnu_debuglink") {
265  Expected<StringRef> ContentsOrErr = Section.getContents();
266  if (!ContentsOrErr) {
267  consumeError(ContentsOrErr.takeError());
268  return false;
269  }
270  DataExtractor DE(*ContentsOrErr, Obj->isLittleEndian(), 0);
271  uint32_t Offset = 0;
272  if (const char *DebugNameStr = DE.getCStr(&Offset)) {
273  // 4-byte align the offset.
274  Offset = (Offset + 3) & ~0x3;
275  if (DE.isValidOffsetForDataOfSize(Offset, 4)) {
276  DebugName = DebugNameStr;
277  CRCHash = DE.getU32(&Offset);
278  return true;
279  }
280  }
281  break;
282  }
283  }
284  return false;
285 }
286 
287 bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,
288  const MachOObjectFile *Obj) {
289  ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid();
290  ArrayRef<uint8_t> bin_uuid = Obj->getUuid();
291  if (dbg_uuid.empty() || bin_uuid.empty())
292  return false;
293  return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size());
294 }
295 
296 } // end anonymous namespace
297 
298 ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
299  const MachOObjectFile *MachExeObj, const std::string &ArchName) {
300  // On Darwin we may find DWARF in separate object file in
301  // resource directory.
302  std::vector<std::string> DsymPaths;
303  StringRef Filename = sys::path::filename(ExePath);
304  DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename));
305  for (const auto &Path : Opts.DsymHints) {
306  DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename));
307  }
308  for (const auto &Path : DsymPaths) {
309  auto DbgObjOrErr = getOrCreateObject(Path, ArchName);
310  if (!DbgObjOrErr) {
311  // Ignore errors, the file might not exist.
312  consumeError(DbgObjOrErr.takeError());
313  continue;
314  }
315  ObjectFile *DbgObj = DbgObjOrErr.get();
316  if (!DbgObj)
317  continue;
318  const MachOObjectFile *MachDbgObj = dyn_cast<const MachOObjectFile>(DbgObj);
319  if (!MachDbgObj)
320  continue;
321  if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj))
322  return DbgObj;
323  }
324  return nullptr;
325 }
326 
327 ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path,
328  const ObjectFile *Obj,
329  const std::string &ArchName) {
330  std::string DebuglinkName;
331  uint32_t CRCHash;
332  std::string DebugBinaryPath;
333  if (!getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash))
334  return nullptr;
335  if (!findDebugBinary(Path, DebuglinkName, CRCHash, Opts.FallbackDebugPath,
336  DebugBinaryPath))
337  return nullptr;
338  auto DbgObjOrErr = getOrCreateObject(DebugBinaryPath, ArchName);
339  if (!DbgObjOrErr) {
340  // Ignore errors, the file might not exist.
341  consumeError(DbgObjOrErr.takeError());
342  return nullptr;
343  }
344  return DbgObjOrErr.get();
345 }
346 
348 LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
349  const std::string &ArchName) {
350  auto I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName));
351  if (I != ObjectPairForPathArch.end())
352  return I->second;
353 
354  auto ObjOrErr = getOrCreateObject(Path, ArchName);
355  if (!ObjOrErr) {
356  ObjectPairForPathArch.emplace(std::make_pair(Path, ArchName),
357  ObjectPair(nullptr, nullptr));
358  return ObjOrErr.takeError();
359  }
360 
361  ObjectFile *Obj = ObjOrErr.get();
362  assert(Obj != nullptr);
363  ObjectFile *DbgObj = nullptr;
364 
365  if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj))
366  DbgObj = lookUpDsymFile(Path, MachObj, ArchName);
367  if (!DbgObj)
368  DbgObj = lookUpDebuglinkObject(Path, Obj, ArchName);
369  if (!DbgObj)
370  DbgObj = Obj;
371  ObjectPair Res = std::make_pair(Obj, DbgObj);
372  ObjectPairForPathArch.emplace(std::make_pair(Path, ArchName), Res);
373  return Res;
374 }
375 
377 LLVMSymbolizer::getOrCreateObject(const std::string &Path,
378  const std::string &ArchName) {
379  Binary *Bin;
380  auto Pair = BinaryForPath.emplace(Path, OwningBinary<Binary>());
381  if (!Pair.second) {
382  Bin = Pair.first->second.getBinary();
383  } else {
385  if (!BinOrErr)
386  return BinOrErr.takeError();
387  Pair.first->second = std::move(BinOrErr.get());
388  Bin = Pair.first->second.getBinary();
389  }
390 
391  if (!Bin)
392  return static_cast<ObjectFile *>(nullptr);
393 
394  if (MachOUniversalBinary *UB = dyn_cast_or_null<MachOUniversalBinary>(Bin)) {
395  auto I = ObjectForUBPathAndArch.find(std::make_pair(Path, ArchName));
396  if (I != ObjectForUBPathAndArch.end())
397  return I->second.get();
398 
400  UB->getObjectForArch(ArchName);
401  if (!ObjOrErr) {
402  ObjectForUBPathAndArch.emplace(std::make_pair(Path, ArchName),
403  std::unique_ptr<ObjectFile>());
404  return ObjOrErr.takeError();
405  }
406  ObjectFile *Res = ObjOrErr->get();
407  ObjectForUBPathAndArch.emplace(std::make_pair(Path, ArchName),
408  std::move(ObjOrErr.get()));
409  return Res;
410  }
411  if (Bin->isObject()) {
412  return cast<ObjectFile>(Bin);
413  }
414  return errorCodeToError(object_error::arch_not_found);
415 }
416 
418 LLVMSymbolizer::createModuleInfo(const ObjectFile *Obj,
419  std::unique_ptr<DIContext> Context,
420  StringRef ModuleName) {
421  auto InfoOrErr =
422  SymbolizableObjectFile::create(Obj, std::move(Context));
423  std::unique_ptr<SymbolizableModule> SymMod;
424  if (InfoOrErr)
425  SymMod = std::move(*InfoOrErr);
426  auto InsertResult =
427  Modules.insert(std::make_pair(ModuleName, std::move(SymMod)));
428  assert(InsertResult.second);
429  if (std::error_code EC = InfoOrErr.getError())
430  return errorCodeToError(EC);
431  return InsertResult.first->second.get();
432 }
433 
435 LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
436  auto I = Modules.find(ModuleName);
437  if (I != Modules.end())
438  return I->second.get();
439 
440  std::string BinaryName = ModuleName;
441  std::string ArchName = Opts.DefaultArch;
442  size_t ColonPos = ModuleName.find_last_of(':');
443  // Verify that substring after colon form a valid arch name.
444  if (ColonPos != std::string::npos) {
445  std::string ArchStr = ModuleName.substr(ColonPos + 1);
446  if (Triple(ArchStr).getArch() != Triple::UnknownArch) {
447  BinaryName = ModuleName.substr(0, ColonPos);
448  ArchName = ArchStr;
449  }
450  }
451  auto ObjectsOrErr = getOrCreateObjectPair(BinaryName, ArchName);
452  if (!ObjectsOrErr) {
453  // Failed to find valid object file.
454  Modules.emplace(ModuleName, std::unique_ptr<SymbolizableModule>());
455  return ObjectsOrErr.takeError();
456  }
457  ObjectPair Objects = ObjectsOrErr.get();
458 
459  std::unique_ptr<DIContext> Context;
460  // If this is a COFF object containing PDB info, use a PDBContext to
461  // symbolize. Otherwise, use DWARF.
462  if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) {
463  const codeview::DebugInfo *DebugInfo;
464  StringRef PDBFileName;
465  auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName);
466  if (!EC && DebugInfo != nullptr && !PDBFileName.empty()) {
467  using namespace pdb;
468  std::unique_ptr<IPDBSession> Session;
469  if (auto Err = loadDataForEXE(PDB_ReaderType::DIA,
470  Objects.first->getFileName(), Session)) {
471  Modules.emplace(ModuleName, std::unique_ptr<SymbolizableModule>());
472  // Return along the PDB filename to provide more context
473  return createFileError(PDBFileName, std::move(Err));
474  }
475  Context.reset(new PDBContext(*CoffObject, std::move(Session)));
476  }
477  }
478  if (!Context)
479  Context =
480  DWARFContext::create(*Objects.second, nullptr,
481  DWARFContext::defaultErrorHandler, Opts.DWPName);
482  return createModuleInfo(Objects.first, std::move(Context), ModuleName);
483 }
484 
485 namespace {
486 
487 // Undo these various manglings for Win32 extern "C" functions:
488 // cdecl - _foo
489 // stdcall - _foo@12
490 // fastcall - @foo@12
491 // vectorcall - foo@@12
492 // These are all different linkage names for 'foo'.
493 StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
494  // Remove any '_' or '@' prefix.
495  char Front = SymbolName.empty() ? '\0' : SymbolName[0];
496  if (Front == '_' || Front == '@')
497  SymbolName = SymbolName.drop_front();
498 
499  // Remove any '@[0-9]+' suffix.
500  if (Front != '?') {
501  size_t AtPos = SymbolName.rfind('@');
502  if (AtPos != StringRef::npos &&
503  std::all_of(SymbolName.begin() + AtPos + 1, SymbolName.end(),
504  [](char C) { return C >= '0' && C <= '9'; })) {
505  SymbolName = SymbolName.substr(0, AtPos);
506  }
507  }
508 
509  // Remove any ending '@' for vectorcall.
510  if (SymbolName.endswith("@"))
511  SymbolName = SymbolName.drop_back();
512 
513  return SymbolName;
514 }
515 
516 } // end anonymous namespace
517 
518 std::string
520  const SymbolizableModule *DbiModuleDescriptor) {
521  // We can spoil names of symbols with C linkage, so use an heuristic
522  // approach to check if the name should be demangled.
523  if (Name.substr(0, 2) == "_Z") {
524  int status = 0;
525  char *DemangledName = itaniumDemangle(Name.c_str(), nullptr, nullptr, &status);
526  if (status != 0)
527  return Name;
528  std::string Result = DemangledName;
529  free(DemangledName);
530  return Result;
531  }
532 
533 #if defined(_MSC_VER)
534  if (!Name.empty() && Name.front() == '?') {
535  // Only do MSVC C++ demangling on symbols starting with '?'.
536  char DemangledName[1024] = {0};
537  DWORD result = ::UnDecorateSymbolName(
538  Name.c_str(), DemangledName, 1023,
539  UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
540  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc
541  UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
542  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers
543  UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords
544  UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types
545  return (result == 0) ? Name : std::string(DemangledName);
546  }
547 #endif
548  if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module())
549  return std::string(demanglePE32ExternCFunc(Name));
550  return Name;
551 }
552 
553 } // namespace symbolize
554 } // namespace llvm
uint64_t CallInst * C
Represents either an error or a value T.
Definition: ErrorOr.h:56
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:474
DILineInfo * getMutableFrame(unsigned Index)
Definition: DIContext.h:88
char * itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
LLVMContext & Context
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:267
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static ErrorOr< std::unique_ptr< SymbolizableObjectFile > > create(const object::ObjectFile *Obj, std::unique_ptr< DIContext > DICtx)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
StringRef getFileName() const
Definition: Binary.cpp:41
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
Definition: StringRef.h:345
Expected< DILineInfo > symbolizeCode(const ObjectFile &Obj, object::SectionedAddress ModuleOffset)
Definition: Symbolize.cpp:75
This class is the base class for all object file types.
Definition: ObjectFile.h:226
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:1192
Error takeError()
Take ownership of the stored error.
Definition: Error.h:552
virtual bool isWin32Module() const =0
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr)
Create a Binary from Source, autodetecting the file type.
Definition: Binary.cpp:45
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:455
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
LLVM_NODISCARD 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:620
void make_absolute(const Twine &current_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
Definition: Path.cpp:853
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
Expected< DIGlobal > symbolizeData(const std::string &ModuleName, object::SectionedAddress ModuleOffset)
Definition: Symbolize.cpp:131
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:578
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:126
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:266
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:25
section_iterator_range sections() const
Definition: ObjectFile.h:315
uint32_t getNumberOfFrames() const
Definition: DIContext.h:93
Analysis containing CSE Info
Definition: CSEInfo.cpp:20
Error loadDataForEXE(PDB_ReaderType Type, StringRef Path, std::unique_ptr< IPDBSession > &Session)
Definition: PDB.cpp:43
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:148
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
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:249
std::vector< std::string > DsymHints
Definition: Symbolize.h:43
static ErrorPolicy defaultErrorHandler(Error E)
Function used to handle default error reporting policy.
Expected< std::vector< DILocal > > symbolizeFrame(const std::string &ModuleName, object::SectionedAddress ModuleOffset)
Definition: Symbolize.cpp:157
Expected< DIInliningInfo > symbolizeInlinedCode(const std::string &ModuleName, object::SectionedAddress ModuleOffset)
Definition: Symbolize.cpp:101
virtual DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const =0
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:981
bool isLittleEndian() const
Definition: Binary.h:140
const T * data() const
Definition: ArrayRef.h:145
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, const LoadedObjectInfo *L=nullptr, function_ref< ErrorPolicy(Error)> HandleError=defaultErrorHandler, std::string DWPName="")
uint32_t crc32(uint32_t CRC, StringRef S)
zlib independent CRC32 calculation.
Definition: CRC.cpp:65
static std::string DemangleName(const std::string &Name, const SymbolizableModule *DbiModuleDescriptor)
Definition: Symbolize.cpp:519
virtual std::vector< DILocal > symbolizeFrame(object::SectionedAddress ModuleOffset) const =0
ArrayRef< uint8_t > getUuid() const
std::string Name
Definition: DIContext.h:108
std::string FunctionName
Definition: DIContext.h:32
reference get()
Returns a reference to the stored T value.
Definition: Error.h:532
bool isObject() const
Definition: Binary.h:100
iterator begin() const
Definition: StringRef.h:101
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:927
static const size_t npos
Definition: StringRef.h:50
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:565
#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:332
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
Definition: Path.cpp:412
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition: Error.h:1227
LLVM_NODISCARD 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:628
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
iterator end() const
Definition: StringRef.h:103
virtual DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const =0
reference get()
Definition: ErrorOr.h:156
Container for description of a global variable.
Definition: DIContext.h:107
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:143
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:580