Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v retrieving revision
1.90 diff -u -r1.90 ChangeLog --- ChangeLog 6 Jan 2003 22:19:50
-0000 1.90 +++ ChangeLog 10 Jan 2003 19:21:35 -0000 @@ -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. Index:
src/org/eclipse/cdt/debug/core/CDebugModel.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java,v retrieving
revision 1.38 diff -u -r1.38 CDebugModel.java ---
src/org/eclipse/cdt/debug/core/CDebugModel.java 2 Dec 2002 23:22:22
-0000 1.38 +++ src/org/eclipse/cdt/debug/core/CDebugModel.java 10
Jan 2003 19:21:35 -0000 @@ -18,6 +18,7 @@ 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.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; @@ -303,6 +305,60
@@ attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer(
ignoreCount ) ); attributes.put( ICBreakpoint.CONDITION,
condition ); 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 Index:
src/org/eclipse/cdt/debug/core/ICBreakpointManager.java =================================================================== RCS
file: src/org/eclipse/cdt/debug/core/ICBreakpointManager.java diff -N
src/org/eclipse/cdt/debug/core/ICBreakpointManager.java --- /dev/null 1
Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/core/ICBreakpointManager.java 10 Jan 2003
19:21:35 -0000 @@ -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 ); +} Index:
src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java,v retrieving
revision 1.1 diff -u -r1.1 ICAddressBreakpoint.java ---
src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java 2 Dec 2002
23:22:22 -0000 1.1 +++
src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java 10 Jan 2003
19:21:35 -0000 @@ -16,6 +16,13 @@ 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. * *
@return the address this breakpoint suspends execution at Index:
src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java,v retrieving
revision 1.1 diff -u -r1.1 ICDebugTarget.java ---
src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java 2 Dec 2002 23:22:22
-0000 1.1 +++
src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java 10 Jan 2003
19:21:35 -0000 @@ -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
@@
IRestart,
IRunToLine,
IState, -
ISwitchToThread +
ISwitchToThread, +
ICBreakpointManager { } Index:
src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java,v retrieving
revision 1.1 diff -u -r1.1 IDisassemblyStorage.java ---
src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java 2 Dec
2002 23:22:22 -0000 1.1 +++
src/org/eclipse/cdt/debug/core/sourcelookup/IDisassemblyStorage.java 10 Jan
2003 19:21:35 -0000 @@ -37,4 +37,11 @@ * @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 ) ; } Index:
src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java,v retrieving
revision 1.7 diff -u -r1.7 DisassemblyStorage.java ---
src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java 2 Jan 2003
20:57:55 -0000 1.7 +++
src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java 10 Jan 2003
19:21:35 -0000 @@ -223,4 +223,16
@@ } 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; + } } Index:
src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java,v retrieving
revision 1.4 diff -u -r1.4 CAddressBreakpoint.java ---
src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java 2
Dec 2002 23:22:22 -0000 1.4 +++
src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java 10
Jan 2003 19:21:36 -0000 @@ -21,14 +21,7 @@ */ 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
<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$ + private
static final String C_ADDRESS_BREAKPOINT =
"org.eclipse.cdt.debug.core.cAddressBreakpointMarker";
//$NON-NLS-1$ /** * Constructor for
CAddressBreakpoint. Index:
src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java,v retrieving
revision 1.4 diff -u -r1.4 CFunctionBreakpoint.java ---
src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java 2
Dec 2002 23:22:22 -0000 1.4 +++
src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java 10
Jan 2003 19:21:36 -0000 @@ -21,7 +21,7 @@ */ 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 Index:
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java,v retrieving
revision 1.65 diff -u -r1.65 CDebugTarget.java ---
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 2 Jan 2003
20:57:55 -0000 1.65 +++
src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 10 Jan 2003
19:21:36 -0000 @@ -18,6 +18,7 @@ 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.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 boolean supportsBreakpoint(
IBreakpoint breakpoint ) { -/* if (
!getConfiguration().supportsBreakpoints() ) return
false; +/* if ( breakpoint instanceof ICBreakpoint
) { ISourceLocator sl =
getSourceLocator(); @@ -399,7 +402,17
@@ } 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
@@ { try { - if
( breakpoint instanceof ICLineBreakpoint ) + if (
breakpoint instanceof ICAddressBreakpoint
) + { + setAddressBreakpoint(
(ICAddressBreakpoint)breakpoint
); + } + else if (
breakpoint instanceof ICLineBreakpoint
) { setLineBreakpoint(
(ICLineBreakpoint)breakpoint ); } @@ -844,6
+861,8 @@ 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
@@ } } + 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
@@ 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; } @@ -2034,5 +2088,28
@@ protected DisassemblyManager
getDisassemblyManager() { 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; } } Index:
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java,v retrieving
revision 1.13 diff -u -r1.13 CStackFrame.java ---
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 17 Dec 2002
19:47:25 -0000 1.13 +++
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 10 Jan 2003
19:21:36 -0000 @@ -22,6 +22,7 @@ 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
@@ 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(); } Index:
src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java,v retrieving
revision 1.7 diff -u -r1.7 DisassemblyManager.java ---
src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java 17
Dec 2002 19:56:22 -0000 1.7 +++
src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java 10
Jan 2003 19:21:35 -0000 @@ -61,6 +61,20
@@ } 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 ) { @@ -124,6 +138,38
@@ if ( instructions.length == 0
) { long
address = frameInfo.getAddress(); + 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 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
|