Skip to content

Commit c3cd186

Browse files
committed
[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
1 parent e1c36bd commit c3cd186

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.c
2+
3+
include Makefile.rules
Lines changed: 29 additions & 0 deletions
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+
import os
9+
10+
import lldbdap_testcase
11+
from lldbsuite.test import lldbtest, lldbutil
12+
13+
14+
class TestDAP_subtleFrames(lldbdap_testcase.DAPTestCaseBase):
15+
def test_subtleFrames(self):
16+
"""
17+
Test that internal stack frames (such as the ones used by `std::function`)
18+
are marked as "subtle".
19+
"""
20+
program = self.getBuildArtifact("a.out")
21+
self.build_and_launch(program)
22+
source = "main.cpp"
23+
self.set_source_breakpoints(source, [line_number(source, "BREAK HERE")])
24+
self.continue_to_next_stop()
25+
26+
backtrace = self.get_stackFrames()[0]
27+
for f in backtrace:
28+
if "__function" in f["name"]:
29+
self.assertEqual(f["presentationHint"], "subtle")
Lines changed: 13 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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)