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 206829 - Debugger steps on invalid lines after source code changes
Summary: Debugger steps on invalid lines after source code changes
Status: RESOLVED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 7.1
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-01 20:22 UTC by bht
Modified: 2012-01-05 15:50 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project in zip file (21.19 KB, application/zip)
2012-01-01 20:22 UTC, bht
Details
screen shot 1 (30.85 KB, image/gif)
2012-01-01 20:23 UTC, bht
Details
screen shot 2 (31.23 KB, image/gif)
2012-01-01 20:24 UTC, bht
Details
screen shot 3 (3.34 KB, image/gif)
2012-01-01 20:24 UTC, bht
Details
screen shot 4 (146.39 KB, image/gif)
2012-01-02 18:34 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bht 2012-01-01 20:22:23 UTC
Created attachment 114536 [details]
project in zip file

In a GlassFish Java Web project, the debugger gets confused in simple scenarios.

Please use the attached project which I created as follows:

- File|New Project|Samples|Java Web|Servlet Stateless (Java EE 6)|Next|Finish
- Project|Properties|Run|Uncheck Deploy on Save
- Add new Java class Test.java
- Modify  StatelessSessionBean return "Hello, " + name + new Test("0") + "!\n";

The error reproduces at my end as follows:

- Set breakpoints on all lines of Test.java between lines 21 and 52
- Start GlassFish in debug mode
- Projects Window|right click project node|Debug
- Step through all lines, then Continue
- Duplicate or remove the line marked for duplication, setting breakpoint on it again
- Save the file
- Projects Window|right click project node|Debug
... repeat until error shows

This is a simple scenario. In my project, where i cannot make a better reproducing testcase, undeploying the project and re-starting the server does not even help, and the debugger gets utterly confused.

I considered the comment in bug 187826"
"The debugger does not know that the application was redeployed and therefore it calculates with shifted line numbers as if only the source file was modified."

So I tried to manually deploy so the debugger has a better chance of detecting source code change.

I started the debug session from the services window, by right clicking on the application icon.

But that fails also. It appears to me (and I might be wrong) that recently a new bug was introduced where the debugger fails to re-calculate source lines.

Practically, in my projects, the debugger does not work for me anymore because it takes a long time to re-compile projects, re-start the server multiple times and so on.

BTW a question: If there are no source code and deployment changes, why then causes the debug action in the projects window a re-deployment?
Comment 1 bht 2012-01-01 20:23:38 UTC
Created attachment 114537 [details]
screen shot 1
Comment 2 bht 2012-01-01 20:24:10 UTC
Created attachment 114538 [details]
screen shot 2
Comment 3 bht 2012-01-01 20:24:37 UTC
Created attachment 114539 [details]
screen shot 3
Comment 4 bht 2012-01-02 18:34:58 UTC
Created attachment 114559 [details]
screen shot 4

Reproduced first time with an empty userdir as follows:

- Open NetBeans with a new userdir - do not import settings
- Close the start page
- Maximise window
- Menu|Tools|Options|Miscellaneous|Files|Uncheck "Enable auto-scanning of sources"
- Open the project
- Set breakpoints on all lines of Test.java between lines 21 and 52
- Start GlassFish in debug mode
- Projects Window|right click project node|Debug
- Step through all lines, then Continue
- Duplicate or remove the line marked for duplication, setting breakpoint on it again, or removing duplicate breakpoints so there is only one
- Save the file
- Projects Window|right click project node|Debug
- repeat once until error shown
Comment 5 Martin Entlicher 2012-01-03 16:46:52 UTC
Thanks for the detailed description, I've reproduced it.
It looks like the debugger thinks that the changed code was deployed to the server, but it was not, because Deploy on Save is set to false.
Comment 6 bht 2012-01-04 06:41:58 UTC
Thanks and a Happy New Year!

How in the meantime can I get the debugger to re-calculate all breakpoints? I remember that even undeploying, re-starting the server, cleaning, building and re-deploying did not help in some scenarios.
Comment 7 Martin Entlicher 2012-01-04 09:46:19 UTC
It's fixed by changeset:   209750:44347bb5c87d
http://hg.netbeans.org/main/rev/44347bb5c87d

Happy New Year to you as well. :-)

I'm not sure of what re-calculation of all breakpoints do you mean, but if you finish the debugger session and start a new one, then the new debugger session will submit breakpoints to the lines that you see in the editor. All shifts that are added during the editing are forgotten. But it's expected that at the time you start the debugger session, the application code that is executed corresponds to the source code. If not, re-deploy should fix that.

IMHO this problem with shifted lines would be fixed by allowing to deploy the application on save. That should keep the source code changes and the execution code in sync.
Comment 8 bht 2012-01-04 11:21:42 UTC
Interesting.

I am still using RC2 containing the bug, and I am interested in working around it cleanly.

The bug does not go away if the debugger is confused, where it says with our testcase there is no executable code on line 51

throw new RuntimeException();

In that scenario, I do this:

- stop the debugging session (from the main menu)
- deploy
- start a new debugging session (from the main menu)

If I understand you correctly, then the debugger should recover this way but it does not.

I think it would help if the debugger could reset itself more easily.

I was getting into a stage, where even undeploying a big app and re-starting the server did not wok around a line number mismatch problem. At that stage, I started to dismantle the large app to isolate the problem, but in the end, the testcase is not as severe as what I saw initially.
Comment 9 Quality Engineering 2012-01-05 15:50:35 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/44347bb5c87d
User: mentlicher@netbeans.org
Log: #206829 Notify the JPDA debugger only when the modified code is successfully deployed.