[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 20:35:15 PST 2025


================
@@ -3801,6 +3801,23 @@ void request_variables(const llvm::json::Object &request) {
       variable_name_counts[GetNonNullVariableName(variable)]++;
     }
 
+    // Show return value if there is any ( in the top frame )
+    auto process = g_dap.target.GetProcess();
+    auto selected_thread = process.GetSelectedThread();
+    lldb::SBValue stop_return_value = selected_thread.GetStopReturnValue();
+    if (stop_return_value.IsValid() &&
+        (selected_thread.GetSelectedFrame().GetFrameID() == 0)) {
+      auto renamed_return_value = stop_return_value.Clone("(Return Value)");
+      int64_t return_ref = 0;
+      if (stop_return_value.MightHaveChildren() ||
+          stop_return_value.IsSynthetic()) {
+        return_ref = g_dap.variables.InsertExpandableVariable(
+            stop_return_value, /*is_permanent=*/false);
+      }
+      variables.emplace_back(CreateVariable(renamed_return_value, return_ref,
+                                            UINT64_MAX, hex, false));
----------------
vogelsgesang wrote:

aren't we also adding the return value to the "globals" and the "registers" group here? I assume it should only be part of "Locals"?

https://github.com/llvm/llvm-project/pull/106907


More information about the lldb-commits mailing list