1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 330646 - Disassembly view causes AssertionError

This commit is contained in:
Anton Leherbauer 2010-11-25 15:36:08 +00:00
parent 818d361c4f
commit 7cdb3eeeb1
2 changed files with 95 additions and 54 deletions

View file

@ -596,7 +596,7 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
} }
private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IInstruction[] instructions, boolean showSymbols, boolean showDisassembly) { private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IInstruction[] instructions, boolean showSymbols, boolean showDisassembly) {
if (!fCallback.hasViewer() || fDsfSessionId == null) { if (!fCallback.hasViewer() || fDsfSessionId == null || fTargetContext == null) {
// return true to avoid a retry // return true to avoid a retry
return true; return true;
} }
@ -709,7 +709,7 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
* @return whether [startAddress] was inserted * @return whether [startAddress] was inserted
*/ */
private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) { private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) {
if (!fCallback.hasViewer() || fDsfSessionId == null) { if (!fCallback.hasViewer() || fDsfSessionId == null || fTargetContext == null) {
// return true to avoid a retry // return true to avoid a retry
return true; return true;
} }

View file

@ -66,6 +66,7 @@ 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.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.IBreakpointManager;
@ -118,6 +119,7 @@ import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
@ -251,6 +253,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private int fAddressSize= 32; private int fAddressSize= 32;
private volatile boolean fUpdatePending; private volatile boolean fUpdatePending;
private volatile int fUpdateCount;
private BigInteger fPCAddress; private BigInteger fPCAddress;
private BigInteger fGotoAddressPending= PC_UNKNOWN; private BigInteger fGotoAddressPending= PC_UNKNOWN;
private BigInteger fFocusAddress= PC_UNKNOWN; private BigInteger fFocusAddress= PC_UNKNOWN;
@ -1481,16 +1484,18 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
public void viewportChanged(int verticalOffset) { public void viewportChanged(int verticalOffset) {
if (fDebugSessionId != null && fGotoAddressPending == PC_UNKNOWN && fScrollPos == null && !fUpdatePending && !fRefreshViewPending) { if (fDebugSessionId != null && fGotoAddressPending == PC_UNKNOWN && fScrollPos == null && !fUpdatePending && !fRefreshViewPending) {
fUpdatePending = true; fUpdatePending = true;
invokeLater(new Runnable() { final int updateCount = fUpdateCount;
public void run() { invokeLater(new Runnable() {
assert fUpdatePending; public void run() {
if (fUpdatePending) { if (updateCount == fUpdateCount) {
fUpdatePending = false; assert fUpdatePending;
updateVisibleArea(); if (fUpdatePending) {
fPCLastAddress = getTopAddress(); fUpdatePending = false;
} updateVisibleArea();
} }
}); }
}
});
} }
} }
@ -1677,15 +1682,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fDebugSessionId == null) { if (fDebugSessionId == null) {
return; return;
} }
if (fUpdatePending) { startUpdate(new Runnable() {
invokeLater(new Runnable() { public void run() {
public void run() { if (DEBUG) System.out.println("retrieveDisassembly "+file); //$NON-NLS-1$
retrieveDisassembly(file, lines, mixed); fBackend.retrieveDisassembly(file, lines, fEndAddress, mixed, fShowSymbols, fShowDisassembly);
}}); }
return; });
}
if (DEBUG) System.out.println("retrieveDisassembly "+file); //$NON-NLS-1$
fBackend.retrieveDisassembly(file, lines, fEndAddress, mixed, fShowSymbols, fShowDisassembly);
} }
private void retrieveDisassembly(BigInteger startAddress, BigInteger endAddress, int lines) { private void retrieveDisassembly(BigInteger startAddress, BigInteger endAddress, int lines) {
@ -1872,7 +1874,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (result != null) { if (result != null) {
fDebugSessionId = result.sessionId; fDebugSessionId = result.sessionId;
if (result.contextChanged && fViewer != null) { if (result.contextChanged && fViewer != null) {
debugContextChanged(); startUpdate(new Runnable() {
public void run() {
debugContextChanged();
}
});
if (prevBackend != null && fBackend != prevBackend) { if (prevBackend != null && fBackend != prevBackend) {
prevBackend.clearDebugContext(); prevBackend.clearDebugContext();
} }
@ -1884,8 +1890,35 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} }
} }
private void startUpdate(final Runnable update) {
final int updateCount = fUpdateCount;
final SafeRunnable safeUpdate = new SafeRunnable() {
public void run() {
if (updateCount == fUpdateCount) {
update.run();
}
}
@Override
public void handleException(Throwable e) {
internalError(e);
}
};
if (fUpdatePending) {
invokeLater(new Runnable() {
public void run() {
if (updateCount == fUpdateCount) {
SafeRunner.run(safeUpdate);
}
}
});
} else {
SafeRunner.run(safeUpdate);
}
}
private void debugContextChanged() { private void debugContextChanged() {
if (DEBUG) System.out.println("DisassemblyPart.debugContextChanged()"); //$NON-NLS-1$ if (DEBUG) System.out.println("DisassemblyPart.debugContextChanged()"); //$NON-NLS-1$
fUpdateCount++;
fRunnableQueue.clear(); fRunnableQueue.clear();
fUpdatePending = false; fUpdatePending = false;
resetViewer(); resetViewer();
@ -1921,8 +1954,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
firePropertyChange(PROP_SUSPENDED); firePropertyChange(PROP_SUSPENDED);
} }
private void attachBreakpointsAnnotationModel() { private void attachBreakpointsAnnotationModel() {
IAnnotationModel annotationModel = fViewer.getAnnotationModel(); IAnnotationModel annotationModel = fViewer.getAnnotationModel();
if (annotationModel instanceof IAnnotationModelExtension) { if (annotationModel instanceof IAnnotationModelExtension) {
@ -2478,35 +2509,41 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (doit != null) { if (doit != null) {
fRunnableQueue.add(doit); fRunnableQueue.add(doit);
} }
if (fUpdatePending) { final int updateCount = fUpdateCount;
if (fRunnableQueue.size() == 1) { if (fUpdatePending) {
Runnable doitlater = new Runnable() { if (fRunnableQueue.size() == 1) {
public void run() { Runnable doitlater = new Runnable() {
doScrollLocked(null); public void run() {
}}; if (updateCount == fUpdateCount) {
invokeLater(doitlater); doScrollLocked(null);
} }
} else { }};
fUpdatePending = true; invokeLater(doitlater);
lockScroller(); }
try { } else {
ArrayList<Runnable> copy = new ArrayList<Runnable>(fRunnableQueue); fUpdatePending = true;
fRunnableQueue.clear(); lockScroller();
for (Iterator<Runnable> iter = copy.iterator(); iter.hasNext();) { try {
Runnable doitnow = iter.next(); ArrayList<Runnable> copy = new ArrayList<Runnable>(fRunnableQueue);
try { fRunnableQueue.clear();
doitnow.run(); for (Iterator<Runnable> iter = copy.iterator(); iter.hasNext();) {
} catch(Exception e) { if (updateCount != fUpdateCount) {
internalError(e); return;
} }
} Runnable doitnow = iter.next();
} finally { try {
fUpdatePending = false; doitnow.run();
unlockScroller(); } catch(Exception e) {
doPending(); internalError(e);
updateVisibleArea(); }
} }
} } finally {
fUpdatePending = false;
unlockScroller();
doPending();
updateVisibleArea();
}
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -2920,7 +2957,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
asyncExec(new Runnable() { asyncExec(new Runnable() {
public void run() { public void run() {
fDebugSessionId = null; fDebugSessionId = null;
debugContextChanged(); startUpdate(new Runnable() {
public void run() {
debugContextChanged();
}
});
} }
}); });
} }