Setting breakpoints

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

Setting breakpoints

dassburger (Bugzilla)
Hello.

We're using SpiderMonkey as an interpretator for embedded script
language in one of our projects. Right now I'm writing a debugger for
it. I have a problem with setting breakpoints while no scripts are at
active execution. User wants to open some script in the debugger, set
some breakpoints and execute it. How to set execution hooks with JSD in
such situations? JSD_SetExecutionHook requires JSDContext, JSDScript
and PCs, but they are not available before the script starts to
execute.

I tried to solve this by storing breakpoint lines and setting a hook at
the start of toplevel script execution. In the hook handler
JSD_SetExecutionHook is called for each breakpoint. But again, there
are problems, as toplevel code, and code inside functions belong to
different JSDScripts and I have no idea how to figure out which line
belongs to which script.

Could someone explain me The Right Way to work with JSD, please?

_______________________________________________
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: Setting breakpoints

James Ross
Dassburger wrote:
> I tried to solve this by storing breakpoint lines and setting a hook at
> the start of toplevel script execution. In the hook handler
> JSD_SetExecutionHook is called for each breakpoint. But again, there
> are problems, as toplevel code, and code inside functions belong to
> different JSDScripts and I have no idea how to figure out which line
> belongs to which script.

You're close - the right way is to set it when the script that contains
the line is loaded using script.baseLineNumber and script.lineExtent.

The debugger notifies you of each script as it is loaded (top-level
always comes first), and you just need to set the breakpoint in each
that overlaps the line (you can check if the line is executable within
that script, but I don't think you have to).

--
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: Setting breakpoints

dassburger (Bugzilla)
James Ross wrote:

> Dassburger wrote:
> > I tried to solve this by storing breakpoint lines and setting a hook at
> > the start of toplevel script execution. In the hook handler
> > JSD_SetExecutionHook is called for each breakpoint. But again, there
> > are problems, as toplevel code, and code inside functions belong to
> > different JSDScripts and I have no idea how to figure out which line
> > belongs to which script.
>
> You're close - the right way is to set it when the script that contains
> the line is loaded using script.baseLineNumber and script.lineExtent.
>
> The debugger notifies you of each script as it is loaded (top-level
> always comes first), and you just need to set the breakpoint in each
> that overlaps the line (you can check if the line is executable within
> that script, but I don't think you have to).

Thank you very much! This is exactly what I need.

For someone who stuck with the same problem: the handler for script
loaded/unloaded event is set by JSD_SetScriptHook(), execution hooks
are set in this handler. Base line number and line extent can be
retrieved with JSD_GetScriptBaseLineNumber() and
JSD_GetScriptLineExtent() respectively.

> --
> 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: Setting breakpoints

dassburger (Bugzilla)
In reply to this post by James Ross

James Ross wrote:

> Dassburger wrote:
> > I tried to solve this by storing breakpoint lines and setting a hook at
> > the start of toplevel script execution. In the hook handler
> > JSD_SetExecutionHook is called for each breakpoint. But again, there
> > are problems, as toplevel code, and code inside functions belong to
> > different JSDScripts and I have no idea how to figure out which line
> > belongs to which script.
>
> You're close - the right way is to set it when the script that contains
> the line is loaded using script.baseLineNumber and script.lineExtent.
>
> The debugger notifies you of each script as it is loaded (top-level
> always comes first), and you just need to set the breakpoint in each
> that overlaps the line (you can check if the line is executable within
> that script, but I don't think you have to).

How to check the executableness of a line within a script?

> --
> 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: Setting breakpoints

James Ross
Dassburger wrote:
> James Ross wrote:
>> The debugger notifies you of each script as it is loaded (top-level
>> always comes first), and you just need to set the breakpoint in each
>> that overlaps the line (you can check if the line is executable within
>> that script, but I don't think you have to).
>
> How to check the executableness of a line within a script?

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/js/jsd/idl/jsdIDebuggerService.idl&rev=1.33&mark=995#990

It's probably overkill in a lot of cases, but Venkman keeps track of
executable lines.

--
James Ross <[hidden email]>
ChatZilla Developer
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger