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

Implementation of disassembly mode.

This commit is contained in:
Mikhail Khodjaiants 2002-10-08 22:03:22 +00:00
parent 347497be9c
commit fdf2c99a70
11 changed files with 455 additions and 127 deletions

View file

@ -0,0 +1,40 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core;
import org.eclipse.core.resources.IStorage;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* Defines methods specific to disassembly.
*
* @since: Oct 8, 2002
*/
public interface IDisassemblyStorage extends IStorage
{
/**
* Returns the debug target of this disassembly.
*
* @return the debug target of this disassembly
*/
IDebugTarget getDebugTarget();
/**
* Returns whether this storage contains the instructions at given address.
*
* @param address - an address
* @return whether this storage contains the instructions at given address
*/
boolean containsAddress( long address );
/**
* Returns the line number for given address.
* @param address - an address
* @return the line number for given address
*/
int getLineNumber( long address ) ;
}

View file

@ -8,13 +8,11 @@ package org.eclipse.cdt.debug.core.sourcelookup;
import java.util.ArrayList;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.IStackFrameInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
@ -32,13 +30,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/
private ICSourceLocation[] fSourceLocations;
/**
* The source presentation mode.
*/
private int fMode = ICSourceLocator.MODE_SOURCE;
private int fInternalMode = MODE_SOURCE;
/**
* Constructor for CSourceLocator.
*/
@ -68,19 +59,11 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/
public Object getSourceElement( IStackFrame stackFrame )
{
Object result = null;
if ( stackFrame != null && stackFrame.getAdapter( IStackFrameInfo.class ) != null )
{
try
{
result = getInput( (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ) );
}
catch( DebugException e )
{
CDebugCorePlugin.log( e );
}
return getInput( (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ) );
}
return result;
return null;
}
/* (non-Javadoc)
@ -88,58 +71,14 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/
public int getLineNumber( IStackFrameInfo frameInfo )
{
int result = 0;
if ( getMode() == MODE_SOURCE )
result = frameInfo.getFrameLineNumber();
return result;
return ( frameInfo != null ) ? frameInfo.getFrameLineNumber() : 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSourceLocator#getMode()
*/
public int getMode()
{
return fMode;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSourceLocator#setMode(int)
*/
public void setMode( int mode )
{
}
protected void setInternalMode( int mode )
{
fInternalMode = mode;
}
protected Object getInput( IStackFrameInfo frameInfo ) throws DebugException
{
Object result = null;
switch( getMode() )
{
case ICSourceLocator.MODE_SOURCE:
result = getSourceInput( frameInfo );
break;
/*
case ICSourceLocator.MODE_DISASSEMBLY:
result = getDisassemblyInput( frameInfo );
break;
case ICSourceLocator.MODE_MIXED:
result = getMixedInput( frameInfo );
break;
*/
}
return result;
}
private Object getSourceInput( IStackFrameInfo info )
protected Object getInput( IStackFrameInfo info )
{
Object result = null;
if ( info != null )
{
setInternalMode( ICSourceLocator.MODE_SOURCE );
String fileName = info.getFile();
if ( fileName != null && fileName.length() > 0 )
{
@ -159,11 +98,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
}
}
}
// switch to assembly mode if source file not found
/*
if ( result == null )
result = getDisassemblyInput( info );
*/
return result;
}
@ -193,22 +127,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElementForAddress(long)
*/
public Object getSourceElementForAddress( long address )
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElementForFunction(String)
*/
public Object getSourceElementForFunction( String function )
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSourceLocator#contains(IResource)
*/

View file

