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

via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 1 06:03:57 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (Da-Viper)

<details>
<summary>Changes</summary>


https://github.com/user-attachments/assets/cff48c6f-37ae-4f72-b881-3eff4178fb3c



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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+11) 


``````````diff
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index c5c4b09f15622b..c9116c62c46b5e 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -3801,6 +3801,17 @@ 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 selectedThread = process.GetSelectedThread();
+    lldb::SBValue stopReturnValue = selectedThread.GetStopReturnValue();
+    if (stopReturnValue.IsValid() &&
+        (selectedThread.GetSelectedFrame().GetFrameID() == 0)) {
+      auto renamedReturnValue = stopReturnValue.Clone("(Return Value)");
+      variables.emplace_back(
+          CreateVariable(renamedReturnValue,0, UINT64_MAX, hex, false));
+    }
+
     // Now we construct the result with unique display variable names
     for (auto i = start_idx; i < end_idx; ++i) {
       lldb::SBValue variable = top_scope->GetValueAtIndex(i);

``````````

</details>


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


More information about the lldb-commits mailing list