[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:11:37 PDT 2024


https://github.com/Da-Viper updated https://github.com/llvm/llvm-project/pull/106907

>From 2ca64edb00d1f7b9d2938c9db32644c4a8cbc13e Mon Sep 17 00:00:00 2001
From: Ezike Ebuka <yerimyah1 at gmail.com>
Date: Sun, 1 Sep 2024 13:48:41 +0100
Subject: [PATCH 1/2] Add: show return value on step out

---
 lldb/tools/lldb-dap/lldb-dap.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

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);

>From 8119240ca46e0e9d25ebc1b9c41d1eb9bd4f9ee2 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka <yerimyah1 at gmail.com>
Date: Sun, 1 Sep 2024 14:10:54 +0100
Subject: [PATCH 2/2] format file

---
 lldb/tools/lldb-dap/lldb-dap.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index c9116c62c46b5e..bf87dd838c8a74 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -3809,7 +3809,7 @@ void request_variables(const llvm::json::Object &request) {
         (selectedThread.GetSelectedFrame().GetFrameID() == 0)) {
       auto renamedReturnValue = stopReturnValue.Clone("(Return Value)");
       variables.emplace_back(
-          CreateVariable(renamedReturnValue,0, UINT64_MAX, hex, false));
+          CreateVariable(renamedReturnValue, 0, UINT64_MAX, hex, false));
     }
 
     // Now we construct the result with unique display variable names



More information about the lldb-commits mailing list