JSD_EvaluateScriptInStackFrame and "var" variables

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

JSD_EvaluateScriptInStackFrame and "var" variables

dassburger (Bugzilla)
Hello!

Again me asking dumb questions. I'm stuck in the situation when I try
to do JSD_EvaluateScriptInStackFrame() while executing some hook
handler (interrupt hook and execution hook). This is the way I try to
implement "Evaluate/Modify" and "Watch" features of the debugger. The
problem arises if I try to evaluate something which contains "var"-ed
variables from the script being debugged. SpiderMonkey seems to report
that their values are undefined. I believe that the problem is somehow
related with "variables object" and "this object" as stated in the
comment to JS_EvaluateScript() in jsapi.h. However, I still can't
understand what is going on here and how to behave in such situation.
Could someone explain me?

_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: JSD_EvaluateScriptInStackFrame and "var" variables

dassburger (Bugzilla)
Here is the example script:

 1:  function a()
 2:  {
 3:    var x = 5;
 4:    y = 6;
 5:    edt1.Text = x+y;
 6:  }
 7:
 8:  var z = 1;
 9:
10:  a();

Suppose we have an execution hook at line 5. If I try to evaluate
scripts "x", "y", "z" in the hook handler with
JSD_EvaluateScriptInStackFrame(), I get following results "undefined",
"6", "1".

_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: JSD_EvaluateScriptInStackFrame and "var" variables

James Ross
Dassburger wrote:

> Here is the example script:
>
>  1:  function a()
>  2:  {
>  3:    var x = 5;
>  4:    y = 6;
>  5:    edt1.Text = x+y;
>  6:  }
>  7:
>  8:  var z = 1;
>  9:
> 10:  a();
>
> Suppose we have an execution hook at line 5. If I try to evaluate
> scripts "x", "y", "z" in the hook handler with
> JSD_EvaluateScriptInStackFrame(), I get following results "undefined",
> "6", "1".

That sounds very much like you're evaluating in the wrong end of the
stack frame - y and z are globals in that script, so it would make sense
of the results.

What's the frame you're using? The one passed to the execution hook
should be the right one.

--
James Ross <[hidden email]>
ChatZilla Developer
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: JSD_EvaluateScriptInStackFrame and "var" variables

dassburger (Bugzilla)
James Ross wrote:

> Dassburger wrote:
> > Here is the example script:
> >
> >  1:  function a()
> >  2:  {
> >  3:    var x = 5;
> >  4:    y = 6;
> >  5:    edt1.Text = x+y;
> >  6:  }
> >  7:
> >  8:  var z = 1;
> >  9:
> > 10:  a();
> >
> > Suppose we have an execution hook at line 5. If I try to evaluate
> > scripts "x", "y", "z" in the hook handler with
> > JSD_EvaluateScriptInStackFrame(), I get following results "undefined",
> > "6", "1".
>
> That sounds very much like you're evaluating in the wrong end of the
> stack frame - y and z are globals in that script, so it would make sense
> of the results.
>
> What's the frame you're using? The one passed to the execution hook
> should be the right one.

I get the frame with JSD_GetStackFrame(jsdc, jsdthreadstate), where
jsdc and jsdthreadstate are the arguments to the hook handler.

> --
> James Ross <[hidden email]>
> ChatZilla Developer

_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: JSD_EvaluateScriptInStackFrame and "var" variables

James Ross
Dassburger wrote:
> James Ross wrote:
>> What's the frame you're using? The one passed to the execution hook
>> should be the right one.
>
> I get the frame with JSD_GetStackFrame(jsdc, jsdthreadstate), where

Apparently that will give the right frame (well, it gives a frame info
NOT a real frame), but the lack of real details of what you're doing
make it impossible to speculate on what you've done wrong.

--
James Ross <[hidden email]>
ChatZilla Developer
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: JSD_EvaluateScriptInStackFrame and "var" variables

dassburger (Bugzilla)
James Ross wrote:

> Dassburger wrote:
> > James Ross wrote:
> >> What's the frame you're using? The one passed to the execution hook
> >> should be the right one.
> >
> > I get the frame with JSD_GetStackFrame(jsdc, jsdthreadstate), where
>
> Apparently that will give the right frame (well, it gives a frame info
> NOT a real frame), but the lack of real details of what you're doing
> make it impossible to speculate on what you've done wrong.

The problem is solved.
http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/97141c804dfa2f79/eea7977ac5ff8fa4?lnk=gst&q=Evaluate+JS_GetFrameCallObject&rnum=1#eea7977ac5ff8fa4

> --
> James Ross <[hidden email]>
> ChatZilla Developer

_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger