mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
Bug 308055: Register values are not updated when switching between frames
This commit is contained in:
parent
4ec5b596be
commit
c13a2bfe52
16 changed files with 669 additions and 24 deletions
|
@ -15,11 +15,13 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||
|
@ -102,15 +104,22 @@ public class CRegisterManager {
|
|||
return fRegisterDescriptors;
|
||||
}
|
||||
|
||||
public IRegisterGroup[] getRegisterGroups() {
|
||||
return (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] );
|
||||
}
|
||||
|
||||
public IRegisterGroup[] getRegisterGroups( CStackFrame frame ) throws DebugException {
|
||||
IRegisterGroup[] groups = (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] );
|
||||
if ( getCurrentFrame() != frame ) {
|
||||
for ( int i = 0; i < groups.length; ++i ) {
|
||||
((CRegisterGroup)groups[i]).resetRegisterValues();
|
||||
}
|
||||
setCurrentFrame( frame );
|
||||
return getRegisterGroups();
|
||||
}
|
||||
|
||||
public void setCurrentFrame( ICStackFrame frame ) throws DebugException {
|
||||
if ( frame != null && !frame.equals( getCurrentFrame() ) ) {
|
||||
for ( IRegisterGroup group : getRegisterGroups() ) {
|
||||
((CRegisterGroup)group).resetRegisterValues();
|
||||
}
|
||||
setCurrentFrame0( (CStackFrame)frame );
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
@ -218,7 +227,7 @@ public class CRegisterManager {
|
|||
}
|
||||
}
|
||||
|
||||
protected CDebugTarget getDebugTarget() {
|
||||
public CDebugTarget getDebugTarget() {
|
||||
return fDebugTarget;
|
||||
}
|
||||
|
||||
|
@ -342,7 +351,7 @@ public class CRegisterManager {
|
|||
return fCurrentFrame;
|
||||
}
|
||||
|
||||
private void setCurrentFrame( CStackFrame currentFrame ) {
|
||||
private void setCurrentFrame0( CStackFrame currentFrame ) {
|
||||
fCurrentFrame = currentFrame;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,7 +223,10 @@ public class CRegister extends CVariable implements ICRegister {
|
|||
}
|
||||
|
||||
public synchronized ICValue getValue() throws DebugException {
|
||||
if ( fValue.equals( CValueFactory.NULL_VALUE ) ) {
|
||||
CStackFrame frame = getCurrentStackFrame();
|
||||
if ( frame == null || frame.isDisposed() )
|
||||
fValue = CValueFactory.NULL_VALUE;
|
||||
else if ( fValue.equals( CValueFactory.NULL_VALUE ) ) {
|
||||
ICDIRegister reg = getCDIRegister();
|
||||
if ( reg != null ) {
|
||||
try {
|
||||
|
|
|
@ -1339,6 +1339,9 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementAdapterFactory">
|
||||
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
|
||||
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
|
||||
</adapter>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.debug.core.model.ICThread"
|
||||
|
@ -1346,6 +1349,9 @@
|
|||
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
|
||||
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
|
||||
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider"/>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
|
||||
</adapter>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.debug.core.model.ICStackFrame"
|
||||
|
@ -1356,6 +1362,9 @@
|
|||
<adapter
|
||||
type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider">
|
||||
</adapter>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
|
||||
</adapter>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.debug.core.model.ICModule"
|
||||
|
@ -1462,6 +1471,22 @@
|
|||
type="org.eclipse.cdt.debug.core.model.IResumeWithoutSignalHandler">
|
||||
</adapter>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.debug.internal.ui.elements.adapters.CRegisterManagerProxy"
|
||||
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementAdapterFactory">
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory">
|
||||
</adapter>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
|
||||
</adapter>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory">
|
||||
</adapter>
|
||||
<adapter
|
||||
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider">
|
||||
</adapter>
|
||||
</factory>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.themes">
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CRegisterManagerProxy;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextManager;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
/**
|
||||
* Singleton that keeps track of <code>CRegisterManagerProxy</code> objects
|
||||
*/
|
||||
public class CRegisterManagerProxies {
|
||||
|
||||
private static CRegisterManagerProxies fgInstance = new CRegisterManagerProxies();
|
||||
|
||||
private Map<ICDebugTarget, CRegisterManagerProxy> fMap;
|
||||
|
||||
public static CRegisterManagerProxies getInstance() {
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
public CRegisterManagerProxies() {
|
||||
super();
|
||||
fMap = new HashMap<ICDebugTarget, CRegisterManagerProxy>();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for ( CRegisterManagerProxy proxy : fMap.values() ) {
|
||||
DebugPlugin.getDefault().removeDebugEventListener( proxy );
|
||||
proxy.dispose();
|
||||
}
|
||||
fMap.clear();
|
||||
}
|
||||
|
||||
public CRegisterManagerProxy getRegisterManagerProxy( ICDebugTarget target ) {
|
||||
CRegisterManagerProxy proxy = fMap.get( target );
|
||||
if ( proxy == null ) {
|
||||
synchronized( this ) {
|
||||
proxy = fMap.get( target );
|
||||
if ( proxy == null ) {
|
||||
proxy = new CRegisterManagerProxy( ((CDebugTarget)target).getRegisterManager() );
|
||||
DebugPlugin.getDefault().addDebugEventListener( proxy );
|
||||
IDebugContextService service = getContextService();
|
||||
if ( service != null ) {
|
||||
ISelection s = service.getActiveContext();
|
||||
if ( s instanceof IStructuredSelection && ((IStructuredSelection)s).size() == 1 ) {
|
||||
Object context = ((IStructuredSelection)s).getFirstElement();
|
||||
proxy.setContext( ( context instanceof ICDebugElement ) ? (ICDebugElement)context : target );
|
||||
}
|
||||
service.addDebugContextListener( proxy );
|
||||
}
|
||||
fMap.put( target, proxy );
|
||||
}
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private IDebugContextService getContextService() {
|
||||
IWorkbenchWindow window = SelectedResourceManager.getDefault().getActiveWindow();
|
||||
if ( window != null ) {
|
||||
IDebugContextManager manager = DebugUITools.getDebugContextManager();
|
||||
return manager.getContextService( window );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -31,9 +31,11 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider;
|
|||
import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelProvider;
|
||||
import org.eclipse.cdt.debug.ui.disassembly.IElementToggleBreakpointAdapter;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider;
|
||||
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
||||
|
||||
public class CDebugElementAdapterFactory implements IAdapterFactory {
|
||||
|
@ -42,6 +44,7 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
private static IElementContentProvider fgThreadContentProvider = new CThreadContentProvider();
|
||||
private static IElementContentProvider fgStackFrameContentProvider = new CStackFrameContentProvider();
|
||||
private static IElementContentProvider fgModuleContentProvider = new ModuleContentProvider();
|
||||
private static IElementContentProvider fgCRegisterManagerContentProvider = new CRegisterManagerContentProvider();
|
||||
|
||||
private static IModelProxyFactory fgDebugElementProxyFactory = new CDebugElementProxyFactory();
|
||||
|
||||
|
@ -54,9 +57,14 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
private static IElementToggleBreakpointAdapter fgDisassemblyToggleBreakpointAdapter = new DisassemblyToggleBreakpointAdapter();
|
||||
private static ISourceDisplay fgSourceDisplayAdapter = new SourceDisplayAdapter();
|
||||
|
||||
private static IViewerInputProvider fgViewerInputProvider = new CViewerInputProvider();
|
||||
private static IColumnPresentationFactory fgRegistersViewColumnPresentationFactory = new RegistersViewColumnPresentationFactory();
|
||||
private static IElementMementoProvider fgRegisterManagerProxyMementoProvider = new CRegisterManagerProxyMementoProvider();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
public Object getAdapter( Object adaptableObject, Class adapterType ) {
|
||||
if ( adapterType.isInstance( adaptableObject ) ) {
|
||||
return adaptableObject;
|
||||
|
@ -71,6 +79,9 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
if ( adaptableObject instanceof ICStackFrame ) {
|
||||
return fgStackFrameContentProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof CRegisterManagerProxy ) {
|
||||
return fgCRegisterManagerContentProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof ICModule ||
|
||||
adaptableObject instanceof ICElement ) {
|
||||
return fgModuleContentProvider;
|
||||
|
@ -91,19 +102,24 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
}
|
||||
if ( adaptableObject instanceof DisassemblyRetrieval ) {
|
||||
return fgDebugElementProxyFactory;
|
||||
}
|
||||
if ( adaptableObject instanceof CRegisterManagerProxy ) {
|
||||
return fgDebugElementProxyFactory;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IElementMementoProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICStackFrame ) {
|
||||
return fgStackFrameMementoProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof IModuleRetrieval ||
|
||||
adaptableObject instanceof ICThread ||
|
||||
adaptableObject instanceof ICModule ||
|
||||
adaptableObject instanceof ICElement)
|
||||
{
|
||||
if ( adaptableObject instanceof IModuleRetrieval
|
||||
|| adaptableObject instanceof ICThread
|
||||
|| adaptableObject instanceof ICModule
|
||||
|| adaptableObject instanceof ICElement ) {
|
||||
return fgModuleMementoProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof CRegisterManagerProxy ) {
|
||||
return fgRegisterManagerProxyMementoProvider;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IDisassemblyContextProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICStackFrame ) {
|
||||
|
@ -130,12 +146,25 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
return fgSourceDisplayAdapter;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IViewerInputProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICDebugTarget
|
||||
|| adaptableObject instanceof ICThread
|
||||
|| adaptableObject instanceof ICStackFrame ) {
|
||||
return fgViewerInputProvider;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IColumnPresentationFactory.class ) ) {
|
||||
if ( adaptableObject instanceof CRegisterManagerProxy ) {
|
||||
return fgRegistersViewColumnPresentationFactory;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||
*/
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] {
|
||||
IElementContentProvider.class,
|
||||
|
@ -147,6 +176,7 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
IDocumentElementAnnotationProvider.class,
|
||||
IElementToggleBreakpointAdapter.class,
|
||||
ISourceDisplay.class,
|
||||
IViewerInputProvider.class,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,11 @@ public class CDebugElementProxyFactory extends DefaultModelProxyFactory {
|
|||
return new ModulesViewModelProxy( mr );
|
||||
}
|
||||
}
|
||||
else if ( IDebugUIConstants.ID_REGISTER_VIEW.equals( context.getId() ) ) {
|
||||
if ( element instanceof CRegisterManagerProxy ) {
|
||||
return new CRegisterManagerModelProxy( (CRegisterManagerProxy)element );
|
||||
}
|
||||
}
|
||||
else if ( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR.equals( context.getId() ) ) {
|
||||
if ( element instanceof DisassemblyRetrieval ) {
|
||||
return new DisassemblyElementProxy( (DisassemblyRetrieval)element );
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
||||
public class CRegisterManagerContentProvider extends ElementContentProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
|
||||
*/
|
||||
@Override
|
||||
protected Object[] getChildren( Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
|
||||
return getElements( getRegisterGroups( (CRegisterManagerProxy)parent ), index, length );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
|
||||
*/
|
||||
@Override
|
||||
protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
|
||||
return getRegisterGroups( (CRegisterManagerProxy)element ).length;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected boolean supportsContextId( String id ) {
|
||||
return IDebugUIConstants.ID_REGISTER_VIEW.equals( id );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
|
||||
*/
|
||||
@Override
|
||||
protected boolean hasChildren( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
|
||||
return getRegisterGroups( (CRegisterManagerProxy)element ).length > 0;
|
||||
}
|
||||
|
||||
private IRegisterGroup[] getRegisterGroups( CRegisterManagerProxy rmp ) {
|
||||
return rmp.getRegisterGroups();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
public class CRegisterManagerModelProxy extends AbstractModelProxy {
|
||||
|
||||
private CRegisterManagerProxy fRegisterManagerProxy;
|
||||
|
||||
public CRegisterManagerModelProxy( CRegisterManagerProxy rmp ) {
|
||||
super();
|
||||
fRegisterManagerProxy = rmp;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy#installed(org.eclipse.jface.viewers.Viewer)
|
||||
*/
|
||||
@Override
|
||||
public void installed( Viewer viewer ) {
|
||||
fRegisterManagerProxy.setModelProxy( this );
|
||||
super.installed( viewer );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#dispose()
|
||||
*/
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
fRegisterManagerProxy.setModelProxy( null );
|
||||
fRegisterManagerProxy = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
ModelDelta delta = new ModelDelta( fRegisterManagerProxy, IModelDelta.CONTENT );
|
||||
fireModelChanged( delta );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.ICThread;
|
||||
import org.eclipse.cdt.debug.internal.core.CRegisterManager;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
/**
|
||||
* Acts as a viewer input for the Registers view
|
||||
*/
|
||||
public class CRegisterManagerProxy implements IDebugEventSetListener, IDebugContextListener {
|
||||
|
||||
private CRegisterManager fRegisterManager;
|
||||
private ICDebugElement fContext;
|
||||
private CRegisterManagerModelProxy fModelProxy;
|
||||
|
||||
public CRegisterManagerProxy( CRegisterManager registerManager ) {
|
||||
super();
|
||||
fRegisterManager = registerManager;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
fRegisterManager = null;
|
||||
fContext = null;
|
||||
fModelProxy = null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
|
||||
*/
|
||||
public void debugContextChanged( DebugContextEvent event ) {
|
||||
ICDebugElement context = null;
|
||||
ISelection s = event.getContext();
|
||||
if ( s instanceof IStructuredSelection ) {
|
||||
IStructuredSelection selection = (IStructuredSelection)s;
|
||||
context =
|
||||
( selection.size() == 1 ) ?
|
||||
( selection.getFirstElement() instanceof ICDebugElement ) ?
|
||||
(ICDebugElement)selection.getFirstElement() : null
|
||||
: null;
|
||||
}
|
||||
setContext( context );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
||||
*/
|
||||
public void handleDebugEvents( DebugEvent[] events ) {
|
||||
CRegisterManagerModelProxy modelProxy = getModelProxy();
|
||||
for( int i = 0; i < events.length; i++ ) {
|
||||
DebugEvent event = events[i];
|
||||
Object source = event.getSource();
|
||||
if ( source instanceof ICDebugTarget
|
||||
&& fRegisterManager.getDebugTarget().equals( source )
|
||||
&& (( event.getKind() == DebugEvent.SUSPEND ) || event.getKind() == DebugEvent.TERMINATE ) ) {
|
||||
if ( modelProxy != null )
|
||||
modelProxy.update();
|
||||
}
|
||||
else if ( source instanceof ICThread
|
||||
&& fRegisterManager.getDebugTarget().equals( ((ICThread)source).getDebugTarget() )
|
||||
&& event.getKind() == DebugEvent.SUSPEND ) {
|
||||
if ( modelProxy != null )
|
||||
modelProxy.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IRegisterGroup[] getRegisterGroups() {
|
||||
return fRegisterManager.getRegisterGroups();
|
||||
}
|
||||
|
||||
public void setModelProxy( CRegisterManagerModelProxy modelProxy ) {
|
||||
fModelProxy = modelProxy;
|
||||
}
|
||||
|
||||
public CRegisterManagerModelProxy getModelProxy() {
|
||||
return fModelProxy;
|
||||
}
|
||||
|
||||
public String getModelIdentifier() {
|
||||
return fRegisterManager.getDebugTarget().getModelIdentifier();
|
||||
}
|
||||
|
||||
public void setContext( ICDebugElement context ) {
|
||||
if ( fContext == null || !fContext.equals( context ) ) {
|
||||
fContext = context;
|
||||
try {
|
||||
fRegisterManager.setCurrentFrame( ( fContext instanceof ICStackFrame ) ? (ICStackFrame)context : null );
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
// TODO: should we pass the error up?
|
||||
}
|
||||
CRegisterManagerModelProxy modelProxy = getModelProxy();
|
||||
if ( modelProxy != null )
|
||||
modelProxy.update();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
||||
public class CRegisterManagerProxyMementoProvider extends DebugElementMementoProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.DebugElementMementoProvider#getElementName(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
@Override
|
||||
protected String getElementName( Object element, IPresentationContext context ) throws CoreException {
|
||||
if ( element instanceof CRegisterManagerProxy ) {
|
||||
if ( IDebugUIConstants.ID_REGISTER_VIEW.equals( context.getId() ) ) {
|
||||
return ((CRegisterManagerProxy)element).getModelIdentifier();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||
import org.eclipse.cdt.debug.internal.ui.CRegisterManagerProxies;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.internal.ui.model.elements.ViewerInputProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
||||
public class CViewerInputProvider extends ViewerInputProvider implements IViewerInputProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ViewerInputProvider#getViewerInput(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
|
||||
*/
|
||||
@Override
|
||||
protected Object getViewerInput( Object source, IPresentationContext context, IViewerUpdate update ) throws CoreException {
|
||||
if ( IDebugUIConstants.ID_REGISTER_VIEW.equals( context.getId() ) && source instanceof ICDebugElement ) {
|
||||
ICDebugTarget target = (ICDebugTarget)((ICDebugElement)source).getDebugTarget();
|
||||
return CRegisterManagerProxies.getInstance().getRegisterManagerProxy( target );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ViewerInputProvider#supportsContextId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected boolean supportsContextId( String id ) {
|
||||
return IDebugUIConstants.ID_REGISTER_VIEW.equals( id );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class ElementAdapterMessages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.elements.adapters.ElementAdapterMessages"; //$NON-NLS-1$
|
||||
|
||||
public static String RegistersViewColumnPresentation_0;
|
||||
|
||||
public static String RegistersViewColumnPresentation_1;
|
||||
|
||||
public static String RegistersViewColumnPresentation_2;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages( BUNDLE_NAME, ElementAdapterMessages.class );
|
||||
}
|
||||
|
||||
private ElementAdapterMessages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
RegistersViewColumnPresentation_0=Type
|
||||
RegistersViewColumnPresentation_1=Name
|
||||
RegistersViewColumnPresentation_2=Value
|
|
@ -0,0 +1,106 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
|
||||
/**
|
||||
* Registers View columns
|
||||
*/
|
||||
public class RegistersViewColumnPresentation implements IColumnPresentation {
|
||||
|
||||
private static final String PREFIX = CDebugUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
|
||||
|
||||
public static final String ID = PREFIX + "registersViewColumnPresentationId"; //$NON-NLS-1$
|
||||
|
||||
private static final String COLUMN_ID_NAME = VariableColumnPresentation.COLUMN_VARIABLE_NAME;
|
||||
private static final String COLUMN_ID_TYPE = VariableColumnPresentation.COLUMN_VARIABLE_TYPE;
|
||||
private static final String COLUMN_ID_VALUE = VariableColumnPresentation.COLUMN_VARIABLE_VALUE;
|
||||
|
||||
private static final String[] ALL_COLUMNS = new String[] {
|
||||
COLUMN_ID_NAME,
|
||||
COLUMN_ID_TYPE,
|
||||
COLUMN_ID_VALUE
|
||||
};
|
||||
|
||||
private static final String[] INITIAL_COLUMNS = new String[] {
|
||||
COLUMN_ID_NAME,
|
||||
COLUMN_ID_VALUE
|
||||
};
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#init(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
public void init( IPresentationContext context ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getAvailableColumns()
|
||||
*/
|
||||
public String[] getAvailableColumns() {
|
||||
return ALL_COLUMNS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getInitialColumns()
|
||||
*/
|
||||
public String[] getInitialColumns() {
|
||||
return INITIAL_COLUMNS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getHeader(java.lang.String)
|
||||
*/
|
||||
public String getHeader( String id ) {
|
||||
if ( COLUMN_ID_TYPE.equals( id ) ) {
|
||||
return ElementAdapterMessages.RegistersViewColumnPresentation_0;
|
||||
}
|
||||
if ( COLUMN_ID_NAME.equals( id ) ) {
|
||||
return ElementAdapterMessages.RegistersViewColumnPresentation_1;
|
||||
}
|
||||
if ( COLUMN_ID_VALUE.equals( id ) ) {
|
||||
return ElementAdapterMessages.RegistersViewColumnPresentation_2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getImageDescriptor(java.lang.String)
|
||||
*/
|
||||
public ImageDescriptor getImageDescriptor( String id ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation#isOptional()
|
||||
*/
|
||||
public boolean isOptional() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* CodeSourcery - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
||||
public class RegistersViewColumnPresentationFactory implements IColumnPresentationFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory#createColumnPresentation(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
|
||||
*/
|
||||
public IColumnPresentation createColumnPresentation( IPresentationContext context, Object element ) {
|
||||
if ( context.getId().equals( IDebugUIConstants.ID_REGISTER_VIEW ) )
|
||||
return new RegistersViewColumnPresentation();
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory#getColumnPresentationId(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
|
||||
*/
|
||||
public String getColumnPresentationId( IPresentationContext context, Object element ) {
|
||||
if ( context.getId().equals( IDebugUIConstants.ID_REGISTER_VIEW ) )
|
||||
return RegistersViewColumnPresentation.ID;
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.debug.internal.ui.CBreakpointUpdater;
|
|||
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebuggerPageAdapter;
|
||||
import org.eclipse.cdt.debug.internal.ui.CRegisterManagerProxies;
|
||||
import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.EvaluationContextManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||
|
@ -331,6 +332,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
|
|||
@Override
|
||||
public void stop( BundleContext context ) throws Exception {
|
||||
CDebugCorePlugin.getDefault().removeCBreakpointListener( CBreakpointUpdater.getInstance() );
|
||||
CRegisterManagerProxies.getInstance().dispose();
|
||||
fDisassemblyEditorManager.dispose();
|
||||
if ( fImageDescriptorRegistry != null ) {
|
||||
fImageDescriptorRegistry.dispose();
|
||||
|
|
Loading…
Add table
Reference in a new issue