* [edbrowse-dev] 'this' in a breakpoint
@ 2019-06-05 5:20 Kevin Carhart
2019-06-05 5:49 ` [edbrowse-dev] " Kevin Carhart
2019-06-05 7:07 ` [edbrowse-dev] " Karl Dahlke
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Carhart @ 2019-06-05 5:20 UTC (permalink / raw)
To: edbrowse-dev
I think 'this' is always returning window within a breakpoint. So if you
have to echo let's say, a, where a = (this, b), I think you would get a
result that didn't reflect the real run.
To recreate, try it with jsrt
I went to the Circle function and added an alert that produces the
following:
when jsrt is run with no breakpoints, what is 'this' in function Circle?
[object Object]
And I assigned window.preserve_this = this
Then I echoed preserve_this from jdb:
jdb
preserve_this
[object Object]
ok(preserve_this)
r,c,a,q
Now I restored Circle, so jsrt is back to factory settings.
Now I put a breakpoint in Circle and echoed 'this' at the breakpoint
prompt.
b base
24269
bp: this
[object global]
Do you think my experiment is sound and can this be alleviated?
thanks
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* [edbrowse-dev] Re: 'this' in a breakpoint
2019-06-05 5:20 [edbrowse-dev] 'this' in a breakpoint Kevin Carhart
@ 2019-06-05 5:49 ` Kevin Carhart
2019-06-05 7:07 ` [edbrowse-dev] " Karl Dahlke
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Carhart @ 2019-06-05 5:49 UTC (permalink / raw)
To: edbrowse-dev
I hope it made sense from context but I goofed here
> have to echo let's say, a, where a = (this, b), I think you would get a
I meant to say... if a = some_function(this,b). And you're trying to
diagnose why a gets undefined and the code crashes trying to use a, for
instance.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [edbrowse-dev] 'this' in a breakpoint
2019-06-05 5:20 [edbrowse-dev] 'this' in a breakpoint Kevin Carhart
2019-06-05 5:49 ` [edbrowse-dev] " Kevin Carhart
@ 2019-06-05 7:07 ` Karl Dahlke
1 sibling, 0 replies; 3+ messages in thread
From: Karl Dahlke @ 2019-06-05 7:07 UTC (permalink / raw)
To: edbrowse-dev
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
Even if you could pass this to the eval function, and there are ways to do it, like eval.call(this,$bp), native eval seems to have no respect for this.
It doesn't inject this into the compilation of the string.
I fed this to the duktape shell and to the mozilla js shell.
You would expect to get 3 and 3, but we get 3 and then undefined.
t = {x:3, eval:eval, a:function(){print(this.x)}}; t.a(); t.eval("this.x");
Unless there is some other clever workaround, you'd have to say window.z=this,eval($bp)
and refer to z as needed, assuming z was not already a local variable, and remembering to delete z when done (cleaning up),
or var z = this; eval($bp); if the point of injection allows that syntax.
This is getting kinda awkward but it's all I have.
Karl Dahlke
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-05 7:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 5:20 [edbrowse-dev] 'this' in a breakpoint Kevin Carhart
2019-06-05 5:49 ` [edbrowse-dev] " Kevin Carhart
2019-06-05 7:07 ` [edbrowse-dev] " Karl Dahlke
edbrowse-dev - development list for edbrowse
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://inbox.vuxu.org/edbrowse-dev
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V1 edbrowse-dev edbrowse-dev/ http://inbox.vuxu.org/edbrowse-dev \
edbrowse-dev@edbrowse.org
public-inbox-index edbrowse-dev
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://inbox.vuxu.org/vuxu.archive.edbrowse.dev
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git