Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 301825 - [breakpoints] Breakpoints view doesn't always link with Debug view any more
Summary: [breakpoints] Breakpoints view doesn't always link with Debug view any more
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Pawel Piech CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-04 08:32 EST by Markus Keller CLA
Modified: 2010-02-25 18:40 EST (History)
3 users (show)

See Also:
darin.eclipse: review+


Attachments
Patch with fix. (28.62 KB, patch)
2010-02-18 19:38 EST, Pawel Piech CLA
no flags Details | Diff
Fix attempt #2. (50.66 KB, patch)
2010-02-24 18:30 EST, Pawel Piech CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-02-04 08:32:18 EST
N20100202-2000

The Breakpoints view doesn't always link with the Debug view any more.

I have "Link with Debug View" enabled, and "Group By > Breakpoint Working Sets". When the Breakpoints view is freshly created, all working sets are now collapsed (in 3.5.2, they used to be expanded). When the Debug view now hits a breakpoint, the breakpoint does not get revealed and selected. After I manually expanded the right working set, the linking starts to work.

I guess there's a problem in the content provider's getParent(..) method, which prevents the BP from being found as long as the viewer model is not populated.
Comment 1 Pawel Piech CLA 2010-02-10 12:04:37 EST
(In reply to comment #0)
> When the Breakpoints view is freshly created, all working sets are now
> collapsed (in 3.5.2, they used to be expanded). 
This issue is tracked in bug 297762.
Comment 2 Pawel Piech CLA 2010-02-18 19:38:00 EST
Created attachment 159506 [details]
Patch with fix.

This patch converts the track selection handling to using model deltas instead of the view attempting to set selection.  Setting selection didn't work for un-expanded elements in the view, because the view is now lazy loading.

The only limitation of this fix is that if a thread has multiple breakpoints associated with it, only one of the breakpoints will be selected.  I'm not sure how important a use case this is.  If we need to overcome this limitation, we'll need to add a new capability to the flexible hierarchy viewer to specify a multi-selection through the delta mechanism.

Finally, this patch makes a small change in the provisional API of the breakpoints view (added a new constant in IBreakpointUIConstants, and changed the value type of another).  This will affect CDT which already uses the new view.  Also, it removes an internal interface IBreakpointOrganizerInputProvider as part of refactoring (bug 303261).

I'll hold off on commiting till I hear from patrick on bug 303261.
Comment 3 Markus Keller CLA 2010-02-19 05:28:05 EST
> Setting selection didn't work for
> un-expanded elements in the view, because the view is now lazy loading.

Selecting un-expanded elements also works in lazy trees, but you need to implement ILazyTreePathContentProvider#getParents(Object).
Comment 4 Pawel Piech CLA 2010-02-19 12:40:47 EST
I committed the fix.  Darin please review.
Comment 5 Pawel Piech CLA 2010-02-19 12:41:55 EST
(In reply to comment #3)
> Selecting un-expanded elements also works in lazy trees, but you need to
> implement ILazyTreePathContentProvider#getParents(Object).

Thank you.  The flexible hierarchy viewer abstracts this interface from the model so it's not an option in this case.
Comment 6 Darin Wright CLA 2010-02-24 11:10:41 EST
If there are multiple breakpoints in one method (for example line breakpoints), the selection in the BP view does not change as one resumes from one breakpoint to the next. I suspect this is because the debug context has not changed? (i.e. still the same frame...) but I have not tracked it down.
Comment 7 Pawel Piech CLA 2010-02-24 12:55:24 EST
(In reply to comment #6)
> If there are multiple breakpoints in one method (for example line breakpoints),
> the selection in the BP view does not change as one resumes from one breakpoint
> to the next. I suspect this is because the debug context has not changed? (i.e.
> still the same frame...) but I have not tracked it down.

I see now: PresentationContext.setProperty() filters out the change in activeContext because it's the same as the previous context... so the update gets lost.  I guess I'll have to find a different way to track the active context.
Comment 8 Pawel Piech CLA 2010-02-24 13:18:14 EST
(In reply to comment #7)
> I guess I'll have to find a different way to track the active context.

What if we added the following to IPresentationContext:

    /**
     * Returns the part that this presentation context is associated with.
     * May return <code>null</code> if the presentation is not associated 
     * with a part.
     *  
     * @return IWorkbenchPart or <code>null</code> 
     */
    public IWorkbenchPart getPart();
    
    /**
     * Returns the window that this presentation context is associated with.
     * May return <code>null</code> if the presentation is not associated 
     * with a window.
     *  
     * @return IWorkbenchWindow or <code>null</code> 
     */
    public IWorkbenchWindow getWindow();


I've come across other cases in DSF where I needed access to the view from the content provider or the model proxy.  So this would be a welcome addition.  There may not be an associated part or window, in which case the model will have to present data without it.
Comment 9 Darin Wright CLA 2010-02-24 15:28:57 EST
Do we need to use the presentation context for this? would it be simpler just to implement it in the view?
Comment 10 Pawel Piech CLA 2010-02-24 16:46:51 EST
(In reply to comment #9)
> Do we need to use the presentation context for this? would it be simpler just
> to implement it in the view?

The view used to do the selection and that resulted in this bug.  It would try to select a breakpoint which was not yet realized in the viewer.  This fix moves the responsibility of selecting the breakpoint to the model proxy.

The model proxy needs to know the active debug context to figure out what to select and when to update the selection.  Unfortunately we don't have an easy way for the model proxy to figure out the debug context since the viewer input is overriden.
Comment 11 Pawel Piech CLA 2010-02-24 18:30:58 EST
Created attachment 160139 [details]
Fix attempt #2.

This fix adds the IPresentationContext.getPart() as described above and it makes the BP manager content provider listen to debug context changes directly.  In the process of implementing this I also tried to reduce the number of locks being held while processing model changes.

One annoying side effect I discovered is that if selection is changed in DV very fast, it queues up a number of selection deltas be processed in the Breakpoints view.  This is actually visible on my machine Linux32/gtk in that the breakpoints view toolbar flickers.  We could address this in a few different ways, e.g. delay the selection in Breakpoints view very briefly and drop the delta if a new selection request comes in.

Darin let me know if you'd rather not add the presentation context methods.  There actually already is a PartPresentationContext, but if its use is to be so wide-spread I think it makes sense to put it in the interface.
Comment 12 Darin Wright CLA 2010-02-25 13:27:26 EST
I'm OK with this change.
Comment 13 Pawel Piech CLA 2010-02-25 18:39:56 EST
I committed the changes with additional fixes, refactoring, and comments.  

Patrick please have a look at this as well since you've authored much of the logic.
Comment 14 Pawel Piech CLA 2010-02-25 18:40:16 EST
(In reply to comment #12)
> I'm OK with this change.