[Scopes] does not show function's return value
The old debugger would show the function's return value on stepping out, like this:

I don't see this in the new debugger.
I just made a simple function and then repeatedly clicked the step over button. Eventually it stops at the end of the function and shows the return value.
You can test it out w/ this test page locally: http://localhost:8000/integration/examples/doc-return-values.html
I can reproduce it with the booleans example without having to clone the repository: https://devtools-html.github.io/debugger-examples/examples/booleans/
To reproduce, open that page, put a breakpoint in the makeBooleans function, then click the button. Then click "step over" repeatedly. It will double stop at the "}" (which is what I was looking at when I found this); the second stop ought to show the return value.
i tried to reproduce this, i get this

Looks like it works now. Or am i misunderstanding something?
That looks correct to me.
Cool thanks! this looks like its fixed, will do a bit more testing and close this
I think I found what is happening. the last bracket requires that you step over twice, it doesnt show the return value on the first step.
I think we don't want to have two steps at the end of the function. any ideas on how to avoid that?
I think we don't want to have two steps at the end of the function. any ideas on how to avoid that?
So Debugger API shows return value at Debugger.Frame::onPop -- you cannot ignore this one. It comes after last step, which can be somehow ignored, but it is hard. A frame has location (offset) property, but it does not give you much.
I think we don't want to have two steps at the end of the function. any ideas on how to avoid that?
This is what I was looking into when I found that I couldn't see the <return> at all.
I'm not sure whether I'll implement it or not, but the basic idea is to add a new debugger API so the server can tell whether it's stopped at a return opcode, and, if so, keep going until the frame pop.
@tromey That would be nice.
to add a new debugger API
@tromey I don't think you needs a new api -- all you need to disable breaking point in SpiderMonkey just before frame pops. (I know how to do it for wasm part -- I was modeling it after the JS behavior)
@tromey @yurydelendik lets move this to a more specific bugzilla ticket.
lets move this to a more specific bugzilla ticket
https://bugzilla.mozilla.org/show_bug.cgi?id=923975
FWIW I tried this with a new artifact build based on today's inbound tip, and I can still reproduce the problem.
i tested it on the next branch seems to be fixed there
#3813 has another example of this.
@julienw talks about it here too #4064
--
When stepping in some code, the "step out" button allows to wait at the end of the current function, so that we can inspect the final state of the function's variables before actually stepping out. This is useful.
However we can't inspect the return value itself. This would be a very useful addition.
Note: this was possible in the old debugger so we should have the data already:

Here's a quick summary of how to pick up this work:
-
re-add the mochitest which exercised this behavior: #4188. You should be able to re-run the test docs and see the test fail
-
reproduce the bug locally by going to the test example and pausing in
returnSomething. See the screenshots from the launchpad and nightly below -
observe the pause data in the pause reducer and how it is used in the scopes util. Hint, the client HAS the correct data on step out.
NOTE: there is a weird double step when stepping out that is distracting... and is in a server-side bug :)
Launchpad
Nightly
Console
why.frameFinished.return exists :smile:
I've got the browser_dbg-returnvalues.js mochitest working again. Going to start looking at the failure.
This is kind of interesting.
getScopes(utils/scopes.js) is trying to build the list of scopes to display in the panel. It would like to recognize the scope of the currently executing frame, to display it specially—in particular, to callgetSpecialVariables, which shows the return value if present. Unfortunately, this call never happens:pauseInfo.frame.scopeisundefined, so it has no idea which scope is the currently executing frame's. Intriguingly,pauseInfo.frame.scopeis set; its value is justundefined.- I looked at the pause packets we're getting from the server; one is shown below. Note that the
frameproperty has type"call", which the protocol documentation says means it should have anenvironmentproperty. It does not. - As a sanity check, I made sure the client is indeed expecting an environment property there. Indeed:
- paused (client/firefox/events.js) receives each pause packet, and passes it to...
- createPause (client/firefox/create.js), which passes the frame to...
- [createFrame (client/firefox/create.js)][createFrame], which checks
frame.environment.
The pause packet
Here's the pause packet we got [edit: had wrong packet, but the story is the same]:
{
"from": "server1.conn47.child1/context27",
"type": "paused",
"actor": "server1.conn47.child1/pause8465",
"frame": {
"actor": "server1.conn47.child1/frame5656",
"type": "call",
"callee": {
"type": "object",
"actor": "server1.conn47.child1/pausedobj8466",
"class": "Function",
"extensible": true,
"frozen": false,
"sealed": false,
"name": "return_something",
"displayName": "return_something",
"parameterNames": [
"x"
],
"location": {
"url": "http://localhost:8000/integration/examples/doc-return-values.html",
"line": 8
}
},
"this": {
"type": "object",
"actor": "server1.conn47.child1/pausedobj8467",
"class": "Window",
"extensible": true,
"frozen": false,
"sealed": false,
"ownPropertyLength": 767,
"preview": {
"kind": "ObjectWithURL",
"url": "http://localhost:8000/integration/examples/doc-return-values.html"
}
},
"arguments": [
2
],
"where": {
"source": {
"actor": "server1.conn47.child1/source29",
"generatedUrl": null,
"url": "http://localhost:8000/integration/examples/doc-return-values.html",
"isBlackBoxed": false,
"isPrettyPrinted": false,
"isSourceMapped": false,
"sourceMapURL": null,
"introductionUrl": null,
"introductionType": null
},
"line": 11,
"column": 4
}
},
"poppedFrames": [],
"why": {
"type": "resumeLimit",
"frameFinished": {
"return": 2
}
}
}