aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/DWARFContext.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-09-15 20:43:18 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-09-15 20:43:18 +0000
commit679e1752f81e21c40392ff90aaaabbe9596ef07f (patch)
tree269ddc28c10a7c0232f470849dbbea5642dccfc4 /llvm/lib/DebugInfo/DWARFContext.cpp
parentd923eb0d1e358b07b4f5c0709d7171ba56d15881 (diff)
downloadllvm-679e1752f81e21c40392ff90aaaabbe9596ef07f.zip
llvm-679e1752f81e21c40392ff90aaaabbe9596ef07f.tar.gz
llvm-679e1752f81e21c40392ff90aaaabbe9596ef07f.tar.bz2
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. llvm-svn: 139835
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARFContext.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARFContext.cpp
index 184a8b5..36c6d98 100644
--- a/llvm/lib/DebugInfo/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARFContext.cpp
@@ -77,15 +77,25 @@ const DWARFDebugAranges *DWARFContext::getDebugAranges() {
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() {