Re: jsdIStackFrame.pc semantics

"John J. Barton" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
Adam, James: sorry, I didn't realize how confusing my example
would be. Let me try to straighten this out.

I was just asking about the "normal" pcToLine at function calls,
not involving eval() or XMLHttpRequest for that matter.

My example used eval() because I have a workaround for bug #332176.
I know the line numbers in eval-ed code overlap the line numbers in
static source.  And that is why I am using PCMAP_PRETTYPRINT because
I don't have the source for the eval-ed code.  But I was just trying
to figure out line numbers for not-eval-ed code.

Just to make it more confusing, my heuristics for non-eval-ed code seem 
ok: I wouldn't be asking except that the heuristics don't work for 
eval-ed code.  So I wanted to understand the right answer for 
non-eval-ed code rather than relying on analysis of the jsd outputs.

So a bit more in direct response to Adam, then I'll repost a new example:

Adam L. Peller wrote:
> John, I may not be parsing your question correctly, but when you're
> inside the eval, the top of the stack will tell you you're at line 5 +
> whatever line of req.responseText you're at, right? (bug #332176)

The top of the stack gives both a line and a PC. The line is mostly 
garbage as a far as I see. The PC needs to be converted into a line with
pcToLine. If I use PRETTYPRINT it is relative to, well approximately,
the start of the function. If I use SOURCETEXT, ditto start of the file.
Its that "approximately" bit I was working on, see my next post.

> 
> You'll probably want PCMAP_SOURCETEXT if you're comparing to the
> actual source code.  PCMAP_PRETTYPRINT only makes sense if you compare
> against the source the way JSD formats it.

I'm only comparing to jsdIScript.functionSource which I believe is
decompiled from the bytecodes, ie PRETTYPRINT.  Eventually I want to
work with the source of eval-ed code so I don't yet know if I can even
have source.

> 
> -Adam
> 
>> I have code like this:
>> --------
>> var req = new XMLHttpRequest();
>>
>> req.onreadystatechange = function() {  // line 3
>>      if( req.readyState == 4) {
>>                 eval( req.responseText);  // line 5
>>      }
>> };
>> ---------
>>
>> When the eval() executes, within which line should I
>> expect the program counter for the caller? I expected
>> line 5, but it comes out on line 6. (Well the numerical
>> value is 4 since it comes out of pcToLine relative to
>> the start of the function).
>>
>> So one model is that the PC is somehow at the end of
>> the function call:
>>
>>                 eval( req.responseText);  // line 5
>> ---------------------------------------^
>> so it is just on the next line "barely".
>>
>> Or there is just another "off-by-one" problem in my code,
>> not the first I guess ;-).
>>
>> But I see one case where the PC points to the line
>> with the eval().
>>
>> This is all with PCMAP_PRETTYPRINT output, which I guess
>> really means source-like text decompiled from bytecodes.
>>
>> Thanks,
>> John.
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> dev-apps-js-debugger mailing list
>> [email protected]
>> https://lists.mozilla.org/listinfo/dev-apps-js-debugger
>>
>>
>> End of dev-apps-js-debugger Digest, Vol 11, Issue 6
>> ***************************************************
>>
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.