Closed Bug 462704 Opened 16 years ago Closed 15 years ago

[jsd] incorrect lineExtent when a while loop ends a method

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.1

People

(Reporter: johnjbarton, Assigned: brendan)

References

Details

(Keywords: fixed1.9.1, Whiteboard: [firebug-p2] fixed-in-tracemonkey)

Attachments

(3 files)

When a function ends with a while loop, jsd gives a lineExtent value that makes the last line appear to be on the while keyword. This makes the line table incorrect and these Javascript functions cannot be breakpointed or single step.

For example, this method will have the wrong line extent unless the comment is removed.
    function inner() {
      console.log("prompt returned: ",x);
      while (x) {  // bug not occurring if s/while/if/;
        var msg = 'this code is reached'; // I want a breakpoint here
        alert(msg);
        break;
      }
      // If this line is not commented, the lineExtent is correct
      // console.log("prompt returned: ",x);
    }
A complete test case:

http://fbug.googlecode.com/svn/chromebug/tests/jsdTests@johnjbarton.com/content/jsd/jsdIScript/bugzilla-462704.js

The firefox extension:
http://fbug.googlecode.com/svn/chromebug/tests/jsdTests@johnjbarton.com

starts jsd and runs the test case. Tools -> Test Now or run firefox from the command line with -chrome chrome://jsdtest/content/testWebPage.html.
Blocks: 449452
Assignee: nobody → rginda
Component: General → JavaScript Debugger
Product: Firefox → Other Applications
QA Contact: general → venkman
Version: 3.0 Branch → 1.9.0 Branch
For reference,the original bug report:
http://code.google.com/p/fbug/issues/detail?id=1239
Whiteboard: [firebug-p2]
Attached file shell0.js
so... a xpcshell testcase is slightly easier for people to deal w/

from xpcshell:
load("shell0.js")
load("shell1.js") /* this is the testcase Test462704 */
test();
Assignee: rginda → general
Blocks: 371802
Component: JavaScript Debugger → JavaScript Engine
OS: Windows XP → All
Priority: -- → P2
Product: Other Applications → Core
QA Contact: venkman → general
Hardware: PC → All
Target Milestone: --- → mozilla1.9.1b2
Version: 1.9.0 Branch → Trunk
Assignee: general → brendan
Status: NEW → ASSIGNED
Attached file DEBUG jsshell testcase
Attachment #347488 - Attachment mime type: application/x-javascript → text/plain
Flags: wanted1.9.1+
Target Milestone: mozilla1.9.1b2 → mozilla1.9.1
Attached patch fixSplinter Review
Codegen changed for loops, which made this ancient bug bite harder. We sometimes need a line number note before JSOP_STOP. This patch emits one when js_EmitTree unwinds to top level and is about to return, which for top level of global and eval code (not function code) happens after each t.l. statement or declaration, but it can't hurt -- CG_CURRENT_LINE(cg) is updated to avoid redundant notes.

/be
Attachment #378763 - Flags: review?(mrbkap)
Comment on attachment 378763 [details] [diff] [review]
fix

Looks good to me, as far as I understand what's going on.
Attachment #378763 - Flags: review?(mrbkap) → review+
http://hg.mozilla.org/tracemonkey/rev/d8316d783668

/be
Whiteboard: [firebug-p2] → [firebug-p2] fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/d8316d783668
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Depends on: 494954
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: