1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[247931] [disassembly] IP annotation does not keep up when stepping fast

This commit is contained in:
Anton Leherbauer 2008-09-19 09:44:13 +00:00
parent 460e9feb79
commit 3e3b711def
4 changed files with 62 additions and 29 deletions

View file

@ -1 +1,3 @@
org.eclipse.dd.dsf.debug.ui/debug = false org.eclipse.dd.dsf.debug.ui/debug = false
org.eclipse.dd.dsf.debug.ui/stepping = false
org.eclipse.dd.dsf.debug.ui/disassembly = false

View file

@ -19,6 +19,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.Platform;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.DsfExecutor;
import org.eclipse.dd.dsf.concurrent.DsfRunnable; import org.eclipse.dd.dsf.concurrent.DsfRunnable;
@ -74,6 +75,8 @@ public final class SteppingController implements IStepQueueManager
*/ */
public final static int MAX_STEP_DELAY= 1000; public final static int MAX_STEP_DELAY= 1000;
private final static boolean DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.dd.dsf.debug.ui/stepping")); //$NON-NLS-1$ //$NON-NLS-2$
/** /**
* Indicates that the given context has been stepping for some time, * Indicates that the given context has been stepping for some time,
* and the UI (views and actions) may need to be updated accordingly. * and the UI (views and actions) may need to be updated accordingly.
@ -349,6 +352,7 @@ public final class SteppingController implements IStepQueueManager
} }
private void doStep(final IExecutionDMContext execCtx, final StepType stepType) { private void doStep(final IExecutionDMContext execCtx, final StepType stepType) {
if (DEBUG) System.out.println("[SteppingController] doStep ctx="+execCtx); //$NON-NLS-1$
disableStepping(execCtx); disableStepping(execCtx);
updateLastStepTime(execCtx); updateLastStepTime(execCtx);
@ -465,6 +469,7 @@ public final class SteppingController implements IStepQueueManager
* @param execCtx * @param execCtx
*/ */
private void doneStepping(final IExecutionDMContext execCtx) { private void doneStepping(final IExecutionDMContext execCtx) {
if (DEBUG) System.out.println("[SteppingController] doneStepping ctx=" + execCtx); //$NON-NLS-1$
enableStepping(execCtx); enableStepping(execCtx);
processStepQueue(execCtx); processStepQueue(execCtx);
} }

View file

