1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 360280 - [breakpoints] Reposition breakpoints when planted on invalid line

This commit is contained in:
Scott Tepavich 2012-01-31 21:21:26 -08:00 committed by Pawel Piech
parent eae1dbf5f8
commit b9255e88a5
16 changed files with 532 additions and 39 deletions

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2; import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
@ -269,6 +270,24 @@ public class CDIDebugModel {
attributes.put( ICBreakpoint.CONDITION, condition ); attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle ); attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpointType.TYPE, type ); attributes.put( ICBreakpointType.TYPE, type );
// Added for source relocated breakpoints.
if (!attributes.containsKey(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE)) {
attributes.put( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, sourceHandle );
}
if (!attributes.containsKey( ICLineBreakpoint2.REQUESTED_LINE )) {
attributes.put( ICLineBreakpoint2.REQUESTED_LINE, new Integer( lineNumber ));
}
if (attributes.containsKey(IMarker.CHAR_START) &&
!attributes.containsKey( ICLineBreakpoint2.REQUESTED_CHAR_START ))
{
attributes.put( ICLineBreakpoint2.REQUESTED_CHAR_START, attributes.get(IMarker.CHAR_START));
}
if (attributes.containsKey(IMarker.CHAR_END) &&
!attributes.containsKey( ICLineBreakpoint2.REQUESTED_CHAR_END ))
{
attributes.put( ICLineBreakpoint2.REQUESTED_CHAR_END, attributes.get(IMarker.CHAR_END));
}
} }
/** /**

View file

@ -396,7 +396,7 @@ public class CDebugUtils {
int lineNumber = breakpoint.getLineNumber(); int lineNumber = breakpoint.getLineNumber();
if (lineNumber > 0) { if (lineNumber > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), new String[]{ Integer.toString(lineNumber) })); //$NON-NLS-1$ label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), (Object[])new String[]{ Integer.toString(lineNumber) })); //$NON-NLS-1$
} }
return label; return label;
} }
@ -404,7 +404,7 @@ public class CDebugUtils {
protected static StringBuffer appendAddress(ICAddressBreakpoint breakpoint, StringBuffer label) throws CoreException { protected static StringBuffer appendAddress(ICAddressBreakpoint breakpoint, StringBuffer label) throws CoreException {
try { try {
label.append(' '); label.append(' ');
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), new String[]{ breakpoint.getAddress() })); //$NON-NLS-1$ label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), (Object[])new String[]{ breakpoint.getAddress() })); //$NON-NLS-1$
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
return label; return label;
@ -414,7 +414,7 @@ public class CDebugUtils {
String function = breakpoint.getFunction(); String function = breakpoint.getFunction();
if (function != null && function.trim().length() > 0) { if (function != null && function.trim().length() > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.2"), new String[]{ function.trim() })); //$NON-NLS-1$ label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.2"), (Object[])new String[]{ function.trim() })); //$NON-NLS-1$
} }
return label; return label;
} }
@ -423,7 +423,7 @@ public class CDebugUtils {
int ignoreCount = breakpoint.getIgnoreCount(); int ignoreCount = breakpoint.getIgnoreCount();
if (ignoreCount > 0) { if (ignoreCount > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), new String[]{ Integer.toString(ignoreCount) })); //$NON-NLS-1$ label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), (Object[])new String[]{ Integer.toString(ignoreCount) })); //$NON-NLS-1$
} }
return label; return label;
} }
@ -432,7 +432,7 @@ public class CDebugUtils {
String condition = breakpoint.getCondition(); String condition = breakpoint.getCondition();
if (condition != null && condition.length() > 0) { if (condition != null && condition.length() > 0) {
buffer.append(' '); buffer.append(' ');
buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), new String[] { condition })); //$NON-NLS-1$ buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), (Object[])new String[] { condition })); //$NON-NLS-1$
} }
} }
@ -440,7 +440,7 @@ public class CDebugUtils {
String expression = watchpoint.getExpression(); String expression = watchpoint.getExpression();
if (expression != null && expression.length() > 0) { if (expression != null && expression.length() > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.5"), new String[] { expression })); //$NON-NLS-1$ label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.5"), (Object[])new String[] { expression })); //$NON-NLS-1$
} }
} }
@ -448,7 +448,7 @@ public class CDebugUtils {
String memorySpace = watchpoint.getMemorySpace(); String memorySpace = watchpoint.getMemorySpace();
if (memorySpace != null && memorySpace.length() > 0) { if (memorySpace != null && memorySpace.length() > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.6"), new String[] { memorySpace })); //$NON-NLS-1$ label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.6"), (Object[])new String[] { memorySpace })); //$NON-NLS-1$
} }
} }
@ -456,7 +456,7 @@ public class CDebugUtils {
String range = watchpoint.getRange().toString(); String range = watchpoint.getRange().toString();
if (range.length() > 0 && !range.equals("0")) { //$NON-NLS-1$ if (range.length() > 0 && !range.equals("0")) { //$NON-NLS-1$
label.append(' '); label.append(' ');
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.7"), new String[]{ range })); //$NON-NLS-1$ label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.7"), (Object[])new String[]{ range })); //$NON-NLS-1$
} }
} }
@ -489,7 +489,7 @@ public class CDebugUtils {
if (typeString.length() > 0) { if (typeString.length() > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format( label.append(MessageFormat.format(
DebugCoreMessages.getString("CDebugUtils.8"), new String[] { typeString })); //$NON-NLS-1$ DebugCoreMessages.getString("CDebugUtils.8"), (Object[])new String[] { typeString })); //$NON-NLS-1$
} }
} }
return label; return label;

View file

@ -236,5 +236,5 @@ public interface ICBreakpoint extends IBreakpoint {
* @return Extension instance. * @return Extension instance.
* @throws CoreException Throws exception in case the extension doesn't exist or cannot be initialized. * @throws CoreException Throws exception in case the extension doesn't exist or cannot be initialized.
*/ */
public ICBreakpointExtension getExtension(String debugModelId, Class extensionType) throws CoreException ; public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) throws CoreException;
} }

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2012 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;
/**
* Extension that allows client to force breakpoint message to refresh.
*
* @since 7.2
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICBreakpoint2 extends ICBreakpoint {
/**
* Refresh the marker message for the breakpoint.
* <p>
* Many of breakpoint settings are backed by marker attributes and it is
* sometimes more convenient to modify those attributes in the marker
* directly rather than through accessor methods of the breakpoint. This
* method allows the client to force the breakpoint to refresh its
* {@link org.eclipse.core.resources.IMarker#MESSAGE} attribute to reflect
* its current attribute values.
* </p>
*
* @throws CoreException if unable to access the property
* on this breakpoint's underlying marker
*/
public void refreshMessage() throws CoreException;
}

View file

@ -0,0 +1,178 @@
/*******************************************************************************
* Copyright (c) 2012 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.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
/**
* Line breakpoint extension that allows a breakpoint to be relocated by a
* debugger to a valid source line.
* <p>Clients which can determine a valid source based on debuggers symbol
* information should call the various <code>setInstalled...</code> methods with
* the corrected location attributes. Note, there is no <code>setInstalledSourceHandle</code>,
* clients should call {@link ICBreakpoint#setSourceHandle(String)}. If multiple
* clients try to change the installed breakpoint location, the last call will
* take precedence. This way debuggers may update the location upon active debug
* context change. <br/>
* The original breakpoint location as configured by the user can always be
* retrieved using the <code>getRequested...</code> methods.
* </p>
* @since 7.2
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICLineBreakpoint2 extends ICLineBreakpoint, ICBreakpoint2 {
/**
* Breakpoint attribute storing the original requested line for this breakpoint
* This attribute is a <code>int</code>.
*/
public static final String REQUESTED_LINE = "requestedLine"; //$NON-NLS-1$
/**
* Breakpoint attribute storing the original requested column for this breakpoint
* This attribute is a <code>int</code>.
*/
public static final String REQUESTED_CHAR_START = "requestedCharStart"; //$NON-NLS-1$
/**
* Breakpoint attribute storing the original requested column for this breakpoint
* This attribute is a <code>int</code>.
*/
public static final String REQUESTED_CHAR_END = "requestedCharEnd"; //$NON-NLS-1$
/**
* Breakpoint attribute storing the original requested file name this breakpoint
* is set in.
* This attribute is a <code>String</code>.
*/
public static final String REQUESTED_SOURCE_HANDLE = "requestedSourceHandle"; //$NON-NLS-1$
/**
* Returns the line number where the breakpoint was set before it was relocated to a
* valid source line.
*
* @return Returns the requested line number attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public int getRequestedLine() throws CoreException;
/**
* Sets the line number where the breakpoint should be set.
*
* @param The requested line number attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public void setRequestedLine(int line) throws CoreException;
/**
* Returns starting source index where the breakpoint was set before it
* was moved to a valid source location.
*
* @return Returns the requested start index attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public int getRequestedCharStart() throws CoreException;
/**
* Sets the starting source index where the breakpoint should be set.
*
* @param The requested start index attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public void setRequestedCharStart(int charStart) throws CoreException;
/**
* Returns ending source index where the breakpoint was set before it
* was moved to a valid source location.
*
* @return Returns the requested end index attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public int getRequestedCharEnd() throws CoreException;
/**
* Sets the staring source index where the breakpoint should be set.
*
* @param The requested end index attribute.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public void setRequestedCharEnd(int charEnd) throws CoreException;
/**
* Returns the file name where the breakpoint was set before it was relocated to a
* valid file.
*
* @return Returns the requested file name.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public String getRequestedSourceHandle() throws CoreException;
/**
* Sets the file name where the breakpoint should be set. May be an empty string
* if the file is not known.
*
* @param Requested file name.
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public void setRequestedSourceHandle(String fileName) throws CoreException;
/**
* Sets the line number where the breakpoint is actually installed. This
* method only updates the {@link IMarker#LINE_NUMBER} attribute and the
* breakpoint message.
*
* @param line Installed line number
* @throws CoreException if unable to access the property
* on this breakpoint's underlying marker
*/
public void setInstalledLineNumber(int line) throws CoreException;
/**
* Sets the start index where the breakpoint is actually installed. This method
* only updates the {@link IMarker#CHAR_START} attribute and the breakpoint
* message.
*
* @param charStart Installed char start
* @throws CoreException
*/
public void setInstalledCharStart(int charStart) throws CoreException;
/**
* Sets the end index where the breakpoint is actually installed. This method
* only updates the {@link IMarker#CHAR_END} attribute and the breakpoint
* message.
*
* @param charEnd Installed char start
* @throws CoreException
*/
public void setInstalledCharEnd(int charStart) throws CoreException;
/**
* Resets the breakpoint location back to the values specified by the
* REQUESTED_* attributes. This operation should be called automatically
* by the implementation when the install count is reset to 0, and does
* not need to be called by the client at that time.
*
* @throws CoreException
*/
public void resetInstalledLocation() throws CoreException;
}

View file

@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -23,7 +24,7 @@ import org.eclipse.core.runtime.Path;
/** /**
* Base class for different types of location breakponts. * Base class for different types of location breakponts.
*/ */
public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLineBreakpoint2 {
/** /**
* Constructor for AbstractLineBreakpoint. * Constructor for AbstractLineBreakpoint.
@ -41,7 +42,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi
* @param add * @param add
* @throws CoreException * @throws CoreException
*/ */
public AbstractLineBreakpoint( IResource resource, String markerType, Map attributes, boolean add ) throws CoreException { public AbstractLineBreakpoint( IResource resource, String markerType, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, markerType, attributes, add ); super( resource, markerType, attributes, add );
} }
@ -110,4 +111,114 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi
public void setFunction( String function ) throws CoreException { public void setFunction( String function ) throws CoreException {
setAttribute( ICLineBreakpoint.FUNCTION, function ); setAttribute( ICLineBreakpoint.FUNCTION, function );
} }
@Override
public int getRequestedLine() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_LINE, -1 );
}
@Override
public void setRequestedLine(int line) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_LINE, line );
}
@Override
public int getRequestedCharStart() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, -1 );
}
@Override
public void setRequestedCharStart(int charStart) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, charStart );
}
@Override
public int getRequestedCharEnd() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, -1 );
}
@Override
public void setRequestedCharEnd(int charEnd) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd );
}
@Override
public String getRequestedSourceHandle() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, "" ); //$NON-NLS-1$
}
@Override
public void setRequestedSourceHandle(String fileName) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName );
}
@Override
public synchronized int decrementInstallCount() throws CoreException {
int count = super.decrementInstallCount();
if (count == 0) {
resetInstalledLocation();
}
return count;
}
@Override
public void setInstalledLineNumber(int line) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
if (line != existingValue) {
setAttribute(IMarker.LINE_NUMBER, line);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void setInstalledCharStart(int charStart) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1);
if (charStart != existingValue) {
setAttribute(IMarker.CHAR_START, charStart);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void setInstalledCharEnd(int charEnd) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1);
if (charEnd != existingValue) {
setAttribute(IMarker.CHAR_END, charEnd);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void resetInstalledLocation() throws CoreException {
boolean locationReset = false;
if (this.getMarker().getAttribute(REQUESTED_LINE) != null) {
int line = this.getMarker().getAttribute(REQUESTED_LINE, -1);
setAttribute(IMarker.LINE_NUMBER, line);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) {
int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1);
setAttribute(IMarker.CHAR_START, charStart);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) {
int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1);
setAttribute(IMarker.CHAR_END, charEnd);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) {
String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$
setAttribute(ICBreakpoint.SOURCE_HANDLE, file);
locationReset = true;
}
if (locationReset) {
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void refreshMessage() throws CoreException {
IMarker marker = ensureMarker();
marker.setAttribute(IMarker.MESSAGE, getMarkerMessage());
}
} }

