Re: jsdIStackFrame.pc semantics

"John J. Barton" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
Ok now I am starting over.  I realize this may all be too complicated to 
sort out.

Here is my new example, a .js file:
---
var dynamic = "var m = 'm';\nvar a;\na = 1 + 2;\na += b;  // line 4";
function first() {
	dump("enter first\n");
	second();  // line 4
	var x1  = 1;
	var y1 = 1;
	var z1 = x1 + y1;
	return z1;
}
function second() {
	dump("enter second\n");
	eval(dynamic);  // line 12
	var x2  = 1;
	var y2 = 1;
	var z2 = x2 + y2;
	return z2;
}
---
I call first() in window.onload.  Here is my stack trace, the format is
Each frame:
<this>.<function>() baseline-extent@pcToLine: line[pcToLine - 2]
where all these values are from frame.script.
Each source line:
(lineToPC)line: lines[line]
where the lines array is from frame.script.functionSource.split('\n');
When I see a line number equal to delta baseline +1 I print >
When I print > and the line contains "eval", I print a line =-=-=
When I see a line number equal to pcToLine I print !

Things to notice:
   1) line[pcToLine - 2] correctly identifies the call except in eval; in
that case its off by one.
   2) line[pcToLine - 1] is too high by one except in eval body ('!' 
lines). (lines is zero based so lines[pcToLine - 1] is the line numbered
pcToline.
   3) The difference in base lines ('>') identifies the eval. (BTW also 
true for nested eval).
   4) The lineToPc gives zero if the line is before the call point.


---
FireclipseErrorReporter.dumpStack: PRETTYPRINT
Window.second() 12-4@4:     a = 3;
(0)1:    var m = "m";
(3)2:    var a;
(20)3:    a = 3;
(30)!:    a += b;
(30)5:
Window.second() 10-7@4:         eval(dynamic);
(0)1:    function second() {
(0)2:        dump("enter second\n");
(0)>:        eval(dynamic);
=-=-= eval =-=-=
(11)!:        var x2 = 1;
(22)5:        var y2 = 1;
(27)6:        var z2 = x2 + y2;
(32)7:        return z2;
(43)8:    }
Window.first() 2-7@4:         second();
(0)1:    function first() {
(0)2:        dump("enter first\n");
(0)3:        second();
(11)!:        var x1 = 1;
(19)5:        var y1 = 1;
(24)6:        var z1 = x1 + y1;
(29)7:        return z1;
(40)8:    }
---
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.