[llvm-commits] [llvm] r139835 - in /llvm/trunk/lib/DebugInfo: DWARFContext.cpp DWARFContext.h DWARFDebugLine.cpp DWARFDebugLine.h
Benjamin Kramer
benny.kra at googlemail.com
Thu Sep 15 13:43:18 PDT 2011
Author: d0k
Date: Thu Sep 15 15:43:18 2011
New Revision: 139835
URL: http://llvm.org/viewvc/llvm-project?rev=139835&view=rev
Log:
DWARF: Remove accessors that parse the whole line table section in one go, this can't possibly work.
The address size is specified by the compile unit associated with a line table, there is no global address size.
Modified:
llvm/trunk/lib/DebugInfo/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/DWARFContext.h
llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugLine.h
Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=139835&r1=139834&r2=139835&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep 15 15:43:18 2011
@@ -77,15 +77,25 @@
return Aranges.get();
}
-const DWARFDebugLine *DWARFContext::getDebugLine() {
- if (Line)
- return Line.get();
-
- DataExtractor lineData(getLineSection(), isLittleEndian(), 0);
-
- Line.reset(new DWARFDebugLine());
- Line->parse(lineData);
- return Line.get();
+const DWARFDebugLine::LineTable *
+DWARFContext::getLineTableForCompileUnit(DWARFCompileUnit *cu) {
+ if (!Line)
+ Line.reset(new DWARFDebugLine());
+
+ unsigned stmtOffset =
+ cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_stmt_list,
+ -1U);
+ if (stmtOffset == -1U)
+ return 0; // No line table for this compile unit.
+
+ // See if the line table is cached.
+ if (const DWARFDebugLine::LineTable *lt = Line->getLineTable(stmtOffset))
+ return lt;
+
+ // We have to parse it first.
+ DataExtractor lineData(getLineSection(), isLittleEndian(),
+ cu->getAddressByteSize());
+ return Line->getOrParseLineTable(lineData, stmtOffset);
}
void DWARFContext::parseCompileUnits() {
Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=139835&r1=139834&r2=139835&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.h Thu Sep 15 15:43:18 2011
@@ -59,8 +59,9 @@
/// Get a pointer to the parsed DebugAranges object.
const DWARFDebugAranges *getDebugAranges();
- /// Get a pointer to the parsed DWARFDebugLine object.
- const DWARFDebugLine *getDebugLine();
+ /// Get a pointer to a parsed line table corresponding to a compile unit.
+ const DWARFDebugLine::LineTable *
+ getLineTableForCompileUnit(DWARFCompileUnit *cu);
bool isLittleEndian() const { return IsLittleEndian; }
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp?rev=139835&r1=139834&r2=139835&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp Thu Sep 15 15:43:18 2011
@@ -99,50 +99,12 @@
Row::postAppend();
}
-void DWARFDebugLine::parse(const DataExtractor debug_line_data) {
- LineTableMap.clear();
- uint32_t offset = 0;
- State state;
- while (debug_line_data.isValidOffset(offset)) {
- const uint32_t debug_line_offset = offset;
-
- if (parseStatementTable(debug_line_data, &offset, state)) {
- // Make sure we don't don't loop infinitely
- if (offset <= debug_line_offset)
- break;
-
- LineTableMap[debug_line_offset] = state;
- state.reset();
- }
- else
- ++offset; // Try next byte in line table
- }
-}
-
DWARFDebugLine::DumpingState::~DumpingState() {}
void DWARFDebugLine::DumpingState::finalize(uint32_t offset) {
LineTable::dump(OS);
}
-void DWARFDebugLine::dump(const DataExtractor debug_line_data, raw_ostream &OS){
- uint32_t offset = 0;
- DumpingState state(OS);
- while (debug_line_data.isValidOffset(offset)) {
- const uint32_t debug_line_offset = offset;
-
- if (parseStatementTable(debug_line_data, &offset, state)) {
- // Make sure we don't don't loop infinitely
- if (offset <= debug_line_offset)
- break;
-
- state.reset();
- }
- else
- ++offset; // Try next byte in line table
- }
-}
-
const DWARFDebugLine::LineTable *
DWARFDebugLine::getLineTable(uint32_t offset) const {
LineTableConstIter pos = LineTableMap.find(offset);
@@ -151,6 +113,20 @@
return 0;
}
+const DWARFDebugLine::LineTable *
+DWARFDebugLine::getOrParseLineTable(DataExtractor debug_line_data,
+ uint32_t offset) {
+ LineTableIter pos = LineTableMap.find(offset);
+ if (pos == LineTableMap.end()) {
+ // Parse and cache the line table for at this offset.
+ State state;
+ if (!parseStatementTable(debug_line_data, &offset, state))
+ return 0;
+ pos->second = state;
+ }
+ return &pos->second;
+}
+
bool
DWARFDebugLine::parsePrologue(DataExtractor debug_line_data,
uint32_t *offset_ptr, Prologue *prologue) {
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.h?rev=139835&r1=139834&r2=139835&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLine.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.h Thu Sep 15 15:43:18 2011
@@ -147,7 +147,7 @@
DoneParsingLineTable = -1
};
- State() : row(0) {}
+ State() : row(StartParsingLineTable) {}
virtual ~State();
virtual void appendRowToMatrix(uint32_t offset);
@@ -173,15 +173,9 @@
static bool parseStatementTable(DataExtractor debug_line_data,
uint32_t *offset_ptr, State &state);
- /// Parse all information in the debug_line_data into an internal
- /// representation.
- void parse(DataExtractor debug_line_data);
- void parseIfNeeded(DataExtractor debug_line_data) {
- if (LineTableMap.empty())
- parse(debug_line_data);
- }
- static void dump(DataExtractor debug_line_data, raw_ostream &OS);
const LineTable *getLineTable(uint32_t offset) const;
+ const LineTable *getOrParseLineTable(DataExtractor debug_line_data,
+ uint32_t offset);
private:
typedef std::map<uint32_t, LineTable> LineTableMapTy;
More information about the llvm-commits
mailing list