View file

@ -25,6 +25,8 @@ CFunctionTracepoint.0=Function tracepoint: {0}
# The marker message of a line breakpoint. # The marker message of a line breakpoint.
CLineBreakpoint.0=Line breakpoint: {0} CLineBreakpoint.0=Line breakpoint: {0}
# The marker message of a relocated line breakpoint.
CLineBreakpoint.1=Line breakpoint (relocated): {0}
# The marker message of a line tracepoint. # The marker message of a line tracepoint.
CLineTracepoint.0=Line tracepoint: {0} CLineTracepoint.0=Line tracepoint: {0}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import com.ibm.icu.text.MessageFormat; import com.ibm.icu.text.MessageFormat;
/** /**
@ -34,7 +35,7 @@ public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddr
/** /**
* Constructor for CAddressBreakpoint. * Constructor for CAddressBreakpoint.
*/ */
public CAddressBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException { public CAddressBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
@ -52,6 +53,6 @@ public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddr
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ return MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
} }
} }

View file

@ -56,6 +56,6 @@ public class CAddressTracepoint extends AbstractTracepoint implements ICAddressB
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CAddressTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ return MessageFormat.format( BreakpointMessages.getString( "CAddressTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
} }
} }

View file

@ -48,7 +48,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
* Map of breakpoint extensions. The keys to the map are debug model IDs * Map of breakpoint extensions. The keys to the map are debug model IDs
* and values are arrays of breakpoint extensions. * and values are arrays of breakpoint extensions.
*/ */
private Map fExtensions = new HashMap(1); private Map<String, ICBreakpointExtension[]> fExtensions = new HashMap<String, ICBreakpointExtension[]>(1);
/** /**
* The number of debug targets the breakpoint is installed in. We don't use * The number of debug targets the breakpoint is installed in. We don't use
@ -67,7 +67,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
/** /**
* Constructor for CBreakpoint. * Constructor for CBreakpoint.
*/ */
public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws CoreException { public CBreakpoint( final IResource resource, final String markerType, final Map<String, Object> attributes, final boolean add ) throws CoreException {
this(); this();
IWorkspaceRunnable wr = new IWorkspaceRunnable() { IWorkspaceRunnable wr = new IWorkspaceRunnable() {
@ -86,7 +86,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
run( wr ); run( wr );
} }
public void createMarker( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws DebugException { public void createMarker( final IResource resource, final String markerType, final Map<String, Object> attributes, final boolean add ) throws DebugException {
IWorkspaceRunnable wr = new IWorkspaceRunnable() { IWorkspaceRunnable wr = new IWorkspaceRunnable() {
@Override @Override
public void run( IProgressMonitor monitor ) throws CoreException { public void run( IProgressMonitor monitor ) throws CoreException {
@ -338,11 +338,11 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
int ignoreCount = getIgnoreCount(); int ignoreCount = getIgnoreCount();
if ( ignoreCount > 0 ) { if ( ignoreCount > 0 ) {
sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.1" ), new Integer[] { new Integer( ignoreCount ) } ) ); //$NON-NLS-1$ sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.1" ), new Object[] { new Integer( ignoreCount ) } ) ); //$NON-NLS-1$
} }
String condition = getCondition(); String condition = getCondition();
if ( condition != null && condition.length() > 0 ) { if ( condition != null && condition.length() > 0 ) {
sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.2" ), new String[] { condition } ) ); //$NON-NLS-1$ sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.2" ), new Object[] { condition } ) ); //$NON-NLS-1$
} }
return sb.toString(); return sb.toString();
} }
@ -376,11 +376,13 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
} }
@Override @Override
public ICBreakpointExtension getExtension(String debugModelId, Class extensionType) throws CoreException { public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) throws CoreException {
ICBreakpointExtension[] extensions = getExtensionsForModelId(debugModelId); ICBreakpointExtension[] extensions = getExtensionsForModelId(debugModelId);
for (int i = 0; i < extensions.length; i++) { for (int i = 0; i < extensions.length; i++) {
if ( extensionType.isAssignableFrom(extensions[i].getClass()) ) { if ( extensionType.isAssignableFrom(extensions[i].getClass()) ) {
return extensions[i]; @SuppressWarnings("unchecked")
V retVal = (V) extensions[i];
return retVal;
} }
} }
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$ 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$
@ -402,7 +404,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
IMarker marker = ensureMarker(); IMarker marker = ensureMarker();
// Read the extension registry and create applicable extensions. // Read the extension registry and create applicable extensions.
List extensions = new ArrayList(4); List<ICBreakpointExtension> extensions = new ArrayList<ICBreakpointExtension>(4);
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.BREAKPOINT_EXTENSION_EXTENSION_POINT_ID); IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.BREAKPOINT_EXTENSION_EXTENSION_POINT_ID);
IConfigurationElement[] elements = ep.getConfigurationElements(); IConfigurationElement[] elements = ep.getConfigurationElements();
for (int i= 0; i < elements.length; i++) { for (int i= 0; i < elements.length; i++) {
@ -432,7 +434,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IC
} }
fExtensions.put(debugModelId, extensions.toArray(new ICBreakpointExtension[extensions.size()])); fExtensions.put(debugModelId, extensions.toArray(new ICBreakpointExtension[extensions.size()]));
} }
return (ICBreakpointExtension[])fExtensions.get(debugModelId); return fExtensions.get(debugModelId);
} }

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import com.ibm.icu.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
@ -18,6 +17,8 @@ import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import com.ibm.icu.text.MessageFormat;
/** /**
* A breakpoint that suspends the execution when a function is entered. * A breakpoint that suspends the execution when a function is entered.
*/ */
@ -34,7 +35,7 @@ public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFun
/** /**
* Constructor for CFunctionBreakpoint. * Constructor for CFunctionBreakpoint.
*/ */
public CFunctionBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException { public CFunctionBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
@ -50,6 +51,6 @@ public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFun
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ return MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
} }
} }

View file

@ -54,6 +54,6 @@ public class CFunctionTracepoint extends AbstractTracepoint implements ICFunctio
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CFunctionTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ return MessageFormat.format( BreakpointMessages.getString( "CFunctionTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
} }
} }

View file

@ -14,6 +14,9 @@ import com.ibm.icu.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -34,7 +37,7 @@ public class CLineBreakpoint extends AbstractLineBreakpoint {
/** /**
* Constructor for CLineBreakpoint. * Constructor for CLineBreakpoint.
*/ */
public CLineBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException { public CLineBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
@ -50,6 +53,27 @@ public class CLineBreakpoint extends AbstractLineBreakpoint {
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ IMarker marker = this.getMarker();
int bp_line = 0;
int bp_request_line = 0;
String bp_file = null;
String bp_reqest_file = null;
if (marker != null) {
bp_line = marker.getAttribute(IMarker.LINE_NUMBER, -1);
bp_request_line = marker.getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1);
bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String)null);
bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String)null);
}
if (bp_line != bp_request_line ||
(bp_file == null && bp_reqest_file != null) ||
(bp_file != null && !bp_file.equals(bp_reqest_file)) )
{
return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.1" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
}
else {
return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
}
} }
} }

View file

@ -13,7 +13,10 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICTracepoint; import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -24,7 +27,7 @@ import com.ibm.icu.text.MessageFormat;
* *
* @since 6.1 * @since 6.1
*/ */
public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint { public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint, ICLineBreakpoint2 {
private static final String C_LINE_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineTracepointMarker"; //$NON-NLS-1$ private static final String C_LINE_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineTracepointMarker"; //$NON-NLS-1$
@ -48,11 +51,121 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint
return C_LINE_TRACEPOINT_MARKER; return C_LINE_TRACEPOINT_MARKER;
} }
@Override
public synchronized int decrementInstallCount() throws CoreException {
int count = super.decrementInstallCount();
if (count == 0) {
resetInstalledLocation();
}
return count;
}
/*(non-Javadoc) /*(non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
@Override @Override
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
return MessageFormat.format( BreakpointMessages.getString( "CLineTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ return MessageFormat.format( BreakpointMessages.getString( "CLineTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
} }
@Override
public int getRequestedLine() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_LINE, -1 );
}
@Override
public void setRequestedLine(int line) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_LINE, line );
}
@Override
public int getRequestedCharStart() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, -1 );
}
@Override
public void setRequestedCharStart(int charStart) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, charStart );
}
@Override
public int getRequestedCharEnd() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, -1 );
}
@Override
public void setRequestedCharEnd(int charEnd) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd );
}
@Override
public String getRequestedSourceHandle() throws CoreException {
return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, "" ); //$NON-NLS-1$
}
@Override
public void setRequestedSourceHandle(String fileName) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName );
}
@Override
public void setInstalledLineNumber(int line) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
if (line != existingValue) {
setAttribute(IMarker.LINE_NUMBER, line);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void setInstalledCharStart(int charStart) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1);
if (charStart != existingValue) {
setAttribute(IMarker.CHAR_START, charStart);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void setInstalledCharEnd(int charEnd) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1);
if (charEnd != existingValue) {
setAttribute(IMarker.CHAR_END, charEnd);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void resetInstalledLocation() throws CoreException {
boolean locationReset = false;
if (this.getMarker().getAttribute(REQUESTED_LINE) != null) {
int line = this.getMarker().getAttribute(REQUESTED_LINE, -1);
setAttribute(IMarker.LINE_NUMBER, line);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) {
int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1);
setAttribute(IMarker.CHAR_START, charStart);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) {
int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1);
setAttribute(IMarker.CHAR_END, charEnd);
locationReset = true;
}
if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) {
String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$
setAttribute(ICBreakpoint.SOURCE_HANDLE, file);
locationReset = true;
}
if (locationReset) {
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@Override
public void refreshMessage() throws CoreException {
IMarker marker = ensureMarker();
marker.setAttribute(IMarker.MESSAGE, getMarkerMessage());
}
} }

View file

@ -36,11 +36,11 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 {
/** /**
* Constructor for CWatchpoint. * Constructor for CWatchpoint.
*/ */
public CWatchpoint( IResource resource, Map attributes, boolean add ) throws CoreException { public CWatchpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
protected CWatchpoint( IResource resource, String marker, Map attributes, boolean add ) throws CoreException { protected CWatchpoint( IResource resource, String marker, Map<String, Object> attributes, boolean add ) throws CoreException {
super( resource, marker, attributes, add ); super( resource, marker, attributes, add );
} }
@ -87,7 +87,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 {
format = BreakpointMessages.getString( "CWatchpoint.1" ); //$NON-NLS-1$ format = BreakpointMessages.getString( "CWatchpoint.1" ); //$NON-NLS-1$
else if ( isWriteType() && isReadType() ) else if ( isWriteType() && isReadType() )
format = BreakpointMessages.getString( "CWatchpoint.2" ); //$NON-NLS-1$ format = BreakpointMessages.getString( "CWatchpoint.2" ); //$NON-NLS-1$
return MessageFormat.format( format, new String[] { CDebugUtils.getBreakpointText( this, false ) } ); return MessageFormat.format( format, new Object[] { CDebugUtils.getBreakpointText( this, false ) } );
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory; import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory;
@ -424,12 +425,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
fElement = element; fElement = element;
} }
@Override @Override
public IPreferenceStore getPreferenceStore() { public IPreferenceStore getPreferenceStore() {
return fCBreakpointPreferenceStore; return fCBreakpointPreferenceStore;
} }
@Override @Override
public boolean performOk() { public boolean performOk() {
final List changedProperties = new ArrayList( 5 ); final List changedProperties = new ArrayList( 5 );
getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() { getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() {
@ -437,7 +438,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
/** /**
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/ */
@Override @Override
public void propertyChange( PropertyChangeEvent event ) { public void propertyChange( PropertyChangeEvent event ) {
changedProperties.add( event.getProperty() ); changedProperties.add( event.getProperty() );
} }
@ -450,7 +451,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
protected void setBreakpointProperties( final List changedProperties ) { protected void setBreakpointProperties( final List changedProperties ) {
IWorkspaceRunnable wr = new IWorkspaceRunnable() { IWorkspaceRunnable wr = new IWorkspaceRunnable() {
@Override @Override
public void run( IProgressMonitor monitor ) throws CoreException { public void run( IProgressMonitor monitor ) throws CoreException {
ICBreakpoint breakpoint = getBreakpoint(); ICBreakpoint breakpoint = getBreakpoint();
Iterator changed = changedProperties.iterator(); Iterator changed = changedProperties.iterator();
@ -468,6 +469,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
else if ( property.equals( CBreakpointPreferenceStore.LINE ) ) { else if ( property.equals( CBreakpointPreferenceStore.LINE ) ) {
// already workspace runnable, setting markers are safe // already workspace runnable, setting markers are safe
breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getPreferenceStore().getInt(CBreakpointPreferenceStore.LINE)); breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getPreferenceStore().getInt(CBreakpointPreferenceStore.LINE));
breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, getPreferenceStore().getInt(CBreakpointPreferenceStore.LINE));
} else { } else {
// this allow set attributes contributed by other plugins // this allow set attributes contributed by other plugins
String value = getPropertyAsString(property); String value = getPropertyAsString(property);
@ -483,6 +485,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
CDebugUIPlugin.log( ce ); CDebugUIPlugin.log( ce );
} }
} }
/** /**
* Creates field editors contributed using breakpointUIContribution extension point * Creates field editors contributed using breakpointUIContribution extension point
* @param breakpoint * @param breakpoint