1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

If the target is suspended by a line breakpoint the source manager tries to retrieve the file resource from the breakpoint marker.

This commit is contained in:
Mikhail Khodjaiants 2003-10-17 15:48:37 +00:00
parent 3a43da5b4b
commit 8720297f8a
3 changed files with 55 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2003-10-17 Mikhail Khodjaiants
If the target is suspended by a line breakpoint the source manager tries to retrieve
the file resource from the breakpoint marker.
* CSourceManager.java
* CDebugTarget.java
2003-10-15 Mikhail Khodjaiants
Improving the source search algorithms.
* CDirectorySourceLocation.java

View file

@ -442,6 +442,13 @@ public class CDebugTarget extends CDebugElement
ISourceLocator locator = getLaunch().getSourceLocator();
if ( locator instanceof IAdaptable )
{
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
if ( clocator instanceof IAdaptable )
{
CSourceManager sm = (CSourceManager)((IAdaptable)clocator).getAdapter( CSourceManager.class );
if ( sm != null )
sm.setDebugTarget( this );
}
IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
if ( listener != null )
CCorePlugin.getWorkspace().addResourceChangeListener( listener );
@ -2777,6 +2784,26 @@ public class CDebugTarget extends CDebugElement
return fRunningInfo;
}
public IFile getCurrentBreakpointFile()
{
Object info = getCurrentStateInfo();
if ( info instanceof ICDIBreakpointHit )
{
ICDIBreakpoint cdiBreakpoint = ((ICDIBreakpointHit)info).getBreakpoint();
if ( cdiBreakpoint != null )
{
IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint );
if ( breakpoint instanceof ICLineBreakpoint )
{
IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource();
if ( resource instanceof IFile )
return (IFile)resource;
}
}
}
return null;
}
protected void setRunningInfo( RunningInfo info )
{
fRunningInfo = info;
@ -2802,6 +2829,7 @@ public class CDebugTarget extends CDebugElement
}
setRunningInfo( info );
}
/*
private boolean applyDeferredBreakpoints()
{

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeListener;
@ -40,6 +41,7 @@ public class CSourceManager implements ICSourceLocator,
private int fMode = ISourceMode.MODE_SOURCE;
private int fRealMode = fMode;
private ILaunch fLaunch = null;
private CDebugTarget fDebugTarget = null;
/**
* Constructor for CSourceManager.
@ -132,6 +134,8 @@ public class CSourceManager implements ICSourceLocator,
*/
public Object getAdapter( Class adapter )
{
if ( adapter.equals( CSourceManager.class ) )
return this;
if ( adapter.equals( IResourceChangeListener.class ) &&
fSourceLocator instanceof IResourceChangeListener )
return fSourceLocator;
@ -148,6 +152,11 @@ public class CSourceManager implements ICSourceLocator,
if ( getMode() == ISourceMode.MODE_SOURCE && getSourceLocator() != null )
{
// if the target is suspended by a line breakpoint the source manager
// tries to retrieve the file resource from the breakpoint marker.
if ( getDebugTarget() != null )
result = getDebugTarget().getCurrentBreakpointFile();
if ( result == null )
result = getSourceLocator().getSourceElement( stackFrame );
}
if ( result == null &&
@ -256,4 +265,14 @@ public class CSourceManager implements ICSourceLocator,
{
return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
}
public void setDebugTarget( CDebugTarget target )
{
fDebugTarget = target;
}
protected CDebugTarget getDebugTarget()
{
return fDebugTarget;
}
}