debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Scopes]  does not show function's return value

Open tromey opened this issue 9 years ago • 22 comments

The old debugger would show the function's return value on stepping out, like this:

screenshot from 2017-07-20 10-21-00

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.

tromey avatar Jul 20 '17 16:07 tromey

You can test it out w/ this test page locally: http://localhost:8000/integration/examples/doc-return-values.html

jasonLaster avatar Jul 20 '17 16:07 jasonLaster

I can reproduce it with the booleans example without having to clone the repository: https://devtools-html.github.io/debugger-examples/examples/booleans/

tromey avatar Jul 20 '17 16:07 tromey

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.

tromey avatar Jul 20 '17 16:07 tromey

i tried to reproduce this, i get this

Looks like it works now. Or am i misunderstanding something?

bomsy avatar Jul 26 '17 11:07 bomsy

That looks correct to me.

tromey avatar Jul 26 '17 13:07 tromey

Cool thanks! this looks like its fixed, will do a bit more testing and close this

bomsy avatar Jul 26 '17 13:07 bomsy

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?

codehag avatar Jul 27 '17 12:07 codehag

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.

yurydelendik avatar Jul 27 '17 14:07 yurydelendik

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 avatar Jul 27 '17 14:07 tromey

@tromey That would be nice.

jasonLaster avatar Jul 27 '17 14:07 jasonLaster

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)

yurydelendik avatar Jul 27 '17 14:07 yurydelendik

@tromey @yurydelendik lets move this to a more specific bugzilla ticket.

jasonLaster avatar Jul 27 '17 14:07 jasonLaster

lets move this to a more specific bugzilla ticket

https://bugzilla.mozilla.org/show_bug.cgi?id=923975

tromey avatar Jul 27 '17 14:07 tromey

FWIW I tried this with a new artifact build based on today's inbound tip, and I can still reproduce the problem.

tromey avatar Jul 27 '17 14:07 tromey

i tested it on the next branch seems to be fixed there

bomsy avatar Jul 27 '17 16:07 bomsy

#3813 has another example of this.

jasonLaster avatar Aug 30 '17 02:08 jasonLaster

@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: capture d ecran de 2017-09-18 15-50-59

jasonLaster avatar Sep 27 '17 15:09 jasonLaster

Here's a quick summary of how to pick up this work:

  1. re-add the mochitest which exercised this behavior: #4188. You should be able to re-run the test docs and see the test fail

  2. reproduce the bug locally by going to the test example and pausing in returnSomething. See the screenshots from the launchpad and nightly below

  3. 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:

jasonLaster avatar Oct 18 '17 18:10 jasonLaster

I've got the browser_dbg-returnvalues.js mochitest working again. Going to start looking at the failure.

jimblandy avatar Oct 19 '17 22:10 jimblandy

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 call getSpecialVariables, which shows the return value if present. Unfortunately, this call never happens: pauseInfo.frame.scope is undefined, so it has no idea which scope is the currently executing frame's. Intriguingly, pauseInfo.frame.scope is set; its value is just undefined.
  • I looked at the pause packets we're getting from the server; one is shown below. Note that the frame property has type "call", which the protocol documentation says means it should have an environment property. It does not.
  • As a sanity check, I made sure the client is indeed expecting an environment property there. Indeed:

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
    }
  }
}

jimblandy avatar Oct 26 '17 05:10 jimblandy