1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

Bug 330259 - [disassembly] debug context is not per workbench window

This commit is contained in:
Patrick Chuong 2010-11-24 14:39:28 +00:00
parent 671675293a
commit 9865f25dbc

View file

@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug fix (326670) * Patrick Chuong (Texas Instruments) - Bug fix (326670)
* Patrick Chuong (Texas Instruments) - Bug fix (329682) * Patrick Chuong (Texas Instruments) - Bug fix (329682)
* Patrick Chuong (Texas Instruments) - bug fix (330259)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -73,6 +74,7 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent; import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
@ -116,7 +118,9 @@ 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.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.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyleRange;
@ -713,7 +717,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected void setSite(IWorkbenchPartSite site) { protected void setSite(IWorkbenchPartSite site) {
super.setSite(site); super.setSite(site);
site.getPage().addPartListener(fPartListener); site.getPage().addPartListener(fPartListener);
DebugUITools.getDebugContextManager().addDebugContextListener(fDebugContextListener = new IDebugContextListener() { IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(site.getWorkbenchWindow());
contextService.addDebugContextListener(fDebugContextListener = new IDebugContextListener() {
public void debugContextChanged(DebugContextEvent event) { public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) {
updateDebugContext(); updateDebugContext();
@ -1841,29 +1846,37 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} }
protected void updateDebugContext() { protected void updateDebugContext() {
IAdaptable context = DebugUITools.getDebugContext(); IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow());
final IDisassemblyBackend prevBackend = fBackend; ISelection activeContext = contextService.getActiveContext();
fDebugSessionId = null; if (activeContext instanceof IStructuredSelection) {
if (context != null) { Object selectedElement = ((IStructuredSelection) activeContext).getFirstElement();
if (fBackend == null || !fBackend.supportsDebugContext(context)) { if (selectedElement instanceof IAdaptable) {
if (fBackend != null) { IAdaptable context = (IAdaptable) selectedElement;
fBackend.clearDebugContext();
fBackend.dispose();
}
fBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
if (fBackend != null) {
fBackend.init(this);
}
}
if (fBackend != null) { final IDisassemblyBackend prevBackend = fBackend;
IDisassemblyBackend.SetDebugContextResult result = fBackend.setDebugContext(context); fDebugSessionId = null;
if (result != null) { if (context != null) {
fDebugSessionId = result.sessionId; if (fBackend == null || !fBackend.supportsDebugContext(context)) {
if (result.contextChanged && fViewer != null) { if (fBackend != null) {
debugContextChanged(); fBackend.clearDebugContext();
if (prevBackend != null && fBackend != prevBackend) { fBackend.dispose();
prevBackend.clearDebugContext(); }
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) {
debugContextChanged();
if (prevBackend != null && fBackend != prevBackend) {
prevBackend.clearDebugContext();
}
}
} }
} }
} }
@ -1965,13 +1978,18 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} }
private BigInteger getTopAddress() { private BigInteger getTopAddress() {
BigInteger topAddress = getAddressOfLine(fViewer.getTopIndex()); if (fViewer != null) {
if (topAddress.equals(fStartAddress)) { BigInteger topAddress = getAddressOfLine(fViewer.getTopIndex());
// in rare cases, the top line can be '...' if (topAddress.equals(fStartAddress)) {
// don't use it as reference, take the next line // in rare cases, the top line can be '...'
topAddress = getAddressOfLine(fViewer.getTopIndex() + 1); // don't use it as reference, take the next line
topAddress = getAddressOfLine(fViewer.getTopIndex() + 1);
}
return topAddress;
} else {
return PC_UNKNOWN;
} }
return topAddress;
} }
private void resetViewer() { private void resetViewer() {