JavaScript-debugging from an extension
"Philipp Vogt" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jsdebugger |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello!
I want to watch the execution of JavaScript-Programs in webpages.
So I wrote an extension with the information about the
debuggerservice
(http://www.xulplanet.com/references/xpcomref/comps/c_jsjsddebuggerser
vice1.html) and venkman (http://www.mozilla.org/projects/venkman/). I
was able to write a scriptHook-handler which gets called each time a
script in a website is detected. Now I want to set breakpoints to
each line, to follow execution. But none of my other hooks
(executionHook, debuggerHook, debugHook etc.) is called.
Can someone tell me what steps are necessary to set a breakpoint on
each line of a script in a webpage and how to set up a handler that
gets called each time? Or some pointers to
documentation/websites/faqs/howtos/books etc.?
That's how I set the breakpoints:
jsdScript is a parameter of scriptHook.onCreate:
if (jsdScript) {
// no internal scripts
if ((jsdScript.fileName.indexOf("http://")==0) ||
(jsdScript.fileName.indexOf("https://")==0) ||
(jsdScript.fileName.indexOf("file:")==0)) {
// set script to debugable
jsdScript.flags |= FLAG_DEBUG;
var lines = String(jsdScript.functionSource).split("\n");
var end = jsdScript.baseLineNumber + jsdScript.lineExtent;
for (var i = jsdScript.baseLineNumber; i <= end; ++i) {
result += "lines[" + i + "/" + end + "]=" + lines[i] + "\n";
try {
// isLineExecutable throws exceptions :-( any suggestions?
// if (jsdScript.isLineExecutable(i, PCMAP_PRETTYPRINT)) {
// calculate pc from linenumber
var mypc = jsdScript.lineToPc(i, PCMAP_SOURCETEXT);
// set breakpoint
jsdScript.setBreakpoint(mypc);
// }
} catch (e) {
// print_error("scriptInfo: ",e);
}
}
}
}
regards
Philipp
- --
Philipp Vogt
Student
Informatik TU-Wien
EMail : [email protected]
pgp fingerprint: F8B3 EFF8 C6D2 31E1 E855 3959 942D 24EA D66B B8A4
pgp-schluessel: http://members.chello.at/philipp.vogt/vogge.asc
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1
iQA/AwUBQTx4seOzKhTmfGETEQJmWwCgpfp4vUI2mfVq0wslhUQGsrzWc1kAoNLn
hVJbKVXcORuwx3l9aMdvLiJI
=Pys6
-----END PGP SIGNATURE-----