1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Moved the generation of expressions for global variables to the mi plugin.

This commit is contained in:
Mikhail Khodjaiants 2003-05-12 21:14:49 +00:00
parent 359c65a4f5
commit 4fc88a9b59
6 changed files with 57 additions and 30 deletions

View file

@ -1,3 +1,9 @@
2003-05-12 Mikhail Khodjaiants
Moved the generation of expressions for global variables to the mi plugin.
* CDebugTarget.java
* CExpression.java
* CDebugModel.java
2003-05-12 Mikhail Khodjaiants
When generating disassembly instructions by file name and line number check
if the frame address is in the address range of the instruction set.

View file

@ -22,6 +22,8 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
@ -44,6 +46,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@ -560,6 +563,28 @@ public class CDebugModel
return null;
}
public static IExpression createExpressionForGlobalVariable( IDebugTarget target, IPath fileName, String name ) throws DebugException
{
if ( target != null && target instanceof CDebugTarget )
{
try
{
ICDIVariableObject vo = ((CDebugTarget)target).getCDISession().getVariableManager().getVariableObject( fileName.lastSegment(), null, name );
ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo );
return new CExpression( (CDebugTarget)target, cdiVariable );
}
catch( CDIException e )
{
throw new DebugException( new Status( IStatus.ERROR,
getPluginIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
e.getMessage(),
null ) );
}
}
return null;
}
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target,
String addressExpression,
int format,

View file

@ -13,9 +13,9 @@ import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.IBinaryModule;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -87,7 +87,6 @@ import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
@ -2342,16 +2341,10 @@ public class CDebugTarget extends CDebugElement
public IPath getPath()
{
IPath path = new Path("");
try
{
IResource res = var.getUnderlyingResource();
if ( res != null )
{
path = res.getLocation();
}
}
catch (CModelException e)
ICElement parent = var.getParent();
if ( parent instanceof IBinaryModule )
{
path = ((IBinaryModule)parent).getPath();
}
return path;
}

View file

@ -10,6 +10,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IValue;
@ -26,12 +27,23 @@ public class CExpression extends CModificationVariable
/**
* Constructor for CExpression.
* @param target
* @param cdiExpression
*/
public CExpression( CDebugTarget target, ICDIExpression cdiExpression )
{
super( target, cdiExpression );
}
/**
* Constructor for CExpression.
* @param target
* @param cdiExpression
*/
public CExpression( CDebugTarget target, ICDIVariable cdiVariable )
{
super( target, cdiVariable );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IExpression#getExpressionText()
*/

View file

@ -1,3 +1,7 @@
2003-05-12 Mikhail Khodjaiants
Moved the generation of expressions for global variables to the mi plugin.
* AddGlobalsActionDelegate.java
2003-05-07 Mikhail Khodjaiants
Display the error message and error image in the debug target's label
if the error status is set.

View file

@ -68,19 +68,6 @@ public class AddGlobalsActionDelegate extends ActionDelegate
{
return fPath;
}
public String toString()
{
String path = "";
if ( getPath() != null )
{
path = getPath().toString();
int index = path.lastIndexOf( '/' );
if ( index != -1 )
path = path.substring( index + 1 );
}
return ( path.length() > 0 ? ( '\'' + path + "\'::" ) : "" ) + getName();
}
}
private Global[] fGlobals;
@ -341,7 +328,7 @@ public class AddGlobalsActionDelegate extends ActionDelegate
Object[] selections = dlg.getResult();
for ( int i = 0; i < selections.length; ++i )
{
createExpression( ((IDebugElement)element).getDebugTarget(), ((Global)selections[i]).toString() );
createExpression( ((IDebugElement)element).getDebugTarget(), (Global)selections[i] );
}
}
}
@ -371,9 +358,9 @@ public class AddGlobalsActionDelegate extends ActionDelegate
return fStatus;
}
private void createExpression( IDebugTarget target, String text ) throws DebugException
private void createExpression( IDebugTarget target, Global global ) throws DebugException
{
IExpression expression = CDebugModel.createExpression( target, text );
IExpression expression = CDebugModel.createExpressionForGlobalVariable( target, global.getPath(), global.getName() );
DebugPlugin.getDefault().getExpressionManager().addExpression( expression );
}
}