Feature Request: Show function return value in the debugger
Gruntfuggly opened this issue ยท 15 comments
Would it be possible to show the last function return value somewhere in the debugger window - preferrably variables?
I know it's possible to get at using gdb commands, but it's fairly convoluted. Not sure how difficult it is on Windows though?
I also think you should be able to see the return value of a function by hovering it, just like in Visual Studio.
Imo this is pretty basic and pretty important. I wonder why so few people miss this...
Why not implement this feature since gdb supports to inspector the return value from a function.
Should be shown in the variables view after exiting or stepping over a function, just like in VS.
Requires DAP support I guess, @weinand?
@Trass3r no, VS Code's new JavaScript debugger shows return values without DAP support:
Apparently this commit.
But a bit weird to see the return value while being inside the function rather than after returning.
@connor4312 VS Code should not use private protocol. If DAP is not sufficient to support showing return values, please create a DAP feature request.
@Trass3r you are invited to file a feature request for whatever you want to add to the DAP.
@weinand js-debug doesn't use anything private/special in DAP. We just return a variable that we name "Return value."
But a bit weird to see the return value while being inside the function rather than after returning.
js-debug will show the return value whenever it's present in the information we get from the runtime. This happens right after you step over a "return" statement, before the function is popped from the stack (though if you're running with sourcemaps, this location can be obscured; tooling seems to be somewhat inconsistent in mapping the whitespace range after return statements)
I agree that this is something that can and should be handled adapter side. We do some fairly advanced things with the return values in js-debug (e.g. allowing them to be used in watch expressions and the repl) and I never ran into a limitation imposed by the DAP.
@connor4312 thanks for your confirmation that you are not using private protocol! :-)
Interesting read: https://stackoverflow.com/questions/267674/how-to-inspect-the-return-value-of-a-function-in-gdb
So in theory instead of stepping over a call you could do something like stepping into it and then execute finish. Or a platform-dependent approach like inspecting RAX etc.
Indeed the stopped event after stepping out contains the return value:
->*stopped,reason="function-finished",frame={addr="0x00007ffff7cef3de",func="myouterfunc",args=[{name="this",value="0x5555556acd20"}],file="file.cpp",fullname="file.cpp",line="67"},gdb-result-var="$1",return-value="(ReturnType &) @0x5555556b2a10: {............}",thread-id="1",stopped-threads="all",core="2"
I got a prototype of the functionality when stepping out. It is indeed a pure adapter change.
Not sure when this changed, but I now see
$ReturnValue: <...>
in the local variables.
Thank you!
Yeah fixed in microsoft/MIEngine#1036, but only when stepping out, not over.
Hello, what if it's a native function? Vscode debugging cannot go inside native functions.
Example:
document.querySelect('html')
