Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Managing breakpoints from the gdb console (core)

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.110
diff -u -r1.110 ChangeLog
--- ChangeLog 27 Jan 2003 18:31:43 -0000 1.110
+++ ChangeLog 27 Jan 2003 22:23:50 -0000
@@ -1,4 +1,19 @@
 2003-01-27 Mikhail Khodjaiants
+ Managing breakpoints from the gdb console.
+ * CDebugCorePlugin.java
+ * CDebugModel.java
+ * IAsyncExecutor.java
+ * ICSourceLocator.java
+ * CAddressBreakpoint.java
+ * CBreakpoint.java
+ * CFunctionBreakpoint.java
+ * CLineBreakpoint.java
+ * CWatchpoint.java
+ * CDebugTarget.java
+ * CSourceLocator.java
+ * CSourceManager.java
+
+2003-01-27 Mikhail Khodjaiants
  Use 'equals' to compare CDI variables instead of names.
  * CStackFrame.java
 
Index: src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java,v
retrieving revision 1.9
diff -u -r1.9 CDebugCorePlugin.java
--- src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java 4 Oct 2002 18:09:01 -0000 1.9
+++ src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java 27 Jan 2003 22:23:50 -0000
@@ -39,6 +39,8 @@
 
  private HashMap fDebugConfigurations;
 
+ private IAsyncExecutor fAsyncExecutor = null;
+
  /**
   * The constructor.
   */
@@ -198,5 +200,16 @@
     }
    }
   }
+ }

+ public void setAsyncExecutor( IAsyncExecutor executor )
+ {
+  fAsyncExecutor = executor;
+ }

+ public void asyncExec( Runnable runnable )
+ {
+  if ( fAsyncExecutor != null )
+   fAsyncExecutor.asyncExec( runnable );
  }
 }
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.39
diff -u -r1.39 CDebugModel.java
--- src/org/eclipse/cdt/debug/core/CDebugModel.java 10 Jan 2003 19:36:42 -0000 1.39
+++ src/org/eclipse/cdt/debug/core/CDebugModel.java 27 Jan 2003 22:23:51 -0000
@@ -14,10 +14,12 @@
 import org.eclipse.cdt.debug.core.cdi.ICDILocation;
 import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
 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.ICDIExpression;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.core.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.ICDebugTargetType;
@@ -307,6 +309,23 @@
   return new CLineBreakpoint( resource, attributes, add );
  }
 
+ public static ICLineBreakpoint createLineBreakpoint( IResource resource,
+               int lineNumber,
+               boolean enabled,
+               int ignoreCount,
+               String condition,
+               ICDIBreakpoint cdiBreakpoint,
+               boolean add ) throws DebugException
+ {
+  HashMap attributes = new HashMap( 10 );
+  attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
+  attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
+  attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
+  attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
+  attributes.put( ICBreakpoint.CONDITION, condition );
+  return new CLineBreakpoint( resource, attributes, cdiBreakpoint, add );
+ }
+
  public static ICAddressBreakpoint addressBreakpointExists( IResource resource, long address ) throws CoreException
  {
   String modelId = getPluginIdentifier();
@@ -341,7 +360,6 @@
  }
 
  public static ICAddressBreakpoint createAddressBreakpoint( IResource resource,
-                  int lineNumber,
                   long address,
                   boolean enabled,
                   int ignoreCount,
@@ -350,7 +368,6 @@
  {
   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 ) );
@@ -361,6 +378,26 @@
   return new CAddressBreakpoint( resource, attributes, add );
  }
 
+ public static ICAddressBreakpoint createAddressBreakpoint( IResource resource,
+                  long address,
+                  boolean enabled,
+                  int ignoreCount,
+                  String condition,
+                  ICDIBreakpoint breakpoint,
+                  boolean add ) throws DebugException
+ {
+  HashMap attributes = new HashMap( 10 );
+  attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
+  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, breakpoint, add );
+ }
+
  public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String _expression_ ) throws CoreException
  {
   String modelId = getPluginIdentifier();
@@ -404,6 +441,27 @@
   attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) );
   attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) );
   return new CWatchpoint( resource, attributes, add );
+ }

+ public static ICWatchpoint createWatchpoint( IResource resource,
+             boolean writeAccess,
+             boolean readAccess,
+             String _expression_,
+             boolean enabled,
+             int ignoreCount,
+             String condition,
+             ICDIWatchpoint watchpoint,
+             boolean add ) throws DebugException
+ {
+  HashMap attributes = new HashMap( 10 );
+  attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
+  attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
+  attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
+  attributes.put( ICBreakpoint.CONDITION, condition );
+  attributes.put( ICWatchpoint._expression_, _expression_ );
+  attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) );
+  attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) );
+  return new CWatchpoint( resource, attributes, watchpoint, add );
  }
  
  public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException
Index: src/org/eclipse/cdt/debug/core/IAsyncExecutor.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/core/IAsyncExecutor.java
diff -N src/org/eclipse/cdt/debug/core/IAsyncExecutor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/core/IAsyncExecutor.java 27 Jan 2003 22:23:50 -0000
@@ -0,0 +1,16 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core;
+
+/**
+ * Enter type comment.
+ *
+ * @since: Jan 27, 2003
+ */
+public interface IAsyncExecutor
+{
+ void asyncExec( Runnable runnable );
+}
Index: src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java,v
retrieving revision 1.6
diff -u -r1.6 ICSourceLocator.java
--- src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java 17 Dec 2002 19:56:22 -0000 1.6
+++ src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java 27 Jan 2003 22:23:51 -0000
@@ -50,4 +50,6 @@
   * @return whether this locator is able to locate the given resource
   */
  boolean contains( IResource resource );

+ Object findSourceElement( String fileName );
 }
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.5
diff -u -r1.5 CAddressBreakpoint.java
--- src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java 10 Jan 2003 19:36:42 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java 27 Jan 2003 22:23:51 -0000
@@ -7,6 +7,7 @@
 
 import java.util.Map;
 
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
 import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -35,7 +36,15 @@
   */
  public CAddressBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
  {
-  super( resource, C_ADDRESS_BREAKPOINT, attributes, add );
+  super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+  * Constructor for CAddressBreakpoint.
+  */
+ public CAddressBreakpoint( IResource resource, Map attributes, ICDIBreakpoint cdiBreakpoint, boolean add ) throws DebugException
+ {
+  super( resource, getMarkerType(), attributes, cdiBreakpoint, add );
  }
 
  /* (non-Javadoc)
Index: src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java,v
retrieving revision 1.9
diff -u -r1.9 CBreakpoint.java
--- src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java 2 Dec 2002 23:22:22 -0000 1.9
+++ src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java 27 Jan 2003 22:23:52 -0000
@@ -9,6 +9,7 @@
 import java.util.Map;
 
 import org.eclipse.cdt.debug.core.CDebugModel;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
 import org.eclipse.cdt.debug.core.model.ICBreakpoint;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -33,6 +34,12 @@
               IDebugEventSetListener
 {
  /**
+  * This field is used to pass a CDI breakpoint to the target if the breakpoint
+  * is created in gdb console.
+  */
+ private ICDIBreakpoint fExternalBreakpoint = null;
+
+ /**
   * Constructor for CBreakpoint.
   */
  public CBreakpoint()
@@ -64,6 +71,32 @@
   run( wr );
  }
 
+ /**
+  * Constructor for CBreakpoint.
+  */
+ public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final ICDIBreakpoint cdiBreakpoint, final boolean add ) throws DebugException
+ {
+  setExternalBreakpoint( cdiBreakpoint );
+  IWorkspaceRunnable wr= new IWorkspaceRunnable()
+         {
+          public void run( IProgressMonitor monitor ) throws CoreException
+          {
+           // create the marker
+           setMarker( resource.createMarker( markerType ) );
+           
+           // set attributes
+           ensureMarker().setAttributes( attributes );
+           
+           //set the marker message
+           setAttribute( IMarker.MESSAGE, getMarkerMessage() );
+           
+           // add to breakpoint manager if requested
+           register( add );
+          }
+         };
+  run( wr );
+ }
+
  /* (non-Javadoc)
   * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
   */
@@ -223,5 +256,15 @@
  protected void setAttribute( String attributeName, Object value ) throws CoreException
  {
   super.setAttribute( attributeName, value );
+ }

+ public ICDIBreakpoint getExternalBreakpoint()
+ {
+  return fExternalBreakpoint;
+ }

+ public void setExternalBreakpoint( ICDIBreakpoint cdiBreakpoint )
+ {
+  fExternalBreakpoint = cdiBreakpoint;
  }
 }
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.5
diff -u -r1.5 CFunctionBreakpoint.java
--- src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java 10 Jan 2003 19:36:42 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java 27 Jan 2003 22:23:51 -0000
@@ -7,6 +7,7 @@
 
 import java.util.Map;
 
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
 import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -42,7 +43,15 @@
   */
  public CFunctionBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
  {
-  super( resource, C_FUNCTION_BREAKPOINT, attributes, add );
+  super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+  * Constructor for CFunctionBreakpoint.
+  */
+ public CFunctionBreakpoint( IResource resource, Map attributes, ICDIBreakpoint cdiBreakpoint, boolean add ) throws DebugException
+ {
+  super( resource, getMarkerType(), attributes, cdiBreakpoint, add );
  }
 
  /* (non-Javadoc)
Index: src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java,v
retrieving revision 1.5
diff -u -r1.5 CLineBreakpoint.java
--- src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java 2 Dec 2002 23:22:22 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java 27 Jan 2003 22:23:51 -0000
@@ -7,6 +7,7 @@
 
 import java.util.Map;
 
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
 import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -36,6 +37,14 @@
  public CLineBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
  {
   super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+  * Constructor for CLineBreakpoint.
+  */
+ public CLineBreakpoint( IResource resource, Map attributes, ICDIBreakpoint cdiBreakpoint, boolean add ) throws DebugException
+ {
+  super( resource, getMarkerType(), attributes, cdiBreakpoint, add );
  }
 
  /* (non-Javadoc)
Index: src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java,v
retrieving revision 1.2
diff -u -r1.2 CWatchpoint.java
--- src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java 2 Dec 2002 23:22:22 -0000 1.2
+++ src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java 27 Jan 2003 22:23:51 -0000
@@ -7,6 +7,7 @@
 
 import java.util.Map;
 
+import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
 import org.eclipse.cdt.debug.core.model.ICWatchpoint;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
@@ -31,15 +32,18 @@
 
  /**
   * Constructor for CWatchpoint.
-  * @param resource
-  * @param markerType
-  * @param attributes
-  * @param add
-  * @throws DebugException
   */
  public CWatchpoint( IResource resource, Map attributes, boolean add ) throws DebugException
  {
   super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+  * Constructor for CWatchpoint.
+  */
+ public CWatchpoint( IResource resource, Map attributes, ICDIWatchpoint watchpoint, boolean add ) throws DebugException
+ {
+  super( resource, getMarkerType(), attributes, watchpoint, add );
  }
 
  /* (non-Javadoc)
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.75
diff -u -r1.75 CDebugTarget.java
--- src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 27 Jan 2003 16:15:33 -0000 1.75
+++ src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 27 Jan 2003 22:23:51 -0000
@@ -74,6 +74,7 @@
 import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager;
 import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
 import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
+import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
 import org.eclipse.core.resources.IFile;
@@ -901,6 +902,14 @@
      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 )
    {
@@ -933,6 +942,10 @@
     {
      getSharedLibraryManager().sharedLibraryUnloaded( (ICDISharedLibrary)source );
     }
+    if ( source instanceof ICDIBreakpoint )
+    {
+     handleBreakpointDestroyedEvent( (ICDIBreakpoint)source );
+    }
    }
    else if ( event instanceof ICDIDisconnectedEvent )
    {
@@ -1463,6 +1476,126 @@
   }
  }
 
+ private void handleLocationBreakpointCreatedEvent( final ICDILocationBreakpoint breakpoint )
+ {
+  Runnable runnable = new Runnable()
+        {
+         public void run()
+         {
+          doHandleLocationBreakpointCreatedEvent( breakpoint );
+         }
+
+        };
+  CDebugCorePlugin.getDefault().asyncExec( runnable );
+ }
+
+ protected void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint breakpoint )
+ {
+  if ( breakpoint.isTemporary() || getBreakpoints().containsValue( breakpoint ) )
+   return;
+  try
+  {
+   if ( breakpoint.getLocation().getFile() != null && breakpoint.getLocation().getFile().length() > 0 )
+   {
+    if ( getSourceLocator() instanceof IAdaptable && ((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class ) != null )
+    {
+     Object sourceElement = ((ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class )).findSourceElement( breakpoint.getLocation().getFile() );
+     if ( sourceElement != null && sourceElement instanceof IFile )
+     {
+      CDebugModel.createLineBreakpoint( (IFile)sourceElement,
+                breakpoint.getLocation().getLineNumber(),
+                breakpoint.isEnabled(),
+                breakpoint.getCondition().getIgnoreCount(),
+                breakpoint.getCondition().getExpression(),
+                breakpoint,
+                true );
+     }
+    }
+   }
+   else if ( breakpoint.getLocation().getAddress() > 0 )
+   {
+    CDebugModel.createAddressBreakpoint( getExecFile(),
+                breakpoint.getLocation().getAddress(),
+                breakpoint.isEnabled(),
+                breakpoint.getCondition().getIgnoreCount(),
+                breakpoint.getCondition().getExpression(),
+                breakpoint,
+                true );
+   }
+  }
+  catch( CDIException e )
+  {
+  }
+  catch( DebugException e )
+  {
+  }
+ }
+
+ private void handleWatchpointCreatedEvent( final ICDIWatchpoint watchpoint )
+ {
+  Runnable runnable = new Runnable()
+        {
+         public void run()
+         {
+          doHandleWatchpointCreatedEvent( watchpoint );
+         }
+
+        };
+  CDebugCorePlugin.getDefault().asyncExec( runnable );
+ }
+
+ protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint watchpoint )
+ {
+  if ( getBreakpoints().containsValue( watchpoint ) )
+   return;
+  try
+  {
+   CDebugModel.createWatchpoint( getExecFile().getProject(),
+            watchpoint.isWriteType(),
+            watchpoint.isReadType(),
+            watchpoint.getWatchExpression(),
+            watchpoint.isEnabled(),
+              watchpoint.getCondition().getIgnoreCount(),
+              watchpoint.getCondition().getExpression(),
+              watchpoint,
+              true );
+  }
+  catch( CDIException e )
+  {
+  }
+  catch( DebugException 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 )
+   {
+   }
+  }
+ }
+
  /**
   * Finds and returns the model thread for the associated CDI thread,
   * or <code>null</code> if not found.
@@ -1615,20 +1748,21 @@
 
  private void setLineBreakpoint( ICLineBreakpoint breakpoint ) throws DebugException
  {
-  ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
   try
   {
-   ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
-   ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
-   ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, condition, null );
-   if ( !getBreakpoints().containsKey( breakpoint ) )
+   ICDIBreakpoint cdiBreakpoint = ((CBreakpoint)breakpoint).getExternalBreakpoint();
+   if ( cdiBreakpoint == null )
+   {
+    setLineBreakpoint0( breakpoint );
+   }
+   else
    {
     getBreakpoints().put( breakpoint, cdiBreakpoint );
-    ((CBreakpoint)breakpoint).incrementInstallCount();
-    if ( !breakpoint.isEnabled() )
-    {
-     cdiBreakpoint.setEnabled( false );
-    }
+   }
+   ((CBreakpoint)breakpoint).incrementInstallCount();
+   if ( !breakpoint.isEnabled() )
+   {
+    cdiBreakpoint.setEnabled( false );
    }
   }
   catch( CoreException ce )
@@ -1640,23 +1774,33 @@
    requestFailed( "Operation failed. Reason: ", e );
   }
  }
+
+ private synchronized void setLineBreakpoint0( ICLineBreakpoint breakpoint ) throws CDIException, CoreException
+ {
+  ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
+  ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
+  ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
+  ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, condition, null );
+  getBreakpoints().put( breakpoint, cdiBreakpoint );
+ }
  
  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 ) )
+   ICDIBreakpoint cdiBreakpoint = ((CBreakpoint)breakpoint).getExternalBreakpoint();
+   if ( cdiBreakpoint == null )
+   {
+    setAddressBreakpoint0( breakpoint );
+   }
+   else
    {
     getBreakpoints().put( breakpoint, cdiBreakpoint );
-    ((CBreakpoint)breakpoint).incrementInstallCount();
-    if ( !breakpoint.isEnabled() )
-    {
-     cdiBreakpoint.setEnabled( false );
-    }
+   }
+   ((CBreakpoint)breakpoint).incrementInstallCount();
+   if ( !breakpoint.isEnabled() )
+   {
+    cdiBreakpoint.setEnabled( false );
    }
   }
   catch( CoreException ce )
@@ -1672,26 +1816,33 @@
    requestFailed( "Operation failed. Reason: ", e );
   }
  }
+  
+ private synchronized void setAddressBreakpoint0( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException
+ {
+  ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
+  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 );
+  getBreakpoints().put( breakpoint, cdiBreakpoint );
+ }
  
  private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException
  {
-  ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
   try
   {
-   ICDICondition condition = bm.createCondition( watchpoint.getIgnoreCount(), watchpoint.getCondition() );
-   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_, condition );
-   if ( !getBreakpoints().containsKey( watchpoint ) )
+   ICDIWatchpoint cdiWatchpoint = (ICDIWatchpoint)((CWatchpoint)watchpoint).getExternalBreakpoint();
+   if ( cdiWatchpoint == null )
+   {
+    setWatchpoint0( watchpoint );
+   }
+   else
    {
     getBreakpoints().put( watchpoint, cdiWatchpoint );
-    ((CBreakpoint)watchpoint).incrementInstallCount();
-    if ( !watchpoint.isEnabled() )
-    {
-     cdiWatchpoint.setEnabled( false );
-    }
+   }
+   ((CBreakpoint)watchpoint).incrementInstallCount();
+   if ( !watchpoint.isEnabled() )
+   {
+    cdiWatchpoint.setEnabled( false );
    }
   }
   catch( CoreException ce )
@@ -1702,6 +1853,18 @@
   {
    requestFailed( "Operation failed. Reason: ", e );
   }
+ }

+ private synchronized void setWatchpoint0( ICWatchpoint watchpoint ) throws CDIException, CoreException
+ {
+  ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
+  ICDICondition condition = bm.createCondition( watchpoint.getIgnoreCount(), watchpoint.getCondition() );
+  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_, condition );
+  getBreakpoints().put( watchpoint, cdiWatchpoint );
  }
  
  private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint )
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java,v
retrieving revision 1.7
diff -u -r1.7 CSourceLocator.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 6 Jan 2003 19:54:30 -0000 1.7
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 27 Jan 2003 22:23:51 -0000
@@ -216,4 +216,34 @@
   }
   return null;
  }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String)
+  */
+ public Object findSourceElement( String fileName )
+ {
+  Object result = null;
+  if ( fileName != null && fileName.length() > 0 )
+  {
+   result = findFileByAbsolutePath( fileName );
+   if ( result == null )
+   {
+    ICSourceLocation[] locations = getSourceLocations();
+    for ( int i = 0; i < locations.length; ++i )
+    {
+     try
+     {
+      result = locations[i].findSourceElement( fileName );
+     }
+     catch( CoreException e )
+     {
+      // do nothing
+     }
+     if ( result != null )
+      break;
+    }
+   }
+  }
+  return result;
+ }
 }
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java,v
retrieving revision 1.6
diff -u -r1.6 CSourceManager.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java 17 Dec 2002 19:56:22 -0000 1.6
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java 27 Jan 2003 22:23:51 -0000
@@ -190,4 +190,16 @@
   list.add( location );
   setSourceLocations( (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ) );
  }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String)
+  */
+ public Object findSourceElement( String fileName )
+ {
+  if ( getCSourceLocator() != null )
+  {
+   return getCSourceLocator().findSourceElement( fileName );
+  }
+  return null;
+ }
 }

Back to the top