Closed
Bug 1250785
Opened 9 years ago
Closed 9 years ago
this is not bound
Categories
(DevTools :: Debugger, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1249193
People
(Reporter: codacodercodacoder, Unassigned)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0
Build ID: 20160210153822
Steps to reproduce:
Stepped (F11) into a method someMethod called like this:
this.someMethod(...);
...
someMethod: function(args) {
var x, y; // <== debugger lands here
Actual results:
In the variables pane, "this" says "undefined"
Expected results:
"this" should evaluate to the correct context upon stepping into the function (F11 means step IN right?)
If I step (F10), the current statement doesn't change but "this" updates correctly to reflect the correct context.
There is some excuse for the (sometimes) annoying extra F10 required when returning from a function, why now another one at the head?
Would be nice to have a small testcase to reproduce the issue.
Component: Untriaged → Developer Tools: Debugger
Comment 3•9 years ago
|
||
Sounds like a dupe of 1249193.
As the screenshot is for Developer Edition, you're using Developer Edition, right?
You've set Version field to firefox 44 but the issue sounds like it's related to the change in firefox 45.
If you observe this issue also on Firefox 44, feel free to reopen this bug.
Here's the details for firefox 45 or later's case:
From bug 1132183 (firefox 45), `this` becomes a real binding, and at the beginning of the function (when the debugger steps into the function), the value of `this` binding is not yet set to expected value.
regression range:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=c3aa84cd334c&tochange=52d7c9292ecfc23a52835c49189dabd561b18675
Following is the bytecode for a function that contains `this` (e.g. function() { return this; }):
00000: functionthis <- (A)
00001: setlocal 0 <- (B)
00005: pop
main:
00006: getlocal 0 <- (C)
00010: return
00011: retrval
When you "Step In" to the function, debugger stops before instruction (A),
the value of `this` is stored in local slot 0, but it's set to expected value after instruction (B),
so the `this` field in the debugger shows `undefined`.
Then, when you click "Step", debugger stops before instruction (C),
so the `this` field in the debugger shows expected value.
(In reply to Tooru Fujisawa [:arai] from comment #3)
> Sounds like a dupe of 1249193.
>
> As the screenshot is for Developer Edition, you're using Developer Edition,
> right?
Yes. I had changed it to 46 but it seems not to have saved correctly.
> Here's the details for firefox 45 or later's case:
>
> From bug 1132183 (firefox 45), `this` becomes a real binding, and at the
> beginning of the function (when the debugger steps into the function), the
> value of `this` binding is not yet set to expected value.
>
> regression range:
>
> https://hg.mozilla.org/integration/mozilla-inbound/
> pushloghtml?fromchange=c3aa84cd334c&tochange=52d7c9292ecfc23a52835c49189dabd5
> 61b18675
>
>
> Following is the bytecode for a function that contains `this` (e.g.
> function() { return this; }):
>
> 00000: functionthis <- (A)
> 00001: setlocal 0 <- (B)
> 00005: pop
> main:
> 00006: getlocal 0 <- (C)
> 00010: return
> 00011: retrval
>
>
> When you "Step In" to the function, debugger stops before instruction (A),
> the value of `this` is stored in local slot 0, but it's set to expected
> value after instruction (B),
> so the `this` field in the debugger shows `undefined`.
>
> Then, when you click "Step", debugger stops before instruction (C),
> so the `this` field in the debugger shows expected value.
>
Yep, that explains what I'm seeing, thanks. However, I was unable to understand from this, are you saying it is, or is not, a bug? I say it is a bug (jn the sense that, it does the least expected thing).
1 - caller had `this`
2 - caller used `this` to make a call (at the callpoint) - press F11
3 - at the callee, the debugger UI stops at a line below the callee's definition line
myMethod: function(...) {
var ... // debugger UI STOPS here
As it has been explained above, I understand why, but it seems to me I am helping the debugger "do the right thing" with an unnecessary STEP instruction (F10). Consider the following
one: function(a) { debugger;
two: function(b) {
var ...; // breakpoint set here
In both `one` and `two`,
* `this` is set correctly.
* `a` and `b` are set correctly.
However, if you STEP INTO (F11) either of these methods, `this` is not set correctly while the args `a` and `b` ARE set correctly.
If the entire stack frame needed my help (ie the args were also not set yet) I could understand it better (but still would be annoying that the debugger needs my help to continue).
So, is this being treated as a bug?
Version: 44 Branch → 46 Branch
(In reply to Loic from comment #2)
> Would be nice to have a small testcase to reproduce the issue.
Huh? I gave the bug a small test case.
Comment 6•9 years ago
|
||
Yes, this is a bug that needs to be addressed somehow (I'm not sure what's the best solution tho).
it will be tracked in bug 1249193.
(In reply to Codacoder from comment #5)
> (In reply to Loic from comment #2)
> > Would be nice to have a small testcase to reproduce the issue.
>
> Huh? I gave the bug a small test case.
here, the testcase means a standalone HTML file that others can use it to reproduce the issue, so that it's clear that others are seeing same issue.
Comment 7•9 years ago
|
||
something like this.
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•