Skip to content

Commit 6f45602

Browse files
authored
[lldb-dap] Mark hidden frames as "subtle" (llvm#105457)
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 hides those stack frames by default, and renders them as grayed out frames, in case the user decides to show them in the stack trace
1 parent a14c730 commit 6f45602

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Test lldb-dap stack trace response
3+
"""
4+
5+
6+
import dap_server
7+
from lldbsuite.test.decorators import *
8+
9+
import lldbdap_testcase
10+
from lldbsuite.test.lldbtest import *
11+
12+
13+
class TestDAP_subtleFrames(lldbdap_testcase.DAPTestCaseBase):
14+
@add_test_categories(["libc++"])
15+
def test_subtleFrames(self):
16+
"""
17+
Internal stack frames (such as the ones used by `std::function`) are marked as "subtle".
18+
"""
19+
program = self.getBuildArtifact("a.out")
20+
self.build_and_launch(program)
21+
source = "main.cpp"
22+
self.set_source_breakpoints(source, [line_number(source, "BREAK HERE")])
23+
self.continue_to_next_stop()
24+
25+
frames = self.get_stackFrames()
26+
for f in frames:
27+
if "__function" in f["name"]:
28+
self.assertEqual(f["presentationHint"], "subtle")
29+
self.assertTrue(any(f.get("presentationHint") == "subtle" for f in frames))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <functional>
2+
#include <iostream>
3+
4+
void greet() {
5+
// BREAK HERE
6+
std::cout << "Hello\n";
7+
}
8+
9+
int main() {
10+
std::function<void()> func{greet};
11+
func();
12+
return 0;
13+
}

lldb/tools/lldb-dap/JSONUtils.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
763763
object.try_emplace("instructionPointerReference", formatted_addr);
764764
}
765765

766+
if (frame.IsArtificial() || frame.IsHidden())
767+
object.try_emplace("presentationHint", "subtle");
768+
766769
return llvm::json::Value(std::move(object));
767770
}
768771

0 commit comments

Comments
 (0)