Implementation of Registers view.
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
|||
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISignal;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope;
|
||||
|
@ -64,6 +65,7 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
|||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IMemoryBlock;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.eclipse.debug.core.model.IThread;
|
||||
|
||||
/**
|
||||
|
@ -173,6 +175,11 @@ public class CDebugTarget extends CDebugElement
|
|||
*/
|
||||
private HashMap fBreakpoints;
|
||||
|
||||
/**
|
||||
* Collection of register groups added to this target. Values are of type <code>CRegisterGroup</code>.
|
||||
*/
|
||||
private List fRegisterGroups;
|
||||
|
||||
/**
|
||||
* Constructor for CDebugTarget.
|
||||
* @param target
|
||||
|
@ -211,6 +218,7 @@ public class CDebugTarget extends CDebugElement
|
|||
{
|
||||
initializeState();
|
||||
initializeBreakpoints();
|
||||
initializeRegisters();
|
||||
getLaunch().addDebugTarget( this );
|
||||
fireCreationEvent();
|
||||
}
|
||||
|
@ -257,6 +265,12 @@ public class CDebugTarget extends CDebugElement
|
|||
}
|
||||
}
|
||||
|
||||
protected void initializeRegisters()
|
||||
{
|
||||
fRegisterGroups = new ArrayList( 20 );
|
||||
createMainRegisterGroup();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
|
||||
*/
|
||||
|
@ -974,6 +988,7 @@ public class CDebugTarget extends CDebugElement
|
|||
protected void cleanup()
|
||||
{
|
||||
removeAllThreads();
|
||||
removeAllRegisterGroups();
|
||||
getCDISession().getEventManager().removeEventListener( this );
|
||||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
|
||||
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
|
||||
|
@ -1596,4 +1611,40 @@ public class CDebugTarget extends CDebugElement
|
|||
{
|
||||
return isAvailable() && isSuspended();
|
||||
}
|
||||
|
||||
protected IRegisterGroup[] getRegisterGroups( CStackFrame stackFrame ) throws DebugException
|
||||
{
|
||||
Iterator it = fRegisterGroups.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
((CRegisterGroup)it.next()).refresh( stackFrame );
|
||||
}
|
||||
return (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] );
|
||||
}
|
||||
|
||||
protected void createMainRegisterGroup()
|
||||
{
|
||||
ICDIRegisterObject[] regObjects = null;
|
||||
try
|
||||
{
|
||||
regObjects = getCDITarget().getRegisterObjects();
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
if ( regObjects != null )
|
||||
{
|
||||
fRegisterGroups.add( new CRegisterGroup( this, "Main", regObjects ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeAllRegisterGroups()
|
||||
{
|
||||
Iterator it = fRegisterGroups.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
((CRegisterGroup)it.next()).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Sep 16, 2002
|
||||
*/
|
||||
public class CRegister extends CModificationVariable implements IRegister
|
||||
{
|
||||
/**
|
||||
* Constructor for CRegister.
|
||||
* @param parent
|
||||
* @param cdiVariable
|
||||
*/
|
||||
public CRegister( CRegisterGroup parent, ICDIRegister cdiRegister )
|
||||
{
|
||||
super( parent, cdiRegister );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegister#getRegisterGroup()
|
||||
*/
|
||||
public IRegisterGroup getRegisterGroup() throws DebugException
|
||||
{
|
||||
return (IRegisterGroup)getParent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Sep 16, 2002
|
||||
*/
|
||||
public class CRegisterGroup extends CDebugElement implements IRegisterGroup
|
||||
{
|
||||
private String fName;
|
||||
private ICDIRegisterObject[] fRegisterObjects;
|
||||
private List fRegisters;
|
||||
private CStackFrame fCurrentStackFrame = null;
|
||||
|
||||
/**
|
||||
* Whether the registers need refreshing
|
||||
*/
|
||||
private boolean fRefresh = true;
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterGroup.
|
||||
* @param target
|
||||
*/
|
||||
public CRegisterGroup( CDebugTarget target, String name, ICDIRegisterObject[] regObjects )
|
||||
{
|
||||
super( target );
|
||||
fName = name;
|
||||
fRegisterObjects = regObjects;
|
||||
fRegisters = new ArrayList();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegisterGroup#getName()
|
||||
*/
|
||||
public String getName() throws DebugException
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegisterGroup#getRegisters()
|
||||
*/
|
||||
public IRegister[] getRegisters() throws DebugException
|
||||
{
|
||||
List list = getRegisters0();
|
||||
return (IRegister[])list.toArray( new IRegister[list.size()] );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegisterGroup#hasRegisters()
|
||||
*/
|
||||
public boolean hasRegisters() throws DebugException
|
||||
{
|
||||
return getRegisters0().size() > 0;
|
||||
}
|
||||
|
||||
private List getRegisters0() throws DebugException
|
||||
{
|
||||
if ( fRegisters == null )
|
||||
{
|
||||
ICDIRegister[] regs = getCDIRegisters();
|
||||
fRegisters = new ArrayList( regs.length );
|
||||
for ( int i = 0; i < regs.length; ++i )
|
||||
{
|
||||
fRegisters.add( new CRegister( this, regs[i] ) );
|
||||
}
|
||||
}
|
||||
else if ( fRefresh )
|
||||
{
|
||||
updateRegisters();
|
||||
}
|
||||
fRefresh = false;
|
||||
return fRegisters;
|
||||
}
|
||||
|
||||
protected void dispose()
|
||||
{
|
||||
Iterator it = fRegisters.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
((CRegister)it.next()).dispose();
|
||||
}
|
||||
fRegisters.clear();
|
||||
}
|
||||
|
||||
protected void refresh( CStackFrame stackFrame )
|
||||
{
|
||||
setCurrentStackFrame( stackFrame );
|
||||
fRefresh = true;
|
||||
}
|
||||
|
||||
private ICDIRegister[] getCDIRegisters() throws DebugException
|
||||
{
|
||||
ICDIRegister[] result = new ICDIRegister[0];
|
||||
CStackFrame currentFrame = getCurrentStackFrame();
|
||||
if ( currentFrame != null )
|
||||
{
|
||||
/*
|
||||
try
|
||||
{
|
||||
*/
|
||||
result = getCurrentStackFrame().getCDIStackFrame().getRegisters( fRegisterObjects );
|
||||
/*
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
targetRequestFailed( e.getMessage(), null );
|
||||
}
|
||||
*/
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void setCurrentStackFrame( CStackFrame stackFrame )
|
||||
{
|
||||
fCurrentStackFrame = stackFrame;
|
||||
}
|
||||
|
||||
protected CStackFrame getCurrentStackFrame()
|
||||
{
|
||||
return fCurrentStackFrame;
|
||||
}
|
||||
|
||||
private void updateRegisters() throws DebugException
|
||||
{
|
||||
ICDIRegister[] cdiRegisters = getCDIRegisters();
|
||||
int index = 0;
|
||||
while( index < fRegisters.size() && index < cdiRegisters.length )
|
||||
{
|
||||
CRegister register = (CRegister)fRegisters.get( index );
|
||||
if ( !cdiRegisters[index].equals( register.getCDIVariable() ) )
|
||||
{
|
||||
register.setCDIVariable( cdiRegisters[index] );
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -220,7 +220,7 @@ public class CStackFrame extends CDebugElement
|
|||
*/
|
||||
public IRegisterGroup[] getRegisterGroups() throws DebugException
|
||||
{
|
||||
return new IRegisterGroup[0];
|
||||
return ((CDebugTarget)getDebugTarget()).getRegisterGroups( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -228,7 +228,7 @@ public class CStackFrame extends CDebugElement
|
|||
*/
|
||||
public boolean hasRegisterGroups() throws DebugException
|
||||
{
|
||||
return getRegisterGroups().length > 0;
|
||||
return ((CDebugTarget)getDebugTarget()).getRegisterGroups( this ).length > 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
After Width: | Height: | Size: 171 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/tnames_co.gif
Normal file
After Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 97 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/dlcl16/tnames_co.gif
Normal file
After Width: | Height: | Size: 101 B |
After Width: | Height: | Size: 165 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/elcl16/tnames_co.gif
Normal file
After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 118 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/register_obj.gif
Normal file
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 255 B |
|
@ -9,8 +9,9 @@ providerName=Eclipse.org
|
|||
RegistersView.name=Registers
|
||||
MemoryView.name=Memory
|
||||
|
||||
MemoryPreferencePage.name=Memory Views
|
||||
CDebuggerPage.name=C Debugger UI Page
|
||||
MemoryPreferencePage.name=Memory Views
|
||||
RegistersPreferencePage.name=Registers View
|
||||
|
||||
RunMenu.label=&Run
|
||||
DebugActionSet.label=C/C++ Debug
|
||||
|
|
|
@ -75,6 +75,12 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage"
|
||||
id="org.eclipse.cdt.debug.ui.MemoryViewPreferencePage">
|
||||
</page>
|
||||
<page
|
||||
name="%RegistersPreferencePage.name"
|
||||
category="org.eclipse.debug.ui.DebugPreferencePage"
|
||||
class="org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage"
|
||||
id="org.eclipse.cdt.debug.ui.RegistersViewPreferencePage">
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.actionSets">
|
||||
|
@ -231,4 +237,5 @@
|
|||
id="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover">
|
||||
</textHover>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.eclipse.debug.core.DebugPlugin;
|
|||
import org.eclipse.debug.core.model.IBreakpoint;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IDisconnect;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.eclipse.debug.core.model.IStackFrame;
|
||||
import org.eclipse.debug.core.model.ITerminate;
|
||||
import org.eclipse.debug.core.model.IThread;
|
||||
|
@ -175,6 +177,14 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
{
|
||||
return getBreakpointImage( (ICBreakpoint)element );
|
||||
}
|
||||
if ( element instanceof IRegisterGroup )
|
||||
{
|
||||
return getRegisterGroupImage( (IRegisterGroup)element );
|
||||
}
|
||||
if ( element instanceof IRegister )
|
||||
{
|
||||
return getRegisterImage( (IRegister)element );
|
||||
}
|
||||
if ( element instanceof IVariable )
|
||||
{
|
||||
return getVariableImage( (IVariable)element );
|
||||
|
@ -195,6 +205,12 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
StringBuffer label = new StringBuffer();
|
||||
try
|
||||
{
|
||||
if ( element instanceof IRegisterGroup )
|
||||
{
|
||||
label.append( ((IRegisterGroup)element).getName() );
|
||||
return label.toString();
|
||||
}
|
||||
|
||||
if ( element instanceof IVariable )
|
||||
{
|
||||
label.append( getVariableText( (IVariable)element ) );
|
||||
|
@ -645,4 +661,14 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Image getRegisterGroupImage( IRegisterGroup element ) throws DebugException
|
||||
{
|
||||
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_REGISTER_GROUP, 0 ) );
|
||||
}
|
||||
|
||||
protected Image getRegisterImage( IRegister element ) throws DebugException
|
||||
{
|
||||
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_REGISTER, 0 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,11 @@ public class CDebugImages
|
|||
public static final String IMG_OBJS_VARIABLE_AGGREGATE = NAME_PREFIX + "var_aggr.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_VARIABLE_POINTER = NAME_PREFIX + "var_pointer.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_VARIABLE_STRING = NAME_PREFIX + "var_string.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_REGISTER_GROUP = NAME_PREFIX + "registergroup_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_REGISTER = NAME_PREFIX + "register_obj.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Set of predefined Image Descriptors.
|
||||
|
@ -65,7 +70,7 @@ public class CDebugImages
|
|||
private static final String T_OBJ = "obj16"; //$NON-NLS-1$
|
||||
private static final String T_OVR = "ovr16"; //$NON-NLS-1$
|
||||
private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$
|
||||
private static final String T_LCL = "clcl16"; //$NON-NLS-1$
|
||||
private static final String T_LCL = "lcl16"; //$NON-NLS-1$
|
||||
private static final String T_CTOOL = "ctool16"; //$NON-NLS-1$
|
||||
private static final String T_CVIEW = "cview16"; //$NON-NLS-1$
|
||||
private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$
|
||||
|
@ -83,6 +88,8 @@ public class CDebugImages
|
|||
public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE = createManaged( T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE );
|
||||
public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER = createManaged( T_OBJ, IMG_OBJS_VARIABLE_POINTER );
|
||||
public static final ImageDescriptor DESC_OBJS_VARIABLE_STRING = createManaged( T_OBJ, IMG_OBJS_VARIABLE_STRING );
|
||||
public static final ImageDescriptor DESC_OBJS_REGISTER_GROUP = createManaged( T_OBJ, IMG_OBJS_REGISTER_GROUP );
|
||||
public static final ImageDescriptor DESC_OBJS_REGISTER = createManaged( T_OBJ, IMG_OBJS_REGISTER );
|
||||
|
||||
/**
|
||||
* Returns the image managed under the given key in this registry.
|
||||
|
@ -110,7 +117,7 @@ public class CDebugImages
|
|||
*/
|
||||
public static void setLocalImageDescriptors( IAction action, String iconName )
|
||||
{
|
||||
setImageDescriptors( action, "lcl16", iconName ); //$NON-NLS-1$
|
||||
setImageDescriptors( action, T_LCL, iconName );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -126,6 +133,7 @@ public class CDebugImages
|
|||
|
||||
private static void setImageDescriptors( IAction action, String type, String relPath )
|
||||
{
|
||||
relPath = relPath.substring( NAME_PREFIX_LENGTH );
|
||||
try
|
||||
{
|
||||
ImageDescriptor id = ImageDescriptor.createFromURL( makeIconFileURL( "d" + type, relPath ) ); //$NON-NLS-1$
|
||||
|
|
|
@ -22,10 +22,15 @@ public interface ICDebugHelpContextIds
|
|||
{
|
||||
public static final String PREFIX = ICDebugUIConstants.PLUGIN_ID + "."; //$NON-NLS-1$
|
||||
|
||||
// Actions
|
||||
public static final String CHANGE_REGISTER_VALUE_ACTION = PREFIX + "change_register_value_action_context"; //$NON-NLS-1$
|
||||
public static final String SHOW_TYPES_ACTION = PREFIX + "show_types_action_context"; //$NON-NLS-1$
|
||||
|
||||
// Views
|
||||
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$
|
||||
public static final String MEMORY_VIEW = PREFIX + "memory_view_context"; //$NON-NLS-1$
|
||||
|
||||
// Preference pages
|
||||
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$
|
||||
public static final String REGISTERS_PREFERENCE_PAGE = PREFIX + "registers_preference_page_context"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.custom.TreeEditor;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.ui.actions.SelectionProviderAction;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Sep 16, 2002
|
||||
*/
|
||||
public class ChangeRegisterValueAction extends SelectionProviderAction
|
||||
{
|
||||
protected Tree fTree;
|
||||
protected TreeEditor fTreeEditor;
|
||||
|
||||
/**
|
||||
* Constructor for ChangeRegisterValueAction.
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public ChangeRegisterValueAction( Viewer viewer )
|
||||
{
|
||||
super( viewer, "Change Register Value" );
|
||||
setDescription( "Change Register Value" );
|
||||
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_CHANGE_REGISTER_VALUE );
|
||||
fTree = ((TreeViewer)viewer).getTree();
|
||||
fTreeEditor = new TreeEditor( fTree );
|
||||
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.CHANGE_REGISTER_VALUE_ACTION );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredViewer;
|
||||
import org.eclipse.swt.custom.BusyIndicator;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
|
||||
/**
|
||||
*
|
||||
* An action that toggles the state of a viewer to show/hide type names
|
||||
* of registers.
|
||||
*
|
||||
* @since Sep 16, 2002
|
||||
*/
|
||||
public class ShowRegisterTypesAction extends Action
|
||||
{
|
||||
private StructuredViewer fViewer;
|
||||
|
||||
/**
|
||||
* Constructor for ShowRegisterTypesAction.
|
||||
*/
|
||||
public ShowRegisterTypesAction( StructuredViewer viewer )
|
||||
{
|
||||
super( "Show &Type Names" );
|
||||
setViewer( viewer );
|
||||
setToolTipText( "Show Type Names" );
|
||||
CDebugImages.setLocalImageDescriptors( this, CDebugImages.IMG_LCL_TYPE_NAMES );
|
||||
setId( CDebugUIPlugin.getUniqueIdentifier() + ".ShowTypesAction" ); //$NON-NLS-1$
|
||||
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.SHOW_TYPES_ACTION );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Action#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
valueChanged( isChecked() );
|
||||
}
|
||||
|
||||
private void valueChanged( boolean on )
|
||||
{
|
||||
if ( getViewer().getControl().isDisposed() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
ILabelProvider labelProvider = (ILabelProvider)getViewer().getLabelProvider();
|
||||
if ( labelProvider instanceof IDebugModelPresentation )
|
||||
{
|
||||
IDebugModelPresentation debugLabelProvider = (IDebugModelPresentation)labelProvider;
|
||||
debugLabelProvider.setAttribute( IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES, ( on ? Boolean.TRUE : Boolean.FALSE ) );
|
||||
BusyIndicator.showWhile( getViewer().getControl().getDisplay(),
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
getViewer().refresh();
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Action#setChecked(boolean)
|
||||
*/
|
||||
public void setChecked( boolean value )
|
||||
{
|
||||
super.setChecked( value );
|
||||
valueChanged( value );
|
||||
}
|
||||
|
||||
protected StructuredViewer getViewer()
|
||||
{
|
||||
return fViewer;
|
||||
}
|
||||
|
||||
protected void setViewer( StructuredViewer viewer )
|
||||
{
|
||||
fViewer = viewer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.ColorFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
|
||||
/**
|
||||
*
|
||||
* A page to set the preferences for the registers view
|
||||
*
|
||||
* @since Sep 16, 2002
|
||||
*/
|
||||
public class RegistersViewPreferencePage extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage
|
||||
{
|
||||
/**
|
||||
* Constructor for RegistersViewPreferencePage.
|
||||
* @param style
|
||||
*/
|
||||
public RegistersViewPreferencePage()
|
||||
{
|
||||
super( GRID );
|
||||
setDescription( "Registers View Settings." );
|
||||
setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PreferencePage#createControl(Composite)
|
||||
*/
|
||||
public void createControl( Composite parent )
|
||||
{
|
||||
super.createControl( parent );
|
||||
WorkbenchHelp.setHelp( parent, ICDebugHelpContextIds.REGISTERS_PREFERENCE_PAGE );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
|
||||
*/
|
||||
protected void createFieldEditors()
|
||||
{
|
||||
addField( new ColorFieldEditor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB, "&Changed register value color:", getFieldEditorParent() ) );
|
||||
|
||||
createSpacer( getFieldEditorParent(), 1 );
|
||||
|
||||
addField( new BooleanFieldEditor( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, "Show type &names by default", SWT.NONE, getFieldEditorParent() ) );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
|
||||
*/
|
||||
public void init( IWorkbench workbench )
|
||||
{
|
||||
}
|
||||
|
||||
public static void initDefaults( IPreferenceStore store )
|
||||
{
|
||||
store.setDefault( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, false );
|
||||
|
||||
PreferenceConverter.setDefault( store,
|
||||
ICDebugPreferenceConstants.CHANGED_REGISTER_RGB,
|
||||
new RGB( 255, 0, 0 ) );
|
||||
}
|
||||
|
||||
protected void createSpacer( Composite composite, int columnSpan )
|
||||
{
|
||||
Label label = new Label( composite, SWT.NONE );
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalSpan = columnSpan;
|
||||
label.setLayoutData( gd );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IPreferencePage#performOk()
|
||||
*/
|
||||
public boolean performOk()
|
||||
{
|
||||
boolean ok = super.performOk();
|
||||
CDebugUIPlugin.getDefault().savePluginPreferences();
|
||||
return ok;
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
|||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||
|
@ -18,6 +17,7 @@ import org.eclipse.debug.ui.IDebugModelPresentation;
|
|||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.IContentProvider;
|
||||
|
@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
|
@ -78,6 +79,7 @@ public class MemoryView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void fillContextMenu( IMenuManager menu )
|
||||
{
|
||||
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.eclipse.cdt.debug.internal.ui.views.registers;
|
|||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.cdt.debug.internal.ui.actions.ChangeRegisterValueAction;
|
||||
import org.eclipse.cdt.debug.internal.ui.actions.ShowRegisterTypesAction;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
|
||||
|
@ -17,8 +19,10 @@ import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
|||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.IContentProvider;
|
||||
|
@ -29,6 +33,7 @@ import org.eclipse.jface.viewers.Viewer;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
|
@ -77,6 +82,15 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void createActions()
|
||||
{
|
||||
IAction action = new ShowRegisterTypesAction( getStructuredViewer() );
|
||||
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( IDebugUIConstants.PREF_SHOW_TYPE_NAMES ) );
|
||||
setAction( "ShowTypeNames", action ); //$NON-NLS-1$
|
||||
|
||||
action = new ChangeRegisterValueAction( getViewer() );
|
||||
action.setEnabled( false );
|
||||
setAction( "ChangeRegisterValue", action ); //$NON-NLS-1$
|
||||
setAction( DOUBLE_CLICK_ACTION, action );
|
||||
|
||||
// set initial content here, as viewer has to be set
|
||||
setInitialContent();
|
||||
}
|
||||
|
@ -94,6 +108,14 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void fillContextMenu( IMenuManager menu )
|
||||
{
|
||||
menu.add( new Separator( ICDebugUIConstants.EMPTY_REGISTER_GROUP ) );
|
||||
menu.add( new Separator( ICDebugUIConstants.REGISTER_GROUP ) );
|
||||
menu.add( getAction( "ChangeRegisterValue" ) ); //$NON-NLS-1$
|
||||
menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) );
|
||||
menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
|
||||
menu.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$
|
||||
|
||||
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -101,6 +123,9 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
*/
|
||||
protected void configureToolBar( IToolBarManager tbm )
|
||||
{
|
||||
tbm.add( new Separator( this.getClass().getName() ) );
|
||||
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
|
||||
tbm.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -5,7 +5,15 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.eclipse.debug.core.model.IStackFrame;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
|
@ -17,6 +25,15 @@ import org.eclipse.jface.viewers.Viewer;
|
|||
*/
|
||||
public class RegistersViewContentProvider implements ITreeContentProvider
|
||||
{
|
||||
/**
|
||||
* A table that maps children to their parent element
|
||||
* such that this content provider can walk back up the
|
||||
* parent chain (since values do not know their
|
||||
* parent).
|
||||
* Map of <code>IVariable</code> (child) -> <code>IVariable</code> (parent).
|
||||
*/
|
||||
private HashMap fParentCache;
|
||||
|
||||
/**
|
||||
* Handler for exceptions as content is retrieved
|
||||
*/
|
||||
|
@ -27,15 +44,62 @@ public class RegistersViewContentProvider implements ITreeContentProvider
|
|||
*/
|
||||
public RegistersViewContentProvider()
|
||||
{
|
||||
super();
|
||||
fParentCache = new HashMap( 10 );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
|
||||
*/
|
||||
public Object[] getChildren( Object parentElement )
|
||||
public Object[] getChildren( Object parent )
|
||||
{
|
||||
return null;
|
||||
Object[] children= null;
|
||||
try
|
||||
{
|
||||
if ( parent instanceof IStackFrame )
|
||||
{
|
||||
children = ((IStackFrame)parent).getRegisterGroups();
|
||||
}
|
||||
else if ( parent instanceof IRegisterGroup )
|
||||
{
|
||||
children = ((IRegisterGroup)parent).getRegisters();
|
||||
}
|
||||
else if ( parent instanceof IVariable )
|
||||
{
|
||||
children = ((IVariable)parent).getValue().getVariables();
|
||||
}
|
||||
if ( children != null )
|
||||
{
|
||||
cache( parent, children );
|
||||
return children;
|
||||
}
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
if ( getExceptionHandler() != null )
|
||||
{
|
||||
getExceptionHandler().handleException( e );
|
||||
}
|
||||
else
|
||||
{
|
||||
CDebugUIPlugin.log( e );
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the given elememts as children of the given
|
||||
* parent.
|
||||
*
|
||||
* @param parent parent element
|
||||
* @param children children elements
|
||||
*/
|
||||
protected void cache( Object parent, Object[] children )
|
||||
{
|
||||
for ( int i = 0; i < children.length; i++ )
|
||||
{
|
||||
fParentCache.put( children[i], parent );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -43,7 +107,7 @@ public class RegistersViewContentProvider implements ITreeContentProvider
|
|||
*/
|
||||
public Object getParent( Object element )
|
||||
{
|
||||
return null;
|
||||
return fParentCache.get( element );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -51,6 +115,30 @@ public class RegistersViewContentProvider implements ITreeContentProvider
|
|||
*/
|
||||
public boolean hasChildren( Object element )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( element instanceof IVariable )
|
||||
{
|
||||
return ((IVariable)element).getValue().hasVariables();
|
||||
}
|
||||
if ( element instanceof IValue )
|
||||
{
|
||||
return ((IValue)element).hasVariables();
|
||||
}
|
||||
if ( element instanceof IRegisterGroup )
|
||||
{
|
||||
return ((IRegisterGroup)element).hasRegisters();
|
||||
}
|
||||
if ( element instanceof IStackFrame )
|
||||
{
|
||||
return ((IStackFrame)element).hasRegisterGroups();
|
||||
}
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
CDebugUIPlugin.log( e );
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,13 +155,40 @@ public class RegistersViewContentProvider implements ITreeContentProvider
|
|||
*/
|
||||
public void dispose()
|
||||
{
|
||||
fParentCache = null;
|
||||
setExceptionHandler( null );
|
||||
}
|
||||
|
||||
protected void clearCache()
|
||||
{
|
||||
if ( fParentCache != null )
|
||||
{
|
||||
fParentCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the cached parent for the given children
|
||||
*
|
||||
* @param children for which to remove cached parents
|
||||
*/
|
||||
public void removeCache( Object[] children )
|
||||
{
|
||||
if ( fParentCache != null )
|
||||
{
|
||||
for ( int i = 0; i < children.length; i++ )
|
||||
{
|
||||
fParentCache.remove( children[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
|
||||
*/
|
||||
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
|
||||
{
|
||||
clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
|
|||
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
||||
import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -135,6 +136,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin
|
|||
protected void initializeDefaultPreferences( IPreferenceStore pstore )
|
||||
{
|
||||
MemoryViewPreferencePage.initDefaults( pstore );
|
||||
RegistersViewPreferencePage.initDefaults( pstore );
|
||||
}
|
||||
|
||||
public static CDTDebugModelPresentation getDebugModelPresentation()
|
||||
|
|
|
@ -37,4 +37,15 @@ public interface ICDebugUIConstants
|
|||
* Status code indicating an unexpected internal error.
|
||||
*/
|
||||
public static final int INTERNAL_ERROR = 150;
|
||||
|
||||
/**
|
||||
* Identifier for an empty group preceeding a
|
||||
* register group in a menu (value <code>"emptyRegisterGroup"</code>).
|
||||
*/
|
||||
public static final String EMPTY_REGISTER_GROUP = "emptyRegisterGroup"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Identifier for a register group in a menu (value <code>"registerGroup"</code>).
|
||||
*/
|
||||
public static final String REGISTER_GROUP = "registerGroup"; //$NON-NLS-1$
|
||||
}
|
||||
|
|