Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2003-11-05 21:50:33 +0000
committerMikhail Khodjaiants2003-11-05 21:50:33 +0000
commit1f66ca3c05bfee8412169eb116e4377ab1887985 (patch)
treeb038afab2110896902c9c2bf87f89527792af0af /debug
parentbb83ae658f29e8dcab152c0a7849111c18786bba (diff)
downloadorg.eclipse.cdt-1f66ca3c05bfee8412169eb116e4377ab1887985.tar.gz
org.eclipse.cdt-1f66ca3c05bfee8412169eb116e4377ab1887985.tar.xz
org.eclipse.cdt-1f66ca3c05bfee8412169eb116e4377ab1887985.zip
Changed the handling of the breakpoint created event to reflect the CDI changes for deferred breakpoints support.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/ChangeLog16
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java4
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java4
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java474
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java9
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java741
6 files changed, 526 insertions, 722 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog
index 69e779a97fa..905ca05039c 100644
--- a/debug/org.eclipse.cdt.debug.core/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.core/ChangeLog
@@ -1,3 +1,19 @@
+2003-11-05 Mikhail Khodjaiants
+ Changed the handling of the breakpoint created event to reflect the CDI changes for deferred
+ breakpoints support.
+ * CBreakpointManager.java
+ * CSharedLibraryManager.java
+ * CDebugTarget.java
+
+2003-11-05 Mikhail Khodjaiants
+ Moved all breakpoint-related functionality to the new class - 'CBreakpointManager'.
+ * CBreakpointManager.java
+
+2003-11-05 Mikhail Khodjaiants
+ The argument type of the 'getBreakpointAddress' method of 'ICBreakpointManager' is changed from
+ 'ICBreakpoint' to 'ICBreakpointManager'.
+ * ICBreakpointMaanger.java
+
2003-10-30 Mikhail Khodjaiants
* CSourceManager.java: implements adapters for 'ISourceMode' and 'IPersistableSourceLocator'.
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
index 9287c047204..3133b541413 100644
--- 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
@@ -5,8 +5,8 @@
*/
package org.eclipse.cdt.debug.core;
+import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.model.IBreakpoint;
/**
* Enter type comment.
@@ -15,5 +15,5 @@ import org.eclipse.debug.core.model.IBreakpoint;
*/
public interface ICBreakpointManager extends IAdaptable
{
- long getBreakpointAddress( IBreakpoint breakpoint );
+ long getBreakpointAddress( ICBreakpoint breakpoint );
}
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 ba63b674684..e64a882d8ed 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,7 +5,6 @@
*/
package org.eclipse.cdt.debug.core.model;
-import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.debug.core.model.IDebugTarget;
/**
@@ -25,7 +24,6 @@ public interface ICDebugTarget extends IDebugTarget,
IJumpToAddress,
IResumeWithoutSignal,
IState,
- ISwitchToThread,
- ICBreakpointManager
+ ISwitchToThread
{
}
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 99dfd35345e..8a6b918010f 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
@@ -7,10 +7,17 @@
package org.eclipse.cdt.debug.internal.core;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.CDebugModel;
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
+import org.eclipse.cdt.debug.core.cdi.ICDICondition;
+import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDICreatedEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
@@ -20,18 +27,25 @@ 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.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.ICFunctionBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.ISourceLocator;
@@ -40,7 +54,7 @@ import org.eclipse.debug.core.model.ISourceLocator;
*
* @since Nov 3, 2003
*/
-public class CBreakpointManager implements ICDIEventListener, IAdaptable
+public class CBreakpointManager implements ICBreakpointManager, ICDIEventListener, IAdaptable
{
public class BreakpointMap
{
@@ -57,47 +71,66 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
protected BreakpointMap()
{
fCBreakpoints = new HashMap( 10 );
- fCDIBreakpoints = new HashMap( 20 );
+ fCDIBreakpoints = new HashMap( 10 );
}
- protected synchronized void put( ICBreakpoint breakpoint, ICDIBreakpoint[] cdiBreakpoints )
+ protected synchronized void put( ICBreakpoint breakpoint, ICDIBreakpoint cdiBreakpoint )
{
+ fCBreakpoints.put( breakpoint, cdiBreakpoint );
+ fCDIBreakpoints.put( cdiBreakpoint, breakpoint );
}
- protected synchronized ICDIBreakpoint[] getCDIBreakpoints( ICBreakpoint breakpoint )
+ protected synchronized ICDIBreakpoint getCDIBreakpoint( ICBreakpoint breakpoint )
{
- return null;
+ return (ICDIBreakpoint)fCBreakpoints.get( breakpoint );
}
protected synchronized ICBreakpoint getCBreakpoint( ICDIBreakpoint cdiBreakpoint )
{
- return null;
+ return (ICBreakpoint)fCDIBreakpoints.get( cdiBreakpoint );
}
protected void removeCBreakpoint( ICBreakpoint breakpoint )
{
+ if ( breakpoint != null )
+ {
+ ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)fCBreakpoints.remove( breakpoint );
+ if ( cdiBreakpoint != null )
+ fCDIBreakpoints.remove( cdiBreakpoint );
+ }
}
protected void removeCDIBreakpoint( ICBreakpoint breakpoin, ICDIBreakpoint cdiBreakpoint )
{
+ if ( cdiBreakpoint != null )
+ {
+ ICBreakpoint breakpoint = (ICBreakpoint)fCDIBreakpoints.remove( cdiBreakpoint );
+ if ( breakpoint != null )
+ fCBreakpoints.remove( breakpoint );
+ }
}
protected ICBreakpoint[] getAllCBreakpoints()
{
- return null;
+ Set set = fCBreakpoints.keySet();
+ return (ICBreakpoint[])set.toArray( new ICBreakpoint[set.size()]);
}
protected ICDIBreakpoint[] getAllCDIBreakpoints()
{
- return null;
+ Set set = fCDIBreakpoints.keySet();
+ return (ICDIBreakpoint[])set.toArray( new ICDIBreakpoint[set.size()]);
}
protected void dispose()
{
+ fCBreakpoints.clear();
+ fCDIBreakpoints.clear();
}
}
private CDebugTarget fDebugTarget;
+
private BreakpointMap fMap;
public CBreakpointManager( CDebugTarget target )
@@ -151,7 +184,7 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
{
getDebugTarget().getCDISession().getEventManager().removeEventListener( this );
removeAllBreakpoints();
- fMap.dispose();
+ getBreakpointMap().dispose();
}
/* (non-Javadoc)
@@ -164,10 +197,8 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
{
if ( event instanceof ICDICreatedEvent )
{
- if ( source instanceof ICDILocationBreakpoint )
- handleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)source );
- else if ( source instanceof ICDIWatchpoint )
- handleWatchpointCreatedEvent( (ICDIWatchpoint)source );
+ if ( source instanceof ICDIBreakpoint )
+ handleBreakpointCreatedEvent( (ICDIBreakpoint)source );
}
}
else if ( event instanceof ICDIDestroyedEvent )
@@ -182,59 +213,279 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
}
}
- public void setBreakpoint( ICBreakpoint breakpoint, boolean defer ) throws DebugException
+ public boolean isTargetBreakpoint( ICBreakpoint breakpoint )
{
+ IResource resource = breakpoint.getMarker().getResource();
+ if ( breakpoint instanceof ICLineBreakpoint )
+ {
+ ICSourceLocator sl = getSourceLocator();
+ if ( sl != null )
+ return sl.contains( resource );
+ }
+ else
+ {
+ IProject project = resource.getProject();
+ if ( project != null && project.exists() )
+ {
+ ICSourceLocator sl = getSourceLocator();
+ if ( sl != null )
+ return sl.contains( project );
+ else
+ {
+ if ( project.equals( getExecFile().getProject() ) )
+ return true;
+ return CDebugUtils.isReferencedProject( getExecFile().getProject(), project );
+ }
+ }
+ }
+ return true;
}
- public void removeBreakpoint( ICBreakpoint breakpoint ) throws DebugException
+ public boolean isCDIRegistered( ICBreakpoint breakpoint )
{
- ICDIBreakpoint[] cdiBreakpoints = fMap.getCDIBreakpoints( breakpoint );
- if ( cdiBreakpoints.length == 0 )
- return;
+ return ( getBreakpointMap().getCDIBreakpoint( breakpoint ) != null );
+ }
- MultiStatus ms = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(),
- DebugException.TARGET_REQUEST_FAILED,
- "Delete breakpoints failed.",
- null );
- ICDIBreakpointManager bm = getCDIBreakpointManager();
- for ( int i = 0; i < cdiBreakpoints.length; ++i )
+ public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint )
+ {
+ return ( getExecFile() != null &&
+ getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ) );
+ }
+
+ public IFile getCDIBreakpointFile( ICDIBreakpoint cdiBreakpoint )
+ {
+ IBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
+ if ( breakpoint instanceof ICLineBreakpoint )
{
+ IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource();
+ if ( resource instanceof IFile )
+ return (IFile)resource;
+ }
+ return null;
+ }
+
+ public ICBreakpoint getBreakpoint( ICDIBreakpoint cdiBreakpoint )
+ {
+ return getBreakpointMap().getCBreakpoint( cdiBreakpoint );
+ }
+
+ public long getBreakpointAddress( ICBreakpoint breakpoint )
+ {
+ if ( breakpoint != null )
+ {
+ ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
+ if ( cdiBreakpoint instanceof ICDILocationBreakpoint )
+ {
+ try
+ {
+ ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation();
+ if ( location != null )
+ return location.getAddress();
+ }
+ catch( CDIException e )
+ {
+ }
+ }
+ }
+ return 0;
+ }
+
+ public void setBreakpoint( ICBreakpoint breakpoint ) throws DebugException
+ {
+ try
+ {
+ ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
+ if ( cdiBreakpoint == null )
+ {
+ if ( breakpoint instanceof ICFunctionBreakpoint )
+ cdiBreakpoint = setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint );
+ else if ( breakpoint instanceof ICAddressBreakpoint )
+ cdiBreakpoint = setAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
+ else if ( breakpoint instanceof ICLineBreakpoint )
+ cdiBreakpoint = setLineBreakpoint( (ICLineBreakpoint)breakpoint );
+ else if ( breakpoint instanceof ICWatchpoint )
+ cdiBreakpoint = setWatchpoint( (ICWatchpoint)breakpoint );
+ }
+ if ( cdiBreakpoint == null )
+ return;
+ if ( !breakpoint.isEnabled() )
+ cdiBreakpoint.setEnabled( false );
+ setBreakpointCondition( breakpoint );
+ }
+ catch( CoreException e )
+ {
+ requestFailed( "Set breakpoint failed. Reason: " + e.getMessage(), e );
+ }
+ catch( NumberFormatException e )
+ {
+ requestFailed( "Set breakpoint failed. Reason: " + e.getMessage(), e );
+ }
+ catch( CDIException e )
+ {
+ targetRequestFailed( "Set breakpoint failed. Reason: " + e.getMessage(), e );
+ }
+ }
+
+ public void removeBreakpoint( ICBreakpoint breakpoint ) throws DebugException
+ {
+ ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
+ if ( cdiBreakpoint != null )
+ {
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
try
{
- bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoints[i] } );
+ bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoint } );
}
catch( CDIException e )
{
- IStatus status = new Status( IStatus.ERROR,
- CDebugCorePlugin.getUniqueIdentifier(),
- DebugException.TARGET_REQUEST_FAILED,
- e.getMessage(),
- e );
- ms.addAll( status );
+ targetRequestFailed( "Delete breakpoint failed. Reason: " + e.getMessage(), e );
}
}
- if ( ms.getSeverity() > IStatus.OK )
- throw new DebugException( ms );
}
public void changeBreakpointProperties( ICBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException
{
+ ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
+ if ( cdiBreakpoint == null )
+ return;
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ try
+ {
+ boolean enabled = breakpoint.isEnabled();
+ boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true );
+ int ignoreCount = breakpoint.getIgnoreCount();
+ int oldIgnoreCount = delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 );
+ String condition = breakpoint.getCondition();
+ String oldCondition = delta.getAttribute( ICBreakpoint.CONDITION, "" );
+ if ( enabled != oldEnabled )
+ {
+ cdiBreakpoint.setEnabled( enabled );
+ }
+ if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) )
+ {
+ ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition );
+ cdiBreakpoint.setCondition( cdiCondition );
+ }
+ }
+ catch( CoreException e )
+ {
+ requestFailed( "Change breakpoint properties failed. Reason: " + e.getMessage(), e );
+ }
+ catch( CDIException e )
+ {
+ targetRequestFailed( "Change breakpoint properties failed. Reason: " + e.getMessage(), e );
+ }
+ }
+
+ private void handleBreakpointCreatedEvent( final ICDIBreakpoint cdiBreakpoint )
+ {
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ if ( cdiBreakpoint instanceof ICDILocationBreakpoint )
+ doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint );
+ else if ( cdiBreakpoint instanceof ICDIWatchpoint )
+ doHandleWatchpointCreatedEvent( (ICDIWatchpoint)cdiBreakpoint );
+ }
+ };
+ CDebugCorePlugin.getDefault().asyncExec( runnable );
}
- private void handleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint )
+ protected void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint )
{
+ if ( cdiBreakpoint.isTemporary() )
+ 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 )
+ {
+ }
+ }
+ if ( breakpoint != null )
+ {
+ try
+ {
+ ((CBreakpoint)breakpoint).incrementInstallCount();
+ }
+ catch( CoreException e )
+ {
+ CDebugCorePlugin.log( e.getStatus() );
+ }
+ }
}
- private void handleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint )
+ protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint )
{
+ ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiWatchpoint );
+ if ( breakpoint == null )
+ {
+ try
+ {
+ breakpoint = CDebugModel.createWatchpoint( getExecFile().getProject(),
+ cdiWatchpoint.isWriteType(),
+ cdiWatchpoint.isReadType(),
+ cdiWatchpoint.getWatchExpression(),
+ cdiWatchpoint.isEnabled(),
+ cdiWatchpoint.getCondition().getIgnoreCount(),
+ cdiWatchpoint.getCondition().getExpression(),
+ false );
+ getBreakpointMap().put( breakpoint, cdiWatchpoint );
+ ((CBreakpoint)breakpoint).register( true );
+ }
+ catch( CDIException e )
+ {
+ }
+ catch( CoreException e )
+ {
+ }
+ }
+ if ( breakpoint != null )
+ {
+ try
+ {
+ ((CBreakpoint)breakpoint).incrementInstallCount();
+ }
+ catch( CoreException e )
+ {
+ CDebugCorePlugin.log( e.getStatus() );
+ }
+ }
}
private void handleBreakpointDestroyedEvent( ICDIBreakpoint cdiBreakpoint )
{
- ICBreakpoint breakpoint = fMap.getCBreakpoint( cdiBreakpoint );
+ ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
if ( breakpoint != null )
{
- fMap.removeCDIBreakpoint( breakpoint, cdiBreakpoint );
+ getBreakpointMap().removeCDIBreakpoint( breakpoint, cdiBreakpoint );
try
{
((CBreakpoint)breakpoint).decrementInstallCount();
@@ -246,13 +497,44 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
}
}
- private void handleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint )
+ private void handleBreakpointChangedEvent( final ICDIBreakpoint cdiBreakpoint )
{
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ doHandleBreakpointChangedEvent( cdiBreakpoint );
+ }
+
+ };
+ CDebugCorePlugin.getDefault().asyncExec( runnable );
+ }
+
+ protected void doHandleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint )
+ {
+ ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
+ if ( breakpoint != null )
+ {
+ try
+ {
+ Map attributes = breakpoint.getMarker().getAttributes();
+ attributes.put( ICBreakpoint.ENABLED, new Boolean( cdiBreakpoint.isEnabled() ) );
+ attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( cdiBreakpoint.getCondition().getIgnoreCount() ) );
+ attributes.put( ICBreakpoint.CONDITION, cdiBreakpoint.getCondition().getExpression() );
+ breakpoint.getMarker().setAttributes( attributes );
+ }
+ catch( CDIException e )
+ {
+ }
+ catch( CoreException e )
+ {
+ }
+ }
}
private void removeAllBreakpoints()
{
- ICDIBreakpoint[] cdiBreakpoints = fMap.getAllCDIBreakpoints();
+ ICDIBreakpoint[] cdiBreakpoints = getBreakpointMap().getAllCDIBreakpoints();
ICDIBreakpointManager bm = getCDIBreakpointManager();
if ( cdiBreakpoints.length > 0 )
{
@@ -264,7 +546,7 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
{
CDebugCorePlugin.log( e.getMessage() );
}
- ICBreakpoint[] breakpoints = fMap.getAllCBreakpoints();
+ ICBreakpoint[] breakpoints = getBreakpointMap().getAllCBreakpoints();
for ( int i = 0; i < breakpoints.length; ++i )
{
try
@@ -278,4 +560,114 @@ public class CBreakpointManager implements ICDIEventListener, IAdaptable
}
}
}
+
+ private synchronized ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException
+ {
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ String function = breakpoint.getFunction();
+ String fileName = ( function != null && function.indexOf( "::" ) == -1 ) ? breakpoint.getFileName() : null;
+ ICDILocation location = bm.createLocation( fileName, function, -1 );
+ ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
+ getBreakpointMap().put( breakpoint, cdiBreakpoint );
+ return cdiBreakpoint;
+ }
+
+ private synchronized ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException
+ {
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) );
+ ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
+ getBreakpointMap().put( breakpoint, cdiBreakpoint );
+ return cdiBreakpoint;
+ }
+
+ private synchronized ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException
+ {
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
+ ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
+ getBreakpointMap().put( breakpoint, cdiBreakpoint );
+ return cdiBreakpoint;
+ }
+
+ private synchronized ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException
+ {
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ int accessType = 0;
+ accessType |= ( watchpoint.isWriteType() ) ? ICDIWatchpoint.WRITE : 0;
+ accessType |= ( watchpoint.isReadType() ) ? ICDIWatchpoint.READ : 0;
+ String expression = watchpoint.getExpression();
+ ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null );
+ getBreakpointMap().put( watchpoint, cdiWatchpoint );
+ return cdiWatchpoint;
+ }
+
+ private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException
+ {
+ ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
+ ICDIBreakpointManager bm = getCDIBreakpointManager();
+ ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
+ cdiBreakpoint.setCondition( condition );
+ }
+
+ private BreakpointMap getBreakpointMap()
+ {
+ return fMap;
+ }
+
+ protected void targetRequestFailed( String message, Throwable e ) throws DebugException
+ {
+ requestFailed0( message, e, DebugException.TARGET_REQUEST_FAILED );
+ }
+
+ protected void requestFailed( String message, Throwable e ) throws DebugException
+ {
+ requestFailed0( message, e, DebugException.REQUEST_FAILED );
+ }
+
+ private void requestFailed0( String message, Throwable e, int code ) throws DebugException
+ {
+ throw new DebugException( new Status( IStatus.ERROR,
+ CDebugModel.getPluginIdentifier(),
+ code,
+ message,
+ e ) );
+ }
+
+ private ICLineBreakpoint createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException
+ {
+ ICLineBreakpoint breakpoint = CDebugModel.createLineBreakpoint( file,
+ cdiBreakpoint.getLocation().getLineNumber(),
+ 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
+ {
+ ICAddressBreakpoint breakpoint = CDebugModel.createAddressBreakpoint( getExecFile(),
+ cdiBreakpoint.getLocation().getAddress(),
+ cdiBreakpoint.isEnabled(),
+ cdiBreakpoint.getCondition().getIgnoreCount(),
+ cdiBreakpoint.getCondition().getExpression(),
+ false );
+ getBreakpointMap().put( breakpoint, cdiBreakpoint );
+ ((CBreakpoint)breakpoint).register( true );
+ return breakpoint;
+ }
+
+ private ICSourceLocator getSourceLocator()
+ {
+ ISourceLocator locator = getDebugTarget().getLaunch().getSourceLocator();
+ return ( locator instanceof IAdaptable ) ? (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ) : null;
+ }
+
+ private IFile getExecFile()
+ {
+ return getDebugTarget().getExecFile();
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java
index 509c335ade5..d78d7a20bf3 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java
@@ -51,7 +51,7 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib
fSharedLibraries.add( library );
library.fireCreationEvent();
if ( library.areSymbolsLoaded() )
- ((CDebugTarget)getDebugTarget()).setDeferredBreakpoints();
+ setBreakpoints();
}
/* (non-Javadoc)
@@ -77,7 +77,7 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib
if ( library != null )
{
library.fireChangeEvent( DebugEvent.STATE );
- ((CDebugTarget)getDebugTarget()).setDeferredBreakpoints();
+ setBreakpoints();
}
}
@@ -181,4 +181,9 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib
}
}
}
+
+ private void setBreakpoints()
+ {
+ ((CDebugTarget)getDebugTarget()).setBreakpoints();
+ }
}
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 a2650912a73..fe96399fd28 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
@@ -6,10 +6,8 @@
package org.eclipse.cdt.debug.internal.core.model;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin;
@@ -28,8 +26,6 @@ import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
import org.eclipse.cdt.debug.core.ICSignalManager;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
-import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
-import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
import org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo;
@@ -51,22 +47,17 @@ 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.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.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.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.ICFunctionBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
import org.eclipse.cdt.debug.core.model.IGlobalVariable;
@@ -77,18 +68,16 @@ import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.model.IState;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
+import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
import org.eclipse.cdt.debug.internal.core.CRegisterManager;
import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager;
import org.eclipse.cdt.debug.internal.core.CSignalManager;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
-import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -236,11 +225,6 @@ public class CDebugTarget extends CDebugElement
private int fSuspendCount = 0;
/**
- * Collection of breakpoints added to this target. Values are of type <code>ICBreakpoint</code>.
- */
- private HashMap fBreakpoints;
-
- /**
* A memory manager for this target.
*/
private CMemoryManager fMemoryManager;
@@ -266,6 +250,11 @@ public class CDebugTarget extends CDebugElement
private CRegisterManager fRegisterManager;
/**
+ * A breakpoint manager for this target.
+ */
+ private CBreakpointManager fBreakpointManager;
+
+ /**
* Whether the debugger process is default.
*/
private boolean fIsDebuggerProcessDefault = false;
@@ -275,12 +264,6 @@ public class CDebugTarget extends CDebugElement
*/
private IFile fExecFile;
- /**
- * If is set to 'true' the debugger will try to set breakpoints on
- * the next resume or step call.
- */
- private boolean fSetBreakpoints = true;
-
private RunningInfo fRunningInfo = null;
/**
@@ -304,7 +287,6 @@ public class CDebugTarget extends CDebugElement
setName( name );
setProcesses( debuggeeProcess, debuggerProcess );
setCDITarget( cdiTarget );
- initializeBreakpointMap( new HashMap( 5 ) );
setExecFile( file );
setConfiguration( cdiTarget.getSession().getConfiguration() );
fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate();
@@ -314,6 +296,7 @@ public class CDebugTarget extends CDebugElement
setSharedLibraryManager( new CSharedLibraryManager( this ) );
setSignalManager( new CSignalManager( this ) );
setRegisterManager( new CRegisterManager( this ) );
+ setBreakpointManager( new CBreakpointManager( this ) );
initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
@@ -365,66 +348,30 @@ public class CDebugTarget extends CDebugElement
* the breakpoint manager.
*
*/
- protected void setBreakpoints()
+ public void setBreakpoints()
{
- if ( getRetryBreakpoints() )
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() );
+ for ( int i = 0; i < bps.length; i++ )
{
- IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() );
- for ( int i = 0; i < bps.length; i++ )
+ if ( bps[i] instanceof ICBreakpoint &&
+ getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)bps[i] ) &&
+ !getBreakpointManager().isCDIRegistered( (ICBreakpoint)bps[i] ) )
{
- if ( bps[i] instanceof ICBreakpoint && isTargetBreakpoint( bps[i] ) && findCDIBreakpoint( bps[i] ) == null )
+ if ( bps[i] instanceof ICAddressBreakpoint )
{
- if ( bps[i] instanceof ICAddressBreakpoint )
+ // disable address breakpoints to prevent the debugger to insert them prematurely
+ try
+ {
+ bps[i].setEnabled( false );
+ }
+ catch( CoreException e )
{
- // disable address breakpoints to prevent the debugger to insert them prematurely
- try
- {
- bps[i].setEnabled( false );
- }
- catch( CoreException e )
- {
- }
}
- breakpointAdded( (ICBreakpoint)bps[i] );
- }
- }
- setRetryBreakpoints( false );
- }
- }
-
- private boolean isTargetBreakpoint( IBreakpoint bp )
- {
- IResource resource = bp.getMarker().getResource();
- if ( bp instanceof ICLineBreakpoint )
- {
- if ( getSourceLocator() instanceof IAdaptable )
- {
- ICSourceLocator sl = (ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class );
- if ( sl != null )
- return sl.contains( resource );
- }
- }
- else
- {
- IProject project = resource.getProject();
- if ( project != null && project.exists() )
- {
- if ( getSourceLocator() instanceof IAdaptable )
- {
- ICSourceLocator sl = (ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class );
- if ( sl != null )
- return sl.contains( project );
- }
- else
- {
- if ( project.equals( getExecFile().getProject() ) )
- return true;
- return CDebugUtils.isReferencedProject( getExecFile().getProject(), project );
}
+ breakpointAdded( (ICBreakpoint)bps[i] );
}
}
- return true;
}
protected void initializeRegisters()
@@ -519,13 +466,7 @@ public class CDebugTarget extends CDebugElement
{
if ( !getConfiguration().supportsBreakpoints() )
return false;
- return ( findCDIBreakpoint( breakpoint ) != null );
- }
-
- private boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint )
- {
- return ( getExecFile() != null &&
- getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ) );
+ return ( breakpoint instanceof ICBreakpoint && getBreakpointManager().isCDIRegistered( (ICBreakpoint)breakpoint ) );
}
/* (non-Javadoc)
@@ -746,29 +687,17 @@ public class CDebugTarget extends CDebugElement
*/
public void breakpointAdded( IBreakpoint breakpoint )
{
- if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() )
+ if ( !(breakpoint instanceof ICBreakpoint) ||
+ !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) ||
+ !isAvailable() )
+ return;
+ if ( breakpoint instanceof ICAddressBreakpoint && !getBreakpointManager().supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ) )
return;
if ( getConfiguration().supportsBreakpoints() )
{
try
{
- if ( breakpoint instanceof ICFunctionBreakpoint )
- {
- setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint );
- }
- else if ( breakpoint instanceof ICAddressBreakpoint )
- {
- if ( supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ) )
- setAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
- }
- else if ( breakpoint instanceof ICLineBreakpoint )
- {
- setLineBreakpoint( (ICLineBreakpoint)breakpoint );
- }
- else if ( breakpoint instanceof ICWatchpoint )
- {
- setWatchpoint( (ICWatchpoint)breakpoint );
- }
+ getBreakpointManager().setBreakpoint( (ICBreakpoint)breakpoint );
}
catch( DebugException e )
{
@@ -782,12 +711,13 @@ public class CDebugTarget extends CDebugElement
*/
public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta )
{
- if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() )
+ if ( !(breakpoint instanceof ICBreakpoint) ||
+ !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) ||
+ !isAvailable() )
return;
try
{
- if ( breakpoint instanceof CBreakpoint )
- removeBreakpoint( (CBreakpoint)breakpoint );
+ getBreakpointManager().removeBreakpoint( (ICBreakpoint)breakpoint );
}
catch( DebugException e )
{
@@ -799,12 +729,14 @@ public class CDebugTarget extends CDebugElement
*/
public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta )
{
- if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() )
+ if ( !(breakpoint instanceof ICBreakpoint) ||
+ !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) ||
+ !isAvailable() ||
+ delta == null )
return;
try
{
- if ( breakpoint instanceof CBreakpoint && delta != null )
- changeBreakpointProperties( (CBreakpoint)breakpoint, delta );
+ getBreakpointManager().changeBreakpointProperties( (ICBreakpoint)breakpoint, delta );
}
catch( DebugException e )
{
@@ -985,7 +917,7 @@ public class CDebugTarget extends CDebugElement
if ( adapter.equals( IJumpToAddress.class ) )
return this;
if ( adapter.equals( ICBreakpointManager.class ) )
- return this;
+ return getBreakpointManager();
if ( adapter.equals( DisassemblyManager.class ) )
return getDisassemblyManager();
if ( adapter.equals( ICSharedLibraryManager.class ) )
@@ -1018,30 +950,11 @@ public class CDebugTarget extends CDebugElement
if ( source instanceof ICDISharedLibrary )
{
getSharedLibraryManager().sharedLibraryLoaded( (ICDISharedLibrary)source );
- if ( ((ICDISharedLibrary)source).areSymbolsLoaded() )
- setRetryBreakpoints( true );
- }
- if ( source instanceof ICDILocationBreakpoint )
- {
- handleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)source );
- }
- if ( source instanceof ICDIWatchpoint )
- {
- handleWatchpointCreatedEvent( (ICDIWatchpoint)source );
}
}
else if ( event instanceof ICDISuspendedEvent )
{
- boolean pass = true;
-/*
- if ( source instanceof ICDITarget &&
- ((ICDISuspendedEvent)event).getReason() instanceof ICDISharedLibraryEvent &&
- applyDeferredBreakpoints() )
- {
- pass = handleInternalSuspendedEvent( (ICDISuspendedEvent)event );
- }
-*/
- if ( pass && (source instanceof ICDITarget || source instanceof ICDIThread) )
+ if ( source instanceof ICDITarget || source instanceof ICDIThread )
{
handleSuspendedEvent( (ICDISuspendedEvent)event );
}
@@ -1070,10 +983,6 @@ public class CDebugTarget extends CDebugElement
{
getSharedLibraryManager().sharedLibraryUnloaded( (ICDISharedLibrary)source );
}
- if ( source instanceof ICDIBreakpoint )
- {
- handleBreakpointDestroyedEvent( (ICDIBreakpoint)source );
- }
}
else if ( event instanceof ICDIDisconnectedEvent )
{
@@ -1096,10 +1005,6 @@ public class CDebugTarget extends CDebugElement
{
getSignalManager().signalChanged( (ICDISignal)source );
}
- if ( source instanceof ICDIBreakpoint )
- {
- handleBreakpointChangedEvent( (ICDIBreakpoint)source );
- }
}
else if ( event instanceof ICDIRestartedEvent )
{
@@ -1250,15 +1155,8 @@ public class CDebugTarget extends CDebugElement
disposeRegisterManager();
disposeDisassemblyManager();
disposeSourceManager();
+ disposeBreakpointManager();
removeAllExpressions();
- try
- {
- removeAllBreakpoints();
- }
- catch( DebugException e )
- {
- CDebugCorePlugin.log( e );
- }
}
/**
@@ -1295,96 +1193,6 @@ public class CDebugTarget extends CDebugElement
}
/**
- * Removes all breakpoints from this target.
- *
- */
- protected void removeAllBreakpoints() throws DebugException
- {
- ICDIBreakpoint[] cdiBreakpoints = (ICDIBreakpoint[])getBreakpoints().values().toArray( new ICDIBreakpoint[0] );
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- if ( cdiBreakpoints.length > 0 )
- {
- try
- {
- bm.deleteBreakpoints( cdiBreakpoints );
- }
- catch( CDIException e )
- {
- logError( e );
- }
- try
- {
- Iterator it = getBreakpoints().keySet().iterator();
- while( it.hasNext() )
- {
- ((CBreakpoint)it.next()).decrementInstallCount();
- }
- getBreakpoints().clear();
- }
- catch( CoreException ce )
- {
- logError( ce );
- }
- }
- }
-
- protected void removeBreakpoint( CBreakpoint breakpoint ) throws DebugException
- {
- ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint );
- if ( cdiBreakpoint == null )
- return;
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- try
- {
- bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoint } );
- getBreakpoints().remove( breakpoint );
- breakpoint.decrementInstallCount();
- }
- catch( CoreException ce )
- {
- requestFailed( "Operation failed. Reason: ", ce );
- }
- catch( CDIException e )
- {
- requestFailed( "Operation failed. Reason: ", e );
- }
- }
-
- protected void changeBreakpointProperties( CBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException
- {
- ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint );
- if ( cdiBreakpoint == null )
- return;
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- try
- {
- boolean enabled = breakpoint.isEnabled();
- boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true );
- int ignoreCount = breakpoint.getIgnoreCount();
- int oldIgnoreCount = delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 );
- String condition = breakpoint.getCondition();
- String oldCondition = delta.getAttribute( ICBreakpoint.CONDITION, "" );
- if ( enabled != oldEnabled )
- {
- cdiBreakpoint.setEnabled( enabled );
- }
- if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) )
- {
- ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition );
- cdiBreakpoint.setCondition( cdiCondition );
- }
- }
- catch( CoreException ce )
- {
- requestFailed( "Operation failed. Reason: ", ce );
- }
- catch( CDIException e )
- {
- requestFailed( "Operation failed. Reason: ", e );
- }
- }
-
- /**
* Creates, adds and returns a thread for the given underlying
* CDI thread. A creation event is fired for the thread.
* Returns <code>null</code> if during the creation of the thread
@@ -1618,16 +1426,19 @@ public class CDebugTarget extends CDebugElement
private void handleWatchpointScope( ICDIWatchpointScope ws )
{
- CBreakpoint watchpoint = (CBreakpoint)findBreakpoint( ws.getWatchpoint() );
- try
- {
- removeBreakpoint( watchpoint );
- }
- catch( DebugException e )
+ ICBreakpoint watchpoint = getBreakpointManager().getBreakpoint( ws.getWatchpoint() );
+ if ( watchpoint != null )
{
- CDebugCorePlugin.log( e );
+ try
+ {
+ getBreakpointManager().removeBreakpoint( watchpoint );
+ }
+ catch( DebugException e )
+ {
+ CDebugCorePlugin.log( e );
+ }
+ fireSuspendEvent( DebugEvent.BREAKPOINT );
}
- fireSuspendEvent( DebugEvent.BREAKPOINT );
}
private void handleSuspendedBySignal( ICDISignalReceived signal )
@@ -1718,177 +1529,6 @@ public class CDebugTarget extends CDebugElement
}
}
- private void handleLocationBreakpointCreatedEvent( final ICDILocationBreakpoint breakpoint )
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- doHandleLocationBreakpointCreatedEvent( breakpoint );
- }
- };
- CDebugCorePlugin.getDefault().asyncExec( runnable );
- }
-
- protected void doHandleLocationBreakpointCreatedEvent( final ICDILocationBreakpoint cdiBreakpoint )
- {
- if ( cdiBreakpoint.isTemporary() || getBreakpoints().containsValue( cdiBreakpoint ) )
- return;
- try
- {
- if ( cdiBreakpoint.getLocation().getFile() != null && cdiBreakpoint.getLocation().getFile().length() > 0 )
- {
- if ( getSourceLocator() instanceof IAdaptable && ((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class ) != null )
- {
- Object sourceElement = ((ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class )).findSourceElement( cdiBreakpoint.getLocation().getFile() );
- if ( sourceElement != null && sourceElement instanceof IFile )
- {
- createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint );
- }
- else if ( cdiBreakpoint.getLocation().getAddress() > 0 )
- {
- createAddressBreakpoint( cdiBreakpoint );
- }
- }
- }
- else if ( cdiBreakpoint.getLocation().getAddress() > 0 )
- {
- createAddressBreakpoint( cdiBreakpoint );
- }
- }
- catch( CDIException e )
- {
- }
- catch( CoreException e )
- {
- }
- }
-
- private void createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException
- {
- ICLineBreakpoint breakpoint = CDebugModel.createLineBreakpoint( file,
- cdiBreakpoint.getLocation().getLineNumber(),
- cdiBreakpoint.isEnabled(),
- cdiBreakpoint.getCondition().getIgnoreCount(),
- cdiBreakpoint.getCondition().getExpression(),
- false );
- getBreakpoints().put( breakpoint, cdiBreakpoint );
- ((CBreakpoint)breakpoint).register( true );
- }
-
- private void createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException
- {
- ICAddressBreakpoint breakpoint = CDebugModel.createAddressBreakpoint( getExecFile(),
- cdiBreakpoint.getLocation().getAddress(),
- cdiBreakpoint.isEnabled(),
- cdiBreakpoint.getCondition().getIgnoreCount(),
- cdiBreakpoint.getCondition().getExpression(),
- false );
- getBreakpoints().put( breakpoint, cdiBreakpoint );
- ((CBreakpoint)breakpoint).register( true );
- }
-
- private void handleWatchpointCreatedEvent( final ICDIWatchpoint watchpoint )
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- doHandleWatchpointCreatedEvent( watchpoint );
- }
-
- };
- CDebugCorePlugin.getDefault().asyncExec( runnable );
- }
-
- protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint )
- {
- if ( getBreakpoints().containsValue( cdiWatchpoint ) )
- return;
- try
- {
- ICWatchpoint watchpoint = CDebugModel.createWatchpoint( getExecFile().getProject(),
- cdiWatchpoint.isWriteType(),
- cdiWatchpoint.isReadType(),
- cdiWatchpoint.getWatchExpression(),
- cdiWatchpoint.isEnabled(),
- cdiWatchpoint.getCondition().getIgnoreCount(),
- cdiWatchpoint.getCondition().getExpression(),
- false );
- getBreakpoints().put( watchpoint, cdiWatchpoint );
- ((CBreakpoint)watchpoint).register( true );
- }
- catch( CDIException e )
- {
- }
- catch( CoreException e )
- {
- }
- }
-
- private void handleBreakpointDestroyedEvent( final ICDIBreakpoint breakpoint )
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- doHandleBreakpointDestroyedEvent( breakpoint );
- }
-
- };
- CDebugCorePlugin.getDefault().asyncExec( runnable );
- }
-
- protected void doHandleBreakpointDestroyedEvent( ICDIBreakpoint cdiBreakpoint )
- {
- IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint );
- if ( breakpoint != null )
- {
- try
- {
- DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
- }
- catch( CoreException e )
- {
- }
- }
- }
-
- private void handleBreakpointChangedEvent( final ICDIBreakpoint breakpoint )
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- doHandleBreakpointChangedEvent( breakpoint );
- }
-
- };
- CDebugCorePlugin.getDefault().asyncExec( runnable );
- }
-
- protected void doHandleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint )
- {
- IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint );
- if ( breakpoint instanceof ICBreakpoint )
- {
- try
- {
- Map attributes = breakpoint.getMarker().getAttributes();
- attributes.put( ICBreakpoint.ENABLED, new Boolean( cdiBreakpoint.isEnabled() ) );
- attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( cdiBreakpoint.getCondition().getIgnoreCount() ) );
- attributes.put( ICBreakpoint.CONDITION, cdiBreakpoint.getCondition().getExpression() );
- breakpoint.getMarker().setAttributes( attributes );
- }
- catch( CDIException e )
- {
- }
- catch( CoreException e )
- {
- }
- }
- }
-
/**
* Finds and returns the model thread for the associated CDI thread,
* or <code>null</code> if not found.
@@ -2000,26 +1640,6 @@ public class CDebugTarget extends CDebugElement
}
/**
- * Returns the map of breakpoints installed in this debug target.
- *
- * @return map of installed breakpoints
- */
- protected HashMap getBreakpoints()
- {
- return fBreakpoints;
- }
-
- /**
- * Sets the map of breakpoints installed in this debug target.
- *
- * @param breakpoints breakpoints map
- */
- private void initializeBreakpointMap( HashMap breakpoints )
- {
- fBreakpoints = breakpoints;
- }
-
- /**
* Returns the debug configuration of this target.
*
* @return the debug configuration of this target
@@ -2039,187 +1659,6 @@ public class CDebugTarget extends CDebugElement
fConfig = config;
}
- private void setLineBreakpoint( ICLineBreakpoint breakpoint ) throws DebugException
- {
- try
- {
- ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint );
- if ( cdiBreakpoint == null )
- {
- cdiBreakpoint = setLineBreakpoint0( breakpoint );
- }
- ((CBreakpoint)breakpoint).incrementInstallCount();
- if ( !breakpoint.isEnabled() )
- {
- cdiBreakpoint.setEnabled( false );
- }
- setBreakpointCondition( breakpoint );
- }
- catch( CoreException ce )
- {
- requestFailed( "Operation failed. Reason: ", ce );
- }
- catch( CDIException e )
- {
- requestFailed( "Operation failed. Reason: ", e );
- }
- }
-
- private synchronized ICDIBreakpoint setLineBreakpoint0( ICLineBreakpoint breakpoint ) throws CDIException, CoreException
- {
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
- ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null );
- getBreakpoints().put( breakpoint, cdiBreakpoint );
- return cdiBreakpoint;
- }
-
- private void setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws DebugException
- {
- try
- {
- ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint );
- if ( cdiBreakpoint == null )
- {
- cdiBreakpoint = setAddressBreakpoint0( breakpoint );
- }
- ((CBreakpoint)breakpoint).incrementInstallCount();
- if ( !breakpoint.isEnabled() )
- {
- cdiBreakpoint.setEnabled( false );
- }
- setBreakpointCondition( breakpoint );
- }
- 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 synchronized ICDIBreakpoint setAddressBreakpoint0( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException
- {
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) );
- ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null );
- getBreakpoints().put( breakpoint, cdiBreakpoint );
- return cdiBreakpoint;
- }
-
- private void setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws DebugException
- {
- try
- {
- ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint );
- if ( cdiBreakpoint == null )
- {
- cdiBreakpoint = setFunctionBreakpoint0( breakpoint );
- }
- ((CBreakpoint)breakpoint).incrementInstallCount();
- if ( !breakpoint.isEnabled() )
- {
- cdiBreakpoint.setEnabled( false );
- }
- setBreakpointCondition( breakpoint );
- }
- 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 synchronized ICDIBreakpoint setFunctionBreakpoint0( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException
- {
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- String function = breakpoint.getFunction();
- String fileName = ( function != null && function.indexOf( "::" ) == -1 ) ? breakpoint.getFileName() : null;
- ICDILocation location = bm.createLocation( fileName, function, -1 );
- ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null );
- getBreakpoints().put( breakpoint, cdiBreakpoint );
- return cdiBreakpoint;
- }
-
- private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException
- {
- try
- {
- ICDIWatchpoint cdiWatchpoint = (ICDIWatchpoint)getBreakpoints().get( watchpoint );
- if ( cdiWatchpoint == null )
- {
- cdiWatchpoint = setWatchpoint0( watchpoint );
- }
- ((CBreakpoint)watchpoint).incrementInstallCount();
- if ( !watchpoint.isEnabled() )
- {
- cdiWatchpoint.setEnabled( false );
- }
- }
- catch( CoreException ce )
- {
- requestFailed( "Operation failed. Reason: ", ce );
- }
- catch( CDIException e )
- {
- requestFailed( "Operation failed. Reason: ", e );
- }
- }
-
- private synchronized ICDIWatchpoint setWatchpoint0( ICWatchpoint watchpoint ) throws CDIException, CoreException
- {
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- int accessType = 0;
- accessType |= ( watchpoint.isWriteType() ) ? ICDIWatchpoint.WRITE : 0;
- accessType |= ( watchpoint.isReadType() ) ? ICDIWatchpoint.READ : 0;
- String expression = watchpoint.getExpression();
- ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null );
- getBreakpoints().put( watchpoint, cdiWatchpoint );
- return cdiWatchpoint;
- }
-
- private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException
- {
- ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint );
- if ( cdiBreakpoint == null )
- return;
- ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
- ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
- cdiBreakpoint.setCondition( condition );
- }
-
- private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint )
- {
- return (ICDIBreakpoint)getBreakpoints().get( breakpoint );
- }
-
- private IBreakpoint findBreakpoint( ICDIBreakpoint cdiBreakpoint )
- {
- if ( cdiBreakpoint == null )
- return null;
- Iterator it = getBreakpoints().keySet().iterator();
- while( it.hasNext() )
- {
- IBreakpoint breakpoint = (IBreakpoint)it.next();
- if ( cdiBreakpoint.equals( getBreakpoints().get( breakpoint ) ) )
- return breakpoint;
- }
- return null;
- }
-
protected boolean supportsExpressionEvaluation()
{
return getConfiguration().supportsExpressionEvaluation();
@@ -2428,7 +1867,7 @@ public class CDebugTarget extends CDebugElement
return fMemoryManager;
}
- private void disposeMemoryManager()
+ protected void disposeMemoryManager()
{
getMemoryManager().dispose();
}
@@ -2590,29 +2029,6 @@ public class CDebugTarget extends CDebugElement
fDisassemblyManager.dispose();
}
- /* (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;
- }
-
/**
* @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(long)
*/
@@ -2640,22 +2056,6 @@ public class CDebugTarget extends CDebugElement
}
}
- private boolean getRetryBreakpoints()
- {
- return fSetBreakpoints;
- }
-
- protected void setRetryBreakpoints( boolean retry )
- {
- fSetBreakpoints = retry;
- }
-
- public void setDeferredBreakpoints()
- {
- setRetryBreakpoints( true );
- setBreakpoints();
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IResumeWithoutSignal#canResumeWithoutSignal()
*/
@@ -2791,15 +2191,7 @@ public class CDebugTarget extends CDebugElement
{
ICDIBreakpoint cdiBreakpoint = ((ICDIBreakpointHit)info).getBreakpoint();
if ( cdiBreakpoint != null )
- {
- IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint );
- if ( breakpoint instanceof ICLineBreakpoint )
- {
- IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource();
- if ( resource instanceof IFile )
- return (IFile)resource;
- }
- }
+ return getBreakpointManager().getCDIBreakpointFile( cdiBreakpoint );
}
return null;
}
@@ -2830,18 +2222,19 @@ public class CDebugTarget extends CDebugElement
setRunningInfo( info );
}
-/*
- private boolean applyDeferredBreakpoints()
+ protected CBreakpointManager getBreakpointManager()
{
- boolean result = false;
- try
- {
- result = getLaunch().getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_DEFERRED_BREAKPOINTS, false );
- }
- catch( CoreException e )
- {
- }
- return result;
+ return fBreakpointManager;
+ }
+
+ protected void setBreakpointManager( CBreakpointManager manager )
+ {
+ fBreakpointManager = manager;
+ }
+
+ protected void disposeBreakpointManager()
+ {
+ if ( getBreakpointManager() != null )
+ getBreakpointManager().dispose();
}
-*/
}

Back to the top