mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
The core support of the prompting source locator.
This commit is contained in:
parent
55d70715c7
commit
9a7b5690eb
7 changed files with 157 additions and 122 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2002-12-17 Mikhail Khodjaiants
|
||||||
|
The core support of the prompting source locator.
|
||||||
|
* ICSourceLocator.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
* CDirectorySourceLocation.java
|
||||||
|
* CSourceLocator.java
|
||||||
|
* CSourceManager.java
|
||||||
|
* DisassemblyManager.java
|
||||||
|
|
||||||
2002-12-17 Mikhail Khodjaiants
|
2002-12-17 Mikhail Khodjaiants
|
||||||
The 'getLineNumber' method of CStackFrame should return the line number associated with the stack frame if the current source locator
|
The 'getLineNumber' method of CStackFrame should return the line number associated with the stack frame if the current source locator
|
||||||
does not implement 'ICSourceLocator'.
|
does not implement 'ICSourceLocator'.
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.debug.core.model.ISourceLocator;
|
import org.eclipse.debug.core.model.ISourceLocator;
|
||||||
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -27,17 +27,8 @@ public interface ICSourceLocator extends ISourceLocator
|
||||||
* @return line number of instruction pointer in this stack frame,
|
* @return line number of instruction pointer in this stack frame,
|
||||||
* or -1 if line number information is unavailable
|
* or -1 if line number information is unavailable
|
||||||
*/
|
*/
|
||||||
int getLineNumber( IStackFrameInfo frameInfo );
|
int getLineNumber( IStackFrame stackFrame );
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a source element that corresponds to the given file name, or
|
|
||||||
* <code>null</code> if a source element could not be located.
|
|
||||||
*
|
|
||||||
* @param fileName the file name for which to locate source
|
|
||||||
* @return an object representing a source element.
|
|
||||||
*/
|
|
||||||
// Object getSourceElement( String fileName );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the source locations of this locator.
|
* Returns the source locations of this locator.
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,14 +68,13 @@ import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
|
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||||
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
|
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarkerDelta;
|
import org.eclipse.core.resources.IMarkerDelta;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
@ -212,7 +211,12 @@ public class CDebugTarget extends CDebugElement
|
||||||
private CMemoryManager fMemoryManager;
|
private CMemoryManager fMemoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A memory manager for this target.
|
* A disassembly manager for this target.
|
||||||
|
*/
|
||||||
|
private DisassemblyManager fDisassemblyManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the debugger process is default.
|
||||||
*/
|
*/
|
||||||
private boolean fIsDebuggerProcessDefault = false;
|
private boolean fIsDebuggerProcessDefault = false;
|
||||||
|
|
||||||
|
@ -244,14 +248,11 @@ public class CDebugTarget extends CDebugElement
|
||||||
setCDITarget( cdiTarget );
|
setCDITarget( cdiTarget );
|
||||||
setBreakpoints( new HashMap( 5 ) );
|
setBreakpoints( new HashMap( 5 ) );
|
||||||
setExecFile( file );
|
setExecFile( file );
|
||||||
if ( getExecFile() != null )
|
|
||||||
{
|
|
||||||
getLaunch().setSourceLocator( createSourceLocator( getExecFile().getProject() ) );
|
|
||||||
}
|
|
||||||
setConfiguration( cdiTarget.getSession().getConfiguration() );
|
setConfiguration( cdiTarget.getSession().getConfiguration() );
|
||||||
fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate();
|
fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate();
|
||||||
fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect();
|
fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect();
|
||||||
setThreadList( new ArrayList( 5 ) );
|
setThreadList( new ArrayList( 5 ) );
|
||||||
|
setDisassemblyManager( new DisassemblyManager( this ) );
|
||||||
initialize();
|
initialize();
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
|
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
|
||||||
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
|
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
|
||||||
|
@ -827,9 +828,9 @@ public class CDebugTarget extends CDebugElement
|
||||||
return this;
|
return this;
|
||||||
if ( adapter.equals( ISourceMode.class ) )
|
if ( adapter.equals( ISourceMode.class ) )
|
||||||
{
|
{
|
||||||
if ( getSourceLocator() instanceof ISourceMode )
|
if ( getSourceLocator() instanceof IAdaptable )
|
||||||
{
|
{
|
||||||
return getSourceLocator();
|
return ((IAdaptable)getSourceLocator()).getAdapter( ISourceMode.class );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( adapter.equals( ICMemoryManager.class ) )
|
if ( adapter.equals( ICMemoryManager.class ) )
|
||||||
|
@ -840,6 +841,8 @@ public class CDebugTarget extends CDebugElement
|
||||||
return this;
|
return this;
|
||||||
if ( adapter.equals( IRunToLine.class ) )
|
if ( adapter.equals( IRunToLine.class ) )
|
||||||
return this;
|
return this;
|
||||||
|
if ( adapter.equals( DisassemblyManager.class ) )
|
||||||
|
return fDisassemblyManager;
|
||||||
return super.getAdapter( adapter );
|
return super.getAdapter( adapter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1832,12 +1835,6 @@ public class CDebugTarget extends CDebugElement
|
||||||
return getLaunch().getSourceLocator();
|
return getLaunch().getSourceLocator();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ISourceLocator createSourceLocator( IProject project )
|
|
||||||
{
|
|
||||||
return new CSourceManager( ( getLaunch().getSourceLocator() != null ) ? getLaunch().getSourceLocator() : new CSourceLocator( project ),
|
|
||||||
new DisassemblyManager( this ) ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setSourceSearchPath()
|
protected void setSourceSearchPath()
|
||||||
{
|
{
|
||||||
ICDISourceManager mgr = getCDISession().getSourceManager();
|
ICDISourceManager mgr = getCDISession().getSourceManager();
|
||||||
|
@ -2020,4 +2017,14 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setDisassemblyManager( DisassemblyManager dm )
|
||||||
|
{
|
||||||
|
fDisassemblyManager = dm;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DisassemblyManager getDisassemblyManager()
|
||||||
|
{
|
||||||
|
return fDisassemblyManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@ import org.eclipse.core.runtime.Path;
|
||||||
public class CDirectorySourceLocation implements ICSourceLocation
|
public class CDirectorySourceLocation implements ICSourceLocation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The directory associated with this source location
|
* The root directory of this source location
|
||||||
*/
|
*/
|
||||||
private IPath fDirectory;
|
private IPath fDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The associted path of this source location.
|
||||||
|
*/
|
||||||
|
private IPath fAssociation = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CDirectorySourceLocation.
|
* Constructor for CDirectorySourceLocation.
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +43,15 @@ public class CDirectorySourceLocation implements ICSourceLocation
|
||||||
setDirectory( directory );
|
setDirectory( directory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for CDirectorySourceLocation.
|
||||||
|
*/
|
||||||
|
public CDirectorySourceLocation( IPath directory, IPath association )
|
||||||
|
{
|
||||||
|
setDirectory( directory );
|
||||||
|
setAssociation( association );
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#findSourceElement(String)
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#findSourceElement(String)
|
||||||
*/
|
*/
|
||||||
|
@ -67,19 +81,17 @@ public class CDirectorySourceLocation implements ICSourceLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the directory in which source elements will
|
* Sets the directory in which source elements will be searched for.
|
||||||
* be searched for.
|
|
||||||
*
|
*
|
||||||
* @param directory a directory
|
* @param directory a directory
|
||||||
*/
|
*/
|
||||||
private void setDirectory( IPath directory )
|
protected void setDirectory( IPath directory )
|
||||||
{
|
{
|
||||||
fDirectory = directory;
|
fDirectory = directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the directory associated with this source
|
* Returns the root directory of this source location.
|
||||||
* location.
|
|
||||||
*
|
*
|
||||||
* @return directory
|
* @return directory
|
||||||
*/
|
*/
|
||||||
|
@ -88,29 +100,45 @@ public class CDirectorySourceLocation implements ICSourceLocation
|
||||||
return fDirectory;
|
return fDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setAssociation( IPath association )
|
||||||
|
{
|
||||||
|
fAssociation = association;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPath getAssociation()
|
||||||
|
{
|
||||||
|
return fAssociation;
|
||||||
|
}
|
||||||
|
|
||||||
private Object findFileByAbsolutePath( String fileName )
|
private Object findFileByAbsolutePath( String fileName )
|
||||||
{
|
{
|
||||||
IPath filePath = new Path( fileName );
|
IPath filePath = new Path( fileName );
|
||||||
String name = filePath.lastSegment();
|
|
||||||
filePath = filePath.removeLastSegments( 1 );
|
|
||||||
IPath path = getDirectory();
|
IPath path = getDirectory();
|
||||||
if ( path.equals( filePath ) )
|
IPath association = getAssociation();
|
||||||
|
if ( path.isPrefixOf( filePath ) )
|
||||||
{
|
{
|
||||||
path = path.append( name );
|
filePath = path.append( filePath.removeFirstSegments( path.segmentCount() ) );
|
||||||
|
}
|
||||||
// Try for a file in another workspace project
|
else if ( association != null && association.isPrefixOf( filePath ) )
|
||||||
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
|
{
|
||||||
if ( f != null )
|
filePath = path.append( filePath.removeFirstSegments( association.segmentCount() ) );
|
||||||
{
|
}
|
||||||
return f;
|
else
|
||||||
}
|
{
|
||||||
|
return null;
|
||||||
File file = path.toFile();
|
}
|
||||||
if ( file.exists() )
|
// Try for a file in another workspace project
|
||||||
{
|
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( filePath );
|
||||||
return createExternalFileStorage( path );
|
if ( f != null )
|
||||||
}
|
{
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File file = filePath.toFile();
|
||||||
|
if ( file.exists() )
|
||||||
|
{
|
||||||
|
return createExternalFileStorage( filePath );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,9 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.model.IPersistableSourceLocator;
|
|
||||||
import org.eclipse.debug.core.model.IStackFrame;
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +26,7 @@ import org.eclipse.debug.core.model.IStackFrame;
|
||||||
*
|
*
|
||||||
* @since Aug 19, 2002
|
* @since Aug 19, 2002
|
||||||
*/
|
*/
|
||||||
public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator
|
public class CSourceLocator implements ICSourceLocator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The array of source locations associated with this locator.
|
* The array of source locations associated with this locator.
|
||||||
|
@ -73,9 +72,10 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.ICSourceLocator#getLineNumber(IStackFrameInfo)
|
* @see org.eclipse.cdt.debug.core.ICSourceLocator#getLineNumber(IStackFrameInfo)
|
||||||
*/
|
*/
|
||||||
public int getLineNumber( IStackFrameInfo frameInfo )
|
public int getLineNumber( IStackFrame frame )
|
||||||
{
|
{
|
||||||
return ( frameInfo != null ) ? frameInfo.getFrameLineNumber() : 0;
|
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class );
|
||||||
|
return ( info != null ) ? info.getFrameLineNumber() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object getInput( IStackFrameInfo info )
|
protected Object getInput( IStackFrameInfo info )
|
||||||
|
@ -86,27 +86,23 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
String fileName = info.getFile();
|
String fileName = info.getFile();
|
||||||
if ( fileName != null && fileName.length() > 0 )
|
if ( fileName != null && fileName.length() > 0 )
|
||||||
{
|
{
|
||||||
ICSourceLocation[] locations = getSourceLocations();
|
result = findFileByAbsolutePath( fileName );
|
||||||
for ( int i = 0; i < locations.length; ++i )
|
if ( result == null )
|
||||||
{
|
{
|
||||||
try
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
{
|
{
|
||||||
result = locations[i].findSourceElement( fileName );
|
try
|
||||||
|
{
|
||||||
|
result = locations[i].findSourceElement( fileName );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
if ( result != null )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch( CoreException e )
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
if ( result != null )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( result == null )
|
|
||||||
{
|
|
||||||
Path path = new Path( fileName );
|
|
||||||
if ( path.isAbsolute() && path.toFile().exists() )
|
|
||||||
{
|
|
||||||
return new FileStorage( path );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,26 +187,20 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
}
|
}
|
||||||
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Object findFileByAbsolutePath( String fileName )
|
||||||
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
|
|
||||||
*/
|
|
||||||
public String getMemento() throws CoreException
|
|
||||||
{
|
{
|
||||||
|
Path path = new Path( fileName );
|
||||||
|
if ( path.isAbsolute() && path.toFile().exists() )
|
||||||
|
{
|
||||||
|
// Try for a file in another workspace project
|
||||||
|
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
|
||||||
|
if ( f != null )
|
||||||
|
{
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
return new FileStorage( path );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration)
|
|
||||||
*/
|
|
||||||
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(String)
|
|
||||||
*/
|
|
||||||
public void initializeFromMemento( String memento ) throws CoreException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
|
@ -14,6 +17,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.model.ISourceLocator;
|
import org.eclipse.debug.core.model.ISourceLocator;
|
||||||
import org.eclipse.debug.core.model.IStackFrame;
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
|
|
||||||
|
@ -24,52 +28,43 @@ import org.eclipse.debug.core.model.IStackFrame;
|
||||||
*/
|
*/
|
||||||
public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
|
public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
|
||||||
{
|
{
|
||||||
private ISourceLocator fSourceLocator;
|
private ISourceLocator fSourceLocator = null;
|
||||||
private DisassemblyManager fDisassemblyManager;
|
|
||||||
private int fMode = ISourceMode.MODE_SOURCE;
|
private int fMode = ISourceMode.MODE_SOURCE;
|
||||||
private int fRealMode = fMode;
|
private int fRealMode = fMode;
|
||||||
|
private ILaunch fLaunch = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CSourceManager.
|
* Constructor for CSourceManager.
|
||||||
*/
|
*/
|
||||||
public CSourceManager( ISourceLocator sourceLocator, DisassemblyManager disassemblyManager )
|
public CSourceManager( ISourceLocator sourceLocator )
|
||||||
{
|
{
|
||||||
setSourceLocator( sourceLocator );
|
setSourceLocator( sourceLocator );
|
||||||
setDisassemblyManager( disassemblyManager );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo)
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo)
|
||||||
*/
|
*/
|
||||||
public int getLineNumber( IStackFrameInfo frameInfo )
|
public int getLineNumber( IStackFrame frame )
|
||||||
{
|
{
|
||||||
if ( getRealMode() == ISourceMode.MODE_SOURCE )
|
if ( getRealMode() == ISourceMode.MODE_SOURCE )
|
||||||
{
|
{
|
||||||
if ( getCSourceLocator() != null )
|
if ( getCSourceLocator() != null )
|
||||||
{
|
{
|
||||||
return getCSourceLocator().getLineNumber( frameInfo );
|
return getCSourceLocator().getLineNumber( frame );
|
||||||
}
|
}
|
||||||
if ( frameInfo != null )
|
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class );
|
||||||
|
if ( info != null )
|
||||||
{
|
{
|
||||||
return frameInfo.getFrameLineNumber();
|
return info.getFrameLineNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( getRealMode() == ISourceMode.MODE_DISASSEMBLY && getDisassemblyManager() != null )
|
if ( getRealMode() == ISourceMode.MODE_DISASSEMBLY && getDisassemblyManager( frame ) != null )
|
||||||
{
|
{
|
||||||
return getDisassemblyManager().getLineNumber( frameInfo );
|
return getDisassemblyManager( frame ).getLineNumber( frame );
|
||||||
}
|
}
|
||||||
return 0;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations()
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations()
|
||||||
*/
|
*/
|
||||||
|
@ -146,10 +141,10 @@ public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
|
||||||
}
|
}
|
||||||
if ( result == null &&
|
if ( result == null &&
|
||||||
( autoDisassembly || getMode() == ISourceMode.MODE_DISASSEMBLY ) &&
|
( autoDisassembly || getMode() == ISourceMode.MODE_DISASSEMBLY ) &&
|
||||||
getDisassemblyManager() != null )
|
getDisassemblyManager( stackFrame ) != null )
|
||||||
{
|
{
|
||||||
setRealMode( ISourceMode.MODE_DISASSEMBLY );
|
setRealMode( ISourceMode.MODE_DISASSEMBLY );
|
||||||
result = getDisassemblyManager().getSourceElement( stackFrame );
|
result = getDisassemblyManager( stackFrame ).getSourceElement( stackFrame );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -167,7 +162,11 @@ public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
|
||||||
|
|
||||||
protected ISourceLocator getSourceLocator()
|
protected ISourceLocator getSourceLocator()
|
||||||
{
|
{
|
||||||
return fSourceLocator;
|
if ( fSourceLocator != null )
|
||||||
|
return fSourceLocator;
|
||||||
|
else if ( fLaunch != null )
|
||||||
|
return fLaunch.getSourceLocator();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSourceLocator( ISourceLocator sl )
|
protected void setSourceLocator( ISourceLocator sl )
|
||||||
|
@ -175,13 +174,20 @@ public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
|
||||||
fSourceLocator = sl;
|
fSourceLocator = sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDisassemblyManager( DisassemblyManager dm )
|
protected DisassemblyManager getDisassemblyManager( IStackFrame stackFrame )
|
||||||
{
|
{
|
||||||
fDisassemblyManager = dm;
|
if ( stackFrame != null )
|
||||||
|
{
|
||||||
|
return (DisassemblyManager)stackFrame.getDebugTarget().getAdapter( DisassemblyManager.class );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DisassemblyManager getDisassemblyManager()
|
public void addSourceLocation( ICSourceLocation location )
|
||||||
{
|
{
|
||||||
return fDisassemblyManager;
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
|
ArrayList list = new ArrayList( Arrays.asList( locations ) );
|
||||||
|
list.add( location );
|
||||||
|
setSourceLocations( (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,16 @@ public class DisassemblyManager
|
||||||
setDebugTarget( target );
|
setDebugTarget( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLineNumber( IStackFrameInfo frameInfo )
|
public int getLineNumber( IStackFrame frame )
|
||||||
{
|
{
|
||||||
DisassemblyStorage storage = getSourceElement( frameInfo );
|
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class );
|
||||||
if ( storage != null )
|
if ( info != null )
|
||||||
{
|
{
|
||||||
return storage.getLineNumber( frameInfo.getAddress() );
|
DisassemblyStorage storage = getSourceElement( info );
|
||||||
|
if ( storage != null )
|
||||||
|
{
|
||||||
|
return storage.getLineNumber( info.getAddress() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue