From 06ad0291255a08746bc2e271a6626cb91afdd25b Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 27 Apr 2004 23:13:23 +0000 Subject: [PATCH] Moved the "FUNCTION" and "ADDRESS" breakpoint attributes to ICLineBreakpoint. Added support for the Disassembly view. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 17 +++ debug/org.eclipse.cdt.debug.core/plugin.xml | 12 +- .../eclipse/cdt/debug/core/CDIDebugModel.java | 4 +- .../debug/core/model/IBreakpointTarget.java | 34 ++++++ .../debug/core/model/ICAddressBreakpoint.java | 26 ----- .../cdt/debug/core/model/ICDebugTarget.java | 3 +- .../core/model/ICFunctionBreakpoint.java | 34 ------ .../debug/core/model/ICLineBreakpoint.java | 63 ++++++++++- .../internal/core/CBreakpointManager.java | 83 ++++++++++---- .../breakpoints/AbstractLineBreakpoint.java | 105 ++++++++++++++++++ .../core/breakpoints/CAddressBreakpoint.java | 48 +------- .../core/breakpoints/CFunctionBreakpoint.java | 75 +------------ .../core/breakpoints/CLineBreakpoint.java | 35 +----- .../internal/core/model/CDebugTarget.java | 18 +++ 14 files changed, 312 insertions(+), 245 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IBreakpointTarget.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 7514a2da0e3..2f5fc942804 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,20 @@ +2004-04-27 Mikhail Khodjaiants + Moved the "FUNCTION" and "ADDRESS" breakpoint attributes to ICLineBreakpoint. + Added support for the Disassembly view. + * plugin.xml + * CDIDebugModel.java + * IBreakpointTarget.java: new + * ICAddressBreakpoint.java + * ICDebugTarget.java + * ICFunctionBreakpoint.java + * ICLineBreakpoint.java + * CBreakpointManager.java + * AbstractLineBreakpoint.java: new + * CAddressBreakpoint.java + * CFunctionBreakpoint.java + * CLineBreakpoint.java + * CDebugTarget.java + 2004-04-26 Mikhail Khodjaiants The notification of the Breakpoint Manager on breakpoint creation has been moved to CBreakpointUpdater. diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml index e3965fb0711..075e30b1733 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.xml +++ b/debug/org.eclipse.cdt.debug.core/plugin.xml @@ -69,6 +69,12 @@ + + + + - - - - "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. - * - * @return the address this breakpoint suspends execution at - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public String getAddress() throws CoreException; - - /** - * Sets the address this breakpoint suspends execution at. - * - * @param address the address this breakpoint suspends execution at - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setAddress( String address ) throws CoreException; } \ No newline at end of file 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 a964d655539..a73ca4df8db 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 @@ -28,7 +28,8 @@ public interface ICDebugTarget extends IDebugTarget, IResumeWithoutSignal, IState, ISwitchToThread, - ICDebugElement { + ICDebugElement, + IBreakpointTarget { /** * Returns the shared libraries loaded in this debug target. An diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java index 53952d05100..e484ef54254 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java @@ -10,44 +10,10 @@ ***********************************************************************/ package org.eclipse.cdt.debug.core.model; -import org.eclipse.core.runtime.CoreException; /** * A breakpoint that suspends the execution when a function is entered. */ public interface ICFunctionBreakpoint extends ICLineBreakpoint { - /** - * Breakpoint attribute storing the function this breakpoint suspends - * execution at (value "org.eclipse.cdt.debug.core.function"). - * This attribute is a String. - */ - public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$ - - /** - * Returns the function this breakpoint suspends execution in. - * - * @return the function this breakpoint suspends execution in - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public String getFunction() throws CoreException; - - /** - * Sets the function this breakpoint suspends execution in. - * - * @param function the function this breakpoint suspends execution in - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setFunction( String function ) throws CoreException; - - /** - * Returns the source file of the function. - * - * @return the source file of the function - * @throws CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public String getFileName() throws CoreException; } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java index d26bbc38c8b..64b41ccf3d6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java @@ -10,12 +10,71 @@ ***********************************************************************/ package org.eclipse.cdt.debug.core.model; +import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.model.ILineBreakpoint; /** - * A breakpoint that suspends the execution when a particular line of code + * A breakpoint that suspends the execution when a particular location of code * is reached. */ public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint { - + + /** + * Breakpoint attribute storing the function this breakpoint suspends + * execution at (value "org.eclipse.cdt.debug.core.function"). + * This attribute is a String. + */ + public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$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. + */ + 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 + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public String getAddress() throws CoreException; + + /** + * Sets the address this breakpoint suspends execution at. + * + * @param address the address this breakpoint suspends execution at + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setAddress( String address ) throws CoreException; + + /** + * Returns the function this breakpoint suspends execution in. + * + * @return the function this breakpoint suspends execution in + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public String getFunction() throws CoreException; + + /** + * Sets the function this breakpoint suspends execution in. + * + * @param function the function this breakpoint suspends execution in + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setFunction( String function ) throws CoreException; + + /** + * Returns the source file (if available) of this breakpoint. + * + * @return the source file of this breakpoint + * @throws CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public String getFileName() throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index a56bbd57eca..6c0d7dffe6f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -225,7 +225,12 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { } public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) { - return (getExecFile() != null && getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() )); + try { + return ( getExecFile() != null && getExecFile().getLocation().toOSString().equals( breakpoint.getSourceHandle() ) ); + } + catch( CoreException e ) { + } + return false; } public IFile getCDIBreakpointFile( ICDIBreakpoint cdiBreakpoint ) { @@ -353,27 +358,7 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { return; ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); if ( breakpoint == null ) { - try { - if ( cdiBreakpoint.getLocation().getFile() != null && cdiBreakpoint.getLocation().getFile().length() > 0 ) { - ICSourceLocator locator = getSourceLocator(); - if ( locator != null ) { - Object sourceElement = locator.findSourceElement( cdiBreakpoint.getLocation().getFile() ); - if ( sourceElement != null && sourceElement instanceof IFile ) { - breakpoint = createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint ); - } - else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) { - breakpoint = createAddressBreakpoint( cdiBreakpoint ); - } - } - } - else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) { - breakpoint = createAddressBreakpoint( cdiBreakpoint ); - } - } - catch( CDIException e ) { - } - catch( CoreException e ) { - } + breakpoint = createLocationBreakpoint( cdiBreakpoint ); } if ( breakpoint != null ) { getBreakpointNotifier().breakpointInstalled( getDebugTarget(), breakpoint ); @@ -521,6 +506,38 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { throw new DebugException( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), code, message, e ) ); } + private ICLineBreakpoint createLocationBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) { + ICLineBreakpoint breakpoint = null; + try { + if ( !isEmpty( cdiBreakpoint.getLocation().getFile() ) ) { + ICSourceLocator locator = getSourceLocator(); + if ( locator != null ) { + Object sourceElement = locator.findSourceElement( cdiBreakpoint.getLocation().getFile() ); + if ( sourceElement != null && sourceElement instanceof IFile ) { + breakpoint = createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint ); + } + else if ( !isEmpty( cdiBreakpoint.getLocation().getFunction() ) ) { + breakpoint = createFunctionBreakpoint( cdiBreakpoint ); + } + else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) { + breakpoint = createAddressBreakpoint( cdiBreakpoint ); + } + } + } + else if ( !isEmpty( cdiBreakpoint.getLocation().getFunction() ) ) { + breakpoint = createFunctionBreakpoint( cdiBreakpoint ); + } + else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) { + breakpoint = createAddressBreakpoint( cdiBreakpoint ); + } + } + catch( CDIException e ) { + } + catch( CoreException e ) { + } + return breakpoint; + } + private ICLineBreakpoint createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { ICLineBreakpoint breakpoint = CDIDebugModel.createLineBreakpoint( cdiBreakpoint.getLocation().getFile(), file, @@ -534,6 +551,24 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { return breakpoint; } + private ICFunctionBreakpoint createFunctionBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { + IFile execFile = getExecFile(); + String sourceHandle = execFile.getFullPath().toOSString(); + ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( sourceHandle, + execFile, + cdiBreakpoint.getLocation().getFunction(), + -1, + -1, + -1, + cdiBreakpoint.isEnabled(), + cdiBreakpoint.getCondition().getIgnoreCount(), + cdiBreakpoint.getCondition().getExpression(), + false ); + getBreakpointMap().put( breakpoint, cdiBreakpoint ); + ((CBreakpoint)breakpoint).register( true ); + return breakpoint; + } + private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { IFile execFile = getExecFile(); String sourceHandle = execFile.getFullPath().toOSString(); @@ -578,4 +613,8 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable { private CBreakpointNotifier getBreakpointNotifier() { return CBreakpointNotifier.getInstance(); } + + private boolean isEmpty( String str ) { + return !( str != null && str.trim().length() > 0 ); + } } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java new file mode 100644 index 00000000000..b73d3526b01 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java @@ -0,0 +1,105 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.debug.internal.core.breakpoints; + +import java.util.Map; + +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * Base class for different types of location breakponts. + */ +public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { + + /** + * Constructor for AbstractLineBreakpoint. + */ + public AbstractLineBreakpoint() { + super(); + } + + /** + * Constructor for AbstractLineBreakpoint. + * + * @param resource + * @param markerType + * @param attributes + * @param add + * @throws CoreException + */ + public AbstractLineBreakpoint( IResource resource, String markerType, Map attributes, boolean add ) throws CoreException { + super( resource, markerType, attributes, add ); + } + + /*(non-Javadoc) + * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() + */ + public int getLineNumber() throws CoreException { + return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); + } + + /*(non-Javadoc) + * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() + */ + public int getCharStart() throws CoreException { + return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); + } + + /*(non-Javadoc) + * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() + */ + public int getCharEnd() throws CoreException { + return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getAddress() + */ + public String getAddress() throws CoreException { + return ensureMarker().getAttribute( ICLineBreakpoint.ADDRESS, "" ); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFileName() + */ + public String getFileName() throws CoreException { + String fileName = ensureMarker().getAttribute( ICBreakpoint.SOURCE_HANDLE, "" ); //$NON-NLS-1$ + IPath path = new Path( fileName ); + return ( path.isValidPath( fileName ) ) ? path.lastSegment() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFunction() + */ + public String getFunction() throws CoreException { + return ensureMarker().getAttribute( ICLineBreakpoint.FUNCTION, "" ); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setAddress(java.lang.String) + */ + public void setAddress( String address ) throws CoreException { + setAttribute( ICLineBreakpoint.ADDRESS, address ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setFunction(java.lang.String) + */ + public void setFunction( String function ) throws CoreException { + setAttribute( ICLineBreakpoint.FUNCTION, function ); + } +} 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 b31fd612540..a149e9e0bb4 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 @@ -15,14 +15,13 @@ import java.util.Map; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.CDebugUtils; -import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; /** * A breakpoint that suspend the execution when a particular address is reached. */ -public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint { +public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddressBreakpoint { private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$ @@ -39,51 +38,6 @@ public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoi super( resource, getMarkerType(), attributes, add ); } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#getAddress() - */ - public String getAddress() throws CoreException { - return ensureMarker().getAttribute( ADDRESS, null ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#setAddress(long) - */ - public void setAddress( String address ) throws CoreException { - setAttribute( ADDRESS, address ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() - */ - public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() - */ - public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() - */ - public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); - } - /** * Returns the type of marker associated with this type of breakpoints */ 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 3f247543cc1..94dc67c3472 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 @@ -14,25 +14,16 @@ import java.text.MessageFormat; import java.util.Map; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; /** * A breakpoint that suspends the execution when a function is entered. */ -public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint { +public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFunctionBreakpoint { private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$ - /** - * Breakpoint attribute storing the function this breakpoint suspends - * execution in (value "org.eclipse.cdt.debug.core.function"). - * This attribute is a String. - */ - protected static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$ - /** * Constructor for CFunctionBreakpoint. */ @@ -46,51 +37,6 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp super( resource, getMarkerType(), attributes, add ); } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#getFunction() - */ - public String getFunction() throws CoreException { - return ensureMarker().getAttribute( FUNCTION, null ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#setFunction(String) - */ - public void setFunction( String function ) throws CoreException { - setAttribute( FUNCTION, function ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() - */ - public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() - */ - public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() - */ - public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); - } - /** * Returns the type of marker associated with this type of breakpoints */ @@ -98,22 +44,7 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp return C_FUNCTION_BREAKPOINT; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint#getFileName() - */ - public String getFileName() throws CoreException { - IResource resource = ensureMarker().getResource(); - if ( resource instanceof IFile ) { - return ((IFile)resource).getLocation().lastSegment(); - } - return null; - } - - /* - * (non-Javadoc) - * + /*(non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ protected String getMarkerMessage() throws CoreException { @@ -130,4 +61,4 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp sb.append( getConditionText() ); return sb.toString(); } -} \ No newline at end of file +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java index 2e4c758df8c..0066e58b786 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java @@ -13,8 +13,6 @@ package org.eclipse.cdt.debug.internal.core.breakpoints; import java.text.MessageFormat; import java.util.Map; -import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; -import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -22,7 +20,7 @@ import org.eclipse.core.runtime.CoreException; * A breakpoint that suspends the execution when a particular line of code is * reached. */ -public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { +public class CLineBreakpoint extends AbstractLineBreakpoint { private static final String C_LINE_BREAKPOINT = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$ @@ -39,33 +37,6 @@ public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { super( resource, getMarkerType(), attributes, add ); } - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() - */ - public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() - */ - public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() - */ - public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); - } - /** * Returns the type of marker associated with this type of breakpoints */ @@ -73,9 +44,7 @@ public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { return C_LINE_BREAKPOINT; } - /* - * (non-Javadoc) - * + /*(non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ protected String getMarkerMessage() throws CoreException { 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 cba86db92f9..b20cfb1ee19 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 @@ -53,12 +53,14 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; +import org.eclipse.cdt.debug.core.model.IBreakpointTarget; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus; import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.core.model.ICDebugTargetType; import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICSharedLibrary; import org.eclipse.cdt.debug.core.model.ICSignal; import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport; @@ -997,6 +999,8 @@ public class CDebugTarget extends CDebugElement return this; if ( adapter.equals( IJumpToAddress.class ) ) return this; + if ( adapter.equals( IBreakpointTarget.class ) ) + return this; if ( adapter.equals( CBreakpointManager.class ) ) return getBreakpointManager(); if ( adapter.equals( DisassemblyManager.class ) ) @@ -2452,4 +2456,18 @@ public class CDebugTarget extends CDebugElement fDisassembly.dispose(); fDisassembly = null; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IBreakpointTarget#getBreakpointAddress(org.eclipse.cdt.debug.core.model.ICLineBreakpoint) + */ + public long getBreakpointAddress( ICLineBreakpoint breakpoint ) throws DebugException { + return ( getBreakpointManager() != null ) ? getBreakpointManager().getBreakpointAddress( breakpoint ) : 0; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IBreakpointTarget#isTargetBreakpoint(org.eclipse.cdt.debug.core.model.ICBreakpoint) + */ + public boolean isTargetBreakpoint( ICBreakpoint breakpoint ) { + return ( getBreakpointManager() != null ) ? getBreakpointManager().isTargetBreakpoint( breakpoint ) : false; + } }