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 42270 - Wrong breakpoint / current line placement in edited files
Summary: Wrong breakpoint / current line placement in edited files
Status: CLOSED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@debugger
URL:
Keywords: API
: 42754 43503 43629 44179 (view as bug list)
Depends on: 42755 43484 45014
Blocks:
  Show dependency tree
 
Reported: 2004-04-21 14:23 UTC by Marek Grummich
Modified: 2006-03-24 10:28 UTC (History)
2 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 Marek Grummich 2004-04-21 14:23:52 UTC
Build 200404191800, j2sdk1.4.2_04

How to reproduce:
- select one line in the editor (shift arrow-down,
control-c)
- repeat several times paste activity (control-v)
- try to place a breakpoint using gutter (click)
on the pasted lines
Comment 1 pfelenda 2004-04-21 14:57:58 UTC
It is reproducible by these steps too :
- hit sometimes Enter key in a method body
- try place breakpoint (ctrl-F8) in the method
-> The brekpoint is pleced not on the row where is caret, but
on row number + count of Enters

(it is not related directly with clipboard)
Comment 2 Miloslav Metelka 2004-04-21 17:46:09 UTC
As it does not happen with other annotations (e.g. Bookmark) I guess
that the problem lies in the debugger's action that attaches the
breakpoint. I've inspected debugger's ToggleBreakpointAction and then
 Context.getCurrentLineNumber() but as it searches in lookup I pass
this to debugger for further evaluation.
Comment 3 Milan Kubec 2004-05-04 09:50:36 UTC
Is there any comment from debugger guys? This issue was marked as
future Q-build stopper.
Comment 4 Jan Jancura 2004-05-04 10:19:13 UTC
We can not effectivelly fix it because of 42755.
I would like to mention that problems with breakpoints in modificated
code are in NetBeans all the time from begining. 
There are two possibilities:
1) you will see breakpoint on the right place & but internally it will
be placed on bas line number (NB36 situation)
2) you will see sometimes breakpoint on a bad position, but internal
line number will be OK.

I would like to wait on 42755.
Comment 5 Jan Jancura 2004-05-10 17:17:34 UTC
*** Issue 42754 has been marked as a duplicate of this issue. ***
Comment 6 Jan Jancura 2004-05-18 09:43:40 UTC
fixed in the main trunk:

  Revision  Changes    Path
  1.9       +9 -1     
debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java
  
 
http://debuggerjpda.netbeans.org/source/browse/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java.diff?r1=1.8&r2=1.9
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ContextProviderImpl.java
  ===================================================================
  RCS file:
/cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- ContextProviderImpl.java	13 May 2004 13:14:19 -0000	1.8
  +++ ContextProviderImpl.java	17 May 2004 22:15:15 -0000	1.9
  @@ -42,6 +42,7 @@
   
   import java.net.URL;
   import java.net.MalformedURLException;
  +import java.util.List;
   import javax.swing.text.Document;
   import javax.swing.text.StyledDocument;
   import org.openide.filesystems.FileStateInvalidException;
  @@ -126,7 +127,14 @@
           LineCookie lineCookie = getCurrentLineCookie ();
           Line.Set lineSet = lineCookie.getLineSet ();
           try {
  -            ln = 2 * ln - lineSet.getOriginal (ln).getLineNumber ();
  +            //ln = 2 * ln - lineSet.getOriginal (ln).getLineNumber ();
  +            List l = lineSet.getLines ();
  +            int i, k = l.size ();
  +            for (i = 0; i < k; i++) {
  +                if (((Line) l.get (i)).getLineNumber () >= ln) {
  +                    return i + 1;
  +                }
  +            }
               return ln + 1;
           } catch (IndexOutOfBoundsException ex) {
               ex.printStackTrace ();
  
  
Comment 7 Jaroslav Tulach 2004-05-20 14:14:34 UTC
Probably not too good fix: why not call: set.getLines().indexOf (line)?

Comment 8 Jan Jancura 2004-05-20 14:32:35 UTC
because it returns completely different information than I need.
I need getoriginalLineNumber for LineSet.getCurrent (currnet) line...

It looks like you do not know how it works...
Comment 9 Jan Jancura 2004-05-23 20:11:43 UTC
*** Issue 43503 has been marked as a duplicate of this issue. ***
Comment 10 Jan Jancura 2004-06-02 13:19:28 UTC
*** Issue 44179 has been marked as a duplicate of this issue. ***
Comment 11 Jan Jancura 2004-06-03 08:46:48 UTC
*** Issue 43629 has been marked as a duplicate of this issue. ***
Comment 12 Jan Jancura 2004-06-07 17:05:20 UTC
I have done some API changes connected with this bug:

Checking in
ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java;
/cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java,v
 <--  ContextProviderImpl.java
new revision: 1.19; previous revision: 1.18
done
Checking in
ant/src/org/netbeans/modules/debugger/projects/DebuggerAnnotation.java;
/cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/DebuggerAnnotation.java,v
 <--  DebuggerAnnotation.java
new revision: 1.5; previous revision: 1.4
done
Processing log script arguments...
More commits to come...
Checking in api/src/org/netbeans/spi/debugger/jpda/ContextProvider.java;
/cvs/debuggerjpda/api/src/org/netbeans/spi/debugger/jpda/ContextProvider.java,v
 <--  ContextProvider.java
new revision: 1.9; previous revision: 1.8
done
Processing log script arguments...
More commits to come...
Checking in src/org/netbeans/modules/debugger/jpda/Context.java;
/cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/Context.java,v
 <--  Context.java
new revision: 1.2; previous revision: 1.1
done
Processing log script arguments...
More commits to come...
Checking in ui/src/org/netbeans/modules/debugger/jpda/ui/Context.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/Context.java,v
 <--  Context.java
new revision: 1.11; previous revision: 1.10
done
Processing log script arguments...
More commits to come...
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointAnnotationListener.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointAnnotationListener.java,v
 <--  BreakpointAnnotationListener.java
new revision: 1.2; previous revision: 1.1
done

Comment 13 Jan Jancura 2004-06-16 16:28:40 UTC
Mostly fixed:


Checking in
ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java;
/cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/ContextProviderImpl.java,v
 <--  ContextProviderImpl.java
new revision: 1.21; previous revision: 1.20
done
Checking in
ant/src/org/netbeans/modules/debugger/projects/DebuggerAnnotation.java;
/cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/projects/DebuggerAnnotation.java,v
 <--  DebuggerAnnotation.java
new revision: 1.6; previous revision: 1.5
done
Processing log script arguments...
More commits to come...
Checking in api/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java;
/cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java,v
 <--  LineBreakpoint.java
new revision: 1.6; previous revision: 1.5
done
Processing log script arguments...
More commits to come...
Checking in api/src/org/netbeans/spi/debugger/jpda/ContextProvider.java;
/cvs/debuggerjpda/api/src/org/netbeans/spi/debugger/jpda/ContextProvider.java,v
 <--  ContextProvider.java
new revision: 1.11; previous revision: 1.10
done
Processing log script arguments...
More commits to come...
Checking in src/org/netbeans/modules/debugger/jpda/Context.java;
/cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/Context.java,v
 <--  Context.java
new revision: 1.4; previous revision: 1.3
done
Checking in src/org/netbeans/modules/debugger/jpda/EngineContext.java;
/cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/EngineContext.java,v
 <--  EngineContext.java
new revision: 1.4; previous revision: 1.3
done
Checking in src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java;
/cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java,v
 <--  JPDADebuggerImpl.java
new revision: 1.37; previous revision: 1.36
done
Processing log script arguments...
More commits to come...
Checking in
test/unit/src/org/netbeans/api/debugger/jpda/test/TestContextProvider.java;
/cvs/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/test/TestContextProvider.java,v
 <--  TestContextProvider.java
new revision: 1.3; previous revision: 1.2
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/debuggerjpda/ui/src/META-INF/debugger/org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointAnnotationListener,v
done
Checking in
ui/src/META-INF/debugger/org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointAnnotationListener;
/cvs/debuggerjpda/ui/src/META-INF/debugger/org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointAnnotationListener,v
 <-- 
org.netbeans.modules.debugger.jpda.ui.breakpoints.BreakpointAnnotationListener
initial revision: 1.1
done
Processing log script arguments...
More commits to come...
Checking in
ui/src/META-INF/debugger/netbeans-JPDASession/Java/org.netbeans.api.debugger.LazyActionsManagerListener;
/cvs/debuggerjpda/ui/src/META-INF/debugger/netbeans-JPDASession/Java/org.netbeans.api.debugger.LazyActionsManagerListener,v
 <--  org.netbeans.api.debugger.LazyActionsManagerListener
new revision: 1.3; previous revision: 1.2
done
Processing log script arguments...
More commits to come...
Checking in ui/src/org/netbeans/modules/debugger/jpda/ui/Context.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/Context.java,v
 <--  Context.java
new revision: 1.13; previous revision: 1.12
done
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/CurrentThreadAnnotationListener.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/CurrentThreadAnnotationListener.java,v
 <--  CurrentThreadAnnotationListener.java
new revision: 1.7; previous revision: 1.6
done
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/DebuggerOutput.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/DebuggerOutput.java,v
 <--  DebuggerOutput.java
new revision: 1.13; previous revision: 1.12
done
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/EngineContext.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/EngineContext.java,v
 <--  EngineContext.java
new revision: 1.10; previous revision: 1.9
done
Checking in ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java,v
 <--  IOManager.java
new revision: 1.11; previous revision: 1.10
done
Processing log script arguments...
More commits to come...
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/actions/ToggleBreakpointActionProvider.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/actions/ToggleBreakpointActionProvider.java,v
 <--  ToggleBreakpointActionProvider.java
new revision: 1.7; previous revision: 1.6
done
Processing log script arguments...
More commits to come...
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointAnnotationListener.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointAnnotationListener.java,v
 <--  BreakpointAnnotationListener.java
new revision: 1.3; previous revision: 1.2
done
RCS file:
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointsUpdater.java,v
done
Checking in
ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointsUpdater.java;
/cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/BreakpointsUpdater.java,v
 <--  BreakpointsUpdater.java
initial revision: 1.1
done
Comment 14 Marek Grummich 2004-06-24 10:00:56 UTC
Seems to be fixed in the build 200406230100 (at least for my test
case) so I don't understand why issue's status is REOPENED. Is it
related to outstanding API changes?
Comment 15 Jan Jancura 2004-06-25 09:32:17 UTC
This bug should be fixed in trunk.

There are several differen usecases how to tes this functionality.
Each usecas tests different "part of code".

Usecase I.
----------
1) open main class file
2) edit file (add some new lines)
3) add line breakpoints there

# this basic test verifies if breakpoints are added to "current" line
not "original" once

Usecase II.
-----------
1) open main class file
2) add line breakpoints there
3) edit file (add some new lines)
4) start debugging (file is compiled automatically)
5) test if breakpoints are reached, and if Step Over traces correctly
through the source code

# this test verifies if breakpoint line numbers are updated, when the
file is compiled and debugger is started

Usecase III.
------------
1) open main class file
2) start debugging (file is compiled automatically)
3) add line breakpoints there
4) edit file (add some new lines)
5) test if breakpoints are reached, and if Step Over traces correctly
through the source code

# this test verifies if getOriginal and getCurrent are used correctly


Usecase IV.
------------
1) open main class file
2) start debugging (file is compiled automatically)
3) edit file (add some new lines)
4) compile file
5) add line breakpoints there
6) test if breakpoints are reached, and if Step Over traces correctly
through the source code

# this test verifies if the original line set is managed properly by
the debugger session


All these usecases should work now. QA, can you add them to your
testplans? Thanks.
Comment 16 Marek Grummich 2004-06-25 10:50:33 UTC
Seems to be fixes in build QBE200406242325, verified