1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

Bug 304108 - [Disassembly] Disassembly view should clear when there is no debug context

This commit is contained in:
Anton Leherbauer 2011-01-17 08:12:25 +00:00
parent 81261aee47
commit c50b35dc33
3 changed files with 63 additions and 48 deletions

View file

@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation
* Freescale Semiconductor - refactoring
* Patrick Chuong (Texas Instruments) - Bug fix (329682)
* Patrick Chuong (Texas Instruments) - Bug fix (304108)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -72,7 +73,8 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#init(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback)
*/
public void init(IDisassemblyPartCallback callback) {
@Override
public void init(IDisassemblyPartCallback callback) {
super.init(callback);
DebugPlugin.getDefault().addDebugEventListener(this);
}
@ -103,7 +105,6 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
assert supportsDebugContext(context) : "caller should not have invoked us"; //$NON-NLS-1$
SetDebugContextResult result = new SetDebugContextResult();
result.sessionId = fCdiSessionId; // initial value; may change
ICDebugTarget cdiDebugTarget = (ICDebugTarget)((ICDebugElement)context).getDebugTarget();
String cdiSessionId = getSessionId(cdiDebugTarget);
@ -112,9 +113,10 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
if (!cdiSessionId.equals(fCdiSessionId)) {
fTargetContext = null;
fTargetFrameContext = null;
result.contextChanged = true;
if (context instanceof ICStackFrame) {
fTargetFrameContext = null;
fFrameLevel = 0;
fTargetContext = (ICThread)((ICStackFrame)context).getThread();
try {
@ -136,16 +138,18 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
if (fTargetContext != null) {
result.sessionId = fCdiSessionId = cdiSessionId;
result.contextChanged = true;
}
}
else if (context instanceof ICStackFrame) {
result.sessionId = fCdiSessionId;
fTargetFrameContext = null;
fFrameLevel = 0;
ICThread newTargetContext = (ICThread)((ICStackFrame)context).getThread();
ICThread oldTargetContext = fTargetContext;
fTargetContext = newTargetContext;
if (oldTargetContext != null && newTargetContext != null) {
if (oldTargetContext == null) {
result.contextChanged = true;
} else if (/*oldTargetContext != null && */newTargetContext != null) {
result.contextChanged = !oldTargetContext.getDebugTarget().equals(newTargetContext.getDebugTarget());
}
try {
@ -166,6 +170,10 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
if (!result.contextChanged) {
fCallback.gotoFrame(fFrameLevel);
}
} else {
fTargetContext = null;
fTargetFrameContext = null;
result.contextChanged = true;
}
return result;
@ -361,7 +369,8 @@ public class DisassemblyBackendCdi extends AbstractDisassemblyBackend implements
* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#evaluateSymbolAddress(java.lang.String, boolean)
*/
public BigInteger evaluateAddressExpression(String symbol, final boolean suppressError) {
@Override
public BigInteger evaluateAddressExpression(String symbol, final boolean suppressError) {
if (fTargetFrameContext != null) {
try {
// This logic was lifted from CMemoryBlockRetrievalExtension.getExtendedMemoryBlock(String, Object)

View file

@ -161,15 +161,16 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
IDMContext dmContext = vmContext.getDMContext();
SetDebugContextResult result = new SetDebugContextResult();
result.sessionId = fDsfSessionId; // initial value; may change
String dsfSessionId = dmContext.getSessionId();
if (!dsfSessionId.equals(fDsfSessionId)) {
// switch to different session or initiate session
if (DEBUG) System.out.println("DisassemblyBackendDsf() " + dsfSessionId); //$NON-NLS-1$
fTargetContext= null;
fTargetFrameContext = null;
result.contextChanged = true;
if (dmContext instanceof IFrameDMContext) {
IFrameDMContext frame= (IFrameDMContext) dmContext;
IExecutionDMContext executionContext= DMContexts.getAncestorOfType(frame, IExecutionDMContext.class);
@ -201,7 +202,6 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
fServicesTracker.dispose();
}
fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fDsfSessionId);
result.contextChanged = true;
// add ourselves as a listener with the new session (context)
final DsfSession newSession = DsfSession.getSession(dsfSessionId);
@ -218,6 +218,7 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
}
}
} else if (dmContext instanceof IFrameDMContext) {
result.sessionId = fDsfSessionId;
// switch to different frame
IFrameDMContext frame= (IFrameDMContext) dmContext;
IExecutionDMContext newExeDmc = DMContexts.getAncestorOfType(frame, IExecutionDMContext.class);
@ -230,7 +231,15 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
if (!result.contextChanged) {
fCallback.gotoFrameIfActive(frame.getLevel());
}
} else {
fTargetContext = null;
fTargetFrameContext = null;
result.contextChanged = true;
}
} else {
fTargetContext = null;
fTargetFrameContext = null;
result.contextChanged = true;
}
return result;

View file

@ -120,9 +120,7 @@ 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;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@ -1847,46 +1845,45 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
return -1;
}
protected void updateDebugContext() {
IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow());
ISelection activeContext = contextService.getActiveContext();
if (activeContext instanceof IStructuredSelection) {
Object selectedElement = ((IStructuredSelection) activeContext).getFirstElement();
if (selectedElement instanceof IAdaptable) {
IAdaptable context = (IAdaptable) selectedElement;
final IDisassemblyBackend prevBackend = fBackend;
fDebugSessionId = null;
if (context != null) {
if (fBackend == null || !fBackend.supportsDebugContext(context)) {
if (fBackend != null) {
fBackend.clearDebugContext();
fBackend.dispose();
}
fBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
if (fBackend != null) {
fBackend.init(this);
}
}
if (fBackend != null) {
IDisassemblyBackend.SetDebugContextResult result = fBackend.setDebugContext(context);
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();
}
}
}
protected void updateDebugContext() {
IAdaptable context = DebugUITools.getDebugContext();
final IDisassemblyBackend prevBackend = fBackend;
fDebugSessionId = null;
if (context != null) {
boolean needUpdate = false;
if (prevBackend == null || !prevBackend.supportsDebugContext(context)) {
needUpdate = true;
fBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
if (fBackend != null) {
if (fBackend.supportsDebugContext(context)) {
fBackend.init(this);
} else {
fBackend = null;
}
}
}
if (fBackend != null) {
IDisassemblyBackend.SetDebugContextResult result = fBackend.setDebugContext(context);
if (result != null) {
fDebugSessionId = result.sessionId;
if (result.contextChanged) {
needUpdate = true;
}
}
}
if (prevBackend != null && fBackend != prevBackend) {
needUpdate = true;
prevBackend.clearDebugContext();
prevBackend.dispose();
}
if (needUpdate && fViewer != null) {
startUpdate(new Runnable() {
public void run() {
debugContextChanged();
}
});
}
}
}