This is the matching change for the data structure name changes for the
[oota-llvm.git] / lib / DebugInfo / DWARFDebugLine.cpp
index c2fb111ebcf7ef72ec69c3814ed06d3cf03583b7..117fa31aa86f6e1218178d906f2d054e384f6b18 100644 (file)
@@ -41,8 +41,9 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS) const {
           "----------------\n";
     for (uint32_t i = 0; i < FileNames.size(); ++i) {
       const FileNameEntry& fileEntry = FileNames[i];
-      OS << format("file_names[%3u] %4u ", i+1, fileEntry.DirIdx)
-         << format("0x%8.8x 0x%8.8x ", fileEntry.ModTime, fileEntry.Length)
+      OS << format("file_names[%3u] %4" PRIu64 " ", i+1, fileEntry.DirIdx)
+         << format("0x%8.8" PRIx64 " 0x%8.8" PRIx64 " ",
+                   fileEntry.ModTime, fileEntry.Length)
          << fileEntry.Name << '\n';
     }
   }
@@ -68,7 +69,7 @@ void DWARFDebugLine::Row::reset(bool default_is_stmt) {
 }
 
 void DWARFDebugLine::Row::dump(raw_ostream &OS) const {
-  OS << format("0x%16.16llx %6u %6u", Address, Line, Column)
+  OS << format("0x%16.16" PRIx64 " %6u %6u", Address, Line, Column)
      << format(" %6u %3u ", File, Isa)
      << (IsStmt ? " is_stmt" : "")
      << (BasicBlock ? " basic_block" : "")
@@ -99,50 +100,12 @@ void DWARFDebugLine::State::appendRowToMatrix(uint32_t offset) {
   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 +114,21 @@ DWARFDebugLine::getLineTable(uint32_t offset) const {
   return 0;
 }
 
+const DWARFDebugLine::LineTable *
+DWARFDebugLine::getOrParseLineTable(DataExtractor debug_line_data,
+                                    uint32_t offset) {
+  std::pair<LineTableIter, bool> pos =
+    LineTableMap.insert(LineTableMapTy::value_type(offset, LineTable()));
+  if (pos.second) {
+    // Parse and cache the line table for at this offset.
+    State state;
+    if (!parseStatementTable(debug_line_data, &offset, state))
+      return 0;
+    pos.first->second = state;
+  }
+  return &pos.first->second;
+}
+
 bool
 DWARFDebugLine::parsePrologue(DataExtractor debug_line_data,
                               uint32_t *offset_ptr, Prologue *prologue) {
@@ -200,7 +178,7 @@ DWARFDebugLine::parsePrologue(DataExtractor debug_line_data,
 
   if (*offset_ptr != end_prologue_offset) {
     fprintf(stderr, "warning: parsing line table prologue at 0x%8.8x should"
-                    " have ended at 0x%8.8x but it ended ad 0x%8.8x\n", 
+                    " have ended at 0x%8.8x but it ended ad 0x%8.8x\n",
             prologue_offset, end_prologue_offset, *offset_ptr);
   }
   return end_prologue_offset;
@@ -222,6 +200,8 @@ DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data,
   const uint32_t end_offset = debug_line_offset + prologue->TotalLength +
                               sizeof(prologue->TotalLength);
 
+  state.reset();
+
   while (*offset_ptr < end_offset) {
     uint8_t opcode = debug_line_data.getU8(offset_ptr);
 
@@ -414,8 +394,8 @@ DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data,
       // field in the header, plus the value of the line_range field,
       // minus 1 (line base + line range - 1). If the desired line
       // increment is greater than the maximum line increment, a standard
-      // opcode must be used instead of a special opcode. The address
-      // advance is calculated by dividing the desired address increment
+      // opcode must be used instead of a special opcode. The "address
+      // advance" is calculated by dividing the desired address increment
       // by the minimum_instruction_length field from the header. The
       // special opcode is then calculated using the following formula:
       //