[llvm] Added --report=debugger option to llvm-debuginfo-analyzer (PR #159853)

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 29 08:38:47 PDT 2025


================
@@ -1903,6 +1921,94 @@ void LVScopeFunction::printExtra(raw_ostream &OS, bool Full) const {
   }
 }
 
+void LVScopeFunction::printDebugger(raw_ostream &OS) const {
+  const LVLines *Lines = getLines();
+  // If there's no lines, this function has no body.
+  if (!Lines)
+    return;
+
+  OS << formattedKind(kind()) << " " << getName() << "\n";
+
+  std::vector<const LVLine *> AllLines;
+  std::unordered_map<LVAddress, std::vector<const LVLocation *>> LifetimeBegins;
+  std::unordered_map<LVAddress, std::vector<const LVLocation *>>
+      LifetimeEndsExclusive;
+
+  // Collect all child scope lines and symbols
+  std::vector<const LVScope *> Worklist = {this};
+  for (unsigned i = 0; i < Worklist.size(); i++) {
+    const LVScope *Scope = Worklist[i];
+    if (Scope->scopeCount()) {
+      for (const LVScope *ChildScope : *Scope->getScopes())
+        Worklist.push_back(ChildScope);
+    }
+    if (Scope->lineCount()) {
+      for (const LVLine *Line : *Scope->getLines()) {
+        AllLines.push_back(Line);
+      }
+    }
+    if (Scope->symbolCount()) {
+      for (const LVSymbol *Symbol : *Scope->getSymbols()) {
+        LVLocations SymbolLocations;
+        Symbol->getLocations(SymbolLocations);
+        if (SymbolLocations.empty())
+          continue;
+
+        for (const LVLocation *Loc : SymbolLocations) {
+          if (Loc->getIsGapEntry())
+            continue;
+
+          LVAddress Begin = Loc->getLowerAddress();
+          LVAddress End = Loc->getUpperAddress();
+          LifetimeBegins[Begin].push_back(Loc);
+          LifetimeEndsExclusive[End].push_back(Loc);
+        }
+      }
----------------
CarlosAlbertoEnciso wrote:

For consistency: `Loc` --> `Location`

https://github.com/llvm/llvm-project/pull/159853


More information about the llvm-commits mailing list