mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementation of address breakpoints.
This commit is contained in:
parent
03e23c8df3
commit
181bd57bf1
30 changed files with 913 additions and 57 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2003-01-10 Mikhail Khodjaiants
|
||||||
|
Implementation of address breakpoints.
|
||||||
|
* ICAddressBreakpoint.java
|
||||||
|
* ICDebugTarget.java
|
||||||
|
* IDisassemblyStorage.java
|
||||||
|
* CDebugModel.java
|
||||||
|
* ICBreakpointManager.java
|
||||||
|
* CAddressBreakpoint.java
|
||||||
|
* CFunctionBreakpoint.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
* CStackFrame.java
|
||||||
|
* DisassemblyManager.java
|
||||||
|
* DisassemblyStorage.java
|
||||||
|
|
||||||
2003-01-06 Alain Magloire
|
2003-01-06 Alain Magloire
|
||||||
|
|
||||||
* build.properties: Patch from Judy Green.
|
* build.properties: Patch from Judy Green.
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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.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.model.ICAddressBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
|
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
|
||||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
|
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
|
||||||
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
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.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.CDebugTarget;
|
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||||
|
@ -305,6 +307,60 @@ public class CDebugModel
|
||||||
return new CLineBreakpoint( resource, attributes, add );
|
return new CLineBreakpoint( resource, attributes, add );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICAddressBreakpoint addressBreakpointExists( IResource resource, long address ) throws CoreException
|
||||||
|
{
|
||||||
|
String modelId = getPluginIdentifier();
|
||||||
|
String markerType = CAddressBreakpoint.getMarkerType();
|
||||||
|
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
||||||
|
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
|
||||||
|
for ( int i = 0; i < breakpoints.length; i++ )
|
||||||
|
{
|
||||||
|
if ( !( breakpoints[i] instanceof ICAddressBreakpoint ) )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ICAddressBreakpoint breakpoint = (ICAddressBreakpoint)breakpoints[i];
|
||||||
|
if ( breakpoint.getMarker().getType().equals( markerType ) )
|
||||||
|
{
|
||||||
|
if ( breakpoint.getMarker().getResource().getLocation().toOSString().equals( resource.getLocation().toOSString() ) )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( Long.parseLong( breakpoint.getAddress() ) == address )
|
||||||
|
{
|
||||||
|
return breakpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICAddressBreakpoint createAddressBreakpoint( IResource resource,
|
||||||
|
int lineNumber,
|
||||||
|
long address,
|
||||||
|
boolean enabled,
|
||||||
|
int ignoreCount,
|
||||||
|
String condition,
|
||||||
|
boolean add ) throws DebugException
|
||||||
|
{
|
||||||
|
HashMap attributes = new HashMap( 10 );
|
||||||
|
attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
|
||||||
|
// attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
|
||||||
|
attributes.put( IMarker.CHAR_START, new Integer( 0 ) );
|
||||||
|
attributes.put( IMarker.CHAR_END, new Integer( 0 ) );
|
||||||
|
attributes.put( IMarker.LINE_NUMBER, new Integer( -1 ) );
|
||||||
|
attributes.put( ICAddressBreakpoint.ADDRESS, Long.toString( address ) );
|
||||||
|
attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
|
||||||
|
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
|
||||||
|
attributes.put( ICBreakpoint.CONDITION, condition );
|
||||||
|
return new CAddressBreakpoint( resource, attributes, add );
|
||||||
|
}
|
||||||
|
|
||||||
public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException
|
public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException
|
||||||
{
|
{
|
||||||
String modelId = getPluginIdentifier();
|
String modelId = getPluginIdentifier();
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.core;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since: Jan 7, 2003
|
||||||
|
*/
|
||||||
|
public interface ICBreakpointManager extends IAdaptable
|
||||||
|
{
|
||||||
|
long getBreakpointAddress( IBreakpoint breakpoint );
|
||||||
|
}
|
|
@ -15,6 +15,13 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public interface ICAddressBreakpoint extends ICLineBreakpoint
|
public interface ICAddressBreakpoint extends ICLineBreakpoint
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Breakpoint attribute storing the address this breakpoint suspends
|
||||||
|
* execution at (value <code>"org.eclipse.cdt.debug.core.address"</code>).
|
||||||
|
* This attribute is a <code>String</code>.
|
||||||
|
*/
|
||||||
|
public static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the address this breakpoint suspends execution at.
|
* Returns the address this breakpoint suspends execution at.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.core.model;
|
package org.eclipse.cdt.debug.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.ICBreakpointManager;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ public interface ICDebugTarget extends IDebugTarget,
|
||||||
IRestart,
|
IRestart,
|
||||||
IRunToLine,
|
IRunToLine,
|
||||||
IState,
|
IState,
|
||||||
ISwitchToThread
|
ISwitchToThread,
|
||||||
|
ICBreakpointManager
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,11 @@ public interface IDisassemblyStorage extends IStorage
|
||||||
* @return the line number for given address
|
* @return the line number for given address
|
||||||
*/
|
*/
|
||||||
int getLineNumber( long address ) ;
|
int getLineNumber( long address ) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the address of instruction at given line.
|
||||||
|
* @param lineNumber - a line number
|
||||||
|
* @return the address of instruction at given line
|
||||||
|
*/
|
||||||
|
long getAddress( int lineNumber ) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,4 +223,16 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage#getAddress(int)
|
||||||
|
*/
|
||||||
|
public long getAddress( int lineNumber )
|
||||||
|
{
|
||||||
|
if ( fInstructions.length > lineNumber && lineNumber >= 0 )
|
||||||
|
{
|
||||||
|
return fInstructions[lineNumber].getAdress();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,7 @@ import org.eclipse.debug.core.DebugException;
|
||||||
*/
|
*/
|
||||||
public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint
|
public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint
|
||||||
{
|
{
|
||||||
private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.jdt.debug.cAddressBreakpointMarker"; //$NON-NLS-1$
|
private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
|
||||||
* Breakpoint attribute storing the address this breakpoint suspends
|
|
||||||
* execution at (value <code>"org.eclipse.cdt.debug.core.address"</code>).
|
|
||||||
* This attribute is a <code>String</code>.
|
|
||||||
*/
|
|
||||||
protected static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CAddressBreakpoint.
|
* Constructor for CAddressBreakpoint.
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.debug.core.DebugException;
|
||||||
*/
|
*/
|
||||||
public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint
|
public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint
|
||||||
{
|
{
|
||||||
private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.jdt.debug.cFunctionBreakpointMarker"; //$NON-NLS-1$
|
private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Breakpoint attribute storing the function this breakpoint suspends
|
* Breakpoint attribute storing the function this breakpoint suspends
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
import org.eclipse.cdt.core.model.ICFile;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||||
|
import org.eclipse.cdt.debug.core.ICBreakpointManager;
|
||||||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
|
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
|
||||||
|
@ -46,10 +47,12 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIRestartedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
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.ICDIThread;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
|
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
|
||||||
|
@ -385,9 +388,9 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public boolean supportsBreakpoint( IBreakpoint breakpoint )
|
public boolean supportsBreakpoint( IBreakpoint breakpoint )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if ( !getConfiguration().supportsBreakpoints() )
|
if ( !getConfiguration().supportsBreakpoints() )
|
||||||
return false;
|
return false;
|
||||||
|
/*
|
||||||
if ( breakpoint instanceof ICBreakpoint )
|
if ( breakpoint instanceof ICBreakpoint )
|
||||||
{
|
{
|
||||||
ISourceLocator sl = getSourceLocator();
|
ISourceLocator sl = getSourceLocator();
|
||||||
|
@ -399,7 +402,17 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
*/
|
*/
|
||||||
return getConfiguration().supportsBreakpoints();
|
if ( breakpoint instanceof ICAddressBreakpoint )
|
||||||
|
{
|
||||||
|
return supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint )
|
||||||
|
{
|
||||||
|
return ( getExecFile() != null &&
|
||||||
|
getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -628,7 +641,11 @@ public class CDebugTarget extends CDebugElement
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( breakpoint instanceof ICLineBreakpoint )
|
if ( breakpoint instanceof ICAddressBreakpoint )
|
||||||
|
{
|
||||||
|
setAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
|
||||||
|
}
|
||||||
|
else if ( breakpoint instanceof ICLineBreakpoint )
|
||||||
{
|
{
|
||||||
setLineBreakpoint( (ICLineBreakpoint)breakpoint );
|
setLineBreakpoint( (ICLineBreakpoint)breakpoint );
|
||||||
}
|
}
|
||||||
|
@ -844,6 +861,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( ICBreakpointManager.class ) )
|
||||||
|
return this;
|
||||||
if ( adapter.equals( DisassemblyManager.class ) )
|
if ( adapter.equals( DisassemblyManager.class ) )
|
||||||
return fDisassemblyManager;
|
return fDisassemblyManager;
|
||||||
return super.getAdapter( adapter );
|
return super.getAdapter( adapter );
|
||||||
|
@ -1614,6 +1633,38 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws DebugException
|
||||||
|
{
|
||||||
|
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) );
|
||||||
|
ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
|
||||||
|
ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, condition, null );
|
||||||
|
if ( !getBreakpoints().containsKey( breakpoint ) )
|
||||||
|
{
|
||||||
|
getBreakpoints().put( breakpoint, cdiBreakpoint );
|
||||||
|
((CBreakpoint)breakpoint).incrementInstallCount();
|
||||||
|
if ( !breakpoint.isEnabled() )
|
||||||
|
{
|
||||||
|
cdiBreakpoint.setEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CoreException ce )
|
||||||
|
{
|
||||||
|
requestFailed( "Operation failed. Reason: ", ce );
|
||||||
|
}
|
||||||
|
catch( CDIException e )
|
||||||
|
{
|
||||||
|
requestFailed( "Operation failed. Reason: ", e );
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
requestFailed( "Operation failed. Reason: ", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException
|
private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException
|
||||||
{
|
{
|
||||||
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
|
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
|
||||||
|
@ -1900,9 +1951,12 @@ public class CDebugTarget extends CDebugElement
|
||||||
protected int getRealSourceMode()
|
protected int getRealSourceMode()
|
||||||
{
|
{
|
||||||
ISourceLocator sl = getSourceLocator();
|
ISourceLocator sl = getSourceLocator();
|
||||||
if ( sl != null && sl instanceof CSourceManager )
|
if ( sl != null &&
|
||||||
|
sl instanceof IAdaptable &&
|
||||||
|
((IAdaptable)sl).getAdapter( ICSourceLocator.class ) != null &&
|
||||||
|
((IAdaptable)sl).getAdapter( ICSourceLocator.class ) instanceof CSourceManager )
|
||||||
{
|
{
|
||||||
return ((CSourceManager)sl).getRealMode();
|
return ((CSourceManager)((IAdaptable)sl).getAdapter( ICSourceLocator.class )).getRealMode();
|
||||||
}
|
}
|
||||||
return ISourceMode.MODE_SOURCE;
|
return ISourceMode.MODE_SOURCE;
|
||||||
}
|
}
|
||||||
|
@ -2035,4 +2089,27 @@ public class CDebugTarget extends CDebugElement
|
||||||
{
|
{
|
||||||
return fDisassemblyManager;
|
return fDisassemblyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.ICBreakpointManager#getBreakpointAddress(IBreakpoint)
|
||||||
|
*/
|
||||||
|
public long getBreakpointAddress( IBreakpoint breakpoint )
|
||||||
|
{
|
||||||
|
ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint );
|
||||||
|
if ( cdiBreakpoint != null && cdiBreakpoint instanceof ICDILocationBreakpoint )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation();
|
||||||
|
if ( location != null )
|
||||||
|
{
|
||||||
|
return location.getAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CDIException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
import org.eclipse.cdt.debug.core.model.IRestart;
|
import org.eclipse.cdt.debug.core.model.IRestart;
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||||
import org.eclipse.debug.core.model.ISourceLocator;
|
import org.eclipse.debug.core.model.ISourceLocator;
|
||||||
|
@ -178,8 +179,9 @@ public class CStackFrame extends CDebugElement
|
||||||
if ( isSuspended() )
|
if ( isSuspended() )
|
||||||
{
|
{
|
||||||
ISourceLocator locator = ((CDebugTarget)getDebugTarget()).getSourceLocator();
|
ISourceLocator locator = ((CDebugTarget)getDebugTarget()).getSourceLocator();
|
||||||
if ( locator != null && locator instanceof ICSourceLocator )
|
if ( locator != null && locator instanceof IAdaptable &&
|
||||||
return ((ICSourceLocator)locator).getLineNumber( this );
|
((IAdaptable)locator).getAdapter( ICSourceLocator.class ) != null )
|
||||||
|
return ((ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class )).getLineNumber( this );
|
||||||
if ( getCDIStackFrame() != null && getCDIStackFrame().getLocation() != null )
|
if ( getCDIStackFrame() != null && getCDIStackFrame().getLocation() != null )
|
||||||
return getCDIStackFrame().getLocation().getLineNumber();
|
return getCDIStackFrame().getLocation().getLineNumber();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,20 @@ public class DisassemblyManager
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getSourceElement( long address )
|
||||||
|
{
|
||||||
|
DisassemblyStorage storage = null;
|
||||||
|
if ( getDisassemblyStorage() != null && getDisassemblyStorage().containsAddress( address ) )
|
||||||
|
{
|
||||||
|
storage = getDisassemblyStorage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storage = loadDisassemblyStorage( address );
|
||||||
|
}
|
||||||
|
return storage;
|
||||||
|
}
|
||||||
|
|
||||||
private void setDebugTarget( CDebugTarget target )
|
private void setDebugTarget( CDebugTarget target )
|
||||||
{
|
{
|
||||||
|
@ -144,6 +158,38 @@ public class DisassemblyManager
|
||||||
}
|
}
|
||||||
return getDisassemblyStorage();
|
return getDisassemblyStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DisassemblyStorage loadDisassemblyStorage( long address )
|
||||||
|
{
|
||||||
|
setDisassemblyStorage( null );
|
||||||
|
if ( getDebugTarget() != null && getDebugTarget().isSuspended() )
|
||||||
|
{
|
||||||
|
ICDISourceManager sm = getDebugTarget().getCDISession().getSourceManager();
|
||||||
|
if ( sm != null )
|
||||||
|
{
|
||||||
|
ICDIInstruction[] instructions = new ICDIInstruction[0];
|
||||||
|
if ( instructions.length == 0 )
|
||||||
|
{
|
||||||
|
if ( address >= 0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
instructions = getFunctionInstructions( sm.getInstructions( address, address + DISASSEMBLY_BLOCK_SIZE ) );
|
||||||
|
}
|
||||||
|
catch( CDIException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( instructions.length > 0 )
|
||||||
|
{
|
||||||
|
setDisassemblyStorage( new DisassemblyStorage( getDebugTarget(), instructions ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getDisassemblyStorage();
|
||||||
|
}
|
||||||
|
|
||||||
private ICDIInstruction[] getFunctionInstructions( ICDIInstruction[] rawInstructions )
|
private ICDIInstruction[] getFunctionInstructions( ICDIInstruction[] rawInstructions )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,25 @@
|
||||||
|
2003-01-10 Mikhail Khodjaiants
|
||||||
|
Implementation of address breakpoints.
|
||||||
|
* CDebugImages.java
|
||||||
|
* CDTDebugModelPresentation.java
|
||||||
|
* BreakpointLocationVerifier.java
|
||||||
|
* CBreakpointPreferencePage.java
|
||||||
|
* ManageBreakpointActionDelegate.java
|
||||||
|
* ManageBreakpointRulerAction.java
|
||||||
|
* ManageBreakpointRulerActionDelegate.java
|
||||||
|
* DisassemblyDocumentProvider.java
|
||||||
|
* DisassemblyEditor.java
|
||||||
|
* DisassemblyEditorInput.java
|
||||||
|
* DisassemblyMarkerAnnotation.java
|
||||||
|
* DisassemblyMarkerAnnotationModel.java
|
||||||
|
* CDebugUIPlugin.java
|
||||||
|
* plugin.properties
|
||||||
|
* plugin.xml
|
||||||
|
|
||||||
|
New icons:
|
||||||
|
* full/obj16/addrbrkp_obj.gif
|
||||||
|
* full/obj16/addrbrkpd_obj.gif
|
||||||
|
|
||||||
2003-01-06 Alain Magloire
|
2003-01-06 Alain Magloire
|
||||||
|
|
||||||
* build.properties: Patch from Judy Green.
|
* build.properties: Patch from Judy Green.
|
||||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkp_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkp_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 151 B |
Binary file not shown.
After Width: | Height: | Size: 147 B |
|
@ -48,3 +48,5 @@ NaturalVariableFormatAction.label=Natural
|
||||||
CDebugActionGroup.name=C/C++ Debug
|
CDebugActionGroup.name=C/C++ Debug
|
||||||
|
|
||||||
SourcePropertyPage.name=Source Lookup
|
SourcePropertyPage.name=Source Lookup
|
||||||
|
|
||||||
|
DisassemblyEditor.name=Disassembly Editor
|
||||||
|
|
|
@ -720,5 +720,16 @@
|
||||||
id="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage">
|
id="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage">
|
||||||
</page>
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="org.eclipse.cdt.debug.ui.editors"
|
||||||
|
point="org.eclipse.ui.editors">
|
||||||
|
<editor
|
||||||
|
name="%DisassemblyEditor.name"
|
||||||
|
extensions="dasm"
|
||||||
|
icon="icons/full/obj16/disassembly_obj.gif"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditor"
|
||||||
|
id="org.eclipse.cdt.debug.ui.DisassemblyEditor">
|
||||||
|
</editor>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -25,9 +25,12 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
|
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.model.IState;
|
import org.eclipse.cdt.debug.core.model.IState;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
|
||||||
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||||
|
@ -126,19 +129,24 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
*/
|
*/
|
||||||
public IEditorInput getEditorInput( Object element )
|
public IEditorInput getEditorInput( Object element )
|
||||||
{
|
{
|
||||||
IFile file = null;
|
|
||||||
if ( element instanceof IMarker )
|
if ( element instanceof IMarker )
|
||||||
{
|
{
|
||||||
IResource resource = ((IMarker)element).getResource();
|
IResource resource = ((IMarker)element).getResource();
|
||||||
if ( resource instanceof IFile )
|
if ( resource instanceof IFile )
|
||||||
file = (IFile)resource;
|
return new FileEditorInput( (IFile)resource );
|
||||||
}
|
}
|
||||||
if ( element instanceof IFile )
|
if ( element instanceof IFile )
|
||||||
file = (IFile)element;
|
{
|
||||||
|
return new FileEditorInput( (IFile)element );
|
||||||
|
}
|
||||||
|
if ( element instanceof ICAddressBreakpoint )
|
||||||
|
{
|
||||||
|
return getDisassemblyEditorInput( (ICAddressBreakpoint)element );
|
||||||
|
}
|
||||||
if ( element instanceof ICLineBreakpoint )
|
if ( element instanceof ICLineBreakpoint )
|
||||||
file = (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class );
|
{
|
||||||
if ( file != null )
|
return new FileEditorInput( (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class ) );
|
||||||
return new FileEditorInput( file );
|
}
|
||||||
if ( element instanceof FileStorage )
|
if ( element instanceof FileStorage )
|
||||||
{
|
{
|
||||||
return new ExternalEditorInput( (IStorage)element );
|
return new ExternalEditorInput( (IStorage)element );
|
||||||
|
@ -491,6 +499,10 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
|
|
||||||
protected Image getBreakpointImage( ICBreakpoint breakpoint ) throws CoreException
|
protected Image getBreakpointImage( ICBreakpoint breakpoint ) throws CoreException
|
||||||
{
|
{
|
||||||
|
if ( breakpoint instanceof ICAddressBreakpoint )
|
||||||
|
{
|
||||||
|
return getAddressBreakpointImage( (ICAddressBreakpoint)breakpoint );
|
||||||
|
}
|
||||||
if ( breakpoint instanceof ICLineBreakpoint )
|
if ( breakpoint instanceof ICLineBreakpoint )
|
||||||
{
|
{
|
||||||
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
|
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
|
||||||
|
@ -517,6 +529,21 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
return fDebugImageRegistry.get( descriptor );
|
return fDebugImageRegistry.get( descriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Image getAddressBreakpointImage( ICAddressBreakpoint breakpoint ) throws CoreException
|
||||||
|
{
|
||||||
|
int flags = computeBreakpointAdornmentFlags( breakpoint );
|
||||||
|
CImageDescriptor descriptor = null;
|
||||||
|
if ( breakpoint.isEnabled() )
|
||||||
|
{
|
||||||
|
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_ADDRESS_BREAKPOINT_ENABLED, flags );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_ADDRESS_BREAKPOINT_DISABLED, flags );
|
||||||
|
}
|
||||||
|
return fDebugImageRegistry.get( descriptor );
|
||||||
|
}
|
||||||
|
|
||||||
protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException
|
protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException
|
||||||
{
|
{
|
||||||
int flags = computeBreakpointAdornmentFlags( watchpoint );
|
int flags = computeBreakpointAdornmentFlags( watchpoint );
|
||||||
|
@ -549,15 +576,14 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
|
|
||||||
protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException
|
protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( breakpoint instanceof ICLineBreakpoint )
|
|
||||||
{
|
|
||||||
return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
|
|
||||||
}
|
|
||||||
if ( breakpoint instanceof ICAddressBreakpoint )
|
if ( breakpoint instanceof ICAddressBreakpoint )
|
||||||
{
|
{
|
||||||
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
|
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
|
||||||
}
|
}
|
||||||
|
if ( breakpoint instanceof ICLineBreakpoint )
|
||||||
|
{
|
||||||
|
return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
|
||||||
|
}
|
||||||
if ( breakpoint instanceof ICFunctionBreakpoint )
|
if ( breakpoint instanceof ICFunctionBreakpoint )
|
||||||
{
|
{
|
||||||
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
|
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
|
||||||
|
@ -591,7 +617,12 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
|
|
||||||
protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException
|
protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException
|
||||||
{
|
{
|
||||||
return null;
|
StringBuffer label = new StringBuffer();
|
||||||
|
appendResourceName( breakpoint, label, qualified );
|
||||||
|
appendAddress( breakpoint, label );
|
||||||
|
appendIgnoreCount( breakpoint, label );
|
||||||
|
appendCondition( breakpoint, label );
|
||||||
|
return label.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException
|
protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException
|
||||||
|
@ -605,7 +636,7 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
if ( !path.isEmpty() )
|
if ( !path.isEmpty() )
|
||||||
label.append( qualified ? path.toOSString() : path.lastSegment() );
|
label.append( qualified ? path.toOSString() : path.lastSegment() );
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException
|
protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException
|
||||||
{
|
{
|
||||||
|
@ -621,6 +652,21 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long address = Long.parseLong( breakpoint.getAddress() );
|
||||||
|
label.append( " [address: " );
|
||||||
|
label.append( CDebugUtils.toHexAddressString( address ) );
|
||||||
|
label.append( ']' );
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException
|
protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException
|
||||||
{
|
{
|
||||||
int ignoreCount = breakpoint.getIgnoreCount();
|
int ignoreCount = breakpoint.getIgnoreCount();
|
||||||
|
@ -723,4 +769,33 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
{
|
{
|
||||||
return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0 ) );
|
return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DisassemblyEditorInput getDisassemblyEditorInput( ICAddressBreakpoint breakpoint )
|
||||||
|
{
|
||||||
|
IDebugTarget[] targets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets();
|
||||||
|
for ( int i = 0; i < targets.length; ++i )
|
||||||
|
{
|
||||||
|
IResource resource = breakpoint.getMarker().getResource();
|
||||||
|
if ( resource != null && resource instanceof IFile &&
|
||||||
|
targets[i].getAdapter( IExecFileInfo.class )!= null &&
|
||||||
|
((IFile)resource).getLocation().toOSString().equals( ((IExecFileInfo)targets[i].getAdapter( IExecFileInfo.class )).getExecFile().getLocation().toOSString() ) )
|
||||||
|
{
|
||||||
|
if ( targets[i].getAdapter( DisassemblyManager.class ) != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long address = Long.parseLong( breakpoint.getAddress() );
|
||||||
|
return new DisassemblyEditorInput( (IStorage)(((DisassemblyManager)targets[i].getAdapter( DisassemblyManager.class )).getSourceElement( address ) ) );
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class CDebugImages
|
||||||
*/
|
*/
|
||||||
public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$
|
||||||
|
@ -93,6 +95,8 @@ public class CDebugImages
|
||||||
|
|
||||||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED );
|
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED );
|
||||||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED );
|
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED );
|
||||||
|
public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED );
|
||||||
|
public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED );
|
||||||
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED );
|
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED );
|
||||||
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED );
|
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED );
|
||||||
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED );
|
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED );
|
||||||
|
|
|
@ -20,9 +20,15 @@ public class BreakpointLocationVerifier
|
||||||
* valid location for a breakpoint in the given document, or -1 if a valid location
|
* valid location for a breakpoint in the given document, or -1 if a valid location
|
||||||
* cannot be found.
|
* cannot be found.
|
||||||
*/
|
*/
|
||||||
public int getValidBreakpointLocation( IDocument doc, int lineNumber )
|
public int getValidLineBreakpointLocation( IDocument doc, int lineNumber )
|
||||||
{
|
{
|
||||||
// for now
|
// for now
|
||||||
return lineNumber + 1;
|
return lineNumber + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getValidAddressBreakpointLocation( IDocument doc, int lineNumber )
|
||||||
|
{
|
||||||
|
// for now
|
||||||
|
return lineNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||||
|
@ -287,7 +289,27 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage
|
||||||
*/
|
*/
|
||||||
private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint )
|
private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint )
|
||||||
{
|
{
|
||||||
if ( breakpoint instanceof ILineBreakpoint )
|
if ( breakpoint instanceof ICAddressBreakpoint )
|
||||||
|
{
|
||||||
|
ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint;
|
||||||
|
String address = "Not available";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
address = CDebugUtils.toHexAddressString( Long.parseLong( abrkpt.getAddress() ) );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if ( address != null )
|
||||||
|
{
|
||||||
|
addField( createLabelEditor( getFieldEditorParent(), "Address: ", address ) );
|
||||||
|
}
|
||||||
|
setTitle( "C/C++ Address Breakpoint Properties" );
|
||||||
|
}
|
||||||
|
else if ( breakpoint instanceof ILineBreakpoint )
|
||||||
{
|
{
|
||||||
String fileName = breakpoint.getMarker().getResource().getLocation().toOSString();
|
String fileName = breakpoint.getMarker().getResource().getLocation().toOSString();
|
||||||
if ( fileName != null )
|
if ( fileName != null )
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDel
|
||||||
return;
|
return;
|
||||||
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
|
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
|
||||||
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
||||||
int lineNumber = bv.getValidBreakpointLocation( document, ((ITextSelection)selection).getStartLine());
|
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine());
|
||||||
if ( lineNumber > -1 )
|
if ( lineNumber > -1 )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
@ -102,7 +104,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IMarker[] markers = null;
|
IMarker[] markers = null;
|
||||||
if ( resource instanceof IFile )
|
if ( resource instanceof IFile && !(getTextEditor().getEditorInput() instanceof DisassemblyEditorInput) )
|
||||||
{
|
{
|
||||||
markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER,
|
markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER,
|
||||||
true,
|
true,
|
||||||
|
@ -229,31 +231,16 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
|
||||||
protected void addMarker()
|
protected void addMarker()
|
||||||
{
|
{
|
||||||
IEditorInput editorInput = getTextEditor().getEditorInput();
|
IEditorInput editorInput = getTextEditor().getEditorInput();
|
||||||
IDocument document = getDocument();
|
|
||||||
int rulerLine = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
|
int rulerLine = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
if ( editorInput instanceof IFileEditorInput )
|
||||||
int lineNumber = bv.getValidBreakpointLocation( document, rulerLine );
|
|
||||||
if ( lineNumber > 0 )
|
|
||||||
{
|
{
|
||||||
String fileName = null;
|
createLineBreakpoint( (IFileEditorInput)editorInput, rulerLine );
|
||||||
if ( editorInput instanceof IFileEditorInput )
|
}
|
||||||
{
|
else if ( editorInput.getAdapter( DisassemblyEditorInput.class ) != null )
|
||||||
fileName = ((IFileEditorInput)editorInput).getFile().getLocation().toString();
|
{
|
||||||
}
|
createAddressBreakpoint( (DisassemblyEditorInput)editorInput.getAdapter( DisassemblyEditorInput.class ), rulerLine );
|
||||||
if ( fileName != null )
|
|
||||||
{
|
|
||||||
if ( CDebugModel.lineBreakpointExists( fileName, lineNumber ) == null )
|
|
||||||
{
|
|
||||||
CDebugModel.createLineBreakpoint( ((IFileEditorInput)editorInput).getFile(),
|
|
||||||
lineNumber,
|
|
||||||
true,
|
|
||||||
0,
|
|
||||||
"",
|
|
||||||
true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( DebugException e )
|
catch( DebugException e )
|
||||||
|
@ -266,6 +253,46 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createLineBreakpoint( IFileEditorInput editorInput, int rulerLine ) throws CoreException
|
||||||
|
{
|
||||||
|
IDocument document = getDocument();
|
||||||
|
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
||||||
|
int lineNumber = bv.getValidLineBreakpointLocation( document, rulerLine );
|
||||||
|
if ( lineNumber > -1 )
|
||||||
|
{
|
||||||
|
String fileName = editorInput.getFile().getLocation().toString();
|
||||||
|
if ( fileName != null )
|
||||||
|
{
|
||||||
|
if ( CDebugModel.lineBreakpointExists( fileName, lineNumber ) == null )
|
||||||
|
{
|
||||||
|
CDebugModel.createLineBreakpoint( editorInput.getFile(), lineNumber, true, 0, "", true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createAddressBreakpoint( DisassemblyEditorInput editorInput, int rulerLine ) throws CoreException
|
||||||
|
{
|
||||||
|
IDocument document = getDocument();
|
||||||
|
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
||||||
|
int lineNumber = bv.getValidAddressBreakpointLocation( document, rulerLine );
|
||||||
|
if ( lineNumber > -1 )
|
||||||
|
{
|
||||||
|
IResource resource = (IResource)editorInput.getAdapter( IResource.class );
|
||||||
|
if ( resource != null )
|
||||||
|
{
|
||||||
|
if ( editorInput.getStorage() != null )
|
||||||
|
{
|
||||||
|
long address = ((IDisassemblyStorage)editorInput.getStorage()).getAddress( lineNumber );
|
||||||
|
if ( address != 0 && CDebugModel.addressBreakpointExists( resource, address ) == null )
|
||||||
|
{
|
||||||
|
CDebugModel.createAddressBreakpoint( resource, lineNumber, address, true, 0, "", true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void removeMarkers( List markers )
|
protected void removeMarkers( List markers )
|
||||||
{
|
{
|
||||||
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
|
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDele
|
||||||
{
|
{
|
||||||
static final private String C_EDITOR_ID = "org.eclipse.cdt.ui.editor.CEditor"; //$NON-NLS-1$
|
static final private String C_EDITOR_ID = "org.eclipse.cdt.ui.editor.CEditor"; //$NON-NLS-1$
|
||||||
static final private String ASM_EDITOR_ID = "org.eclipse.cdt.ui.editor.asm.AsmEditor"; //$NON-NLS-1$
|
static final private String ASM_EDITOR_ID = "org.eclipse.cdt.ui.editor.asm.AsmEditor"; //$NON-NLS-1$
|
||||||
|
static final private String DISASSEMBLY_EDITOR_ID = "org.eclipse.cdt.debug.ui.DisassemblyEditor"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IEditorActionDelegate#setActiveEditor(IAction, IEditorPart)
|
* @see IEditorActionDelegate#setActiveEditor(IAction, IEditorPart)
|
||||||
|
@ -31,7 +32,7 @@ public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDele
|
||||||
if ( targetEditor != null )
|
if ( targetEditor != null )
|
||||||
{
|
{
|
||||||
String id = targetEditor.getSite().getId();
|
String id = targetEditor.getSite().getId();
|
||||||
if ( !id.equals( C_EDITOR_ID ) && !id.equals( ASM_EDITOR_ID ) )
|
if ( !id.equals( C_EDITOR_ID ) && !id.equals( ASM_EDITOR_ID ) && !id.equals( DISASSEMBLY_EDITOR_ID ) )
|
||||||
targetEditor = null;
|
targetEditor = null;
|
||||||
}
|
}
|
||||||
super.setActiveEditor( callerAction, targetEditor );
|
super.setActiveEditor( callerAction, targetEditor );
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IStorage;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
|
import org.eclipse.ui.editors.text.StorageDocumentProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since: Jan 6, 2003
|
||||||
|
*/
|
||||||
|
public class DisassemblyDocumentProvider extends StorageDocumentProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for DisassemblyDocumentProvider.
|
||||||
|
*/
|
||||||
|
public DisassemblyDocumentProvider()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createAnnotationModel(Object)
|
||||||
|
*/
|
||||||
|
protected IAnnotationModel createAnnotationModel( Object element ) throws CoreException
|
||||||
|
{
|
||||||
|
if ( element != null && element instanceof DisassemblyEditorInput )
|
||||||
|
{
|
||||||
|
IResource resource = (IResource)((DisassemblyEditorInput)element).getAdapter( IResource.class );
|
||||||
|
IStorage storage = ((DisassemblyEditorInput)element).getStorage();
|
||||||
|
if ( resource != null && storage != null && storage instanceof IDisassemblyStorage )
|
||||||
|
return new DisassemblyMarkerAnnotationModel( (IDisassemblyStorage)storage, resource );
|
||||||
|
}
|
||||||
|
return super.createAnnotationModel( element );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since: Jan 6, 2003
|
||||||
|
*/
|
||||||
|
public class DisassemblyEditor extends AsmTextEditor
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for DisassemblyEditor.
|
||||||
|
*/
|
||||||
|
public DisassemblyEditor()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
setDocumentProvider( CDebugUIPlugin.getDefault().getDisassemblyDocumentProvider() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.ui.IStorageEditorInput;
|
||||||
*/
|
*/
|
||||||
public class DisassemblyEditorInput implements IStorageEditorInput
|
public class DisassemblyEditorInput implements IStorageEditorInput
|
||||||
{
|
{
|
||||||
private final static String FILE_NAME_EXTENSION = ".s";
|
private final static String FILE_NAME_EXTENSION = ".dasm";
|
||||||
protected IStorage fStorage;
|
protected IStorage fStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,6 +111,10 @@ public class DisassemblyEditorInput implements IStorageEditorInput
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( adapter.equals( DisassemblyEditorInput.class ) )
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||||
|
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||||
|
import org.eclipse.ui.texteditor.MarkerUtilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since: Jan 6, 2003
|
||||||
|
*/
|
||||||
|
public class DisassemblyMarkerAnnotation extends MarkerAnnotation
|
||||||
|
{
|
||||||
|
private IDebugModelPresentation fPresentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for DisassemblyMarkerAnnotation.
|
||||||
|
* @param marker
|
||||||
|
*/
|
||||||
|
public DisassemblyMarkerAnnotation( IMarker marker )
|
||||||
|
{
|
||||||
|
super( marker );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.MarkerAnnotation#initialize()
|
||||||
|
*/
|
||||||
|
protected void initialize()
|
||||||
|
{
|
||||||
|
IMarker marker = getMarker();
|
||||||
|
|
||||||
|
if ( MarkerUtilities.isMarkerType( marker, CLineBreakpoint.getMarkerType() ) ||
|
||||||
|
MarkerUtilities.isMarkerType( marker, CAddressBreakpoint.getMarkerType() ) )
|
||||||
|
{
|
||||||
|
if ( fPresentation == null )
|
||||||
|
fPresentation = DebugUITools.newDebugModelPresentation();
|
||||||
|
|
||||||
|
setLayer( 4 );
|
||||||
|
setImage( fPresentation.getImage( marker ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.initialize();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,310 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.ICBreakpointManager;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.resources.IMarkerDelta;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.IBreakpointManager;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
import org.eclipse.jface.text.Position;
|
||||||
|
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
|
||||||
|
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since: Jan 9, 2003
|
||||||
|
*/
|
||||||
|
public class DisassemblyMarkerAnnotationModel extends AbstractMarkerAnnotationModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Internal resource change listener.
|
||||||
|
*/
|
||||||
|
class ResourceChangeListener implements IResourceChangeListener
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* @see IResourceChangeListener#resourceChanged
|
||||||
|
*/
|
||||||
|
public void resourceChanged( IResourceChangeEvent e )
|
||||||
|
{
|
||||||
|
IResourceDelta delta = e.getDelta();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( delta != null )
|
||||||
|
delta.accept( getResourceDeltaVisitor() );
|
||||||
|
}
|
||||||
|
catch( CoreException x )
|
||||||
|
{
|
||||||
|
doHandleCoreException( x, "Resource Changed" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal resource delta visitor.
|
||||||
|
*/
|
||||||
|
class ResourceDeltaVisitor implements IResourceDeltaVisitor
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* @see IResourceDeltaVisitor#visit
|
||||||
|
*/
|
||||||
|
public boolean visit( IResourceDelta delta ) throws CoreException
|
||||||
|
{
|
||||||
|
if ( delta != null && /*getResource().equals( delta.getResource() )*/delta.getResource() instanceof IFile )
|
||||||
|
{
|
||||||
|
update( delta.getMarkerDeltas() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The workspace */
|
||||||
|
private IWorkspace fWorkspace;
|
||||||
|
|
||||||
|
/** The resource */
|
||||||
|
private IResource fResource;
|
||||||
|
|
||||||
|
/** The resource change listener */
|
||||||
|
private IResourceChangeListener fResourceChangeListener = new ResourceChangeListener();
|
||||||
|
|
||||||
|
/** The resource delta visitor */
|
||||||
|
private IResourceDeltaVisitor fResourceDeltaVisitor = new ResourceDeltaVisitor();
|
||||||
|
|
||||||
|
private IDisassemblyStorage fStorage = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for DisassemblyMarkerAnnotationModel.
|
||||||
|
*/
|
||||||
|
public DisassemblyMarkerAnnotationModel( IDisassemblyStorage storage, IResource resource )
|
||||||
|
{
|
||||||
|
fResource = resource;
|
||||||
|
fWorkspace = resource.getWorkspace();
|
||||||
|
fStorage = storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#retrieveMarkers()
|
||||||
|
*/
|
||||||
|
protected IMarker[] retrieveMarkers() throws CoreException
|
||||||
|
{
|
||||||
|
if ( fStorage == null )
|
||||||
|
return null;
|
||||||
|
IDebugTarget target = fStorage.getDebugTarget();
|
||||||
|
if ( target != null )
|
||||||
|
{
|
||||||
|
IBreakpointManager bm = DebugPlugin.getDefault().getBreakpointManager();
|
||||||
|
IBreakpoint[] brkpts = bm.getBreakpoints();
|
||||||
|
ArrayList list = new ArrayList( brkpts.length );
|
||||||
|
for ( int i = 0; i < brkpts.length; ++i )
|
||||||
|
{
|
||||||
|
if ( target.supportsBreakpoint( brkpts[i] ) && isAcceptable( brkpts[i].getMarker() ) )
|
||||||
|
{
|
||||||
|
list.add( brkpts[i].getMarker() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (IMarker[])list.toArray( new IMarker[list.size()] );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#deleteMarkers(IMarker[])
|
||||||
|
*/
|
||||||
|
protected void deleteMarkers( final IMarker[] markers ) throws CoreException
|
||||||
|
{
|
||||||
|
fWorkspace.run( new IWorkspaceRunnable()
|
||||||
|
{
|
||||||
|
public void run( IProgressMonitor monitor ) throws CoreException
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < markers.length; ++i )
|
||||||
|
{
|
||||||
|
markers[i].delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#listenToMarkerChanges(boolean)
|
||||||
|
*/
|
||||||
|
protected void listenToMarkerChanges( boolean listen )
|
||||||
|
{
|
||||||
|
if ( listen )
|
||||||
|
fWorkspace.addResourceChangeListener( fResourceChangeListener );
|
||||||
|
else
|
||||||
|
fWorkspace.removeResourceChangeListener( fResourceChangeListener );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#isAcceptable(IMarker)
|
||||||
|
*/
|
||||||
|
protected boolean isAcceptable( IMarker marker )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ( marker.getType().equals( CLineBreakpoint.getMarkerType() ) ||
|
||||||
|
marker.getType().equals( CAddressBreakpoint.getMarkerType() ) );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IResourceDeltaVisitor getResourceDeltaVisitor()
|
||||||
|
{
|
||||||
|
return fResourceDeltaVisitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates this model to the given marker deltas.
|
||||||
|
*
|
||||||
|
* @param markerDeltas the list of marker deltas
|
||||||
|
*/
|
||||||
|
protected void update( IMarkerDelta[] markerDeltas )
|
||||||
|
{
|
||||||
|
if ( markerDeltas.length == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( int i = 0; i < markerDeltas.length; i++ )
|
||||||
|
{
|
||||||
|
IMarkerDelta delta = markerDeltas[i];
|
||||||
|
switch( delta.getKind() )
|
||||||
|
{
|
||||||
|
case IResourceDelta.ADDED :
|
||||||
|
addMarkerAnnotation( delta.getMarker() );
|
||||||
|
break;
|
||||||
|
case IResourceDelta.REMOVED :
|
||||||
|
removeMarkerAnnotation( delta.getMarker() );
|
||||||
|
break;
|
||||||
|
case IResourceDelta.CHANGED :
|
||||||
|
modifyMarkerAnnotation( delta.getMarker() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fireModelChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(IMarker)
|
||||||
|
*/
|
||||||
|
protected Position createPositionFromMarker( IMarker marker )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( marker.getType().equals( CLineBreakpoint.getMarkerType() ) )
|
||||||
|
{
|
||||||
|
return createPositionFromLineBreakpoint( marker );
|
||||||
|
}
|
||||||
|
if ( marker.getType().equals( CAddressBreakpoint.getMarkerType() ) )
|
||||||
|
{
|
||||||
|
return createPositionFromAddressBreakpoint( marker );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Position createPositionFromLineBreakpoint( IMarker marker )
|
||||||
|
{
|
||||||
|
if ( fStorage == null )
|
||||||
|
return null;
|
||||||
|
IDebugTarget target = fStorage.getDebugTarget();
|
||||||
|
if ( target != null && target.getAdapter( ICBreakpointManager.class ) != null )
|
||||||
|
{
|
||||||
|
ICBreakpointManager bm = (ICBreakpointManager)target.getAdapter( ICBreakpointManager.class );
|
||||||
|
long address = bm.getBreakpointAddress( DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ) );
|
||||||
|
if ( address != 0 )
|
||||||
|
{
|
||||||
|
return createPositionFromAddress( address );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Position createPositionFromAddressBreakpoint( IMarker marker ) throws CoreException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return createPositionFromAddress( Long.parseLong( marker.getAttribute( ICAddressBreakpoint.ADDRESS, "0" ) ) );
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Position createPositionFromAddress( long address )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int start = -1;
|
||||||
|
int line = fStorage.getLineNumber( address );
|
||||||
|
if ( line > 0 && fDocument != null )
|
||||||
|
{
|
||||||
|
start = fDocument.getLineOffset( line - 1 );
|
||||||
|
if ( start > -1 )
|
||||||
|
{
|
||||||
|
return new Position( start, fDocument.getLineLength( line - 1 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( BadLocationException x )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker)
|
||||||
|
*/
|
||||||
|
protected MarkerAnnotation createMarkerAnnotation( IMarker marker )
|
||||||
|
{
|
||||||
|
return new DisassemblyMarkerAnnotation( marker );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#getMarkerPosition(IMarker)
|
||||||
|
*/
|
||||||
|
public Position getMarkerPosition( IMarker marker )
|
||||||
|
{
|
||||||
|
return createPositionFromMarker( marker );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doHandleCoreException( CoreException e, String message )
|
||||||
|
{
|
||||||
|
handleCoreException( e, message );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IResource getResource()
|
||||||
|
{
|
||||||
|
return fResource;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
|
import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
||||||
import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyDocumentProvider;
|
||||||
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
||||||
import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
|
import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
|
||||||
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
|
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
|
||||||
|
@ -65,6 +66,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
|
||||||
|
|
||||||
private CDebugImageDescriptorRegistry fImageDescriptorRegistry;
|
private CDebugImageDescriptorRegistry fImageDescriptorRegistry;
|
||||||
|
|
||||||
|
// Document provider for disassembly editor
|
||||||
|
private DisassemblyDocumentProvider fDisassemblyDocumentProvider = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -462,4 +466,14 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the document provider used for the disassembly editor
|
||||||
|
*/
|
||||||
|
public DisassemblyDocumentProvider getDisassemblyDocumentProvider()
|
||||||
|
{
|
||||||
|
if ( fDisassemblyDocumentProvider == null )
|
||||||
|
fDisassemblyDocumentProvider = new DisassemblyDocumentProvider();
|
||||||
|
return fDisassemblyDocumentProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue