1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12: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) {
if (!fCallback.hasViewer() || fDsfSessionId == null) {
if (!fCallback.hasViewer() || fDsfSessionId == null || fTargetContext == null) {
// return true to avoid a retry
return true;
}
@ -709,7 +709,7 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
* @return whether [startAddress] was inserted
*/
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;
}

View file

@ -66,6 +66,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
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.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@ -251,6 +253,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private int fAddressSize= 32;
private volatile boolean fUpdatePending;
private volatile int fUpdateCount;
private BigInteger fPCAddress;
private BigInteger fGotoAddressPending= PC_UNKNOWN;
private BigInteger fFocusAddress= PC_UNKNOWN;
@ -1481,13 +1484,15 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
public void viewportChanged(int verticalOffset) {
if (fDebugSessionId != null && fGotoAddressPending == PC_UNKNOWN && fScrollPos == null && !fUpdatePending && !fRefreshViewPending) {
fUpdatePending = true;
final int updateCount = fUpdateCount;
invokeLater(new Runnable() {
public void run() {
if (updateCount == fUpdateCount) {
assert fUpdatePending;
if (fUpdatePending) {
fUpdatePending = false;
updateVisibleArea();
fPCLastAddress = getTopAddress();
}
}
}
});
@ -1677,16 +1682,13 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fDebugSessionId == null) {
return;
}
if (fUpdatePending) {
invokeLater(new Runnable() {
startUpdate(new Runnable() {
public void run() {
retrieveDisassembly(file, lines, mixed);
}});
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) {
if (fDebugSessionId == null) {
@ -1872,7 +1874,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (result != null) {
fDebugSessionId = result.sessionId;
if (result.contextChanged && fViewer != null) {
startUpdate(new Runnable() {
public void run() {
debugContextChanged();
}
});
if (prevBackend != null && fBackend != prevBackend) {
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() {
if (DEBUG) System.out.println("DisassemblyPart.debugContextChanged()"); //$NON-NLS-1$
fUpdateCount++;
fRunnableQueue.clear();
fUpdatePending = false;
resetViewer();
@ -1921,8 +1954,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
firePropertyChange(PROP_SUSPENDED);
}
private void attachBreakpointsAnnotationModel() {
IAnnotationModel annotationModel = fViewer.getAnnotationModel();
if (annotationModel instanceof IAnnotationModelExtension) {
@ -2478,11 +2509,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (doit != null) {
fRunnableQueue.add(doit);
}
final int updateCount = fUpdateCount;
if (fUpdatePending) {
if (fRunnableQueue.size() == 1) {
Runnable doitlater = new Runnable() {
public void run() {
if (updateCount == fUpdateCount) {
doScrollLocked(null);
}
}};
invokeLater(doitlater);
}
@ -2493,6 +2527,9 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
ArrayList<Runnable> copy = new ArrayList<Runnable>(fRunnableQueue);
fRunnableQueue.clear();
for (Iterator<Runnable> iter = copy.iterator(); iter.hasNext();) {
if (updateCount != fUpdateCount) {
return;
}
Runnable doitnow = iter.next();
try {
doitnow.run();
@ -2920,10 +2957,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
asyncExec(new Runnable() {
public void run() {
fDebugSessionId = null;
startUpdate(new Runnable() {
public void run() {
debugContextChanged();
}
});
}
});
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#setUpdatePending(boolean)