diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog
index 4dfb56e038d..76dbace4fb5 100644
--- a/debug/org.eclipse.cdt.debug.core/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.core/ChangeLog
@@ -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
* build.properties: Patch from Judy Green.
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
index aa2fa3ee447..19a1a74adef 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
@@ -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.ICDIObject;
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.ICDebugTargetType;
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.internal.core.CDebugUtils;
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.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
@@ -305,6 +307,60 @@ public class CDebugModel
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
{
String modelId = getPluginIdentifier();
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java
new file mode 100644
index 00000000000..9287c047204
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java
@@ -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 );
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java
index 129e943ddf6..3c310252706 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java
@@ -15,6 +15,13 @@ import org.eclipse.core.runtime.CoreException;
*/
public interface ICAddressBreakpoint extends ICLineBreakpoint
{
+ /**
+ * Breakpoint attribute storing the address this breakpoint suspends
+ * execution at (value "org.eclipse.cdt.debug.core.address"
).
+ * This attribute is a String
.
+ */
+ public static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$
+
/**
* Returns the address this breakpoint suspends execution at.
*
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java
index 6321873f8cd..5a5aebb2a61 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java
@@ -5,6 +5,7 @@
*/
package org.eclipse.cdt.debug.core.model;
+import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.debug.core.model.IDebugTarget;
/**
@@ -20,6 +21,7 @@ public interface ICDebugTarget extends IDebugTarget,
IRestart,
IRunToLine,
IState,
- ISwitchToThread
+ ISwitchToThread,
+ ICBreakpointManager
{
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java
index 388ad1229ce..809c7fd6c61 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java
@@ -37,4 +37,11 @@ public interface IDisassemblyStorage extends IStorage
* @return the line number for given 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 ) ;
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
index c5b488ddb47..f53065f3721 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
@@ -223,4 +223,16 @@ public class DisassemblyStorage implements IDisassemblyStorage
}
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;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java
index ae94648639e..6d630dc79ef 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java
@@ -21,14 +21,7 @@ import org.eclipse.debug.core.DebugException;
*/
public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint
{
- private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.jdt.debug.cAddressBreakpointMarker"; //$NON-NLS-1$
-
- /**
- * Breakpoint attribute storing the address this breakpoint suspends
- * execution at (value "org.eclipse.cdt.debug.core.address"
).
- * This attribute is a String
.
- */
- protected static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$
+ private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$
/**
* Constructor for CAddressBreakpoint.
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java
index 09e2f170138..ae5a8a6178a 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java
@@ -21,7 +21,7 @@ import org.eclipse.debug.core.DebugException;
*/
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
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index 68947a6940d..7dc3d43ecc1 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
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.cdi.CDIException;
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.ICDISuspendedEvent;
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.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
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.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
@@ -385,9 +388,9 @@ public class CDebugTarget extends CDebugElement
*/
public boolean supportsBreakpoint( IBreakpoint breakpoint )
{
-/*
if ( !getConfiguration().supportsBreakpoints() )
return false;
+/*
if ( breakpoint instanceof ICBreakpoint )
{
ISourceLocator sl = getSourceLocator();
@@ -399,7 +402,17 @@ public class CDebugTarget extends CDebugElement
}
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)
@@ -628,7 +641,11 @@ public class CDebugTarget extends CDebugElement
{
try
{
- if ( breakpoint instanceof ICLineBreakpoint )
+ if ( breakpoint instanceof ICAddressBreakpoint )
+ {
+ setAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
+ }
+ else if ( breakpoint instanceof ICLineBreakpoint )
{
setLineBreakpoint( (ICLineBreakpoint)breakpoint );
}
@@ -844,6 +861,8 @@ public class CDebugTarget extends CDebugElement
return this;
if ( adapter.equals( IRunToLine.class ) )
return this;
+ if ( adapter.equals( ICBreakpointManager.class ) )
+ return this;
if ( adapter.equals( DisassemblyManager.class ) )
return fDisassemblyManager;
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
{
ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
@@ -1900,9 +1951,12 @@ public class CDebugTarget extends CDebugElement
protected int getRealSourceMode()
{
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;
}
@@ -2035,4 +2089,27 @@ public class CDebugTarget extends CDebugElement
{
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;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
index 38333c2c2ef..0859c81f417 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
@@ -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.IStackFrameInfo;
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.model.IRegisterGroup;
import org.eclipse.debug.core.model.ISourceLocator;
@@ -178,8 +179,9 @@ public class CStackFrame extends CDebugElement
if ( isSuspended() )
{
ISourceLocator locator = ((CDebugTarget)getDebugTarget()).getSourceLocator();
- if ( locator != null && locator instanceof ICSourceLocator )
- return ((ICSourceLocator)locator).getLineNumber( this );
+ if ( locator != null && locator instanceof IAdaptable &&
+ ((IAdaptable)locator).getAdapter( ICSourceLocator.class ) != null )
+ return ((ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class )).getLineNumber( this );
if ( getCDIStackFrame() != null && getCDIStackFrame().getLocation() != null )
return getCDIStackFrame().getLocation().getLineNumber();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java
index d677e6fba5d..017cd176848 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java
@@ -61,6 +61,20 @@ public class DisassemblyManager
}
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 )
{
@@ -144,6 +158,38 @@ public class DisassemblyManager
}
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 )
{
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index c11052b5527..e9159c0590f 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -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
* build.properties: Patch from Judy Green.
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkp_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkp_obj.gif
new file mode 100644
index 00000000000..80eb70008cd
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkp_obj.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkpd_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkpd_obj.gif
new file mode 100644
index 00000000000..5f6c10598b4
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/addrbrkpd_obj.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index a1f969f3383..f7a72711b3e 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -48,3 +48,5 @@ NaturalVariableFormatAction.label=Natural
CDebugActionGroup.name=C/C++ Debug
SourcePropertyPage.name=Source Lookup
+
+DisassemblyEditor.name=Disassembly Editor
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 4e07ecef686..176cbe6437a 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -720,5 +720,16 @@
id="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage">
+
+
+
+
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
index 4523e6e905c..4a1da0df45e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
@@ -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.ICWatchpoint;
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.IState;
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.ui.CDebugUIPlugin;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
@@ -126,19 +129,24 @@ public class CDTDebugModelPresentation extends LabelProvider
*/
public IEditorInput getEditorInput( Object element )
{
- IFile file = null;
if ( element instanceof IMarker )
{
IResource resource = ((IMarker)element).getResource();
if ( resource instanceof IFile )
- file = (IFile)resource;
+ return new FileEditorInput( (IFile)resource );
}
if ( element instanceof IFile )
- file = (IFile)element;
+ {
+ return new FileEditorInput( (IFile)element );
+ }
+ if ( element instanceof ICAddressBreakpoint )
+ {
+ return getDisassemblyEditorInput( (ICAddressBreakpoint)element );
+ }
if ( element instanceof ICLineBreakpoint )
- file = (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class );
- if ( file != null )
- return new FileEditorInput( file );
+ {
+ return new FileEditorInput( (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class ) );
+ }
if ( element instanceof FileStorage )
{
return new ExternalEditorInput( (IStorage)element );
@@ -491,6 +499,10 @@ public class CDTDebugModelPresentation extends LabelProvider
protected Image getBreakpointImage( ICBreakpoint breakpoint ) throws CoreException
{
+ if ( breakpoint instanceof ICAddressBreakpoint )
+ {
+ return getAddressBreakpointImage( (ICAddressBreakpoint)breakpoint );
+ }
if ( breakpoint instanceof ICLineBreakpoint )
{
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
@@ -517,6 +529,21 @@ public class CDTDebugModelPresentation extends LabelProvider
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
{
int flags = computeBreakpointAdornmentFlags( watchpoint );
@@ -549,15 +576,14 @@ public class CDTDebugModelPresentation extends LabelProvider
protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException
{
-
- if ( breakpoint instanceof ICLineBreakpoint )
- {
- return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
- }
if ( breakpoint instanceof ICAddressBreakpoint )
{
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
}
+ if ( breakpoint instanceof ICLineBreakpoint )
+ {
+ return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
+ }
if ( breakpoint instanceof ICFunctionBreakpoint )
{
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
@@ -591,7 +617,12 @@ public class CDTDebugModelPresentation extends LabelProvider
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
@@ -605,7 +636,7 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( !path.isEmpty() )
label.append( qualified ? path.toOSString() : path.lastSegment() );
return label;
-}
+ }
protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException
{
@@ -621,6 +652,21 @@ public class CDTDebugModelPresentation extends LabelProvider
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
{
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 ) );
}
+
+ 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;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
index 17b508b44ee..eb8de36dd8f 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
@@ -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_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_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$
@@ -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_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_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 );
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java
index 9ac68e79815..6ee353e13f1 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java
@@ -20,9 +20,15 @@ public class BreakpointLocationVerifier
* valid location for a breakpoint in the given document, or -1 if a valid location
* cannot be found.
*/
- public int getValidBreakpointLocation( IDocument doc, int lineNumber )
+ public int getValidLineBreakpointLocation( IDocument doc, int lineNumber )
{
// for now
return lineNumber + 1;
}
+
+ public int getValidAddressBreakpointLocation( IDocument doc, int lineNumber )
+ {
+ // for now
+ return lineNumber;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java
index 56512447f9f..c459701ff49 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java
@@ -5,8 +5,10 @@
*/
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.ICWatchpoint;
+import org.eclipse.cdt.debug.internal.core.CDebugUtils;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.ILineBreakpoint;
@@ -287,7 +289,27 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage
*/
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();
if ( fileName != null )
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java
index 9bda93e3c94..87a4c8e61ae 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java
@@ -195,7 +195,7 @@ public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDel
return;
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
- int lineNumber = bv.getValidBreakpointLocation( document, ((ITextSelection)selection).getStartLine());
+ int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine());
if ( lineNumber > -1 )
{
try
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
index d3a6bcd4d24..2a752a153bc 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
@@ -10,6 +10,8 @@ import java.util.Iterator;
import java.util.List;
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.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -102,7 +104,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
try
{
IMarker[] markers = null;
- if ( resource instanceof IFile )
+ if ( resource instanceof IFile && !(getTextEditor().getEditorInput() instanceof DisassemblyEditorInput) )
{
markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER,
true,
@@ -229,31 +231,16 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
protected void addMarker()
{
IEditorInput editorInput = getTextEditor().getEditorInput();
- IDocument document = getDocument();
int rulerLine = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
try
{
- BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
- int lineNumber = bv.getValidBreakpointLocation( document, rulerLine );
- if ( lineNumber > 0 )
+ if ( editorInput instanceof IFileEditorInput )
{
- String fileName = null;
- if ( editorInput instanceof IFileEditorInput )
- {
- fileName = ((IFileEditorInput)editorInput).getFile().getLocation().toString();
- }
- if ( fileName != null )
- {
- if ( CDebugModel.lineBreakpointExists( fileName, lineNumber ) == null )
- {
- CDebugModel.createLineBreakpoint( ((IFileEditorInput)editorInput).getFile(),
- lineNumber,
- true,
- 0,
- "",
- true );
- }
- }
+ createLineBreakpoint( (IFileEditorInput)editorInput, rulerLine );
+ }
+ else if ( editorInput.getAdapter( DisassemblyEditorInput.class ) != null )
+ {
+ createAddressBreakpoint( (DisassemblyEditorInput)editorInput.getAdapter( DisassemblyEditorInput.class ), rulerLine );
}
}
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 )
{
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java
index 9313b1b2ad6..a56f01aa174 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java
@@ -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 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)
@@ -31,7 +32,7 @@ public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDele
if ( targetEditor != null )
{
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;
}
super.setActiveEditor( callerAction, targetEditor );
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyDocumentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyDocumentProvider.java
new file mode 100644
index 00000000000..dc217d6dba9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyDocumentProvider.java
@@ -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 );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditor.java
new file mode 100644
index 00000000000..4b7b7c093b5
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditor.java
@@ -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() );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java
index 5e5787bcdb1..060f38fdbd4 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java
@@ -21,7 +21,7 @@ import org.eclipse.ui.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;
/**
@@ -111,6 +111,10 @@ public class DisassemblyEditorInput implements IStorageEditorInput
// ignore
}
}
+ if ( adapter.equals( DisassemblyEditorInput.class ) )
+ {
+ return this;
+ }
return null;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java
new file mode 100644
index 00000000000..08e66b3a3c2
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java
@@ -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();
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java
new file mode 100644
index 00000000000..2a5174d4d6e
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java
@@ -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;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
index e13348e5db0..f1a8ed54fcd 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
@@ -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.CDebugImageDescriptorRegistry;
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.preferences.CDebugPreferencePage;
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
@@ -65,6 +66,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
private CDebugImageDescriptorRegistry fImageDescriptorRegistry;
+ // Document provider for disassembly editor
+ private DisassemblyDocumentProvider fDisassemblyDocumentProvider = null;
+
/**
* The constructor.
*/
@@ -462,4 +466,14 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
}
return false;
}
+
+ /**
+ * Returns the document provider used for the disassembly editor
+ */
+ public DisassemblyDocumentProvider getDisassemblyDocumentProvider()
+ {
+ if ( fDisassemblyDocumentProvider == null )
+ fDisassemblyDocumentProvider = new DisassemblyDocumentProvider();
+ return fDisassemblyDocumentProvider;
+ }
}