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

Copied the target factory methods from CDebugModel to CDIDebugModel.

Marked the old methods as deprecated.
This commit is contained in:
Mikhail Khodjaiants 2004-07-21 20:04:37 +00:00
parent d2c66d5edc
commit 5ddf5b1eb3
3 changed files with 217 additions and 312 deletions

View file

@ -1,3 +1,9 @@
2004-07-21 Mikhail Khodjaiants
Copied the target factory methods from CDebugModel to CDIDebugModel.
Marked the old methods as deprecated.
* CDebugModel.java
* CDIDebugModel.java
2004-07-21 Mikhail Khodjaiants 2004-07-21 Mikhail Khodjaiants
CDebugTarget and CThread cleanup. CDebugTarget and CThread cleanup.
* CoreModelMessages.properties * CoreModelMessages.properties

View file

@ -10,10 +10,18 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
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.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
@ -23,25 +31,33 @@ import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor; import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CCoreFileDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CExpression; import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CGlobalVariable; import org.eclipse.cdt.debug.internal.core.model.CGlobalVariable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; 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.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression; import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IProcess;
/** /**
* Provides utility methods for creating debug sessions, targets and * Provides utility methods for creating debug sessions, targets and
@ -57,6 +73,135 @@ public class CDIDebugModel {
return CDebugCorePlugin.getUniqueIdentifier(); return CDebugCorePlugin.getUniqueIdentifier();
} }
/**
* Creates and returns a debug target for the given CDI target,
* with the specified name, and associates it with the given process for console
* I/O. The allow terminate flag specifies whether the debug target will support
* termination (<code>ITerminate</code>). The allow disconnect flag
* specifies whether the debug target will support disconnection
* (<code>IDisconnect</code>). The resume flag specifies if the target
* process should be resumed on startup.
* The debug target is added to the given launch.
*
* @param launch the launch the new debug target will be contained in
* @param cdiTarget the CDI target to create a debug target for
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>.
* @param debuggeeProcess the process to associate with the debug target, which will be returned from <code>IDebugTarget.getProcess</code>
* @param debuggerProcess the process to associate with the debugger.
* @param file the executable to debug.
* @param allowTerminate whether the target will support termianation
* @param allowDisconnect whether the target will support disconnection
* @param stopInMain whether to set a temporary breakpoint in main.
* @return a debug target
* @throws DebugException
*/
public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
target[0] = new CDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect );
ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
if ( config.supportsBreakpoints() && stopInMain ) {
stopInMain( (CDebugTarget)target[0] );
}
if ( config.supportsResume() ) {
target[0].resume();
}
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
}
/**
* Creates and returns an attached debug target for the given CDI target,
* with the specified name.
*
* @param launch the launch the new debug target will be contained in
* @param cdiTarget the CDI target to create a debug target for
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>.
* @param debuggerProcess the process to associate with the debugger.
* @param file the executable to debug.
* @return a debug target
* @throws DebugException
*/
public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
target[0] = new CDebugTarget( launch, cdiTarget, name, null, debuggerProcess, file, false, true );
ICDIEvent[] events = new ICDIEvent[]{ new ICDISuspendedEvent() {
public ICDISessionObject getReason() {
return null;
}
public ICDIObject getSource() {
return cdiTarget;
}
} };
((CDebugTarget)target[0]).handleDebugEvents( events );
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
}
/**
* Creates and returns a post-mortem debug target for the given CDI target,
* with the specified name.
*
* @param launch the launch the new debug target will be contained in
* @param cdiTarget the CDI target to create a debug target for
* @param name the name to associate with this target, which will be returned from <code>IDebugTarget.getName</code>.
* @param debuggerProcess the process to associate with the debugger.
* @param file the executable to debug.
* @return a debug target
* @throws DebugException
*/
public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
public void run( IProgressMonitor m ) throws CoreException {
target[0] = new CCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
ICDIEvent[] events = new ICDIEvent[]{ new ICDISuspendedEvent() {
public ICDISessionObject getReason() {
return null;
}
public ICDIObject getSource() {
return cdiTarget;
}
} };
((CDebugTarget)target[0]).handleDebugEvents( events );
}
};
try {
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
return target[0];
}
/** /**
* Creates and returns a line breakpoint for the source defined by * Creates and returns a line breakpoint for the source defined by
* the given source handle, at the given line number. The marker associated * the given source handle, at the given line number. The marker associated
@ -407,4 +552,19 @@ public class CDIDebugModel {
} }
return null; return null;
} }
protected static void stopInMain( CDebugTarget target ) throws DebugException {
ICDILocation location = target.getCDISession().getBreakpointManager().createLocation( "", "main", 0 ); //$NON-NLS-1$ //$NON-NLS-2$
try {
target.setInternalTemporaryBreakpoint( location );
}
catch( DebugException e ) {
String message = MessageFormat.format( DebugCoreMessages.getString( "CDebugModel.0" ), new String[]{ e.getStatus().getMessage() } ); //$NON-NLS-1$
IStatus newStatus = new Status( IStatus.WARNING, e.getStatus().getPlugin(), ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null );
if ( !CDebugUtils.question( newStatus, target ) ) {
target.terminate();
throw new DebugException( new Status( IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(), e.getStatus().getMessage(), null ) );
}
}
}
} }

View file

@ -8,34 +8,20 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; 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.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.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock; import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.model.CCoreFileDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CExpression; import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CFormattedMemoryBlock; import org.eclipse.cdt.debug.internal.core.model.CFormattedMemoryBlock;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -46,351 +32,104 @@ import org.eclipse.debug.core.model.IProcess;
/** /**
* *
* Provides utility methods for creating debug sessions, targets and * Provides utility methods for creating debug sessions, targets and breakpoints specific to the CDI debug model.
* breakpoints specific to the CDI debug model.
*
* @since Aug 1, 2002
*/ */
public class CDebugModel public class CDebugModel {
{
/** /**
* Constructor for CDebugModel. * Constructor for CDebugModel.
*/ */
public CDebugModel() public CDebugModel() {
{
super(); super();
} }
/** /**
* Returns the identifier for the CDI debug model plug-in * Returns the identifier for the CDI debug model plug-in
* *
* @return plugin identifier * @return plugin identifier
*/ */
public static String getPluginIdentifier() public static String getPluginIdentifier() {
{
return CDebugCorePlugin.getUniqueIdentifier(); return CDebugCorePlugin.getUniqueIdentifier();
} }
/** /**
* Creates and returns a debug target for the given CDI target, with * @deprecated
* the specified name, and associates the debug target with the * Use {@link CDIDebugModel#newDebugTarget(ILaunch, ICDITarget, String, IProcess, IProcess, IFile, boolean, boolean, boolean)}.
* given process for console I/O. The allow terminate flag specifies
* whether the debug target will support termination (<code>ITerminate</code>).
* The allow disconnect flag specifies whether the debug target will
* support disconnection (<code>IDisconnect</code>). The resume
* flag specifies if the target process should be resumed on startup.
* The debug target is added to the given launch.
*
* @param launch the launch the new debug target will be contained in
* @param cdiTarget the CDI target to create a debug target for
* @param name the name to associate with this target, which will be
* returned from <code>IDebugTarget.getName</code>.
* @param debuggeeProcess the process to associate with the debug target,
* which will be returned from <code>IDebugTarget.getProcess</code>
* @param debuggerProcess the process to associate with the debugger.
* @param file the executable to debug.
* @param allowTerminate whether the target will support termianation
* @param allowDisconnect whether the target will support disconnection
* @param stopInMain whether to set a temporary breakpoint in main.
* @return a debug target
*/ */
public static IDebugTarget newDebugTarget( final ILaunch launch, public static IDebugTarget newDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IProcess debuggerProcess, final IFile file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain ) throws DebugException {
final ICDITarget cdiTarget, return CDIDebugModel.newDebugTarget( launch, cdiTarget, name, debuggeeProcess, debuggerProcess, file, allowTerminate, allowDisconnect, stopInMain );
final String name,
final IProcess debuggeeProcess,
final IProcess debuggerProcess,
final IFile file,
final boolean allowTerminate,
final boolean allowDisconnect,
final boolean stopInMain ) throws DebugException
{
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable()
{
public void run( IProgressMonitor m )
{
target[0] = new CDebugTarget( launch,
cdiTarget,
name,
debuggeeProcess,
debuggerProcess,
file,
allowTerminate,
allowDisconnect );
}
};
try
{
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e )
{
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
if ( config.supportsBreakpoints() && stopInMain )
{
stopInMain( (CDebugTarget)target[0] );
}
if ( config.supportsResume() )
{
target[0].resume();
}
return target[0];
} }
public static IDebugTarget newAttachDebugTarget( final ILaunch launch, /**
final ICDITarget cdiTarget, * @deprecated
final String name, * Use {@link CDIDebugModel#newAttachDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
final IProcess debuggerProcess, */
final IFile file ) throws DebugException public static IDebugTarget newAttachDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException {
{ return CDIDebugModel.newAttachDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable()
{
public void run( IProgressMonitor m )
{
target[0] = new CDebugTarget( launch,
cdiTarget,
name,
null,
debuggerProcess,
file,
false,
true );
}
};
try
{
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e )
{
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
ICDIEvent[] events = new ICDIEvent[]
{
new ICDISuspendedEvent()
{
public ICDISessionObject getReason()
{
return null;
}
public ICDIObject getSource()
{
return cdiTarget;
}
}
};
((CDebugTarget)target[0]).handleDebugEvents( events );
return target[0];
} }
public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, /**
final ICDITarget cdiTarget, * @deprecated
final String name, * Use {@link CDIDebugModel#newCoreFileDebugTarget(ILaunch, ICDITarget, String, IProcess, IFile)}.
final IProcess debuggerProcess, */
final IFile file ) throws DebugException public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget cdiTarget, final String name, final IProcess debuggerProcess, final IFile file ) throws DebugException {
{ return CDIDebugModel.newCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable()
{
public void run( IProgressMonitor m )
{
target[0] = new CCoreFileDebugTarget( launch,
cdiTarget,
name,
debuggerProcess,
file );
}
};
try
{
ResourcesPlugin.getWorkspace().run( r, null );
}
catch( CoreException e )
{
CDebugCorePlugin.log( e );
throw new DebugException( e.getStatus() );
}
ICDIEvent[] events = new ICDIEvent[]
{
new ICDISuspendedEvent()
{
public ICDISessionObject getReason()
{
return null;
}
public ICDIObject getSource()
{
return cdiTarget;
}
}
};
((CDebugTarget)target[0]).handleDebugEvents( events );
return target[0];
} }
public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException {
{ if ( target != null && target instanceof CDebugTarget ) {
if ( target != null && target instanceof CDebugTarget ) try {
{
try
{
ICDIExpression cdiExpression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( text ); ICDIExpression cdiExpression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( text );
return new CExpression( (CDebugTarget)target, cdiExpression ); return new CExpression( (CDebugTarget)target, cdiExpression );
} }
catch( CDIException e ) catch( CDIException e ) {
{ throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getMessage(), null ) );
throw new DebugException( new Status( IStatus.ERROR,
getPluginIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
e.getMessage(),
null ) );
} }
} }
return null; return null;
} }
public static IExpression createExpressionForGlobalVariable( IDebugTarget target, IPath fileName, String name ) throws DebugException public static IExpression createExpressionForGlobalVariable( IDebugTarget target, IPath fileName, String name ) throws DebugException {
{ if ( target != null && target instanceof CDebugTarget ) {
if ( target != null && target instanceof CDebugTarget )
{
ICDIVariableObject vo = null; ICDIVariableObject vo = null;
try try {
{
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( fileName.lastSegment(), null, name ); vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( fileName.lastSegment(), null, name );
ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo ); ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo );
return new CExpression( (CDebugTarget)target, cdiVariable ); return new CExpression( (CDebugTarget)target, cdiVariable );
} }
catch( CDIException e ) catch( CDIException e ) {
{ throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), //$NON-NLS-1$
throw new DebugException( new Status( IStatus.ERROR, null ) );
getPluginIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
( vo != null ) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), //$NON-NLS-1$
null ) );
} }
} }
return null; return null;
} }
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns, char paddingChar ) throws DebugException {
String addressExpression, if ( target != null && target instanceof CDebugTarget ) {
int format, try {
int wordSize, ICDIExpression expression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( addressExpression );
int numberOfRows, ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns );
int numberOfColumns, return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns, paddingChar );
char paddingChar ) throws DebugException
{
if ( target != null && target instanceof CDebugTarget )
{
try
{
ICDIExpression expression = ((CDebugTarget)target).getCDISession()
.getExpressionManager()
.createExpression( addressExpression );
ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession()
.getMemoryManager()
.createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns );
return new CFormattedMemoryBlock( (CDebugTarget)target,
cdiMemoryBlock,
expression,
format,
wordSize,
numberOfRows,
numberOfColumns,
paddingChar );
} }
catch( CDIException e ) catch( CDIException e ) {
{ throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getDetailMessage(), null ) );
throw new DebugException( new Status( IStatus.ERROR,
getPluginIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
e.getDetailMessage(),
null ) );
} }
} }
return null; return null;
} }
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns ) throws DebugException {
String addressExpression, if ( target != null && target instanceof CDebugTarget ) {
int format, try {
int wordSize, ICDIExpression expression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( addressExpression );
int numberOfRows, ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns );
int numberOfColumns ) throws DebugException return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns );
{
if ( target != null && target instanceof CDebugTarget )
{
try
{
ICDIExpression expression = ((CDebugTarget)target).getCDISession()
.getExpressionManager()
.createExpression( addressExpression );
ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession()
.getMemoryManager()
.createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns );
return new CFormattedMemoryBlock( (CDebugTarget)target,
cdiMemoryBlock,
expression,
format,
wordSize,
numberOfRows,
numberOfColumns );
} }
catch( CDIException e ) catch( CDIException e ) {
{ throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getDetailMessage(), null ) );
throw new DebugException( new Status( IStatus.ERROR,
getPluginIdentifier(),
DebugException.TARGET_REQUEST_FAILED,
e.getDetailMessage(),
null ) );
} }
} }
return null; return null;
} }
}
private static void stopInMain( CDebugTarget target ) throws DebugException
{
ICDILocation location = target.getCDISession().getBreakpointManager().createLocation( "", "main", 0 ); //$NON-NLS-1$ //$NON-NLS-2$
try
{
target.setInternalTemporaryBreakpoint( location );
}
catch( DebugException e )
{
String message = MessageFormat.format( DebugCoreMessages.getString( "CDebugModel.0" ), new String[] { e.getStatus().getMessage() } ); //$NON-NLS-1$
IStatus newStatus = new Status( IStatus.WARNING,
e.getStatus().getPlugin(),
ICDebugInternalConstants.STATUS_CODE_QUESTION,
message,
null );
if ( !CDebugUtils.question( newStatus, target ) )
{
target.terminate();
throw new DebugException( new Status( IStatus.OK,
e.getStatus().getPlugin(),
e.getStatus().getCode(),
e.getStatus().getMessage(),
null ) );
}
}
}
}