Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333891 - [breakpoints] Breakpoint Undo doesn't handle duplicates
Summary: [breakpoints] Breakpoint Undo doesn't handle duplicates
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: 4.5 M3   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-10 13:00 EST by Curtis Windatt CLA
Modified: 2014-10-16 05:28 EDT (History)
7 users (show)

See Also:
daniel_megert: review+


Attachments
Handle Duplicate Breakpoints (2.22 KB, patch)
2014-07-25 07:04 EDT, Sarika Sinha CLA
daniel_megert: review-
Details | Diff
Handle Duplicate Breakpoints (2.38 KB, patch)
2014-10-09 07:32 EDT, Sarika Sinha CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Windatt CLA 2011-01-10 13:00:38 EST
1) Create a breakpoint
2) Open breakpoints view
3) Select the breakpoint and delete it from the view
4) Create another breakpoint in the same location
5) In the view, Ctrl-Z to undo

Result, there are two duplicate breakpoints.

When adding breakpoints back with undo, we can try to remove duplicates the same way we do with refactor/import.
Comment 1 Akihiko Takajo CLA 2013-04-26 04:34:27 EDT
recreatable with 4.3M6
Comment 2 Sarika Sinha CLA 2014-07-25 07:04:36 EDT
Created attachment 245378 [details]
Handle Duplicate Breakpoints

This patch adds a check to make sure that there is no matching breakpoint marker at the same line before adding a new one
Comment 3 Michael Rennie CLA 2014-08-05 12:49:49 EDT
(In reply to Sarika Sinha from comment #2)
> Created attachment 245378 [details]
> Handle Duplicate Breakpoints
> 
> This patch adds a check to make sure that there is no matching breakpoint
> marker at the same line before adding a new one

I think to be a bit more sure we have a dupe, we would need to compare more than just the line number and resource - we should probably compare elements from the bp marker attribute mapping as well. 

While testing it seems a dead breakpoint is (still?) put back:

1. new workspace / java project / class
2. create class load BP and method BP, open bp view
3. select + delete the method bp -> undo
4. notice the method bp is put back, but without entry / exit, etc attributes. Also note you cannot toggle the bp from the editor, and it does not appear again in the bp view.
Comment 4 Sarika Sinha CLA 2014-08-11 07:47:04 EDT
(In reply to Michael Rennie from comment #3)
> (In reply to Sarika Sinha from comment #2)
> > Created attachment 245378 [details]
> > Handle Duplicate Breakpoints
> > 
> > This patch adds a check to make sure that there is no matching breakpoint
> > marker at the same line before adding a new one
> 
> I think to be a bit more sure we have a dupe, we would need to compare more
> than just the line number and resource - we should probably compare elements
> from the bp marker attribute mapping as well. 
> 
> While testing it seems a dead breakpoint is (still?) put back:
> 
> 1. new workspace / java project / class
> 2. create class load BP and method BP, open bp view
> 3. select + delete the method bp -> undo
> 4. notice the method bp is put back, but without entry / exit, etc
> attributes. Also note you cannot toggle the bp from the editor, and it does
> not appear again in the bp view.

Step 4 . I was able to toggle and it was added in the bp view if we just foloow the above steps. But yes there are some other undo cases where the bp is shown only in the editor and not the bp view. But that is another bug where undo is not working properly.

Also If I compare existing.getAttributes().equal(newMarker.getAttributes()) It fails. We can compare the CharStart and Char End along with line no and resource check.
Comment 5 Dani Megert CLA 2014-10-08 10:36:56 EDT
It fixes exactly the reported steps but as soon as I e.g.

- delete from view
- Ctrl+Z
- Ctrl+Y (redo)
- Ctrl+Z

==> breakpoint comes back in the editor but not in the Breakpoints view.

Note that this is not due to your patch, but it would be good to have a fix that covers the undo/redo scenario as a whole.
Comment 6 Sarika Sinha CLA 2014-10-09 02:10:44 EDT
(In reply to Dani Megert from comment #5)
> It fixes exactly the reported steps but as soon as I e.g.
> 
> - delete from view
> - Ctrl+Z
> - Ctrl+Y (redo)
> - Ctrl+Z
> 
> ==> breakpoint comes back in the editor but not in the Breakpoints view.
> 
> Note that this is not due to your patch, but it would be good to have a fix
> that covers the undo/redo scenario as a whole.

Yes there are issues with redo and we have another bug for it and the solutions are totally independent so I think we should go ahead and fix this at least. Mostly the other solution will be in JDT Debug component.
Comment 7 Dani Megert CLA 2014-10-09 04:24:22 EDT
(In reply to Sarika Sinha from comment #6)
> (In reply to Dani Megert from comment #5)
> > It fixes exactly the reported steps but as soon as I e.g.
> > 
> > - delete from view
> > - Ctrl+Z
> > - Ctrl+Y (redo)
> > - Ctrl+Z
> > 
> > ==> breakpoint comes back in the editor but not in the Breakpoints view.
> > 
> > Note that this is not due to your patch, but it would be good to have a fix
> > that covers the undo/redo scenario as a whole.
> 
> Yes there are issues with redo and we have another bug for it

Do you mean bug 424561?


> and the solutions are totally independent so I think we should go ahead and 
> fix this at least.

OK, let's move on with this bug here, given we have a bug for the other scenario.
Comment 8 Dani Megert CLA 2014-10-09 04:32:17 EDT
Comment on attachment 245378 [details]
Handle Duplicate Breakpoints

The fix works as already outlined in my previous comment.

Some minor issues that need to be addressed:
- breakpoint.getMarker() can return 'null' and hence a cause a potential NPE
- the new method can return 'null', hence this must be specified in the Javadoc
- I would rename the method to findMatchingBreakpoint
- write English sentences, e.g. "line number" and not  "line no" ;-)
- use a traditional comment if the comment is more than one line
Comment 9 Sarika Sinha CLA 2014-10-09 07:32:46 EDT
Created attachment 247750 [details]
Handle Duplicate Breakpoints

Updated the patch with review comments.

Bug 424561 and Bug 404990 describes the similar undo scenario.
Comment 10 Dani Megert CLA 2014-10-09 07:48:45 EDT
(In reply to Dani Megert from comment #8)
> - write English sentences, e.g. "line number" and not  "line no" ;-)

This wasn't done in the new methods Javadoc. Fixed this. Also, please put primitive values inside a code tag, e.g.  <code>null</code>. Done that too.

Committed your patch with http://git.eclipse.org/c/platform/eclipse.platform.debug.git/commit/?id=8a1df72b32d13765ec6e719f211a79d27a86667c
Comment 11 Dani Megert CLA 2014-10-09 08:06:16 EDT
Oops, I missed another potential NPE in this code:

(Integer) bpMarker.getAttribute(IMarker.LINE_NUMBER) == (line == null ? -1 : line.intValue())

If the attribute is null it will end up in
(Integer)null == -1
which will fail.


Fixed with http://git.eclipse.org/c/platform/eclipse.platform.debug.git/commit/?id=564d3bfae3140780ca5879d4cbbe3601cf6916d2
Comment 12 Sarika Sinha CLA 2014-10-16 05:28:02 EDT
Verified using
Eclipse SDK

Version: Mars (4.5)
Build id: I20141014-0800