Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Show function return value in the debugger #3214

Open
Gruntfuggly opened this issue Feb 25, 2019 · 15 comments
Open

Feature Request: Show function return value in the debugger #3214

Gruntfuggly opened this issue Feb 25, 2019 · 15 comments

Comments

@Gruntfuggly
Copy link

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?

@Gruntfuggly Gruntfuggly changed the title Feature Request: Show function return value Feature Request: Show function return value in the debugger Feb 25, 2019
@natrist
Copy link

natrist commented Apr 16, 2019

I also think you should be able to see the return value of a function by hovering it, just like in Visual Studio.

@HorstBaerbel
Copy link

Imo this is pretty basic and pretty important. I wonder why so few people miss this...

@dreamer2q
Copy link

Why not implement this feature since gdb supports to inspector the return value from a function.

@Trass3r
Copy link

Trass3r commented Jul 22, 2020

Should be shown in the variables view after exiting or stepping over a function, just like in VS.
Requires DAP support I guess, @weinand?

@weinand
Copy link

weinand commented Jul 22, 2020

@Trass3r no, VS Code's new JavaScript debugger shows return values without DAP support:

2020-07-22_21-25-52

@Trass3r
Copy link

Trass3r commented Jul 22, 2020

Apparently this commit.
But a bit weird to see the return value while being inside the function rather than after returning.

@weinand
Copy link

weinand commented Jul 22, 2020

@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.

@connor4312
Copy link
Member

connor4312 commented Jul 22, 2020

@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.

@weinand
Copy link

weinand commented Jul 22, 2020

@connor4312 thanks for your confirmation that you are not using private protocol! :-)

@Trass3r
Copy link

Trass3r commented Jul 23, 2020

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.

@Trass3r
Copy link

Trass3r commented Aug 5, 2020

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"

https://github.com/microsoft/MIEngine/blob/54b7d6b6dcc11d99297bcad8df765870f4e80da0/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs#L1238

Trass3r added a commit to Trass3r/MIEngine that referenced this issue Aug 7, 2020
@Trass3r
Copy link

Trass3r commented Aug 7, 2020

I got a prototype of the functionality when stepping out. It is indeed a pure adapter change.

Trass3r added a commit to Trass3r/MIEngine that referenced this issue Aug 18, 2020
Trass3r added a commit to Trass3r/MIEngine that referenced this issue Aug 28, 2020
Trass3r added a commit to Trass3r/MIEngine that referenced this issue Sep 5, 2020
Trass3r added a commit to Trass3r/MIEngine that referenced this issue Sep 17, 2020
Trass3r added a commit to Trass3r/MIEngine that referenced this issue Sep 17, 2020
WardenGnaw pushed a commit to microsoft/MIEngine that referenced this issue Sep 18, 2020
@Gruntfuggly
Copy link
Author

Not sure when this changed, but I now see

$ReturnValue: <...>

in the local variables.

Thank you!

@Trass3r
Copy link

Trass3r commented Jun 16, 2021

Yeah fixed in microsoft/MIEngine#1036, but only when stepping out, not over.

https://sourceware.org/bugzilla/show_bug.cgi?id=26354

@gaowujie2004
Copy link

Hello, what if it's a native function? Vscode debugging cannot go inside native functions.

Example:
document.querySelect('html')

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

No branches or pull requests

10 participants