Closed Bug 667925 Opened 13 years ago Closed 9 years ago

Line number is bogus on JSOP_TRACE opcodes

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

Attachments

(1 file)

print(disassemble("-l", function () {
    for (var i = 0;  // line 2
         i < 9;      // line 3
         i++) {      // line 4
        f();         // line 5
    }                // line 6
}));

00000:   2  zero
00001:   2  setlocal 0
00004:   2  pop
00005:   2  goto 22 (+17)
00008:   2  trace 0        <--- bogus
00011:   5  callgname "f"
00014:   5  call 0
00017:   5  pop
00018:   4  localinc 0
00021:   4  pop
00022:   3  getlocal 0
00025:   3  int8 9
00027:   3  lt
00028:   3  ifne 8 (-20)
00031:   6  stop

JSOP_TRACE gets the line number 2 just because the code immediately before it happens to be on line 2.

When stepping through this code in the debugger, your line numbers would go
    2 3   2 5 4 3   2 5 4 3   2 5 4 3   2 5 4 3...
which makes no sense.

It makes more sense for JSOP_TRACE to have the line number of the code immediately after it.
Attached patch v1Splinter Review
I discovered this while writing tests for the new breakpoint API in jsdbg2 branch (landing soon). In short, a breakpoint on line 2 of the above sample code shouldn't hit more than once, but it hits each time through the loop because of the JSOP_TRACE instruction.

So here's the fix. The heuristic is kind of lame, but it works in this case and makes my test pass.
Assignee: general → jorendorff
Attachment #542502 - Flags: review?(cdleary)
Attachment #542502 - Flags: review?(cdleary) → review+
Depends on: 672829
https://hg.mozilla.org/mozilla-central/rev/13c14153bd63
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: