[llvm-c] Improve TargetMachine bindings
[oota-llvm.git] / lib / DebugInfo / DWARFDebugRangeList.cpp
index 8012e306c78d3dc8fbe548a8cb95add0725a3746..1806beee72853149e3156b1c25cb36dc91ea36da 100644 (file)
@@ -37,10 +37,7 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
       clear();
       return false;
     }
-    // The end of any given range list is marked by an end of list entry,
-    // which consists of a 0 for the beginning address offset
-    // and a 0 for the ending address offset.
-    if (entry.StartAddress == 0 && entry.EndAddress == 0)
+    if (entry.isEndOfListEntry())
       break;
     Entries.push_back(entry);
   }
@@ -50,10 +47,21 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
 void DWARFDebugRangeList::dump(raw_ostream &OS) const {
   for (int i = 0, n = Entries.size(); i != n; ++i) {
     const char *format_str = (AddressSize == 4
-                              ? "%08x %08"PRIx64" %08"PRIx64"\n"
-                              : "%08x %016"PRIx64" %016"PRIx64"\n");
+                              ? "%08x %08"  PRIx64 " %08"  PRIx64 "\n"
+                              : "%08x %016" PRIx64 " %016" PRIx64 "\n");
     OS << format(format_str, Offset, Entries[i].StartAddress,
                                      Entries[i].EndAddress);
   }
   OS << format("%08x <End of list>\n", Offset);
 }
+
+bool DWARFDebugRangeList::containsAddress(uint64_t BaseAddress,
+                                          uint64_t Address) const {
+  for (int i = 0, n = Entries.size(); i != n; ++i) {
+    if (Entries[i].isBaseAddressSelectionEntry(AddressSize))
+      BaseAddress = Entries[i].EndAddress;
+    else if (Entries[i].containsAddress(BaseAddress, Address))
+      return true;
+  }
+  return false;
+}