2017-02-09 09:09:54 +08:00
|
|
|
//===- SymbolizableObjectFile.h ---------------------------------*- C++ -*-===//
|
2015-10-30 06:21:37 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the SymbolizableObjectFile class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
|
|
|
|
#define LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
|
|
|
|
|
2017-02-09 09:09:54 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/DebugInfo/DIContext.h"
|
2015-10-30 06:21:37 +08:00
|
|
|
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
|
2017-02-09 09:09:54 +08:00
|
|
|
#include "llvm/Support/ErrorOr.h"
|
|
|
|
#include <cstdint>
|
2015-10-30 06:21:37 +08:00
|
|
|
#include <map>
|
2017-02-09 09:09:54 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <system_error>
|
2015-10-30 06:21:37 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2017-02-09 09:09:54 +08:00
|
|
|
|
2015-10-30 06:21:37 +08:00
|
|
|
class DataExtractor;
|
|
|
|
|
|
|
|
namespace symbolize {
|
|
|
|
|
|
|
|
class SymbolizableObjectFile : public SymbolizableModule {
|
|
|
|
public:
|
|
|
|
static ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
|
|
|
|
create(object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);
|
|
|
|
|
|
|
|
DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind,
|
|
|
|
bool UseSymbolTable) const override;
|
|
|
|
DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,
|
|
|
|
FunctionNameKind FNKind,
|
|
|
|
bool UseSymbolTable) const override;
|
2015-10-30 07:49:19 +08:00
|
|
|
DIGlobal symbolizeData(uint64_t ModuleOffset) const override;
|
2015-10-30 06:21:37 +08:00
|
|
|
|
|
|
|
// Return true if this is a 32-bit x86 PE COFF module.
|
|
|
|
bool isWin32Module() const override;
|
|
|
|
|
|
|
|
// Returns the preferred base of the module, i.e. where the loader would place
|
|
|
|
// it in memory assuming there were no conflicts.
|
|
|
|
uint64_t getModulePreferredBase() const override;
|
|
|
|
|
|
|
|
private:
|
2015-11-14 01:00:36 +08:00
|
|
|
bool shouldOverrideWithSymbolTable(FunctionNameKind FNKind,
|
|
|
|
bool UseSymbolTable) const;
|
|
|
|
|
2015-10-30 06:21:37 +08:00
|
|
|
bool getNameFromSymbolTable(object::SymbolRef::Type Type, uint64_t Address,
|
|
|
|
std::string &Name, uint64_t &Addr,
|
|
|
|
uint64_t &Size) const;
|
|
|
|
// For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
|
|
|
|
// (function descriptor) section and OpdExtractor refers to its contents.
|
|
|
|
std::error_code addSymbol(const object::SymbolRef &Symbol,
|
|
|
|
uint64_t SymbolSize,
|
|
|
|
DataExtractor *OpdExtractor = nullptr,
|
|
|
|
uint64_t OpdAddress = 0);
|
|
|
|
std::error_code addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
|
|
|
|
|
|
|
|
object::ObjectFile *Module;
|
|
|
|
std::unique_ptr<DIContext> DebugInfoContext;
|
|
|
|
|
|
|
|
struct SymbolDesc {
|
|
|
|
uint64_t Addr;
|
|
|
|
// If size is 0, assume that symbol occupies the whole memory range up to
|
|
|
|
// the following symbol.
|
|
|
|
uint64_t Size;
|
2017-02-09 09:09:54 +08:00
|
|
|
|
2015-10-30 06:21:37 +08:00
|
|
|
friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
|
|
|
|
return s1.Addr < s2.Addr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::map<SymbolDesc, StringRef> Functions;
|
|
|
|
std::map<SymbolDesc, StringRef> Objects;
|
|
|
|
|
|
|
|
SymbolizableObjectFile(object::ObjectFile *Obj,
|
|
|
|
std::unique_ptr<DIContext> DICtx);
|
|
|
|
};
|
|
|
|
|
2017-02-09 09:09:54 +08:00
|
|
|
} // end namespace symbolize
|
|
|
|
|
|
|
|
} // end namespace llvm
|
2015-10-30 06:21:37 +08:00
|
|
|
|
2017-02-09 09:09:54 +08:00
|
|
|
#endif // LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
|