Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334007 - Breakpoint undo should not automatically register a breakpoint
Summary: Breakpoint undo should not automatically register a breakpoint
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-11 12:33 EST by Michael Rennie CLA
Modified: 2011-01-14 09:43 EST (History)
2 users (show)

See Also:


Attachments
Fix (5.70 KB, patch)
2011-01-13 07:54 EST, Dani Megert CLA
no flags Details | Diff
Fix (6.55 KB, patch)
2011-01-13 08:17 EST, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2011-01-11 12:33:42 EST
code from HEAD (testing in I20110104-0920)

While testing the undo support for breakpoints I discovered some breakpoints sporadically showing up in the view. I my case there were 4 that would show randomly:

1. a Java exception breakpoint for java.lang.Exception
2. a Java exception breakpoint for java.lang.Throwable
3. a JSDT script load breakpoint for global script load
4. a JSDT script exception breakpoint

When I dug deeper I realized these are the breakpoints that back the JDT debug option for suspending on uncaught exceptions (1 and 2) and the breakpoints that back the JSDT debug options for suspending on exceptions and all script loads.

It seems that this code in BreakpointManager line 790 causes the issue:

else if (getBreakpoint(marker) == null) {
  try {
    IBreakpoint breakpoint= createBreakpoint(marker);
    breakpoint.setRegistered(true);
    fAdded.add(breakpoint);
  } ...

where the problem comes from setting any one of these breakpoints as registered: doing so makes them visible in the breakpoints view. When we are re-creating the breakpoint for the marker we should only call the setRegistered(..) method if the registered attribute on the marker is set to true. 

Setting the registered stated of a breakpoint is a very common way to 'hide' a breakpoint from users, as it causes it to not show in the breakpoints view, we should make sure to preserve this state.

The bug seems to be timing sensitive, but the steps I used to reproduce:

1. create simple class with main method
2. check on the JDT > Debug > suspend on all uncaught exceptions preference
3. restart workbench
4. debug the simple class

After a few iterations of this you should see one (or all) of the breakpoints mentioned appear in the breakpoints view (you will need to have JSDT installed to see the last two).

See the JavaDebugOptionsManager class for more details on where / how the hidden exception breakpoints are created.
Comment 1 Michael Rennie CLA 2011-01-11 13:36:04 EST
digging a bit deeper I remembered that when we delete a breakpoint we set its' registered state to false, so even during the restore code the marker will not have the right state to restore the registered state.

We need to store the registered state somehow and properly restore it when the breakpoint deletion is undone.
Comment 2 Dani Megert CLA 2011-01-12 10:28:49 EST
(In reply to comment #1)
> digging a bit deeper I remembered that when we delete a breakpoint we set its'
> registered state to false, so even during the restore code the marker will not
> have the right state to restore the registered state.
> 
> We need to store the registered state somehow and properly restore it when the
> breakpoint deletion is undone.

Either that (preferred) or add something to the marker before we delete it.
Comment 3 Dani Megert CLA 2011-01-13 07:54:21 EST
Fixed in HEAD.
Available in builds >= N2011013-2000.

Verified that the tests are green again except for the following test which only failed on Mac (and which I can't check since I have no Mac):

testRunToLine	Error	N/A

java.lang.NullPointerException
at org.eclipse.jdt.debug.tests.breakpoints.RunToLineTests.runToLine(RunToLineTests.java:188)
at org.eclipse.jdt.debug.tests.breakpoints.RunToLineTests.testRunToLine(RunToLineTests.java:86)
at org.eclipse.jdt.debug.tests.AbstractDebugTest.runBare(AbstractDebugTest.java:1763)
at org.eclipse.jdt.debug.tests.DebugSuite$1.run(DebugSuite.java:54)
at java.lang.Thread.run(Thread.java:613)

and which might be unrelated.


Mike can you verify with your manual test cases?
Comment 4 Dani Megert CLA 2011-01-13 07:54:57 EST
Created attachment 186718 [details]
Fix
Comment 5 Dani Megert CLA 2011-01-13 08:17:27 EST
Created attachment 186719 [details]
Fix
Comment 6 Michael Rennie CLA 2011-01-14 09:43:49 EST
+1 works fine