@ -36,6 +36,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.DsfExecutor;
@ -193,7 +194,7 @@ import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
@SuppressWarnings("restriction") @SuppressWarnings("restriction")
public abstract class DisassemblyPart extends WorkbenchPart implements IDisassemblyPart, IViewportListener, ITextPresentationListener, SessionEndedListener { public abstract class DisassemblyPart extends WorkbenchPart implements IDisassemblyPart, IViewportListener, ITextPresentationListener, SessionEndedListener {
private final static boolean DEBUG = DsfDebugUIPlugin.getDefault().isDebugging(); private final static boolean DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.dd.dsf.debug.ui/disassembly")); //$NON-NLS-1$//$NON-NLS-2$
/** /**
* Annotation model attachment key for breakpoint annotations. * Annotation model attachment key for breakpoint annotations.
@ -2409,26 +2410,40 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
@DsfServiceEventHandler @DsfServiceEventHandler
public void handleEvent(IExitedDMEvent event) { public void handleEvent(IExitedDMEvent event) {
if (event.getDMContext().equals(fTargetContext) final IExecutionDMContext context= event.getDMContext();
|| DMContexts.isAncestorOf(event.getDMContext(), fTargetContext)) { if (context.equals(fTargetContext)
setDebugContext(null); || DMContexts.isAncestorOf(fTargetContext, context)) {
asyncExec(new Runnable() {
public void run() {
setDebugContext(null);
}});
} }
} }
@DsfServiceEventHandler @DsfServiceEventHandler
public void handleEvent(ISuspendedDMEvent event) { public void handleEvent(ISuspendedDMEvent event) {
if (event.getDMContext().equals(fTargetContext) final IExecutionDMContext context= event.getDMContext();
|| DMContexts.isAncestorOf(event.getDMContext(), fTargetContext)) { if (context.equals(fTargetContext)
updatePC(PC_UNKNOWN); || DMContexts.isAncestorOf(fTargetContext, context)) {
asyncExec(new Runnable() {
public void run() {
updatePC(PC_UNKNOWN);
}
});
firePropertyChange(PROP_SUSPENDED); firePropertyChange(PROP_SUSPENDED);
} }
} }
@DsfServiceEventHandler @DsfServiceEventHandler
public void handleEvent(IResumedDMEvent event) { public void handleEvent(IResumedDMEvent event) {
if (event.getDMContext().equals(fTargetContext) final IExecutionDMContext context= event.getDMContext();
|| DMContexts.isAncestorOf(event.getDMContext(), fTargetContext)) { if (context.equals(fTargetContext)
updatePC(PC_RUNNING); || DMContexts.isAncestorOf(fTargetContext, context)) {
asyncExec(new Runnable() {
public void run() {
updatePC(PC_RUNNING);
}
});
firePropertyChange(PROP_SUSPENDED); firePropertyChange(PROP_SUSPENDED);
} }
} }

View file

@ -147,16 +147,18 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
private final IWorkbenchPage fPage; private final IWorkbenchPage fPage;
private final FrameData fFrameData; private final FrameData fFrameData;
private final boolean fEventTriggered;
/** /**
* Constructs a new source lookup job. * Constructs a new source lookup job.
*/ */
public LookupJob(FrameData frameData, IWorkbenchPage page) { public LookupJob(FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
super("DSF Source Lookup"); //$NON-NLS-1$ super("DSF Source Lookup"); //$NON-NLS-1$
setPriority(Job.INTERACTIVE); setPriority(Job.INTERACTIVE);
setSystem(true); setSystem(true);
fFrameData = frameData; fFrameData = frameData;
fPage = page; fPage = page;
fEventTriggered = eventTriggered;
} }
IDMContext getDmc() { return fFrameData.fDmc; } IDMContext getDmc() { return fFrameData.fDmc; }
@ -173,7 +175,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
fPrevResult = result; fPrevResult = result;
fPrevFrameData = fFrameData; fPrevFrameData = fFrameData;
fRunningLookupJob = null; fRunningLookupJob = null;
startDisplayJob(fPrevResult, fFrameData, fPage); startDisplayJob(fPrevResult, fFrameData, fPage, fEventTriggered);
} }
}}); }});
return Status.OK_STATUS; return Status.OK_STATUS;
@ -230,17 +232,17 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
* Job that positions the editor and paints the IP Annotation for given DMC. * Job that positions the editor and paints the IP Annotation for given DMC.
*/ */
class DisplayJob extends UIJob { class DisplayJob extends UIJob {
private SourceLookupResult fResult; private final SourceLookupResult fResult;
private IWorkbenchPage fPage; private final IWorkbenchPage fPage;
private FrameData fFrameData; private final FrameData fFrameData;
private DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() { private final DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() {
public void run() { public void run() {
// If the current display job does not match up with "this", it means that this job got canceled // If the current display job does not match up with "this", it means that this job got canceled
// after it already completed and after this runnable was queued into the dispatch thread. // after it already completed and after this runnable was queued into the dispatch thread.
if (fRunningDisplayJob == DisplayJob.this) { if (fRunningDisplayJob == DisplayJob.this) {
fRunningDisplayJob = null; fRunningDisplayJob = null;
if (!fDoneStepping.getAndSet(true)) { if (fEventTriggered && !fDoneStepping.getAndSet(true)) {
doneStepping(fResult.getDmc()); doneStepping(fResult.getDmc());
} }
serviceDisplayAndClearingJobs(); serviceDisplayAndClearingJobs();
@ -248,22 +250,24 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
} }
}; };
private AtomicBoolean fDoneStepping = new AtomicBoolean(false); private final AtomicBoolean fDoneStepping = new AtomicBoolean(false);
private IRegion fRegion; private IRegion fRegion;
private ITextViewer fTextViewer; private ITextViewer fTextViewer;
private final boolean fEventTriggered;
IDMContext getDmc() { return fResult.getDmc(); } IDMContext getDmc() { return fResult.getDmc(); }
/** /**
* Constructs a new source display job * Constructs a new source display job
*/ */
public DisplayJob(SourceLookupResult result, FrameData frameData, IWorkbenchPage page) { public DisplayJob(SourceLookupResult result, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
super("Debug Source Display"); //$NON-NLS-1$ super("Debug Source Display"); //$NON-NLS-1$
setSystem(true); setSystem(true);
setPriority(Job.INTERACTIVE); setPriority(Job.INTERACTIVE);
fResult = result; fResult = result;
fFrameData = frameData; fFrameData = frameData;
fPage = page; fPage = page;
fEventTriggered = eventTriggered;
} }
@Override @Override
@ -614,16 +618,18 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
* @see org.eclipse.debug.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) * @see org.eclipse.debug.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean)
*/ */
public void displaySource(Object context, final IWorkbenchPage page, final boolean force) { public void displaySource(Object context, final IWorkbenchPage page, final boolean force) {
fStepCount = 0;
if (!(context instanceof IDMVMContext)) return; if (!(context instanceof IDMVMContext)) return;
final IDMContext dmc = ((IDMVMContext)context).getDMContext(); final IDMContext dmc = ((IDMVMContext)context).getDMContext();
// Quick test. DMC is checked again in source lookup participant, but // Quick test. DMC is checked again in source lookup participant, but
// it's much quicker to test here. // it's much quicker to test here.
if (!(dmc instanceof IFrameDMContext)) return; if (!(dmc instanceof IFrameDMContext)) return;
doDisplaySource((IFrameDMContext) dmc, page, force); doDisplaySource((IFrameDMContext) dmc, page, force, false);
} }
private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force) { private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force, final boolean eventTriggered) {
if (context.getLevel() < 0) { if (context.getLevel() < 0) {
return; return;
} }
@ -648,9 +654,9 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
frameData.fFile = data.getFile(); frameData.fFile = data.getFile();
if (!force && frameData.equals(fPrevFrameData)) { if (!force && frameData.equals(fPrevFrameData)) {
fPrevResult.updateArtifact(context); fPrevResult.updateArtifact(context);
startDisplayJob(fPrevResult, frameData, page); startDisplayJob(fPrevResult, frameData, page, eventTriggered);
} else { } else {
startLookupJob(frameData, page); startLookupJob(frameData, page, eventTriggered);
} }
} }
}); });
@ -665,25 +671,30 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
} }
} }
private void startLookupJob(final FrameData frameData, final IWorkbenchPage page) { private void startLookupJob(final FrameData frameData, final IWorkbenchPage page, boolean eventTriggered) {
// If there is a previous lookup job running, cancel it. // If there is a previous lookup job running, cancel it.
if (fRunningLookupJob != null) { if (fRunningLookupJob != null) {
fRunningLookupJob.cancel(); fRunningLookupJob.cancel();
} }
fRunningLookupJob = new LookupJob(frameData, page); fRunningLookupJob = new LookupJob(frameData, page, eventTriggered);
fRunningLookupJob.schedule(); fRunningLookupJob.schedule();
} }
// To be called only on dispatch thread. // To be called only on dispatch thread.
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page) { private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page) {
DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page); startDisplayJob(lookupResult, frameData, page, false);
}
// To be called only on dispatch thread.
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered);
if (fRunningDisplayJob != null) { if (fRunningDisplayJob != null) {
fPendingDisplayJob = null; fPendingDisplayJob = null;
IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc, IExecutionDMContext.class); IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc, IExecutionDMContext.class);
fPendingExecDmcsToClear.removeAll(Arrays.asList(execCtxs)); fPendingExecDmcsToClear.removeAll(Arrays.asList(execCtxs));
if (frameData.isIdentical(fRunningDisplayJob.fFrameData)) { if (!eventTriggered && frameData.isIdentical(fRunningDisplayJob.fFrameData)) {
// identical location - we are done // identical location - we are done
return; return;
} }
@ -793,7 +804,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
final IDMContext dmc = ((IDMVMContext)context).getDMContext(); final IDMContext dmc = ((IDMVMContext)context).getDMContext();
if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) { if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
doDisplaySource((IFrameDMContext) dmc, page, false); doDisplaySource((IFrameDMContext) dmc, page, false, true);
} }
} }
}}); }});