Skip to content

Commit 6dad5e4

Browse files
Serhiy Redkolanza
authored andcommitted
The field ‘totalFrames’ which is total number of frames available, is mandatory in StackTraces response for VSCode extension that implements DAP and declares capability 'supportsDelayedStackTraceLoading':
"The debug adapter supports the delayed loading of parts of the stack, which requires that both the 'startFrame' and 'levels' arguments and the 'totalFrames' result of the 'StackTrace' request are supported." Lack of this field makes VSCode incorrectly display stack traces information D71034
1 parent d0ccd55 commit 6dad5e4

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,29 @@ def get_dict_value(self, d, key_path):
132132
key, key_path, d))
133133
return value
134134

135-
def get_stackFrames(self, threadId=None, startFrame=None, levels=None,
136-
dump=False):
135+
def get_stackFrames_and_totalFramesCount(self, threadId=None, startFrame=None,
136+
levels=None, dump=False):
137137
response = self.vscode.request_stackTrace(threadId=threadId,
138138
startFrame=startFrame,
139139
levels=levels,
140140
dump=dump)
141141
if response:
142-
return self.get_dict_value(response, ['body', 'stackFrames'])
143-
return None
142+
stackFrames = self.get_dict_value(response, ['body', 'stackFrames'])
143+
totalFrames = self.get_dict_value(response, ['body', 'totalFrames'])
144+
self.assertTrue(totalFrames > 0,
145+
'verify totalFrames count is provided by extension that supports '
146+
'async frames loading')
147+
return (stackFrames, totalFrames)
148+
return (None, 0)
149+
150+
def get_stackFrames(self, threadId=None, startFrame=None, levels=None,
151+
dump=False):
152+
(stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount(
153+
threadId=threadId,
154+
startFrame=startFrame,
155+
levels=levels,
156+
dump=dump)
157+
return stackFrames
144158

145159
def get_source_and_line(self, threadId=None, frameIndex=0):
146160
stackFrames = self.get_stackFrames(threadId=threadId,

lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ def test_stackTrace(self):
7676
self.continue_to_breakpoints(breakpoint_ids)
7777
startFrame = 0
7878
# Verify we get all stack frames with no arguments
79-
stackFrames = self.get_stackFrames()
79+
(stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount()
8080
frameCount = len(stackFrames)
8181
self.assertTrue(frameCount >= 20,
8282
'verify we get at least 20 frames for all frames')
83+
self.assertTrue(totalFrames == frameCount,
84+
'verify we get correct value for totalFrames count')
8385
self.verify_stackFrames(startFrame, stackFrames)
8486

8587
# Verify all stack frames by specifying startFrame = 0 and levels not
@@ -133,11 +135,15 @@ def test_stackTrace(self):
133135
# Verify we cap things correctly when we ask for too many frames
134136
startFrame = 5
135137
levels = 1000
136-
stackFrames = self.get_stackFrames(startFrame=startFrame,
137-
levels=levels)
138+
(stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount(
139+
startFrame=startFrame,
140+
levels=levels)
138141
self.assertTrue(len(stackFrames) == frameCount - startFrame,
139142
('verify less than 1000 frames with startFrame=%i and'
140143
' levels=%i') % (startFrame, levels))
144+
self.assertTrue(totalFrames == frameCount,
145+
'verify we get correct value for totalFrames count '
146+
'when requested frames not from 0 index')
141147
self.verify_stackFrames(startFrame, stackFrames)
142148

143149
# Verify level=0 works with non-zerp start frame

lldb/tools/lldb-vscode/lldb-vscode.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,8 @@ void request_stackTrace(const llvm::json::Object &request) {
21662166
break;
21672167
stackFrames.emplace_back(CreateStackFrame(frame));
21682168
}
2169+
const auto totalFrames = thread.GetNumFrames();
2170+
body.try_emplace("totalFrames", totalFrames);
21692171
}
21702172
body.try_emplace("stackFrames", std::move(stackFrames));
21712173
response.try_emplace("body", std::move(body));

0 commit comments

Comments
 (0)