summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/DebugInfo/DIContext.h18
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h12
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h10
3 files changed, 33 insertions, 7 deletions
diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
index ce0a156e9f7..d1336610f32 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <memory>
@@ -26,8 +27,6 @@
namespace llvm {
-class raw_ostream;
-
/// A format-neutral container for source line information.
struct DILineInfo {
std::string FileName;
@@ -46,15 +45,30 @@ struct DILineInfo {
FileName == RHS.FileName && FunctionName == RHS.FunctionName &&
StartLine == RHS.StartLine && Discriminator == RHS.Discriminator;
}
+
bool operator!=(const DILineInfo &RHS) const {
return !(*this == RHS);
}
+
bool operator<(const DILineInfo &RHS) const {
return std::tie(FileName, FunctionName, Line, Column, StartLine,
Discriminator) <
std::tie(RHS.FileName, RHS.FunctionName, RHS.Line, RHS.Column,
RHS.StartLine, RHS.Discriminator);
}
+
+ operator bool() const { return (*this) != DILineInfo(); }
+
+ void dump(raw_ostream &OS) {
+ OS << "Line info: ";
+ if (FileName != "<invalid>")
+ OS << "file '" << FileName << "', ";
+ if (FunctionName != "<invalid>")
+ OS << "function '" << FunctionName << "', ";
+ OS << "line " << Line << ", ";
+ OS << "column " << Column << ", ";
+ OS << "start line " << StartLine << '\n';
+ }
};
using DILineInfoTable = SmallVector<std::pair<uint64_t, DILineInfo>, 16>;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
index 4cecd22d450..2cd8fa95431 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -257,6 +257,18 @@ public:
/// Get a pointer to a parsed line table corresponding to a compile unit.
const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
+ /// Wraps the returned DIEs for a given address.
+ struct DIEsForAddress {
+ DWARFCompileUnit *CompileUnit = nullptr;
+ DWARFDie FunctionDIE;
+ DWARFDie BlockDIE;
+ operator bool() const { return CompileUnit != nullptr; }
+ };
+
+ /// Get the compilation unit, the function DIE and lexical block DIE for the
+ /// given address where applicable.
+ DIEsForAddress getDIEsForAddress(uint64_t Address);
+
DILineInfo getLineInfoForAddress(uint64_t Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size,
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 0df5c16e4a2..fb4b50f354b 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -329,6 +329,11 @@ public:
void collectAddressRanges(DWARFAddressRangesVector &CURanges);
+ /// Returns subprogram DIE with address range encompassing the provided
+ /// address. The pointer is alive as long as parsed compile unit DIEs are not
+ /// cleared.
+ DWARFDie getSubroutineForAddress(uint64_t Address);
+
/// getInlinedChainForAddress - fetches inlined chain for a given address.
/// Returns empty chain if there is no subprogram containing address. The
/// chain is valid as long as parsed compile unit DIEs are not cleared.
@@ -411,11 +416,6 @@ private:
/// parseDWO - Parses .dwo file for current compile unit. Returns true if
/// it was actually constructed.
bool parseDWO();
-
- /// getSubroutineForAddress - Returns subprogram DIE with address range
- /// encompassing the provided address. The pointer is alive as long as parsed
- /// compile unit DIEs are not cleared.
- DWARFDie getSubroutineForAddress(uint64_t Address);
};
} // end namespace llvm
OpenPOWER on IntegriCloud