1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bugs 216092 & 211533.

This commit is contained in:
Ken Ryall 2008-01-25 22:58:17 +00:00
parent 0b0508f728
commit ceb1b0efad
18 changed files with 679 additions and 169 deletions

View file

@ -4,6 +4,7 @@
<extension-point id="CDebugger" name="%CDebugger.name" schema="schema/CDebugger.exsd"/>
<extension-point id="BreakpointActionType" name="%BreakpointAction" schema="schema/BreakpointAction.exsd"/>
<extension-point id="BreakpointExtension" name="%BreakpointAction" schema="schema/BreakpointExtension.exsd"/>
<extension
id="cBreakpointMarker"
@ -201,5 +202,14 @@
</factory>
</extension>
<extension
point="org.eclipse.cdt.debug.core.BreakpointExtension">
<breakpointExtension
class="org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpointFilterExtension"
debugModelId="org.eclipse.cdt.debug.core"
id="org.eclipse.cdt.debug.core.filter"
markerType="org.eclipse.cdt.debug.core.cBreakpointMarker">
</breakpointExtension>
</extension>
</plugin>

View file

@ -0,0 +1,127 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.debug.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.debug.core" id="BreakpointExtension" name="BreakpointExtension"/>
</appInfo>
<documentation>
This extension point defines a mechanism for defining a debug model specific extension to C breakpoints.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="breakpointExtension" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
a fully qualified identifier of the target extension point
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
an optional identifier of the extension instance
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
an optional name of the extension instance
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="breakpointExtension">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
specifies a unique identifier for this breakpoint extension type.
</documentation>
</annotation>
</attribute>
<attribute name="markerType" type="string" use="required">
<annotation>
<documentation>
specifies the fully qualified identifier (id) of the corresponding marker definition for breakpoints that this extension applies to
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
specifies the fully qualified name of the Java class that implements &lt;code&gt;ICBreakpointExtension&lt;/code&gt;.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.core.model.ICBreakpointExtension"/>
</appInfo>
</annotation>
</attribute>
<attribute name="debugModelId" type="string" use="required">
<annotation>
<documentation>
specifies the fully qualified identifer (id) of the debug model that this extension applies to
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
The following is an example of a breakpoint extension extension point.
&lt;p&gt;
&lt;pre&gt;
&lt;extension point=&quot;org.eclipse.cdt.debug.BreakpointExtension&quot;&gt;
&lt;breakpointExtension
id=&quot;com.example.ExampleBreakpointExtension&quot;
markerType=&quot;com.example.ExampleBreakpointMarker&quot;
debugModeId=&quot;com.example.debug&quot;
class=&quot;com.example.BreakpointExtensionImpl&quot;&gt;
&lt;/breakpointExtension&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;/p&gt;
In the example above, the specified type of breakpoint extension is implemented by the class &quot;com.example.BreakpointExtensionImpl&quot;.
This extension is going to apply to breakpoints with markers extending &quot;com.example.ExampleBreakpointMarker&quot;, and to debug model with ID of &quot;com.example.debug&quot;.
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
Value of the attribute &lt;b&gt;class&lt;/b&gt; must be a fully qualified name of a Java class that implements the interface &lt;b&gt;org.eclipse.cdt.debug.core.model.ICBreakpointExtension&lt;/b&gt;, and which supplies a constructor with a single argument of type &lt;b&gt;org.eclipse.cdt.debug.core.model.ICBreakpoint&lt;/b&gt;.
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
Copyright (c) 2007 Wind River Systems and others.&lt;br&gt;
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
</documentation>
</annotation>
</schema>

View file

@ -83,6 +83,10 @@ public class CDebugCorePlugin extends Plugin {
public static final String BREAKPOINT_ACTION_EXTENSION_POINT_ID = "BreakpointActionType"; //$NON-NLS-1$
public static final String ACTION_TYPE_ELEMENT = "actionType"; //$NON-NLS-1$
public static final String BREAKPOINT_EXTENSION_EXTENSION_POINT_ID = "BreakpointExtension"; //$NON-NLS-1$
public static final String BREAKPOINT_EXTENSION_ELEMENT = "breakpointExtension"; //$NON-NLS-1$
/**
* Dummy source lookup director needed to manage common source containers.
*/

View file

@ -206,61 +206,13 @@ public interface ICBreakpoint extends IBreakpoint {
public void resetInstallCount() throws CoreException;
/**
* Add the given target to the list of this breakpoint's targets.
* Target filters are not persisted across workbench invocations.
* Returns a breakpoint extension registered for the given debug model
* and of the given type.
*
* @param target the target to add to the list of this breakpoint's targets.
* @throws CoreException if unable to set the target filter
* @param debugModelId Debug model ID of the extension.
* @param extensionType Type of the extension.
* @return Extension instance.
* @throws CoreException Throws exception in case the extension doesn't exist or cannot be initialized.
*/
public void setTargetFilter( ICDebugTarget target ) throws CoreException;
/**
* Removes the given target from the breakpoint's target list.
* The breakpoint has no effect in the given target.
*
* @param target the target filter to be removed
* @exception CoreException if unable to remove the target filter
*/
public void removeTargetFilter( ICDebugTarget target ) throws CoreException;
/**
* Restricts this breakpoint to suspend only in the given threads
* when encounterd in the given threads' target.
* All threads must be from the same target.
* Thread filters are not persisted across workbench invocations.
*
* @param threads the thread filters to be set
* @exception CoreException if unable to set the thread filters
*/
public void setThreadFilters( ICThread[] threads ) throws CoreException;
/**
* Returns all target filters set on this breakpoint.
*
* @return the targets that this breakpoint is resticted to
* @exception CoreException if unable to determine this breakpoint's
* target filters
*/
public ICDebugTarget[] getTargetFilters() throws CoreException;
/**
* Removes this breakpoint's thread filters in the given target, if any.
* Has no effect if this breakpoint does not have filters in the given target.
* All threads must be from the same target.
*
* @param threads the thread filters to be removed
* @exception CoreException if unable to remove the thread filter
*/
public void removeThreadFilters( ICThread[] threads ) throws CoreException;
/**
* Returns the threads in the given target in which this breakpoint
* is enabled or <code>null</code> if this breakpoint is enabled in
* all threads in the given target.
*
* @return the threads in the given target that this breakpoint is enabled for
* @exception CoreException if unable to determine this breakpoint's thread
* filters
*/
public ICThread[] getThreadFilters( ICDebugTarget target ) throws CoreException;
public ICBreakpointExtension getExtension(String debugModelId, Class extensionType) throws CoreException ;
}

View file

@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException;
/**
* An extension to {@link ICBreakpoint} with model-specific breakpoint
* attributes. Different debug models can use the standard C breakpoints that
* extend the basic <code>ICBreakpiont</code>. The can use this extension
* mechanism to edit and store model-specific data in the original breakpoint
* object.
*
* A breakpoint extension is defined by an extension of kind
* <code>"org.eclipse.cdt.debug.core.BreakpointExtension"</code></li>.
* The <code>ICBreakpoint</code> implementation instantiates breakpoint
* extensions registered for its specific marker type when a client requests
* extensions for a given debug model type. Thus the extension classes and
* plugins that declare them are not loaded unless requested by a client.
*
* @see ICBreakpoint#getExtension(String, Class)
*/
public interface ICBreakpointExtension {
/**
* Initializes the extension with the given breakpoint instance.
* The breakpoint extension may initialize its data using attributes
* stored in the breakpoint marker.
*
* @param breakpoint Breakpoint instance that this extension belongs to.
* @throws CoreException Thrown in case of errors reading the breakpoint
* marker.
*/
public void initialize(ICBreakpoint breakpoint) throws CoreException;
}

View file

@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Refactored from ICBreakpoint
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException;
/**
* Breakpoint extension to allow filtering based on CDTs extended standard debug
* model elements.
*/
public interface ICBreakpointFilterExtension extends ICBreakpointExtension {
/**
* Add the given target to the list of this breakpoint's targets.
* Target filters are not persisted across workbench invocations.
*
* @param target the target to add to the list of this breakpoint's targets.
* @throws CoreException if unable to set the target filter
*/
public void setTargetFilter( ICDebugTarget target ) throws CoreException;
/**
* Removes the given target from the breakpoint's target list.
* The breakpoint has no effect in the given target.
*
* @param target the target filter to be removed
* @exception CoreException if unable to remove the target filter
*/
public void removeTargetFilter( ICDebugTarget target ) throws CoreException;
/**
* Restricts this breakpoint to suspend only in the given threads
* when encounterd in the given threads' target.
* All threads must be from the same target.
* Thread filters are not persisted across workbench invocations.
*
* @param threads the thread filters to be set
* @exception CoreException if unable to set the thread filters
*/
public void setThreadFilters( ICThread[] threads ) throws CoreException;
/**
* Returns all target filters set on this breakpoint.
*
* @return the targets that this breakpoint is resticted to
* @exception CoreException if unable to determine this breakpoint's
* target filters
*/
public ICDebugTarget[] getTargetFilters() throws CoreException;
/**
* Removes this breakpoint's thread filters in the given target, if any.
* Has no effect if this breakpoint does not have filters in the given target.
* All threads must be from the same target.
*
* @param threads the thread filters to be removed
* @exception CoreException if unable to remove the thread filter
*/
public void removeThreadFilters( ICThread[] threads ) throws CoreException;
/**
* Returns the threads in the given target in which this breakpoint
* is enabled or <code>null</code> if this breakpoint is enabled in
* all threads in the given target.
*
* @return the threads in the given target that this breakpoint is enabled for
* @exception CoreException if unable to determine this breakpoint's thread
* filters
*/
public ICThread[] getThreadFilters( ICDebugTarget target ) throws CoreException;
}

View file

@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
@ -50,20 +51,21 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint2;
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.ICDITargetConfiguration;
import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint2;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointFilterExtension;
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.ICWatchpoint2;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointProblems;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
@ -329,7 +331,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
ICBreakpoint b = (ICBreakpoint)breakpoints[i];
boolean install = false;
try {
ICDebugTarget[] tfs = b.getTargetFilters();
ICDebugTarget[] tfs = getFilterExtension(b).getTargetFilters();
install = Arrays.asList( tfs ).contains( getDebugTarget() );
}
catch( CoreException e ) {
@ -484,7 +486,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
try {
BreakpointProblems.removeProblemsForResolvedBreakpoint(breakpoint, getDebugTarget().getInternalID());
breakpoint.setTargetFilter( getDebugTarget() );
getFilterExtension(breakpoint).setTargetFilter( getDebugTarget() );
((CBreakpoint)breakpoint).register( true );
}
catch( CoreException e ) {
@ -513,7 +515,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
if ( breakpoint != null ) {
try {
breakpoint.setTargetFilter( getDebugTarget() );
getFilterExtension(breakpoint).setTargetFilter( getDebugTarget() );
((CBreakpoint)breakpoint).register( true );
}
catch( CoreException e ) {
@ -532,8 +534,10 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
int newLineNumber = movedEvent.getNewLocation().getLineNumber();
int currLineNumber = breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, newLineNumber);
breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, newLineNumber);
fBreakpointProblems.add(BreakpointProblems.reportBreakpointMoved(
breakpoint, currLineNumber, newLineNumber, getDebugTarget().getName(), getDebugTarget().getInternalID()));
IMarker marker = BreakpointProblems.reportBreakpointMoved(
breakpoint, currLineNumber, newLineNumber, getDebugTarget().getName(), getDebugTarget().getInternalID());
if (marker != null)
fBreakpointProblems.add(marker);
} catch (CoreException e) {}
}
@ -612,7 +616,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
if ( breakpoint != null ) {
if ( isFilteredByTarget( breakpoint, getDebugTarget() ) ) {
try {
breakpoint.removeTargetFilter( getDebugTarget() );
getFilterExtension(breakpoint).removeTargetFilter( getDebugTarget() );
}
catch( CoreException e ) {
}
@ -665,7 +669,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
ICBreakpoint breakpoint = (ICBreakpoint) iter.next();
if ( isFilteredByTarget( breakpoint, target ) ) {
try {
breakpoint.removeTargetFilter( target );
getFilterExtension(breakpoint).removeTargetFilter( target );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e.getStatus() );
@ -724,7 +728,9 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
String fileName = breakpoint.getFileName();
ICDIFunctionLocation location = cdiTarget.createFunctionLocation( fileName, function );
ICDICondition condition = createCondition( breakpoint );
fBreakpointProblems.add(BreakpointProblems.reportUnresolvedBreakpoint(breakpoint, getDebugTarget().getName(), getDebugTarget().getInternalID()));
IMarker marker = BreakpointProblems.reportUnresolvedBreakpoint(breakpoint, getDebugTarget().getName(), getDebugTarget().getInternalID());
if (marker != null)
fBreakpointProblems.add(marker);
if (bpManager2 != null)
b = bpManager2.setFunctionBreakpoint( ICDIBreakpoint.REGULAR, location, condition, true, breakpoints[i].isEnabled() );
else
@ -798,7 +804,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
private String[] getThreadNames( ICBreakpoint breakpoint ) {
try {
ICThread[] threads = breakpoint.getThreadFilters( getDebugTarget() );
ICThread[] threads = getFilterExtension(breakpoint).getThreadFilters( getDebugTarget() );
if ( threads == null )
return new String[0];
String[] names = new String[threads.length];
@ -1205,7 +1211,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
private boolean isFilteredByTarget( ICBreakpoint breakpoint, ICDebugTarget target ) {
boolean result = false;
try {
ICDebugTarget[] tfs = breakpoint.getTargetFilters();
ICDebugTarget[] tfs = getFilterExtension(breakpoint).getTargetFilters();
result = Arrays.asList( tfs ).contains( target );
}
catch( CoreException e ) {
@ -1230,4 +1236,9 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
}
return false;
}
private ICBreakpointFilterExtension getFilterExtension(ICBreakpoint bp) throws CoreException{
return (ICBreakpointFilterExtension)bp.getExtension(
CDIDebugModel.getPluginIdentifier(), ICBreakpointFilterExtension.class);
}
}

View file

@ -124,10 +124,13 @@ public class BreakpointProblems {
lineBreakpoint.getMarker().getResource(),
lineBreakpoint.getLineNumber(), description, severity,
"")); //$NON-NLS-1$
if (marker != null)
{
marker.setAttribute(BREAKPOINT_PROBLEM_TYPE, problemType);
marker.setAttribute(BREAKPOINT_CONTEXT_NAME, contextName);
marker.setAttribute(BREAKPOINT_CONTEXT_ID, contextID);
}
}
return marker;
}
} catch (CoreException e) {

View file

@ -11,42 +11,50 @@
package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.model.Breakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* The base class for all C/C++ specific breakpoints.
*/
public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IDebugEventSetListener {
private Map fFilteredThreadsByTarget;
/**
* Map of breakpoint extensions. The keys to the map are debug model IDs
* and values are arrays of breakpoint extensions.
*/
private Map fExtensions = new HashMap(1);
/**
* Constructor for CBreakpoint.
*/
public CBreakpoint() {
fFilteredThreadsByTarget = new HashMap( 10 );
}
/**
* Constructor for CBreakpoint.
*/
@ -282,64 +290,6 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
return sb.toString();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getTargetFilters()
*/
public ICDebugTarget[] getTargetFilters() throws CoreException {
Set set = fFilteredThreadsByTarget.keySet();
return (ICDebugTarget[])set.toArray( new ICDebugTarget[set.size()] );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getThreadFilters(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public ICThread[] getThreadFilters( ICDebugTarget target ) throws CoreException {
Set set = (Set)fFilteredThreadsByTarget.get( target );
return ( set != null ) ? (ICThread[])set.toArray( new ICThread[set.size()] ) : null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public void removeTargetFilter( ICDebugTarget target ) throws CoreException {
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
fFilteredThreadsByTarget.remove( target );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[])
*/
public void removeThreadFilters( ICThread[] threads ) throws CoreException {
if ( threads != null && threads.length > 0 ) {
IDebugTarget target = threads[0].getDebugTarget();
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
Set set = (Set)fFilteredThreadsByTarget.get( target );
if ( set != null ) {
set.removeAll( Arrays.asList( threads ) );
if ( set.isEmpty() ) {
fFilteredThreadsByTarget.remove( target );
}
}
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public void setTargetFilter( ICDebugTarget target ) throws CoreException {
fFilteredThreadsByTarget.put( target, null );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[])
*/
public void setThreadFilters( ICThread[] threads ) throws CoreException {
if ( threads != null && threads.length > 0 ) {
fFilteredThreadsByTarget.put( threads[0].getDebugTarget(), new HashSet( Arrays.asList( threads ) ) );
}
}
/**
* Change notification when there are no marker changes. If the marker
@ -365,4 +315,65 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID
public void setModule( String module ) throws CoreException {
setAttribute( MODULE, module );
}
public ICBreakpointExtension getExtension(String debugModelId, Class extensionType) throws CoreException {
ICBreakpointExtension[] extensions = getExtensionsForModelId(debugModelId);
for (int i = 0; i < extensions.length; i++) {
if ( extensionType.isAssignableFrom(extensions[i].getClass()) ) {
return extensions[i];
}
}
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.ERROR, "Extension " + extensionType + " not defined for breakpoint " + this, null)); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Reads platform extension registry for breakpoint extensions registered
* for the given debug model.
* @param debugModelId Requested debug model that the extensions were
* registerd for.
* @return Breakpoint extensions.
* @throws CoreException Throws exception in case the breakpoint marker
* cannot be accessed.
*/
private ICBreakpointExtension[] getExtensionsForModelId(String debugModelId) throws CoreException {
if (!fExtensions.containsKey(debugModelId)) {
// Check to make sure that a marker is present. Extensions can only be created
// once the marker type is known.
IMarker marker = ensureMarker();
// Read the extension registry and create applicable extensions.
List extensions = new ArrayList(4);
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.BREAKPOINT_EXTENSION_EXTENSION_POINT_ID);
IConfigurationElement[] elements = ep.getConfigurationElements();
for (int i= 0; i < elements.length; i++) {
if ( elements[i].getName().equals(CDebugCorePlugin.BREAKPOINT_EXTENSION_ELEMENT) ) {
String elementDebugModelId = elements[i].getAttribute("debugModelId");
String elementMarkerType = elements[i].getAttribute("markerType");
if (elementDebugModelId == null) {
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: markerType", null)); //$NON-NLS-1$ //$NON-NLS-2$
} else if (elementMarkerType == null){
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: debugModelId", null)); //$NON-NLS-1$ //$NON-NLS-2$
} else if ( debugModelId.equals(elementDebugModelId) && marker.isSubtypeOf(elementMarkerType)) {
String className = elements[i].getAttribute("class");
if (className == null){
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: className", null)); //$NON-NLS-1$ //$NON-NLS-2$
} else {
ICBreakpointExtension extension;
try {
extension = (ICBreakpointExtension)elements[i].createExecutableExtension("class");
extension.initialize(this);
extensions.add(extension);
} catch (CoreException e) {
CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " contains an invalid value for attribute: className", e)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
}
}
fExtensions.put(debugModelId, extensions.toArray(new ICBreakpointExtension[extensions.size()]));
}
return (ICBreakpointExtension[])fExtensions.get(debugModelId);
}
}

View file

@ -0,0 +1,96 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointFilterExtension;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IDebugTarget;
/**
*
*/
public class CBreakpointFilterExtension implements ICBreakpointFilterExtension {
public void initialize(ICBreakpoint breakpoint) {
}
private Map fFilteredThreadsByTarget = new HashMap( 10 );
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getTargetFilters()
*/
public ICDebugTarget[] getTargetFilters() throws CoreException {
Set set = fFilteredThreadsByTarget.keySet();
return (ICDebugTarget[])set.toArray( new ICDebugTarget[set.size()] );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getThreadFilters(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public ICThread[] getThreadFilters( ICDebugTarget target ) throws CoreException {
Set set = (Set)fFilteredThreadsByTarget.get( target );
return ( set != null ) ? (ICThread[])set.toArray( new ICThread[set.size()] ) : null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public void removeTargetFilter( ICDebugTarget target ) throws CoreException {
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
fFilteredThreadsByTarget.remove( target );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[])
*/
public void removeThreadFilters( ICThread[] threads ) throws CoreException {
if ( threads != null && threads.length > 0 ) {
IDebugTarget target = threads[0].getDebugTarget();
if ( fFilteredThreadsByTarget.containsKey( target ) ) {
Set set = (Set)fFilteredThreadsByTarget.get( target );
if ( set != null ) {
set.removeAll( Arrays.asList( threads ) );
if ( set.isEmpty() ) {
fFilteredThreadsByTarget.remove( target );
}
}
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget)
*/
public void setTargetFilter( ICDebugTarget target ) throws CoreException {
fFilteredThreadsByTarget.put( target, null );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[])
*/
public void setThreadFilters( ICThread[] threads ) throws CoreException {
if ( threads != null && threads.length > 0 ) {
fFilteredThreadsByTarget.put( threads[0].getDebugTarget(), new HashSet( Arrays.asList( threads ) ) );
}
}
}

View file

@ -1033,14 +1033,12 @@
</adapt>
</enabledWhen>
</page>
<page
class="org.eclipse.cdt.debug.internal.ui.propertypages.CBreakpointFilteringPage"
<page class="org.eclipse.cdt.debug.internal.ui.propertypages.CBreakpointFilteringPage"
id="org.eclipse.cdt.debug.ui.propertypages.breakpoint.filtering"
name="%FilteringBreakpointPage.label">
<filter name="debugModelId" value="org.eclipse.cdt.debug.core"/>
<enabledWhen>
<adapt
type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
</adapt>
<adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint"/>
</enabledWhen>
</page>
<page

View file

@ -0,0 +1,136 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionFilter;
/**
* Input for breakpoint properties dialog. It captures both the
* selected breakpoint object as well as the selected debug context.
* This combined context can then be used by breakpoint property
* pages to access model and target specific breakpoint settings.
*/
public class CBreakpointContext extends PlatformObject {
// Register an adapter factory for the class when it is first loaded.
static {
Platform.getAdapterManager().registerAdapters(new CBreakpointContextAdapterFactory(), CBreakpointContext.class);
}
/**
* Breakpoint object held by this context.
*/
private final ICBreakpoint fBreakpoint;
/**
* The active debug context held by this context.
*/
private final ISelection fDebugContext;
/**
* Creates a new breakpoint context with given breakpoint and debbug
* context selection.
*/
public CBreakpointContext(ICBreakpoint breakpoint, ISelection debugContext) {
fBreakpoint = breakpoint;
fDebugContext = debugContext;
}
/**
* Returns the breakpoint.
*/
public ICBreakpoint getBreakpoint() { return fBreakpoint; }
/**
* Returns the debug context.
*/
public ISelection getDebugContext() { return fDebugContext; }
}
/**
* Action filter for the breakpoint context, which allows property
* pages to filter their activation based on the debug model ID of
* the active debug context.
*/
class CBreakpointContextActionFilter implements IActionFilter {
private static String[] EMPTY_IDENTIFIERS_ARRAY = new String[0];
public boolean testAttribute(Object target, String name, String value) {
if (target instanceof CBreakpointContext) {
if ("debugModelId".equals(name)) {
String[] targetModelIds = getDebugModelIds( (CBreakpointContext)target );
for (int i = 0; i < targetModelIds.length; i++) {
if (targetModelIds[i].equals(value)) {
return true;
}
}
}
}
return false;
}
private String[] getDebugModelIds(CBreakpointContext bpContext) {
ISelection debugContext = bpContext.getDebugContext();
if (debugContext instanceof IStructuredSelection) {
Object debugElement = ((IStructuredSelection)debugContext).getFirstElement();
if (debugElement instanceof IAdaptable) {
IDebugModelProvider debugModelProvider =
(IDebugModelProvider)((IAdaptable)debugElement).getAdapter(IDebugModelProvider.class);
if (debugModelProvider != null) {
return debugModelProvider.getModelIdentifiers();
} else if (debugElement instanceof IDebugElement) {
return new String[] { ((IDebugElement)debugElement).getModelIdentifier() };
}
}
}
return EMPTY_IDENTIFIERS_ARRAY;
}
}
/**
* Adapter factory which returns the breakpoint object and the action
* filter for the CBreakpointContext type.
*/
class CBreakpointContextAdapterFactory implements IAdapterFactory {
private static final Class[] fgAdapterList = new Class[] {
IBreakpoint.class, ICBreakpoint.class, IActionFilter.class
};
private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter();
public Object getAdapter(Object obj, Class adapterType) {
if (adapterType.isInstance( ((CBreakpointContext)obj).getBreakpoint() )) {
return ((CBreakpointContext)obj).getBreakpoint();
}
if (IActionFilter.class.equals(adapterType)) {
return fgActionFilter;
}
return null;
}
public Class[] getAdapterList() {
return fgAdapterList;
}
}

View file

@ -51,6 +51,8 @@ public interface ICDebugHelpContextIds {
public static final String SHOW_DETAIL_PANE_ACTION = PREFIX + "show_detail_pane_action_context"; //$NON-NLS-1$
public static final String CONFIGURE_COLUMNS_ACTION = PREFIX + "configure_columns_context"; //$NON-NLS-1$;
public static final String SHOW_COLUMNS_ACTION = PREFIX + "show_columns_context"; //$NON-NLS-1$;
public static final String MODULE_DETAIL_PANE_SELECT_ALL_ACTION = PREFIX + "module_detail_pane_select_all_action_context"; //$NON-NLS-1$
public static final String MODULE_DETAIL_PANE_COPY_ACTION = PREFIX + "detail_pane_copy_action_context"; //$NON-NLS-1$
// Views & Editors
/**
@ -59,6 +61,7 @@ public interface ICDebugHelpContextIds {
public static final String MEMORY_VIEW = PREFIX + "MemoryView_context"; //$NON-NLS-1$
public static final String SHARED_LIBRARIES_VIEW = PREFIX + "shared_libraries_view_context"; //$NON-NLS-1$
public static final String MODULES_VIEW = PREFIX + "modules_view_context"; //$NON-NLS-1$
public static final String MODULES_DETAIL_PANE = PREFIX + "modules_detail_pane"; //$NON-NLS-1$
public static final String SIGNALS_VIEW = PREFIX + "signals_view_context"; //$NON-NLS-1$
public static final String DISASSEMBLY_VIEW = PREFIX + "disassembly_view_context"; //$NON-NLS-1$
public static final String SOURCE_NOT_FOUND = PREFIX + "source_not_found"; //$NON-NLS-1$

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.internal.ui.CBreakpointContext;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@ -28,7 +30,7 @@ public class CBreakpointPropertiesAction implements IObjectActionDelegate {
private IWorkbenchPart fPart;
private ICBreakpoint fBreakpoint;
private ICBreakpoint fContext;
/**
* Constructor for CBreakpointPropertiesAction.
@ -54,7 +56,7 @@ public class CBreakpointPropertiesAction implements IObjectActionDelegate {
}
public ISelection getSelection() {
return new StructuredSelection( getBreakpoint() );
return new StructuredSelection( new CBreakpointContext(getBreakpoint(), getDebugContext()) );
}
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
@ -73,10 +75,12 @@ public class CBreakpointPropertiesAction implements IObjectActionDelegate {
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
if ( ss.isEmpty() || ss.size() > 1 ) {
action.setEnabled(false);
return;
}
Object element = ss.getFirstElement();
if ( element instanceof ICBreakpoint ) {
action.setEnabled(true);
setBreakpoint( (ICBreakpoint)element );
}
}
@ -87,10 +91,14 @@ public class CBreakpointPropertiesAction implements IObjectActionDelegate {
}
protected ICBreakpoint getBreakpoint() {
return fBreakpoint;
return fContext;
}
private ISelection getDebugContext() {
return DebugUITools.getDebugContextManager().getContextService(fPart.getSite().getWorkbenchWindow()).getActiveContext();
}
protected void setBreakpoint( ICBreakpoint breakpoint ) {
fBreakpoint = breakpoint;
fContext = breakpoint;
}
}

View file

@ -11,9 +11,12 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.internal.ui.CBreakpointContext;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@ -28,7 +31,7 @@ import org.eclipse.ui.dialogs.PropertyDialogAction;
*/
public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction {
private IBreakpoint fBreakpoint;
private Object fContext;
/**
* Creates the action to modify the breakpoint properties.
@ -44,14 +47,14 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
* @see Action#run()
*/
public void run() {
if ( fBreakpoint != null ) {
if ( fContext != null ) {
PropertyDialogAction action = new PropertyDialogAction( getTargetPart().getSite(), new ISelectionProvider() {
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
}
public ISelection getSelection() {
return new StructuredSelection( fBreakpoint );
return new StructuredSelection( fContext );
}
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
@ -69,7 +72,16 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
* @see IUpdate#update()
*/
public void update() {
fBreakpoint = getBreakpoint();
setEnabled( fBreakpoint != null );
IBreakpoint breakpoint = getBreakpoint();
if (breakpoint instanceof ICBreakpoint) {
fContext = new CBreakpointContext((ICBreakpoint)breakpoint, getDebugContext());
} else {
fContext = breakpoint;
}
setEnabled( fContext != null );
}
private ISelection getDebugContext() {
return DebugUITools.getDebugContextManager().getContextService(getTargetPart().getSite().getWorkbenchWindow()).getActiveContext();
}
}

View file

@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.propertypages;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointFilterExtension;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -37,7 +40,18 @@ public class CBreakpointFilteringPage extends PropertyPage {
}
public ICBreakpoint getBreakpoint() {
return (ICBreakpoint)getElement();
return (ICBreakpoint)getElement().getAdapter(ICBreakpoint.class);
}
public ICBreakpointFilterExtension getFilterExtension() {
ICBreakpoint bp = getBreakpoint();
if (bp != null) {
try {
return (ICBreakpointFilterExtension)bp.getExtension(
CDIDebugModel.getPluginIdentifier(), ICBreakpointFilterExtension.class);
} catch (CoreException e) {}
}
return null;
}
protected void createThreadFilterEditor( Composite parent ) {

View file

@ -394,7 +394,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
protected ICBreakpoint getBreakpoint() {
IAdaptable element = getElement();
return ( element instanceof ICBreakpoint ) ? (ICBreakpoint)element : null;
return ( element instanceof ICBreakpoint ) ? (ICBreakpoint)element : (ICBreakpoint)element.getAdapter(ICBreakpoint.class);
}
/* (non-Javadoc)

View file

@ -12,7 +12,8 @@ package org.eclipse.cdt.debug.internal.ui.propertypages;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointFilterExtension;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
@ -282,11 +283,11 @@ public class ThreadFilterEditor {
* checked.
*/
protected void setInitialCheckedState() {
ICBreakpoint breakpoint = fPage.getBreakpoint();
ICBreakpointFilterExtension filterExtension = fPage.getFilterExtension();
try {
ICDebugTarget[] targets = breakpoint.getTargetFilters();
ICDebugTarget[] targets = filterExtension.getTargetFilters();
for( int i = 0; i < targets.length; i++ ) {
ICThread[] filteredThreads = breakpoint.getThreadFilters( targets[i] );
ICThread[] filteredThreads = filterExtension.getThreadFilters( targets[i] );
if ( filteredThreads != null ) {
for ( int j = 0; j < filteredThreads.length; ++j )
fCheckHandler.checkThread( filteredThreads[j], true );
@ -302,7 +303,7 @@ public class ThreadFilterEditor {
}
protected void doStore() {
ICBreakpoint breakpoint = fPage.getBreakpoint();
ICBreakpointFilterExtension filterExtension = fPage.getFilterExtension();
IDebugTarget[] targets = getDebugTargets();
for ( int i = 0; i < targets.length; ++i ) {
if ( !(targets[i] instanceof ICDebugTarget) )
@ -311,16 +312,16 @@ public class ThreadFilterEditor {
if ( getThreadViewer().getChecked( targets[i] ) ) {
if ( getThreadViewer().getGrayed( targets[i] ) ) {
ICThread[] threads = getTargetThreadFilters( (ICDebugTarget)targets[i] );
breakpoint.setThreadFilters( threads );
filterExtension.setThreadFilters( threads );
}
else {
breakpoint.setTargetFilter( (ICDebugTarget)targets[i] );
filterExtension.setTargetFilter( (ICDebugTarget)targets[i] );
}
}
else {
breakpoint.removeTargetFilter( (ICDebugTarget)targets[i] );
filterExtension.removeTargetFilter( (ICDebugTarget)targets[i] );
}
DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged( breakpoint );
DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged( fPage.getBreakpoint() );
}
catch( CoreException e ) {
CDebugUIPlugin.log( e );