@ -0,0 +1,130 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.sourcelookup;
import org.eclipse.cdt.debug.core.IStackFrameInfo;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
/**
* Enter type comment.
*
* @since: Oct 8, 2002
*/
public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
{
protected ISourceLocator fSourceLocator;
protected int fMode = ISourceMode.MODE_SOURCE;
/**
* Constructor for CSourceManager.
*/
public CSourceManager( ISourceLocator sourceLocator )
{
fSourceLocator = sourceLocator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo)
*/
public int getLineNumber( IStackFrameInfo frameInfo )
{
if ( getMode() == ISourceMode.MODE_SOURCE )
{
if ( getCSourceLocator() != null )
{
return getCSourceLocator().getLineNumber( frameInfo );
}
if ( frameInfo != null )
{
return frameInfo.getFrameLineNumber();
}
}
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceElement(String)
*/
public Object getSourceElement( String fileName )
{
return ( getCSourceLocator() != null ) ? getCSourceLocator().getSourceElement( fileName ) : null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations()
*/
public ICSourceLocation[] getSourceLocations()
{
return ( getCSourceLocator() != null ) ? getCSourceLocator().getSourceLocations() : new ICSourceLocation[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSourceLocations(ICSourceLocation[])
*/
public void setSourceLocations( ICSourceLocation[] locations )
{
if ( getCSourceLocator() != null )
{
getCSourceLocator().setSourceLocations( locations );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#contains(IResource)
*/
public boolean contains( IResource resource )
{
return ( getCSourceLocator() != null ) ? getCSourceLocator().contains( resource ) : false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ISourceMode#getMode()
*/
public int getMode()
{
return fMode;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.sourcelookup.ISourceMode#setMode(int)
*/
public void setMode( int mode )
{
fMode = mode;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
*/
public Object getSourceElement( IStackFrame stackFrame )
{
return ( getSourceLocator() != null ) ? getSourceLocator() : null;
}
protected ICSourceLocator getCSourceLocator()
{
if ( getSourceLocator() instanceof ICSourceLocator )
return (ICSourceLocator)getSourceLocator();
return null;
}
protected ISourceLocator getSourceLocator()
{
return fSourceLocator;
}
}

View file

@ -0,0 +1,23 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.sourcelookup;
/**
* Enter type comment.
*
* @since: Oct 8, 2002
*/
public class DisassemblyManager
{
/**
* Constructor for DisassemblyManager.
*/
public DisassemblyManager()
{
super();
}
}

View file

@ -6,6 +6,7 @@
package org.eclipse.cdt.debug.core.sourcelookup;
import org.eclipse.cdt.debug.core.IStackFrameInfo;
import org.eclipse.core.resources.IResource;
import org.eclipse.debug.core.model.ISourceLocator;
/**
@ -17,24 +18,6 @@ import org.eclipse.debug.core.model.ISourceLocator;
*/
public interface ICSourceLocator extends ISourceLocator
{
static final public int MODE_SOURCE = 0;
static final public int MODE_DISASSEMBLY = 1;
static final public int MODE_MIXED = 2;
/**
* Returns the current source presentation mode.
*
* @return the current source presentation mode
*/
int getMode();
/**
* Sets the source presentation mode.
*
* @param the source presentation mode to set
*/
void setMode( int mode );
/**
* Returns the line number of the instruction pointer in the specified
* stack frame that corresponds to a line in an associated source element,
@ -55,24 +38,6 @@ public interface ICSourceLocator extends ISourceLocator
*/
Object getSourceElement( String fileName );
/**
* Returns a source element that corresponds to the given function, or
* <code>null</code> if a source element could not be located.
*
* @param function the function name for which to locate source
* @return an object representing a source element.
*/
Object getSourceElementForFunction( String function );
/**
* Returns a source element that corresponds to the given address, or
* <code>null</code> if a source element could not be located.
*
* @param address the address for which to locate source
* @return an object representing a source element.
*/
Object getSourceElementForAddress( long address );
/**
* Returns the source locations of this locator.
*
@ -86,4 +51,12 @@ public interface ICSourceLocator extends ISourceLocator
* @param location - an array of source locations
*/
void setSourceLocations( ICSourceLocation[] locations );
/**
* Returns whether this locator is able to locate the given resource.
*
* @param resource the resource to locate
* @return whether this locator is able to locate the given resource
*/
boolean contains( IResource resource );
}

View file

@ -0,0 +1,33 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.sourcelookup;
/**
* Defines constatnts and methods to set the source presentation mode.
*
* @since: Oct 8, 2002
*/
public interface ISourceMode
{
static final public int MODE_SOURCE = 0;
static final public int MODE_DISASSEMBLY = 1;
static final public int MODE_MIXED = 2;
/**
* Returns the current source presentation mode.
*
* @return the current source presentation mode
*/
int getMode();
/**
* Sets the source presentation mode.
*
* @param the source presentation mode to set
*/
void setMode( int mode );
}

View file

@ -0,0 +1,122 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.core;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.cdt.debug.core.IDisassemblyStorage;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* Enter type comment.
*
* @since: Oct 8, 2002
*/
public class DisassemblyStorage implements IDisassemblyStorage
{
protected ICDIInstruction[] fInstructions;
protected IDebugTarget fDebugTarget;
protected ByteArrayInputStream fInputStream = null;
protected long fStartAddress = 0;
protected long fEndAddress = 0;
/**
* Constructor for DisassemblyStorage.
*/
public DisassemblyStorage( IDebugTarget target, ICDIInstruction[] instructions )
{
setDebugTarget( target );
setInstructions( instructions );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IDisassemblyStorage#getDebugTarget()
*/
public IDebugTarget getDebugTarget()
{
return fDebugTarget;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IDisassemblyStorage#containsAddress(Long)
*/
public boolean containsAddress( long address )
{
return ( address >= fStartAddress && address <= fEndAddress );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IDisassemblyStorage#getLineNumber(Long)
*/
public int getLineNumber( long address )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IStorage#getContents()
*/
public InputStream getContents() throws CoreException
{
if ( fInputStream != null )
fInputStream.reset();
return fInputStream;
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IStorage#getFullPath()
*/
public IPath getFullPath()
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IStorage#getName()
*/
public String getName()
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IStorage#isReadOnly()
*/
public boolean isReadOnly()
{
return true;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
if ( adapter.equals( IStorage.class ) )
return this;
if ( adapter.equals( IDisassemblyStorage.class ) )
return this;
if ( adapter.equals( DisassemblyStorage.class ) )
return this;
return null;
}
protected void setDebugTarget( IDebugTarget target )
{
fDebugTarget = target;
}
protected void setInstructions( ICDIInstruction[] intructions )
{
fInstructions = intructions;
}
}

View file

@ -217,8 +217,7 @@ public class CDebugTarget extends CDebugElement
setCDITarget( cdiTarget );
setBreakpoints( new HashMap( 5 ) );
setTemporaryBreakpoints( new ArrayList() );
if ( getLaunch().getSourceLocator() == null )
getLaunch().setSourceLocator( createSourceLocator( project ) );
getLaunch().setSourceLocator( createSourceLocator( project ) );
setConfiguration( cdiTarget.getSession().getConfiguration() );
fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate();
fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect();
@ -353,9 +352,9 @@ public class CDebugTarget extends CDebugElement
if ( breakpoint instanceof ICBreakpoint )
{
ISourceLocator sl = getSourceLocator();
if ( sl != null && sl instanceof CSourceLocator )
if ( sl != null && sl instanceof ICSourceLocator )
{
return ((CSourceLocator)sl).contains( breakpoint.getMarker().getResource() );
return ((ICSourceLocator)sl).contains( breakpoint.getMarker().getResource() );
}
return true;
}
@ -1803,7 +1802,7 @@ public class CDebugTarget extends CDebugElement
protected ISourceLocator createSourceLocator( IProject project )
{
return new CSourceLocator( project );
return ( getLaunch().getSourceLocator() != null ) ? getLaunch().getSourceLocator() : new CSourceLocator( project );
}
protected void setSourceSearchPath()

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View file

@ -60,6 +60,7 @@ public class CDebugImages
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_OBJS_DISASSEMBLY = NAME_PREFIX + "disassembly_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$
@ -90,6 +91,7 @@ public class CDebugImages
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 );
public static final ImageDescriptor DESC_OBJS_DISASSEMBLY = createManaged( T_OBJ, IMG_OBJS_DISASSEMBLY );
/**
* Returns the image managed under the given key in this registry.

View file

@ -0,0 +1,88 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.editors;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IStorageEditorInput;
/**
* Enter type comment.
*
* @since: Oct 8, 2002
*/
public class DisassemblyEditorInput implements IStorageEditorInput
{
protected IStorage fStorage;
/**
* Constructor for DisassemblyEditorInput.
*/
public DisassemblyEditorInput( IStorage storage )
{
fStorage = storage;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IStorageEditorInput#getStorage()
*/
public IStorage getStorage() throws CoreException
{
return fStorage;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#exists()
*/
public boolean exists()
{
return true;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#getImageDescriptor()
*/
public ImageDescriptor getImageDescriptor()
{
return CDebugImages.DESC_OBJS_DISASSEMBLY;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#getName()
*/
public String getName()
{
return "disassembly.s";
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#getPersistable()
*/
public IPersistableElement getPersistable()
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#getToolTipText()
*/
public String getToolTipText()
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
return null;
}
}