Skip to content

Conversation

@da-viper
Copy link
Contributor

@da-viper da-viper commented Sep 1, 2024

show_return_values.mp4

@llvmbot
Copy link
Member

llvmbot commented Sep 1, 2024

@llvm/pr-subscribers-lldb

Author: None (Da-Viper)

Changes
show_return_values.mp4

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

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+11)
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);

@github-actions
Copy link

github-actions bot commented Sep 1, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@walter-erquinigo walter-erquinigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better!
Could you please write some tests?

@da-viper
Copy link
Contributor Author

@JDevlieghere was away for sometime could you please review this.

thanks

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-viper da-viper force-pushed the show_return_value_on_step_out branch from a5e336a to 42e3bd5 Compare February 13, 2025 13:25
@da-viper
Copy link
Contributor Author

Is there any that needs to be done one the PR?

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as long as this is well tested!

Copy link
Member

@vogelsgesang vogelsgesang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you 🙂

@vogelsgesang
Copy link
Member

@da-viper Can you rebase and merge this PR by yourself? Or do you need somebody to merge it on your behalf?

@da-viper da-viper force-pushed the show_return_value_on_step_out branch from 04db61f to 4453e42 Compare March 1, 2025 23:01
@da-viper
Copy link
Contributor Author

da-viper commented Mar 1, 2025

@da-viper Can you rebase and merge this PR by yourself? Or do you need somebody to merge it on your behalf?

I rebased but I do not have the necessary permissions to merge

@JDevlieghere JDevlieghere merged commit 8ec0d60 into llvm:main Mar 2, 2025
12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 2, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building lldb,llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/13574

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/evaluate/TestDAP_evaluate.py (1171 of 2097)
PASS: lldb-api :: tools/lldb-dap/server/TestDAP_server.py (1172 of 2097)
PASS: lldb-api :: tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (1173 of 2097)
UNSUPPORTED: lldb-api :: tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py (1174 of 2097)
PASS: lldb-api :: tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py (1175 of 2097)
PASS: lldb-api :: tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py (1176 of 2097)
PASS: lldb-api :: tools/lldb-dap/step/TestDAP_step.py (1177 of 2097)
PASS: lldb-api :: tools/lldb-dap/threads/TestDAP_threads.py (1178 of 2097)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestAppleSimulatorOSType.py (1179 of 2097)
PASS: lldb-api :: tools/lldb-dap/module/TestDAP_module.py (1180 of 2097)
FAIL: lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py (1181 of 2097)
******************** TEST 'lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children -p TestDAP_variables_children.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41)
  clang revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
  llvm revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']
[{'$__lldb_extensions': {'declaration': {'line': 16, 'path': '/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 8, 'evaluateName': 'indexed', 'id': 4, 'indexedVariables': 1, 'memoryReference': '0xFFFFC1E13ECB', 'name': 'indexed', 'type': 'Indexed', 'value': 'Indexed @ 0xffffc1e13ecb', 'variablesReference': 4}, {'$__lldb_extensions': {'declaration': {'line': 17, 'path': '/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 10, 'evaluateName': 'not_indexed', 'id': 5, 'memoryReference': '0xFFFFC1E13ECA', 'name': 'not_indexed', 'type': 'NotIndexed', 'value': 'NotIndexed @ 0xffffc1e13eca', 'variablesReference': 5}, {'$__lldb_extensions': {'declaration': {'line': 18, 'path': '/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 12, 'evaluateName': 'non_primitive_result', 'id': 6, 'memoryReference': '0xFFFFC1E13EA8', 'name': 'non_primitive_result', 'type': 'NonPrimitive', 'value': 'NonPrimitive @ 0xffffc1e13ea8', 'variablesReference': 6}]
========= DEBUG ADAPTER PROTOCOL LOGS =========
1740875526.826271534 stdin/stdout --> 
Content-Length: 344

{
  "arguments": {
    "adapterID": "lldb-native",
    "clientID": "vscode",
    "columnsStartAt1": true,
    "linesStartAt1": true,
    "locale": "en-us",
    "pathFormat": "path",
    "sourceInitFile": false,
    "supportsRunInTerminalRequest": true,
    "supportsStartDebuggingRequest": true,
    "supportsVariablePaging": true,
    "supportsVariableType": true
  },
  "command": "initialize",
  "seq": 1,
  "type": "request"
}
1740875526.828252316 stdin/stdout <-- 
Content-Length: 1631

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 2, 2025

LLVM Buildbot has detected a new failure on builder lldb-arm-ubuntu running on linaro-lldb-arm-ubuntu while building lldb,llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/12219

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/stackTrace/TestDAP_stackTrace.py (1173 of 2915)
PASS: lldb-api :: tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py (1174 of 2915)
PASS: lldb-api :: tools/lldb-dap/server/TestDAP_server.py (1175 of 2915)
PASS: lldb-api :: tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (1176 of 2915)
UNSUPPORTED: lldb-api :: tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py (1177 of 2915)
PASS: lldb-api :: tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py (1178 of 2915)
PASS: lldb-api :: tools/lldb-dap/step/TestDAP_step.py (1179 of 2915)
PASS: lldb-api :: tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py (1180 of 2915)
PASS: lldb-api :: tools/lldb-dap/threads/TestDAP_threads.py (1181 of 2915)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestAppleSimulatorOSType.py (1182 of 2915)
FAIL: lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py (1183 of 2915)
******************** TEST 'lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch armv8l --build-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children -p TestDAP_variables_children.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41)
  clang revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
  llvm revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']
[{'$__lldb_extensions': {'declaration': {'line': 16, 'path': '/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 8, 'evaluateName': 'indexed', 'id': 4, 'indexedVariables': 1, 'memoryReference': '0xFFF74EB3', 'name': 'indexed', 'type': 'Indexed', 'value': 'Indexed @ 0xfff74eb3', 'variablesReference': 4}, {'$__lldb_extensions': {'declaration': {'line': 17, 'path': '/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 10, 'evaluateName': 'not_indexed', 'id': 5, 'memoryReference': '0xFFF74EB2', 'name': 'not_indexed', 'type': 'NotIndexed', 'value': 'NotIndexed @ 0xfff74eb2', 'variablesReference': 5}, {'$__lldb_extensions': {'declaration': {'line': 18, 'path': '/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 12, 'evaluateName': 'non_primitive_result', 'id': 6, 'memoryReference': '0xFFF74E98', 'name': 'non_primitive_result', 'type': 'NonPrimitive', 'value': 'NonPrimitive @ 0xfff74e98', 'variablesReference': 6}]
========= DEBUG ADAPTER PROTOCOL LOGS =========
1740875904.488634348 stdin/stdout --> 
Content-Length: 344

{
  "arguments": {
    "adapterID": "lldb-native",
    "clientID": "vscode",
    "columnsStartAt1": true,
    "linesStartAt1": true,
    "locale": "en-us",
    "pathFormat": "path",
    "sourceInitFile": false,
    "supportsRunInTerminalRequest": true,
    "supportsStartDebuggingRequest": true,
    "supportsVariablePaging": true,
    "supportsVariableType": true
  },
  "command": "initialize",
  "seq": 1,
  "type": "request"
}
1740875904.491610289 stdin/stdout <-- 
Content-Length: 1631

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 2, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-windows running on linaro-armv8-windows-msvc-05 while building lldb,llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/141/builds/6707

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: tools/lldb-dap/stackTrace/TestDAP_stackTrace.py (1173 of 2091)
PASS: lldb-api :: tools/lldb-dap/send-event/TestDAP_sendEvent.py (1174 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py (1175 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py (1176 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/step/TestDAP_step.py (1177 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py (1178 of 2091)
PASS: lldb-api :: tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (1179 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py (1180 of 2091)
UNSUPPORTED: lldb-api :: tools/lldb-dap/threads/TestDAP_threads.py (1181 of 2091)
PASS: lldb-api :: tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py (1182 of 2091)
FAIL: lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py (1183 of 2091)
******************** TEST 'lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py' FAILED ********************
Script:
--
C:/Users/tcwg/scoop/apps/python/current/python.exe C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/llvm-project/lldb\test\API\dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib --env LLVM_INCLUDE_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/include --env LLVM_TOOLS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin --arch aarch64 --build-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex --lldb-module-cache-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-lldb\lldb-api --clang-module-cache-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-clang\lldb-api --executable C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/lldb.exe --compiler C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/clang.exe --dsymutil C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/dsymutil.exe --make C:/Users/tcwg/scoop/shims/make.exe --llvm-tools-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin --lldb-obj-root C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/tools/lldb --lldb-libs-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib --skip-category=watchpoint C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\tools\lldb-dap\variables\children -p TestDAP_variables_children.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41)
  clang revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
  llvm revision 8ec0d60e28f77149eef9c865515b79bc0a5e8f41
Skipping the following test categories: ['watchpoint', 'libc++', 'libstdcxx', 'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']

[{'$__lldb_extensions': {'declaration': {'line': 16, 'path': 'C:\\Users\\tcwg\\llvm-worker\\lldb-aarch64-windows\\llvm-project\\lldb\\test\\API\\tools\\lldb-dap\\variables\\children\\main.cpp'}}, 'declarationLocationReference': 8, 'evaluateName': 'indexed', 'id': 4, 'indexedVariables': 1, 'memoryReference': '0xAD9990F78B', 'name': 'indexed', 'type': 'Indexed', 'value': 'Indexed @ 0xad9990f78b', 'variablesReference': 4}, {'$__lldb_extensions': {'declaration': {'line': 17, 'path': 'C:\\Users\\tcwg\\llvm-worker\\lldb-aarch64-windows\\llvm-project\\lldb\\test\\API\\tools\\lldb-dap\\variables\\children\\main.cpp'}}, 'declarationLocationReference': 10, 'evaluateName': 'not_indexed', 'id': 5, 'memoryReference': '0xAD9990F78A', 'name': 'not_indexed', 'type': 'NotIndexed', 'value': 'NotIndexed @ 0xad9990f78a', 'variablesReference': 5}, {'$__lldb_extensions': {'declaration': {'line': 18, 'path': 'C:\\Users\\tcwg\\llvm-worker\\lldb-aarch64-windows\\llvm-project\\lldb\\test\\API\\tools\\lldb-dap\\variables\\children\\main.cpp'}}, 'declarationLocationReference': 12, 'evaluateName': 'non_primitive_result', 'id': 6, 'memoryReference': '0xAD9990F770', 'name': 'non_primitive_result', 'type': 'NonPrimitive', 'value': 'NonPrimitive @ 0xad9990f770', 'variablesReference': 6}]

========= DEBUG ADAPTER PROTOCOL LOGS =========

1740877711.230330706 stdin/stdout --> 

Content-Length: 344







{

  "arguments": {

    "adapterID": "lldb-native",

    "clientID": "vscode",

    "columnsStartAt1": true,


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants