2011-09-13 21:42:23 +02:00
|
|
|
//===-- DIContext.h ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-09-15 22:43:22 +02:00
|
|
|
// This file defines DIContext, an abstract data structure that holds
|
2011-09-13 21:42:23 +02:00
|
|
|
// debug information data.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_DICONTEXT_H
|
|
|
|
#define LLVM_DEBUGINFO_DICONTEXT_H
|
|
|
|
|
2012-12-03 18:02:12 +01:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2012-11-12 22:40:38 +01:00
|
|
|
#include "llvm/Object/ObjectFile.h"
|
|
|
|
#include "llvm/Object/RelocVisitor.h"
|
2013-08-06 12:32:39 +02:00
|
|
|
#include "llvm/Support/Casting.h"
|
2011-09-16 00:26:16 +02:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2014-04-18 23:36:39 +02:00
|
|
|
#include <string>
|
|
|
|
|
2011-09-13 21:42:23 +02:00
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class raw_ostream;
|
|
|
|
|
2011-09-15 22:43:22 +02:00
|
|
|
/// DILineInfo - a format-neutral container for source line information.
|
2014-04-18 23:36:39 +02:00
|
|
|
struct DILineInfo {
|
|
|
|
std::string FileName;
|
|
|
|
std::string FunctionName;
|
2011-09-15 22:43:22 +02:00
|
|
|
uint32_t Line;
|
|
|
|
uint32_t Column;
|
|
|
|
|
2014-04-18 23:36:39 +02:00
|
|
|
DILineInfo()
|
|
|
|
: FileName("<invalid>"), FunctionName("<invalid>"), Line(0), Column(0) {}
|
2011-09-21 03:13:16 +02:00
|
|
|
|
|
|
|
bool operator==(const DILineInfo &RHS) const {
|
|
|
|
return Line == RHS.Line && Column == RHS.Column &&
|
2014-04-18 23:36:39 +02:00
|
|
|
FileName == RHS.FileName && FunctionName == RHS.FunctionName;
|
2011-09-21 03:13:16 +02:00
|
|
|
}
|
|
|
|
bool operator!=(const DILineInfo &RHS) const {
|
|
|
|
return !(*this == RHS);
|
|
|
|
}
|
2011-09-15 22:43:22 +02:00
|
|
|
};
|
|
|
|
|
2013-01-26 01:28:05 +01:00
|
|
|
typedef SmallVector<std::pair<uint64_t, DILineInfo>, 16> DILineInfoTable;
|
|
|
|
|
2012-09-04 10:12:33 +02:00
|
|
|
/// DIInliningInfo - a format-neutral container for inlined code description.
|
|
|
|
class DIInliningInfo {
|
|
|
|
SmallVector<DILineInfo, 4> Frames;
|
|
|
|
public:
|
|
|
|
DIInliningInfo() {}
|
|
|
|
DILineInfo getFrame(unsigned Index) const {
|
|
|
|
assert(Index < Frames.size());
|
|
|
|
return Frames[Index];
|
|
|
|
}
|
2015-10-30 01:02:55 +01:00
|
|
|
DILineInfo *getMutableFrame(unsigned Index) {
|
|
|
|
assert(Index < Frames.size());
|
|
|
|
return &Frames[Index];
|
|
|
|
}
|
2012-09-04 10:12:33 +02:00
|
|
|
uint32_t getNumberOfFrames() const {
|
|
|
|
return Frames.size();
|
|
|
|
}
|
|
|
|
void addFrame(const DILineInfo &Frame) {
|
|
|
|
Frames.push_back(Frame);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-30 00:49:19 +01:00
|
|
|
/// DIGlobal - container for description of a global variable.
|
|
|
|
struct DIGlobal {
|
|
|
|
std::string Name;
|
|
|
|
uint64_t Start;
|
|
|
|
uint64_t Size;
|
|
|
|
|
|
|
|
DIGlobal() : Name("<invalid>"), Start(0), Size(0) {}
|
|
|
|
};
|
|
|
|
|
2014-10-10 17:51:02 +02:00
|
|
|
/// A DINameKind is passed to name search methods to specify a
|
|
|
|
/// preference regarding the type of name resolution the caller wants.
|
|
|
|
enum class DINameKind { None, ShortName, LinkageName };
|
|
|
|
|
2012-07-02 07:54:45 +02:00
|
|
|
/// DILineInfoSpecifier - controls which fields of DILineInfo container
|
|
|
|
/// should be filled with data.
|
2014-05-15 23:24:32 +02:00
|
|
|
struct DILineInfoSpecifier {
|
|
|
|
enum class FileLineInfoKind { None, Default, AbsoluteFilePath };
|
2014-10-10 17:51:02 +02:00
|
|
|
typedef DINameKind FunctionNameKind;
|
2014-05-15 23:24:32 +02:00
|
|
|
|
|
|
|
FileLineInfoKind FLIKind;
|
|
|
|
FunctionNameKind FNKind;
|
|
|
|
|
|
|
|
DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::Default,
|
|
|
|
FunctionNameKind FNKind = FunctionNameKind::None)
|
|
|
|
: FLIKind(FLIKind), FNKind(FNKind) {}
|
2012-07-02 07:54:45 +02:00
|
|
|
};
|
|
|
|
|
2013-01-25 21:26:43 +01:00
|
|
|
/// Selects which debug sections get dumped.
|
|
|
|
enum DIDumpType {
|
|
|
|
DIDT_Null,
|
|
|
|
DIDT_All,
|
|
|
|
DIDT_Abbrev,
|
|
|
|
DIDT_AbbrevDwo,
|
|
|
|
DIDT_Aranges,
|
2013-02-06 00:30:58 +01:00
|
|
|
DIDT_Frames,
|
2013-01-25 21:26:43 +01:00
|
|
|
DIDT_Info,
|
|
|
|
DIDT_InfoDwo,
|
2013-09-24 00:44:47 +02:00
|
|
|
DIDT_Types,
|
2014-01-09 06:08:24 +01:00
|
|
|
DIDT_TypesDwo,
|
2013-01-25 21:26:43 +01:00
|
|
|
DIDT_Line,
|
2014-02-25 00:58:54 +01:00
|
|
|
DIDT_LineDwo,
|
2013-06-19 23:37:13 +02:00
|
|
|
DIDT_Loc,
|
2014-03-25 02:44:02 +01:00
|
|
|
DIDT_LocDwo,
|
2015-11-12 10:38:54 +01:00
|
|
|
DIDT_Macro,
|
2013-01-25 21:26:43 +01:00
|
|
|
DIDT_Ranges,
|
2013-02-12 17:20:28 +01:00
|
|
|
DIDT_Pubnames,
|
2013-09-26 01:02:41 +02:00
|
|
|
DIDT_Pubtypes,
|
2013-09-20 01:01:29 +02:00
|
|
|
DIDT_GnuPubnames,
|
2013-09-24 21:50:00 +02:00
|
|
|
DIDT_GnuPubtypes,
|
2013-01-25 21:26:43 +01:00
|
|
|
DIDT_Str,
|
|
|
|
DIDT_StrDwo,
|
2014-11-14 17:15:53 +01:00
|
|
|
DIDT_StrOffsetsDwo,
|
|
|
|
DIDT_AppleNames,
|
|
|
|
DIDT_AppleTypes,
|
|
|
|
DIDT_AppleNamespaces,
|
2015-11-11 20:28:21 +01:00
|
|
|
DIDT_AppleObjC,
|
|
|
|
DIDT_CUIndex,
|
2015-11-11 20:40:49 +01:00
|
|
|
DIDT_TUIndex,
|
2013-01-25 21:26:43 +01:00
|
|
|
};
|
|
|
|
|
2011-09-13 21:42:23 +02:00
|
|
|
class DIContext {
|
|
|
|
public:
|
2013-08-06 12:32:39 +02:00
|
|
|
enum DIContextKind {
|
2015-04-23 19:37:47 +02:00
|
|
|
CK_DWARF,
|
|
|
|
CK_PDB
|
2013-08-06 12:32:39 +02:00
|
|
|
};
|
|
|
|
DIContextKind getKind() const { return Kind; }
|
|
|
|
|
|
|
|
DIContext(DIContextKind K) : Kind(K) {}
|
2015-04-23 19:37:47 +02:00
|
|
|
virtual ~DIContext() {}
|
2011-09-13 21:42:23 +02:00
|
|
|
|
2016-01-26 16:09:42 +01:00
|
|
|
virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
|
|
|
|
bool DumpEH = false) = 0;
|
2011-09-15 22:43:22 +02:00
|
|
|
|
2012-09-04 10:12:33 +02:00
|
|
|
virtual DILineInfo getLineInfoForAddress(uint64_t Address,
|
|
|
|
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
|
2013-01-26 01:28:05 +01:00
|
|
|
virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,
|
|
|
|
uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
|
2012-09-04 10:12:33 +02:00
|
|
|
virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,
|
|
|
|
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
|
2013-08-06 12:32:39 +02:00
|
|
|
private:
|
|
|
|
const DIContextKind Kind;
|
2011-09-13 21:42:23 +02:00
|
|
|
};
|
|
|
|
|
2015-05-21 23:24:32 +02:00
|
|
|
/// An inferface for inquiring the load address of a loaded object file
|
|
|
|
/// to be used by the DIContext implementations when applying relocations
|
|
|
|
/// on the fly.
|
|
|
|
class LoadedObjectInfo {
|
2015-08-05 22:20:29 +02:00
|
|
|
protected:
|
|
|
|
LoadedObjectInfo(const LoadedObjectInfo &) = default;
|
|
|
|
LoadedObjectInfo() = default;
|
|
|
|
|
2015-05-21 23:24:32 +02:00
|
|
|
public:
|
2015-06-04 22:41:51 +02:00
|
|
|
virtual ~LoadedObjectInfo() = default;
|
2015-05-21 23:24:32 +02:00
|
|
|
|
2015-07-29 20:07:48 +02:00
|
|
|
/// Obtain the Load Address of a section by SectionRef.
|
2015-05-21 23:24:32 +02:00
|
|
|
///
|
2015-07-28 19:52:11 +02:00
|
|
|
/// Calculate the address of the given section.
|
2015-05-21 23:24:32 +02:00
|
|
|
/// The section need not be present in the local address space. The addresses
|
2015-07-29 20:07:48 +02:00
|
|
|
/// need to be consistent with the addresses used to query the DIContext and
|
2015-05-21 23:24:32 +02:00
|
|
|
/// the output of this function should be deterministic, i.e. repeated calls with
|
2015-07-28 19:52:11 +02:00
|
|
|
/// the same Sec should give the same address.
|
|
|
|
virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const = 0;
|
2015-05-21 23:24:32 +02:00
|
|
|
|
|
|
|
/// If conveniently available, return the content of the given Section.
|
|
|
|
///
|
|
|
|
/// When the section is available in the local address space, in relocated (loaded)
|
|
|
|
/// form, e.g. because it was relocated by a JIT for execution, this function
|
|
|
|
/// should provide the contents of said section in `Data`. If the loaded section
|
|
|
|
/// is not available, or the cost of retrieving it would be prohibitive, this
|
|
|
|
/// function should return false. In that case, relocations will be read from the
|
|
|
|
/// local (unrelocated) object file and applied on the fly. Note that this method
|
|
|
|
/// is used purely for optimzation purposes in the common case of JITting in the
|
|
|
|
/// local address space, so returning false should always be correct.
|
2015-07-28 19:52:11 +02:00
|
|
|
virtual bool getLoadedSectionContents(const object::SectionRef &Sec,
|
|
|
|
StringRef &Data) const {
|
2015-05-21 23:24:32 +02:00
|
|
|
return false;
|
|
|
|
}
|
2015-05-22 07:33:54 +02:00
|
|
|
|
|
|
|
/// Obtain a copy of this LoadedObjectInfo.
|
|
|
|
///
|
|
|
|
/// The caller is responsible for deallocation once the copy is no longer required.
|
2015-06-04 22:54:32 +02:00
|
|
|
virtual std::unique_ptr<LoadedObjectInfo> clone() const = 0;
|
2015-05-21 23:24:32 +02:00
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
}
|
2011-09-13 21:42:23 +02:00
|
|
|
|
|
|
|
#endif
|