[PATCH] D27183: Add function to DWARFContext to get all line addresses

Simon Que via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 18:11:34 PST 2016


sque-google created this revision.
sque-google added a reviewer: echristo.
sque-google added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

Get all addresses that appear in the line tables of all compile units within the DWARF context.


https://reviews.llvm.org/D27183

Files:
  include/llvm/DebugInfo/DWARF/DWARFContext.h
  lib/DebugInfo/DWARF/DWARFContext.cpp


Index: lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFContext.cpp
+++ lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -432,6 +432,19 @@
   return Line->getOrParseLineTable(lineData, stmtOffset);
 }
 
+std::set<uint64_t> DWARFContext::getAllLineAddresses() {
+  parseCompileUnits();
+
+  std::set<uint64_t> Result;
+  for (const auto &CU : CUs) {
+    const DWARFLineTable* table = getLineTableForUnit(CU.get());
+    for (const DWARFDebugLine::Row &row : table->Rows) {
+      Result.insert(row.Address);
+    }
+  }
+  return Result;
+}
+
 void DWARFContext::parseCompileUnits() {
   CUs.parse(*this, getInfoSection());
 }
Index: include/llvm/DebugInfo/DWARF/DWARFContext.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -34,6 +34,7 @@
 #include <deque>
 #include <map>
 #include <memory>
+#include <set>
 #include <utility>
 
 namespace llvm {
@@ -191,6 +192,10 @@
   /// Get a pointer to a parsed line table corresponding to a compile unit.
   const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
 
+  /// Get a set of all addresses that appear in the line tables of the compile
+  /// units in this DWARF context.
+  std::set<uint64_t> getAllLineAddresses();
+
   DILineInfo getLineInfoForAddress(uint64_t Address,
       DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
   DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27183.79489.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/cb51844e/attachment.bin>


More information about the llvm-commits mailing list