[llvm] Added --report=debugger option to llvm-debuginfo-analyzer (PR #159853)
Javier Lopez-Gomez via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 07:40:51 PDT 2025
================
@@ -0,0 +1,272 @@
+//===-- DebuggerView.cpp ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Options and functions related to --debugger-view for llvm-debuginfo-analyzer
+//
+//===----------------------------------------------------------------------===//
+
+#include "DebuggerView.h"
+#include "Options.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/DebugInfo/LogicalView/LVReaderHandler.h"
+
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+
+using namespace llvm;
+using namespace debuggerview;
+
+cl::OptionCategory llvm::debuggerview::Category(
+ "Debugger View",
+ "Special printing mode that emulate how debugger uses debug info.");
+
+cl::opt<bool> llvm::debuggerview::Enable(
+ "debugger-view",
+ cl::desc("Enables debugger view. Normal debug-info printing is disabled "
+ "and options are ignored."),
+ cl::init(false), cl::cat(Category));
+static cl::opt<bool>
+ IncludeVars("debugger-view-vars",
+ cl::desc("Include live variables at each statement line."),
+ cl::init(false), cl::cat(Category));
+static cl::opt<bool>
+ IncludeCode("debugger-view-code",
+ cl::desc("Include disassembly at each statement line"),
+ cl::init(false), cl::cat(Category));
+static cl::opt<bool> IncludeRanges("debugger-view-ranges",
+ cl::desc("Include variable ranges"),
+ cl::init(false), cl::cat(Category));
+static cl::opt<bool> Help(
+ "debugger-view-help",
+ cl::desc(
+ "Print a detailed help screen about what kind of output to expect"),
+ cl::init(false), cl::cat(Category));
+
+constexpr const char *HelpText =
+ R"(Prints debug info in a way that is easy to verify correctness of debug info.
+FUNCTION: main
+ LINE: my_source_file.c:1 [main] <---- New statement lines, inlined callstack
+ VAR: argc : int : {expression} <---- Variables live at this point
+ VAR: argv : char ** : {expression}
+ LINE: my_source_file.c:2 [main]
+ VAR: argc : int
+ VAR: argv : char **
+ LINE: my_source_file.c:3 [main]
+ VAR: argc : int
+ VAR: argv : char **
+ LINE: my_source_file.c:4 [main]
+)";
+
+using namespace llvm;
+using namespace logicalview;
+
+template <typename T>
+static T Take(Expected<T> ExpectedResult, const Twine &Msg) {
+ if (!ExpectedResult) {
+ auto Err = ExpectedResult.takeError();
+ errs() << Msg << " " << toStringWithoutConsuming(Err) << '\n';
+ exit(2);
+ }
+ T ret = std::move(*ExpectedResult);
+ return ret;
+}
+
+namespace {
+
+struct ScopePrinter {
+ std::vector<const LVLine *> Lines;
+ std::unordered_map<LVAddress, std::vector<const LVLocation *>> LivetimeBegins;
----------------
jalopezg-git wrote:
That is right -- apologies for the misleading suggestion :sweat_smile:.
https://github.com/llvm/llvm-project/pull/159853
More information about the llvm-commits
mailing list