[Lldb-commits] [lldb] [lldb-dap] Mark hidden frames as "subtle" (PR #105457)
Adrian Vogelsgesang via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 20 19:05:19 PDT 2024
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/105457
>From bdd78f79c8eb1a439472c1aa5a1bb25e83494a79 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang <avogelsgesang at salesforce.com>
Date: Wed, 21 Aug 2024 00:12:39 +0000
Subject: [PATCH] [lldb-dap] Show hidden frames as "subtle"
This commit takes advantage of the recently introduced
`SBFrame::IsHidden` to show those hidden frames as "subtle" frames in
the UI. E.g., VS Code renders such frames grayed out in the stack trace
---
.../lldb-dap/stackTrace/subtleFrames/Makefile | 3 ++
.../subtleFrames/TestDAP_subtleFrames.py | 29 +++++++++++++++++++
.../lldb-dap/stackTrace/subtleFrames/main.cpp | 13 +++++++++
lldb/tools/lldb-dap/JSONUtils.cpp | 3 ++
4 files changed, 48 insertions(+)
create mode 100644 lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
create mode 100644 lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
create mode 100644 lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
new file mode 100644
index 00000000000000..a6ae713cf424ff
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.c
+
+include Makefile.rules
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
new file mode 100644
index 00000000000000..d4b28c35d08df2
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -0,0 +1,29 @@
+"""
+Test lldb-dap stack trace response
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+import os
+
+import lldbdap_testcase
+from lldbsuite.test import lldbtest, lldbutil
+
+
+class TestDAP_subtleFrames(lldbdap_testcase.DAPTestCaseBase):
+ def test_subtleFrames(self):
+ """
+ Test that internal stack frames (such as the ones used by `std::function`)
+ are marked as "subtle".
+ """
+ program = self.getBuildArtifact("a.out")
+ self.build_and_launch(program)
+ source = "main.cpp"
+ self.set_source_breakpoints(source, [line_number(source, "BREAK HERE")])
+ self.continue_to_next_stop()
+
+ backtrace = self.get_stackFrames()[0]
+ for f in backtrace:
+ if "__function" in f["name"]:
+ self.assertEqual(f["presentationHint"], "subtle")
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
new file mode 100644
index 00000000000000..71944528441e38
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
@@ -0,0 +1,13 @@
+#include <functional>
+#include <iostream>
+
+void greet() {
+ // BREAK HERE
+ std::cout << "Hello\n";
+}
+
+int main() {
+ std::function<void()> func{greet};
+ func();
+ return 0;
+}
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index a8b85f55939e17..c080fd395b7288 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -763,6 +763,9 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
object.try_emplace("instructionPointerReference", formatted_addr);
}
+ if (frame.IsArtificial() || frame.IsHidden())
+ object.try_emplace("presentationHint", "subtle");
+
return llvm::json::Value(std::move(object));
}
More information about the lldb-commits
mailing list