This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 216360 - Debugger stops at wrong line when code is changed
Summary: Debugger stops at wrong line when code is changed
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 7.3
Hardware: PC Linux
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
: 217259 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-08-03 11:51 UTC by Vladimir Riha
Modified: 2013-01-15 13:47 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-08-03 11:51:14 UTC
Consider following code:

function clone(el){
   iterator++;
   $(el).parent().append("<li>clone "+iterator+"</li>"); // breakpoint here
    }

Set the breakpoint to the line with jquery usage and run html file. When clone() function is called, code execution stops correctly on the line with breakpoint. Continue (F5). Now modify it like this (simple add a console.log line, nothing else):

...
 iterator++;
console.log("A");
   $(el).parent().append("<li>clone "+iterator+"</li>"); // breakpoint here
...

and save the file. File is refreshed in browser. Now when the clone() function is triggered, the code execution stops on the line with console.log(). Note that correct line is colored red and also line number in Breakpoints window reflects current (increased) line number of the line with jquery. 


Product Version: NetBeans IDE Dev (Build EaselCSS-428-on-20120803)
Java: 1.7.0_06-ea; Java HotSpot(TM) Client VM 23.2-b09
System: Linux version 3.0.0-23-generic running on i386; UTF-8; en_US (nb)
Comment 1 Martin Entlicher 2012-08-06 14:52:07 UTC
Listening on line changes is not implemented yet.
Comment 2 David Konecny 2012-08-23 06:03:28 UTC
*** Bug 217259 has been marked as a duplicate of this bug. ***
Comment 3 David Konecny 2012-08-23 06:05:33 UTC
It this hard to fix? Could it be resolved this week? :-)

Implementation wise I think you do not need to listen on changes but when debugging session is restarted (eg. on consequent Run operation) the breakpoints should be updated in WebKit runtime.
Comment 4 Martin Entlicher 2012-08-23 15:36:51 UTC
Fixed by changeset:   230787:c33dc69bfb45
http://hg.netbeans.org/web-main/rev/c33dc69bfb45

We re-submit the breakpoint after reload if the line has changed.
Comment 5 Vladimir Riha 2012-08-24 12:15:25 UTC
thanks a lot, seems to work quite good. I noticed one thing:

Let's say I have this code:

function dummyClipBoard2() {
    console.log("===== LOG ========"); // line breakpoint here
    print();
}

Now delete content of line (let's call it X) with the breakpoint, so result is:

function dummyClipBoard2() {

    print();
}

Now X is still red, and because the line is empty, code execution stops on the line X+1, (so print()), which is at the time green. The same happens if you add breakpoint to line that contains only comment. It stops at the next executed line. While I personally like this behavior, is this as expected/wanted? 

I checked Java debugging and with such case the java debugging fails with some message ("Not able to submit breakpoint LineBreakpoint...")...



Product Version: NetBeans IDE Dev (Build EaselCSS-556-on-20120824)
Java: 1.7.0_06; Java HotSpot(TM) Client VM 23.2-b09
System: Linux version 3.2.0-29-generic-pae running on i386; UTF-8; en_US (nb)
Comment 6 David Konecny 2012-08-26 20:34:24 UTC
When debugger session is started there are events coming back from debugger, eg. Debugger.breakpointResolved which tell us (I think) where exactly the breakpoint was resolved. Could we use them to automatically "adjust" breakpoint or put it into a "not a valid code breakpoint" state?
Comment 7 David Konecny 2012-08-27 21:14:39 UTC
I filed last comment as issue 217486.
Comment 8 Quality Engineering 2012-09-03 12:59:30 UTC
Integrated into 'main-golden', will be available in build *201209031048* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c33dc69bfb45
User: mentlicher@netbeans.org
Log: #216360: Listen on the Line object to update LineBreakpoint's line number.
Comment 9 Vladimir Riha 2012-11-22 10:31:14 UTC
I'm sorry, but this is happening again. Let's say you have function like:


function test(){
                window.console.log("1");
                window.console.log("2");   
                window.console.log("3"); // line breakpoint here
}

Now run it and somehow call test(), code execution stops OK. Now modify test() and repeat steps above (long wait due to 220836):

function test(){
                window.console.log("1");
                window.console.log("2");
                window.console.log("1"); 
                window.console.log("3"); // line breakpoint stays here, code stops here, ok
}

Now add another similar modification and save file:

function test(){
                window.console.log("1");
                window.console.log("2");
                window.console.log("1"); 
                window.console.log("2"); //  code stops here, wrong
                window.console.log("3"); // line breakpoint stays here,
}

It seems like it works with one modification (one reload?) and then it starts to  stop at incorrect lines



Product Version: NetBeans IDE Dev (Build web-main-9296-on-20121121)
Java: 1.7.0_10-ea; Java HotSpot(TM) Client VM 23.6-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_10-ea-b16
System: Linux version 3.2.0-33-generic-pae running on i386; UTF-8; en_US (nb)
Comment 10 Vladimir Riha 2012-11-30 13:26:21 UTC
At first look, it looks like #220836 also fixed this issue but I'll test it more thoroughly later today/on Monday.
Comment 11 Martin Entlicher 2012-11-30 13:36:41 UTC
Only partially. When a code is removed from a line with a breakpoint, which makes the line empty, the execution is suspended on a next line, but the breakpoint annotation stays on the empty line. This is described in comment #c5.

Breakpoint line updates are now fixed by changeset:   241226:b2a01676fb1a
http://hg.netbeans.org/web-main/rev/b2a01676fb1a
Comment 12 Quality Engineering 2012-12-03 03:01:17 UTC
Integrated into 'main-golden', will be available in build *201212030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/b2a01676fb1a
User: mentlicher@netbeans.org
Log: #216360: Update line breakpoints when Debugger.breakpointResolved is received.
Comment 13 Vladimir Riha 2013-01-15 13:47:55 UTC
I no longer can reproduce it => verified, thanks

Product Version: NetBeans IDE 7.3 RC1 (Build 201301142100)
Java: 1.7.0_10; Java HotSpot(TM) Client VM 23.6-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_10-b18
System: Linux version 3.2.0-35-generic-pae running on i386; UTF-8; en_US (nb)