Skip to content

Commit 42e3bd5

Browse files
committed
[lldb-dap] Fix: only show return values in the local scope.
1 parent b53a1d0 commit 42e3bd5

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ def test_return_variables(self):
688688
threads = self.dap_server.get_threads()
689689
for thread in threads:
690690
if thread.get("reason") == "breakpoint":
691-
# We have a thread that
692691
thread_id = thread["id"]
693692

694693
self.stepOut(threadId=thread_id)

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,7 +4192,7 @@ void request_variables(DAP &dap, const llvm::json::Object &request) {
41924192
if (num_children == 0 && variablesReference == VARREF_LOCALS) {
41934193
// Check for an error in the SBValueList that might explain why we don't
41944194
// have locals. If we have an error display it as the sole value in the
4195-
// the locals.
4195+
// locals.
41964196

41974197
// "error" owns the error string so we must keep it alive as long as we
41984198
// want to use the returns "const char *"
@@ -4225,21 +4225,23 @@ void request_variables(DAP &dap, const llvm::json::Object &request) {
42254225
variable_name_counts[GetNonNullVariableName(variable)]++;
42264226
}
42274227

4228-
// Show return value if there is any ( in the top frame )
4229-
auto process = g_dap.target.GetProcess();
4230-
auto selected_thread = process.GetSelectedThread();
4231-
lldb::SBValue stop_return_value = selected_thread.GetStopReturnValue();
4232-
if (stop_return_value.IsValid() &&
4233-
(selected_thread.GetSelectedFrame().GetFrameID() == 0)) {
4234-
auto renamed_return_value = stop_return_value.Clone("(Return Value)");
4235-
int64_t return_var_ref = 0;
4236-
if (stop_return_value.MightHaveChildren() ||
4237-
stop_return_value.IsSynthetic()) {
4238-
return_var_ref = g_dap.variables.InsertExpandableVariable(
4239-
stop_return_value, /*is_permanent=*/false);
4228+
// Show return value if there is any ( in the local top frame )
4229+
if (variablesReference == VARREF_LOCALS) {
4230+
auto process = g_dap.target.GetProcess();
4231+
auto selected_thread = process.GetSelectedThread();
4232+
lldb::SBValue stop_return_value = selected_thread.GetStopReturnValue();
4233+
if (stop_return_value.IsValid() &&
4234+
(selected_thread.GetSelectedFrame().GetFrameID() == 0)) {
4235+
auto renamed_return_value = stop_return_value.Clone("(Return Value)");
4236+
int64_t return_var_ref = 0;
4237+
if (stop_return_value.MightHaveChildren() ||
4238+
stop_return_value.IsSynthetic()) {
4239+
return_var_ref = g_dap.variables.InsertExpandableVariable(
4240+
stop_return_value, /*is_permanent=*/false);
4241+
}
4242+
variables.emplace_back(CreateVariable(
4243+
renamed_return_value, return_var_ref, UINT64_MAX, hex, false));
42404244
}
4241-
variables.emplace_back(CreateVariable(renamed_return_value, return_var_ref,
4242-
UINT64_MAX, hex, false));
42434245
}
42444246

42454247
// Now we construct the result with unique display variable names

0 commit comments

Comments
 (0)