From e436aadfcd8227f159c5a77a05138a572e37867c Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 15 Oct 2009 12:32:03 +0000 Subject: [PATCH] [292271] DsfSession.addServiceEventListener must be used on the Executor thread. --- .../ui/disassembly/DisassemblyPart.java | 45 ++++++++++++++----- .../sourcelookup/DsfSourceDisplayAdapter.java | 11 +++-- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index 603e993ab11..975f459f19e 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -1765,7 +1765,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem String debuggerPath= file; // try reverse lookup - final ISourceLookup lookup= getService(ISourceLookup.class); final ISourceLookupDMContext ctx= DMContexts.getAncestorOfType(fTargetContext, ISourceLookupDMContext.class); final DsfExecutor executor= getSession().getExecutor(); Query query= new Query() { @@ -1778,6 +1777,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem rm.done(); } }; + final ISourceLookup lookup= getService(ISourceLookup.class); lookup.getDebuggerPath(ctx, file, request); } }; @@ -2361,14 +2361,22 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } if (fTargetContext != null) { if (fDebugSessionId != null) { - if (getSession() != null) { - getSession().removeServiceEventListener(this); + if (getSession() != null) { + // Store the values that we are going to change + final DsfSession session = getSession(); + final DsfServicesTracker trackerToDispose= fServicesTracker; + session.getExecutor().execute(new DsfRunnable() { + public void run() { + session.removeServiceEventListener(DisassemblyPart.this); + if (trackerToDispose != null) { + trackerToDispose.dispose(); + } + + } + }); } } fDebugSessionId= sessionId; - if (fServicesTracker != null) { - fServicesTracker.dispose(); - } fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId); if (fViewer != null) { debugContextChanged(); @@ -2389,14 +2397,22 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } else if (fDebugSessionId != null) { if (getSession() != null) { - getSession().removeServiceEventListener(this); + // Store the values that we are going to change + final DsfSession session = getSession(); + final DsfServicesTracker trackerToDispose= fServicesTracker; + session.getExecutor().execute(new DsfRunnable() { + public void run() { + session.removeServiceEventListener(DisassemblyPart.this); + if (trackerToDispose != null) { + trackerToDispose.dispose(); + } + + } + }); } fDebugSessionId= null; fTargetContext= null; - if (fServicesTracker != null) { - fServicesTracker.dispose(); - fServicesTracker= null; - } + fServicesTracker= null; if (fViewer != null) { debugContextChanged(); } @@ -2410,7 +2426,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem resetViewer(); if (fDebugSessionId != null) { final DsfSession session= getSession(); - session.addServiceEventListener(this, null); + session.getExecutor().execute(new DsfRunnable() { + public void run() { + session.addServiceEventListener(DisassemblyPart.this, null); + } + }); + updatePC(PC_UNKNOWN); if (fGotoAddressPending != PC_UNKNOWN) { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index befe3d2fee1..b0aec5fd100 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -591,7 +591,9 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl final IInstructionPointerPresentation ipPresentation = (IInstructionPointerPresentation) session.getModelAdapter(IInstructionPointerPresentation.class); fIPManager = new InstructionPointerManager(ipPresentation); - fSession.addServiceEventListener(this, null); + fExecutor.execute(new DsfRunnable() { public void run() { + fSession.addServiceEventListener(DsfSourceDisplayAdapter.this, null); + }}); fController = controller; if (fController != null) { @@ -616,8 +618,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl fController.removeSteppingControlParticipant(this); fController = null; } - fSession.removeServiceEventListener(this); - fServicesTracker.dispose(); + fExecutor.execute(new DsfRunnable() { public void run() { + fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this); + fServicesTracker.dispose(); + }}); + fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant}); // fSourceLookupParticipant is disposed by the source lookup director