-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb-dap] Support StackFrameFormat #137113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2168161
[lldb-dap] Support StackFrameFormat
JDevlieghere 5b1378f
Fix incorrect interpretation of includeAll
JDevlieghere 3cf5b4f
Black & Darker disagree
JDevlieghere 66f2253
Simplify dap.configuration.displayExtendedBacktrace
JDevlieghere 0584669
Fix decorator
JDevlieghere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,14 +49,16 @@ static constexpr int StackPageSize = 20; | |
// | ||
// s=3,l=3 = [th0->s3, label1, th1->s0] | ||
static bool FillStackFrames(DAP &dap, lldb::SBThread &thread, | ||
lldb::SBFormat &frame_format, | ||
llvm::json::Array &stack_frames, int64_t &offset, | ||
const int64_t start_frame, const int64_t levels) { | ||
const int64_t start_frame, const int64_t levels, | ||
const bool include_all) { | ||
bool reached_end_of_stack = false; | ||
for (int64_t i = start_frame; | ||
static_cast<int64_t>(stack_frames.size()) < levels; i++) { | ||
if (i == -1) { | ||
stack_frames.emplace_back( | ||
CreateExtendedStackFrameLabel(thread, dap.frame_format)); | ||
CreateExtendedStackFrameLabel(thread, frame_format)); | ||
continue; | ||
} | ||
|
||
|
@@ -67,10 +69,10 @@ static bool FillStackFrames(DAP &dap, lldb::SBThread &thread, | |
break; | ||
} | ||
|
||
stack_frames.emplace_back(CreateStackFrame(frame, dap.frame_format)); | ||
stack_frames.emplace_back(CreateStackFrame(frame, frame_format)); | ||
} | ||
|
||
if (dap.configuration.displayExtendedBacktrace && reached_end_of_stack) { | ||
if (include_all && reached_end_of_stack) { | ||
// Check for any extended backtraces. | ||
for (uint32_t bt = 0; | ||
bt < thread.GetProcess().GetNumExtendedBacktraceTypes(); bt++) { | ||
|
@@ -80,8 +82,9 @@ static bool FillStackFrames(DAP &dap, lldb::SBThread &thread, | |
continue; | ||
|
||
reached_end_of_stack = FillStackFrames( | ||
dap, backtrace, stack_frames, offset, | ||
(start_frame - offset) > 0 ? start_frame - offset : -1, levels); | ||
dap, backtrace, frame_format, stack_frames, offset, | ||
(start_frame - offset) > 0 ? start_frame - offset : -1, levels, | ||
include_all); | ||
if (static_cast<int64_t>(stack_frames.size()) >= levels) | ||
break; | ||
} | ||
|
@@ -178,14 +181,54 @@ void StackTraceRequestHandler::operator()( | |
llvm::json::Array stack_frames; | ||
llvm::json::Object body; | ||
|
||
lldb::SBFormat frame_format = dap.frame_format; | ||
bool include_all = dap.configuration.displayExtendedBacktrace; | ||
|
||
if (const auto *format = arguments->getObject("format")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another thing I notice is the I'm not sure what that would mean in terms of a stack frame however, just thought I would note that for completeness. |
||
// Indicates that all stack frames should be included, even those the debug | ||
// adapter might otherwise hide. | ||
include_all = GetBoolean(format, "includeAll").value_or(false); | ||
|
||
// Parse the properties that have a corresponding format string. | ||
// FIXME: Support "parameterTypes" and "hex". | ||
const bool module = GetBoolean(format, "module").value_or(false); | ||
const bool line = GetBoolean(format, "line").value_or(false); | ||
const bool parameters = GetBoolean(format, "parameters").value_or(false); | ||
const bool parameter_names = | ||
GetBoolean(format, "parameterNames").value_or(false); | ||
const bool parameter_values = | ||
GetBoolean(format, "parameterValues").value_or(false); | ||
|
||
// Only change the format string if we have to. | ||
if (module || line || parameters || parameter_names || parameter_values) { | ||
std::string format_str; | ||
llvm::raw_string_ostream os(format_str); | ||
|
||
if (module) | ||
os << "{${module.file.basename} }"; | ||
|
||
if (line) | ||
os << "{${line.file.basename}:${line.number}:${line.column} }"; | ||
|
||
if (parameters || parameter_names || parameter_values) | ||
os << "{${function.name-with-args}}"; | ||
else | ||
os << "{${function.name-without-args}}"; | ||
|
||
lldb::SBError error; | ||
frame_format = lldb::SBFormat(format_str.c_str(), error); | ||
assert(error.Success()); | ||
} | ||
} | ||
|
||
if (thread.IsValid()) { | ||
const auto start_frame = | ||
GetInteger<uint64_t>(arguments, "startFrame").value_or(0); | ||
const auto levels = GetInteger<uint64_t>(arguments, "levels").value_or(0); | ||
int64_t offset = 0; | ||
bool reached_end_of_stack = | ||
FillStackFrames(dap, thread, stack_frames, offset, start_frame, | ||
levels == 0 ? INT64_MAX : levels); | ||
bool reached_end_of_stack = FillStackFrames( | ||
dap, thread, frame_format, stack_frames, offset, start_frame, | ||
levels == 0 ? INT64_MAX : levels, include_all); | ||
body.try_emplace("totalFrames", | ||
start_frame + stack_frames.size() + | ||
(reached_end_of_stack ? 0 : StackPageSize)); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
But I could not see why this test is skipped on windows
there is a
#include <unistd.h>
but it is not used any whereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. All the tests in this file are skipped on Windows for as far as the history goes back. I can try removing all of them in a followup and see what the Windows bot say.