1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Added the bookkeeping of registers and register groups.

This commit is contained in:
Mikhail Khodjaiants 2004-10-08 18:40:29 +00:00
parent 1b2f0d5e9e
commit 69a0850c87
11 changed files with 198 additions and 59 deletions

View file

@ -1,3 +1,11 @@
2004-10-08 Mikhail Khodjaiants
Added the bookkeeping of registers and register groups.
* ICVariable.java
* IEnableDisableTarget.java: new
* AbstractCVariable.java
* CRegister.java
* CRegisterGroup.java
2004-10-07 Mikhail Khodjaiants
Pass the current stack frame to the registers manager to provide the evaluation context.
* ICRegisterManager.java

View file

@ -17,7 +17,7 @@ import org.eclipse.debug.core.model.IVariable;
/**
* C/C++ specific extension <code>IVariable</code>.
*/
public interface ICVariable extends IVariable, ICDebugElement, IFormatSupport, ICastToArray, IValueModification {
public interface ICVariable extends IVariable, ICDebugElement, IFormatSupport, ICastToArray, IValueModification, IEnableDisableTarget {
/**
* Returns the type of this variable.
@ -27,28 +27,6 @@ public interface ICVariable extends IVariable, ICDebugElement, IFormatSupport, I
*/
ICType getType() throws DebugException;
/**
* Returns whether this variable is enabled.
*
* @return whether this variable is enabled
*/
boolean isEnabled();
/**
* Sets the enabled state of this action.
*
* @param enabled <code>true</code> to enable, and <code>false</code> to disable
* @throws DebugException
*/
void setEnabled( boolean enabled ) throws DebugException;
/**
* Returns whether this variable supports enable/disable operation.
*
* @return whether this variable supports enable/disable operation
*/
boolean canEnableDisable();
/**
* Returns whether this variable is an argument.
*

View file

@ -0,0 +1,42 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
/**
* Provides support for enable/disable actions.
*/
public interface IEnableDisableTarget {
/**
* Returns whether this object supports enable/disable operations.
*
* @return whether this object supports enable/disable operations
*/
boolean canEnableDisable();
/**
* Returns whether this object is enabled.
*
* @return <code>true</code> if this obvject is enabled,
* or <code>false</code> otherwise.
*/
boolean isEnabled();
/**
* Enables/disables this object
*
* @param enabled enablement flag value
* @throws DebugException
*/
void setEnabled( boolean enabled ) throws DebugException;
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.debug.core.DebugException;
/**
@ -52,6 +53,15 @@ public abstract class AbstractCVariable extends CDebugElement implements ICVaria
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter ) {
if ( IEnableDisableTarget.class.equals( adapter ) )
return this;
return super.getAdapter( adapter );
}
/**
* Returns the text presentation of this variable as an expression.
*

View file

@ -46,11 +46,4 @@ public class CRegister extends CGlobalVariable implements IRegister {
public IRegisterGroup getRegisterGroup() throws DebugException {
return (IRegisterGroup)getParent();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#isEnabled()
*/
public boolean isEnabled() {
return true;
}
}

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegister;
import org.eclipse.debug.core.model.IRegisterGroup;
@ -20,7 +22,7 @@ import org.eclipse.debug.core.model.IRegisterGroup;
/**
* Represents a group of registers.
*/
public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
public class CRegisterGroup extends CDebugElement implements IRegisterGroup, IEnableDisableTarget {
private String fName;
@ -28,6 +30,8 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
private IRegister[] fRegisters;
private boolean fIsEnabled = true;
/**
* Constructor for CRegisterGroup.
*/
@ -57,6 +61,7 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
catch( DebugException e ) {
fRegisters[i] = new CRegister( this, fRegisterObjects[i], e.getMessage() );
}
((CRegister)fRegisters[i]).setEnabled( isEnabled() );
}
}
return fRegisters;
@ -97,4 +102,46 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
}
}
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter ) {
if ( IEnableDisableTarget.class.equals( adapter ) )
return this;
return super.getAdapter( adapter );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IEnableDisableTarget#canEnableDisable()
*/
public boolean canEnableDisable() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IEnableDisableTarget#isEnabled()
*/
public boolean isEnabled() {
return fIsEnabled;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IEnableDisableTarget#setEnabled(boolean)
*/
public void setEnabled( boolean enabled ) throws DebugException {
if ( fRegisters != null ) {
synchronized( fRegisters ) {
if ( fRegisters != null ) {
for ( int i = 0; i < fRegisters.length; ++i ) {
if ( fRegisters[i] instanceof CRegister ) {
((CRegister)fRegisters[i]).setEnabled( enabled );
}
}
}
}
}
fIsEnabled = enabled;
fireChangeEvent( DebugEvent.CONTENT );
}
}

View file

@ -1,3 +1,10 @@
2004-10-08 Mikhail Khodjaiants
Added the bookkeeping of registers and register groups.
* CDebugImages.java
* CDTDebugModelPresentation.java
* EnableVariablesActionDelegate.java
* plugin.xml
2004-10-07 Mikhail Khodjaiants
Added images of disabled registers and register groups.
* icons/full/obj16/registerd_obj.gif: new

View file

@ -751,6 +751,32 @@
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
label="%DisableVariablesAction.label"
icon="icons/full/clcl16/disabled_co.gif"
helpContextId="disable_variables_action_context"
tooltip="%DisableVariablesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate"
menubarPath="variableGroup"
enablesFor="2+"
id="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate">
<selection
class="org.eclipse.cdt.debug.core.model.ICVariable">
</selection>
</action>
<action
label="%EnableVariablesAction.label"
icon="icons/full/clcl16/enabled_co.gif"
helpContextId="enable_variables_action_context"
tooltip="%EnableVariablesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate"
menubarPath="variableGroup"
enablesFor="2+"
id="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate">
<selection
class="org.eclipse.cdt.debug.core.model.ICVariable">
</selection>
</action>
</viewerContribution>
</extension>
<extension

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor;
import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate;
import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement;
@ -50,6 +51,7 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
@ -285,6 +287,15 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) {
baseText.append( getFormattedString( " <{0}>", ((ICDebugElementStatus)element).getMessage() ) ); //$NON-NLS-1$
}
if ( element instanceof IAdaptable ) {
IEnableDisableTarget target = (IEnableDisableTarget)((IAdaptable)element).getAdapter( IEnableDisableTarget.class );
if ( target != null ) {
if ( !target.isEnabled() ) {
baseText.append( ' ' );
baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$
}
}
}
return baseText.toString();
}
@ -490,9 +501,11 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
result.insert( 0, typeName + ' ' );
}
}
String valueString = DebugUIPlugin.getModelPresentation().getText( value );
if ( valueString.length() > 0 ) {
result.append( " = " ).append( valueString ); //$NON-NLS-1$
if ( expression.isEnabled() ) {
String valueString = DebugUIPlugin.getModelPresentation().getText( value );
if ( valueString.length() > 0 ) {
result.append( " = " ).append( valueString ); //$NON-NLS-1$
}
}
}
}
@ -523,16 +536,14 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
if ( name != null )
label.append( name.trim() );
IValue value = var.getValue();
String valueString = DebugUIPlugin.getModelPresentation().getText( value );
if ( !isEmpty( valueString ) ) {
label.append( " = " ); //$NON-NLS-1$
label.append( valueString );
if ( value != null ) {
String valueString = DebugUIPlugin.getModelPresentation().getText( value );
if ( !isEmpty( valueString ) ) {
label.append( " = " ); //$NON-NLS-1$
label.append( valueString );
}
}
}
if ( !((ICVariable)var).isEnabled() ) {
label.append( ' ' );
label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$
}
return label.toString();
}
@ -804,11 +815,14 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
}
protected Image getRegisterGroupImage( IRegisterGroup element ) {
IEnableDisableTarget target = (IEnableDisableTarget)element.getAdapter( IEnableDisableTarget.class );
if ( target != null && !target.isEnabled() )
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP_DISABLED );
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP );
}
protected Image getRegisterImage( IRegister element ) {
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER );
return ( ( element instanceof ICVariable && ((ICVariable)element).isEnabled() ) ) ? fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER ) : fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_DISABLED );
}
protected Image getExpressionImage( IExpression element ) {
@ -825,6 +839,8 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
private String getVariableTypeName( ICType type ) {
StringBuffer result = new StringBuffer();
String typeName = type.getName();
if ( typeName != null )
typeName = typeName.trim();
if ( type.isArray() && typeName != null ) {
int index = typeName.indexOf( '[' );
if ( index != -1 )

View file

@ -88,7 +88,9 @@ public class CDebugImages
public static final String IMG_OBJS_VARIABLE_POINTER_DISABLED = NAME_PREFIX + "vard_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_GROUP_DISABLED = NAME_PREFIX + "registergroupd_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_OBJS_REGISTER_DISABLED = NAME_PREFIX + "registerd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_DISASSEMBLY = NAME_PREFIX + "disassembly_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "project_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CLOSED_PROJECT = NAME_PREFIX + "cproject_obj.gif"; //$NON-NLS-1$
@ -160,7 +162,9 @@ public class CDebugImages
public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER_DISABLED = createManaged( T_OBJ, IMG_OBJS_VARIABLE_POINTER_DISABLED );
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_GROUP_DISABLED = createManaged( T_OBJ, IMG_OBJS_REGISTER_GROUP_DISABLED );
public static final ImageDescriptor DESC_OBJS_REGISTER = createManaged( T_OBJ, IMG_OBJS_REGISTER );
public static final ImageDescriptor DESC_OBJS_REGISTER_DISABLED = createManaged( T_OBJ, IMG_OBJS_REGISTER_DISABLED );
public static final ImageDescriptor DESC_OBJS_DISASSEMBLY = createManaged( T_OBJ, IMG_OBJS_DISASSEMBLY );
public static final ImageDescriptor DESC_OBJS_PROJECT = createManaged( T_OBJ, IMG_OBJS_PROJECT );
public static final ImageDescriptor DESC_OBJS_CLOSED_PROJECT = createManaged( T_OBJ, IMG_OBJS_CLOSED_PROJECT );

View file

@ -11,8 +11,9 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.IAction;
@ -83,19 +84,18 @@ public class EnableVariablesActionDelegate implements IViewActionDelegate {
public void run() {
while( enum.hasNext() ) {
ICVariable var = (ICVariable)enum.next();
try {
if ( size > 1 ) {
if ( isEnableAction() )
var.setEnabled( true );
IEnableDisableTarget target = getEnableDisableTarget( enum.next() );
if ( target != null ) {
try {
if ( size > 1 ) {
target.setEnabled( isEnableAction() );
}
else
var.setEnabled( false );
target.setEnabled( !target.isEnabled() );
}
catch( DebugException e ) {
ms.merge( e.getStatus() );
}
else
var.setEnabled( !var.isEnabled() );
}
catch( DebugException e ) {
ms.merge( e.getStatus() );
}
}
update();
@ -117,16 +117,16 @@ public class EnableVariablesActionDelegate implements IViewActionDelegate {
return;
IStructuredSelection sel = (IStructuredSelection)selection;
Object o = sel.getFirstElement();
if ( !(o instanceof ICVariable) )
if ( getEnableDisableTarget( o ) == null )
return;
Iterator enum = sel.iterator();
boolean allEnabled = true;
boolean allDisabled = true;
while( enum.hasNext() ) {
ICVariable var = (ICVariable)enum.next();
if ( !var.canEnableDisable() )
IEnableDisableTarget target = getEnableDisableTarget( enum.next() );
if ( target != null && !target.canEnableDisable() )
continue;
if ( var.isEnabled() )
if ( target.isEnabled() )
allDisabled = false;
else
allEnabled = false;
@ -144,4 +144,12 @@ public class EnableVariablesActionDelegate implements IViewActionDelegate {
protected void update() {
getView().getViewSite().getSelectionProvider().setSelection( getView().getViewSite().getSelectionProvider().getSelection() );
}
protected IEnableDisableTarget getEnableDisableTarget( Object obj ) {
IEnableDisableTarget target = null;
if ( obj instanceof IAdaptable ) {
target = (IEnableDisableTarget)((IAdaptable)obj).getAdapter( IEnableDisableTarget.class );
}
return target;
}
}