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

Implementing retargettable breakpoint related actions.

This commit is contained in:
Mikhail Khodjaiants 2004-04-12 22:33:55 +00:00
parent 9494a0f14e
commit 2a72346aa5
31 changed files with 1536 additions and 1819 deletions

View file

@ -1,3 +1,23 @@
2004-04-12 Mikhail Khodjaiants
Implementing retargettable breakpoint related actions.
* CDebugModel.java
* CDIDebugModel.java
* ICAddressBreakpoint.java
* ICBreakpoint.java
* ICFunctionBreakpoint.java
* ICLineBreakpoint.java
* ICWatchpoint.java
* CBreakpointManager.java
* CDebugUtils.java
* BreakpointMessages.properties
* BreakpointMessages.java
* CAddressBreakpoint.java
* CBreakpoint.java
* CFunctionBreakpoint.java
* CLineBreakpoint.java
* CWatchpoint.java
* plugin.xml
2004-04-11 Mikhail Khodjaiants 2004-04-11 Mikhail Khodjaiants
Stack frame should provide an adapter for IRunToLine. Stack frame should provide an adapter for IRunToLine.
* CStackFrame.java * CStackFrame.java

View file

@ -43,6 +43,9 @@
<attribute <attribute
name="org.eclipse.cdt.debug.core.installCount"> name="org.eclipse.cdt.debug.core.installCount">
</attribute> </attribute>
<attribute
name="org.eclipse.cdt.debug.core.sourceHandle">
</attribute>
</extension> </extension>
<extension <extension
id="commonCLineBreakpointMarker" id="commonCLineBreakpointMarker"

View file

@ -1,16 +1,36 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
/** /**
* Provides utility methods for creating debug sessions, targets and * Provides utility methods for creating debug sessions, targets and
* breakpoints specific to the CDI debug model. * breakpoints specific to the CDI debug model.
*
* @since: Feb 23, 2004
*/ */
public class CDIDebugModel { public class CDIDebugModel {
/** /**
@ -21,4 +41,312 @@ public class CDIDebugModel {
public static String getPluginIdentifier() { public static String getPluginIdentifier() {
return CDebugCorePlugin.getUniqueIdentifier(); return CDebugCorePlugin.getUniqueIdentifier();
} }
/**
* Creates and returns a line breakpoint for the source defined by
* the given source handle, at the given line number. The marker associated
* with the breakpoint will be created on the specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param lineNumber the line number on which the breakpoint is set - line
* numbers are 1 based, associated with the source file in which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return a line breakpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICLineBreakpoint createLineBreakpoint( String sourceHandle,
IResource resource,
int lineNumber,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CLineBreakpoint( resource, attributes, register );
}
/**
* Creates and returns an address breakpoint for the source defined by
* the given source handle, at the given address. The marker associated
* with the breakpoint will be created on the specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param address the address on which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICAddressBreakpoint createAddressBreakpoint( String sourceHandle,
IResource resource,
long address,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.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( IMarker.LINE_NUMBER, new Integer( -1 ) );
attributes.put( ICAddressBreakpoint.ADDRESS, Long.toString( address ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CAddressBreakpoint( resource, attributes, register );
}
/**
* Creates and returns a watchpoint for the source defined by
* the given source handle, at the given expression. The marker associated
* with the watchpoint will be created on the specified resource.
*
* @param sourceHandle the handle to the watchpoint source
* @param resource the resource on which to create the associated watchpoint marker
* @param writeAccess whether this is write watchpoint
* @param readAccess whether this is read watchpoint
* @param expression the expression on which the watchpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return a watchpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICWatchpoint createWatchpoint( String sourceHandle,
IResource resource,
boolean writeAccess,
boolean readAccess,
String expression,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICWatchpoint.EXPRESSION, expression );
attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) );
attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) );
return new CWatchpoint( resource, attributes, register );
}
/**
* Creates and returns a breakpoint for the function defined by
* the given name. The marker associated with the breakpoint will
* be created on the specified resource.
*
* @param sourceHandle the handle to the breakpoint source
* @param resource the resource on which to create the associated breakpoint marker
* @param function the name of the function this breakpoint suspends execution in
* @param charStart the first character index associated with the breakpoint,
* or -1 if unspecified, in the source file in which the breakpoint is set
* @param charEnd the last character index associated with the breakpoint,
* or -1 if unspecified, in the source file in which the breakpoint is set
* @param lineNumber the lineNumber on which the breakpoint is set, or -1 if
* unspecified - line numbers are 1 based, associated with the source file
* in which the breakpoint is set
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
* @param register whether to add this breakpoint to the breakpoint manager
* @return an address breakpoint
* @throws CoreException if this method fails. Reasons include:<ul>
* <li>Failure creating underlying marker. The exception's status contains
* the underlying exception responsible for the failure.</li></ul>
*/
public static ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle,
IResource resource,
String function,
int charStart,
int charEnd,
int lineNumber,
boolean enabled,
int ignoreCount,
String condition,
boolean register ) throws CoreException {
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICFunctionBreakpoint.FUNCTION, function );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
return new CFunctionBreakpoint( resource, attributes, register );
}
/**
* Returns the line breakpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the
* given line number.
*
* @param sourceHandle the source handle
* @param resource the breakpoint resource
* @param lineNumber the line number
* @return the line breakpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such breakpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CLineBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
if ( !(breakpoints[i] instanceof ICLineBreakpoint) ) {
continue;
}
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
if ( breakpoint.getLineNumber() == lineNumber ) {
return breakpoint;
}
}
}
}
}
return null;
}
/**
* Returns the address breakpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the
* given address.
*
* @param sourceHandle the source handle
* @param resource the breakpoint resource
* @param address the address
* @return the address breakpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such breakpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICAddressBreakpoint addressBreakpointExists( String sourceHandle, IResource resource, long address ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CAddressBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
if ( !(breakpoints[i] instanceof ICAddressBreakpoint) ) {
continue;
}
ICAddressBreakpoint breakpoint = (ICAddressBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
try {
if ( Long.parseLong( breakpoint.getAddress() ) == address ) {
return breakpoint;
}
}
catch( NumberFormatException e ) {
}
}
}
}
}
return null;
}
/**
* Returns the watchpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the
* given expression.
*
* @param sourceHandle the source handle
* @param resource the breakpoint resource
* @param expression the expression
* @return the watchpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such watchpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICWatchpoint watchpointExists( String sourceHandle, IResource resource, String expression ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CWatchpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
if ( !(breakpoints[i] instanceof ICWatchpoint) ) {
continue;
}
ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
if ( breakpoint.getExpression().equals( expression ) ) {
return breakpoint;
}
}
}
}
}
return null;
}
/**
* Returns the function breakpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource with the
* given function name.
*
* @param sourceHandle the source handle
* @param resource the breakpoint resource
* @param function the fully qualified function name
* @return the breakpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such breakpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICFunctionBreakpoint functionBreakpointExists( String sourceHandle, IResource resource, String function ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CFunctionBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
if ( !(breakpoints[i] instanceof ICFunctionBreakpoint) ) {
continue;
}
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( function ) ) {
return breakpoint;
}
}
}
}
}
return null;
}
} }

View file

@ -264,287 +264,6 @@ public class CDebugModel
return target[0]; return target[0];
} }
/**
* Returns a C/C++ line breakpoint that is already registered with the breakpoint
* manager for a file with the given name at the given line number.
*
* @param fileName fully qualified file name
* @param lineNumber line number
* @return a C/C++ line breakpoint that is already registered with the breakpoint
* manager for a file with the given name at the given line number or <code>null</code>
* if no such breakpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICLineBreakpoint lineBreakpointExists( String fileName, int lineNumber ) throws CoreException
{
String modelId = getPluginIdentifier();
String markerType = CLineBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for ( int i = 0; i < breakpoints.length; i++ )
{
if ( !( breakpoints[i] instanceof ICLineBreakpoint ) )
{
continue;
}
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) )
{
if ( breakpoint.getMarker().getResource().getLocation().toOSString().equals( fileName ) )
{
if ( breakpoint.getLineNumber() == lineNumber )
{
return breakpoint;
}
}
}
}
return null;
}
public static ICLineBreakpoint createLineBreakpoint( IResource resource,
int lineNumber,
boolean enabled,
int ignoreCount,
String condition,
boolean add ) throws DebugException
{
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
return new CLineBreakpoint( resource, attributes, add );
}
public static ICAddressBreakpoint addressBreakpointExists( IResource resource, long address ) throws CoreException
{
String modelId = getPluginIdentifier();
String markerType = CAddressBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for ( int i = 0; i < breakpoints.length; i++ )
{
if ( !( breakpoints[i] instanceof ICAddressBreakpoint ) )
{
continue;
}
ICAddressBreakpoint breakpoint = (ICAddressBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) )
{
if ( breakpoint.getMarker().getResource().getLocation().toOSString().equals( resource.getLocation().toOSString() ) )
{
try
{
if ( Long.parseLong( breakpoint.getAddress() ) == address )
{
return breakpoint;
}
}
catch( NumberFormatException e )
{
}
}
}
}
return null;
}
public static ICAddressBreakpoint createAddressBreakpoint( IResource resource,
long address,
boolean enabled,
int ignoreCount,
String condition,
boolean add ) throws DebugException
{
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.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( IMarker.LINE_NUMBER, new Integer( -1 ) );
attributes.put( ICAddressBreakpoint.ADDRESS, Long.toString( address ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
return new CAddressBreakpoint( resource, attributes, add );
}
public static ICFunctionBreakpoint functionBreakpointExists( IFunction function ) throws CoreException
{
String modelId = getPluginIdentifier();
String markerType = CFunctionBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for ( int i = 0; i < breakpoints.length; i++ )
{
if ( !( breakpoints[i] instanceof ICFunctionBreakpoint ) )
{
continue;
}
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) )
{
if ( breakpoint.getMarker().getResource().equals( CDebugUtils.getFunctionResource( function ) ) )
{
if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( CDebugUtils.getFunctionName( function ) ) )
{
return breakpoint;
}
}
}
}
return null;
}
public static ICFunctionBreakpoint createFunctionBreakpoint( IFunction function,
boolean enabled,
int ignoreCount,
String condition,
boolean add ) throws DebugException
{
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
int lineNumber = -1;
int charStart = -1;
int charEnd = -1;
try
{
ISourceRange sourceRange = function.getSourceRange();
if ( sourceRange != null )
{
charStart = sourceRange.getStartPos();
charEnd = charStart + sourceRange.getLength();
// for now
if ( charEnd == 0 )
lineNumber = sourceRange.getStartLine();
}
}
catch( CModelException e )
{
CDebugCorePlugin.log( e.getStatus() );
}
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICFunctionBreakpoint.FUNCTION, CDebugUtils.getFunctionName( function ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
return new CFunctionBreakpoint( CDebugUtils.getFunctionResource( function ), attributes, add );
}
public static ICFunctionBreakpoint methodBreakpointExists( IMethod method ) throws CoreException
{
String modelId = getPluginIdentifier();
String markerType = CFunctionBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for ( int i = 0; i < breakpoints.length; i++ )
{
if ( !( breakpoints[i] instanceof ICFunctionBreakpoint ) )
{
continue;
}
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) )
{
if ( breakpoint.getMarker().getResource().equals( CDebugUtils.getMethodResource( method ) ) )
{
if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( CDebugUtils.getMethodQualifiedName( method ) ) )
{
return breakpoint;
}
}
}
}
return null;
}
public static ICFunctionBreakpoint createMethodBreakpoint( IMethod method,
boolean enabled,
int ignoreCount,
String condition,
boolean add ) throws DebugException
{
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
int lineNumber = -1;
int charStart = -1;
int charEnd = -1;
try
{
ISourceRange sourceRange = method.getSourceRange();
if ( sourceRange != null )
{
charStart = sourceRange.getStartPos();
charEnd = charStart + sourceRange.getLength();
// for now
if ( charEnd == 0 )
lineNumber = sourceRange.getStartLine();
}
}
catch( CModelException e )
{
CDebugCorePlugin.log( e.getStatus() );
}
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICFunctionBreakpoint.FUNCTION, CDebugUtils.getMethodQualifiedName( method ) );
attributes.put( IBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
attributes.put( ICBreakpoint.CONDITION, condition );
return new CFunctionBreakpoint( CDebugUtils.getMethodResource( method ), attributes, add );
}
public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException
{
String modelId = getPluginIdentifier();
String markerType = CWatchpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for ( int i = 0; i < breakpoints.length; i++ )
{
if ( !( breakpoints[i] instanceof ICWatchpoint ) )
{
continue;
}
ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType )&&
breakpoint.getMarker().getResource().equals( resource ) &&
breakpoint.isWriteType() == write &&
breakpoint.isReadType() == read &&
breakpoint.getExpression().equals( expression ) )
{
return breakpoint;
}
}
return null;
}
public static ICWatchpoint createWatchpoint( IResource resource,
boolean writeAccess,
boolean readAccess,
String expression,
boolean enabled,
int ignoreCount,
String condition,
boolean add ) throws DebugException
{
HashMap attributes = new HashMap( 10 );
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IBreakpoint.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, add );
}
public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException
{ {
if ( target != null && target instanceof CDebugTarget ) if ( target != null && target instanceof CDebugTarget )

View file

@ -1,19 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.core.runtime.IAdaptable;
/**
* Enter type comment.
*
* @since: Jan 7, 2003
*/
public interface ICBreakpointManager extends IAdaptable
{
long getBreakpointAddress( ICBreakpoint breakpoint );
}

View file

@ -1,20 +1,22 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* * A breakpoint that suspend the execution when a particular address is reached.
* A breakpoint that suspend execution when a particular address is reached.
*
* @since Aug 21, 2002
*/ */
public interface ICAddressBreakpoint extends ICLineBreakpoint public interface ICAddressBreakpoint extends ICLineBreakpoint {
{
/** /**
* Breakpoint attribute storing the address this breakpoint suspends * Breakpoint attribute storing the address this breakpoint suspends
* execution at (value <code>"org.eclipse.cdt.debug.core.address"</code>). * execution at (value <code>"org.eclipse.cdt.debug.core.address"</code>).
@ -26,8 +28,8 @@ public interface ICAddressBreakpoint extends ICLineBreakpoint
* Returns the address this breakpoint suspends execution at. * Returns the address this breakpoint suspends execution at.
* *
* @return the address this breakpoint suspends execution at * @return the address this breakpoint suspends execution at
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public String getAddress() throws CoreException; public String getAddress() throws CoreException;
@ -35,8 +37,8 @@ public interface ICAddressBreakpoint extends ICLineBreakpoint
* Sets the address this breakpoint suspends execution at. * Sets the address this breakpoint suspends execution at.
* *
* @param address the address this breakpoint suspends execution at * @param address the address this breakpoint suspends execution at
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public void setAddress( String address ) throws CoreException; public void setAddress( String address ) throws CoreException;
} }

View file

@ -1,64 +1,72 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
/** /**
*
* A breakpoint specific to the C/C++ debug model. A C/C++ breakpoint supports: * A breakpoint specific to the C/C++ debug model. A C/C++ breakpoint supports:
* <ul> * <ul>
* <li>a condition</li> * <li>a condition</li>
* <li>an ignore count</li> * <li>an ignore count</li>
* <li>a thread filter to restrict a breakpoin to a specific thread</li> * <li>a thread filter to restrict the breakpoint to a specific thread</li>
* <li>an installed property that indicates a breakpoint was successfully * <li>an installed property that indicates a breakpoint was successfully
* installed in debug target</li> * installed in debug target</li>
* </ul> * </ul>
*
* @since Aug 21, 2002
*/ */
public interface ICBreakpoint extends IBreakpoint public interface ICBreakpoint extends IBreakpoint {
{
/** /**
* Breakpoint attribute storing the number of debug targets a * Breakpoint attribute storing the number of debug targets a breakpoint is
* breakpoint is installed in (value <code>"org.eclipse.cdt.debug.core.installCount"</code>). * installed in (value <code>"org.eclipse.cdt.debug.core.installCount"</code>).
* This attribute is a <code>int</code>. * This attribute is an <code>int</code>.
*/ */
public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$ public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$
/** /**
* Breakpoint attribute storing the conditional expression * Breakpoint attribute storing the conditional expression associated with
* associated with this breakpoint (value <code>"org.eclipse.cdt.debug.core.condition"</code>). * this breakpoint (value <code>"org.eclipse.cdt.debug.core.condition"</code>).
* This attribute is a <code>String</code>. * This attribute is a <code>String</code>.
*/ */
public static final String CONDITION = "org.eclipse.cdt.debug.core.condition"; //$NON-NLS-1$ public static final String CONDITION = "org.eclipse.cdt.debug.core.condition"; //$NON-NLS-1$
/** /**
* Breakpoint attribute storing a breakpoint's ignore count value * Breakpoint attribute storing a breakpoint's ignore count value (value
* (value <code>"org.eclipse.cdt.debug.core.ignoreCount"</code>). * <code>"org.eclipse.cdt.debug.core.ignoreCount"</code>). This attribute
* This attribute is a <code>int</code>. * is an <code>int</code>.
*/ */
public static final String IGNORE_COUNT = "org.eclipse.cdt.debug.core.ignoreCount"; //$NON-NLS-1$ public static final String IGNORE_COUNT = "org.eclipse.cdt.debug.core.ignoreCount"; //$NON-NLS-1$
/** /**
* Breakpoint attribute storing an identifier of the thread this * Breakpoint attribute storing an identifier of the thread this breakpoint
* breakpoint is restricted in (value <code>"org.eclipse.cdt.debug.core.threadId"</code>). * is restricted in (value <code>"org.eclipse.cdt.debug.core.threadId"</code>).
* This attribute is a <code>String</code>. * This attribute is a <code>String</code>.
*/ */
public static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$ public static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$
/** /**
* Returns whether this breakpoint is installed in at least * Breakpoint attribute storing a source handle this breakpoint
* one debug target. * is set in (value <code>"org.eclipse.cdt.debug.core.sourceHandle"</code>).
* This attribute is a <code>String</code>.
*/
public static final String SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$
/**
* Returns whether this breakpoint is installed in at least one debug
* target.
* *
* @return whether this breakpoint is installed * @return whether this breakpoint is installed
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public boolean isInstalled() throws CoreException; public boolean isInstalled() throws CoreException;
@ -66,8 +74,8 @@ public interface ICBreakpoint extends IBreakpoint
* Returns whether this breakpoint is conditional. * Returns whether this breakpoint is conditional.
* *
* @return whether this breakpoint is conditional * @return whether this breakpoint is conditional
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public boolean isConditional() throws CoreException; public boolean isConditional() throws CoreException;
@ -75,8 +83,8 @@ public interface ICBreakpoint extends IBreakpoint
* Returns the conditional expression associated with this breakpoint. * Returns the conditional expression associated with this breakpoint.
* *
* @return this breakpoint's conditional expression * @return this breakpoint's conditional expression
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public String getCondition() throws CoreException; public String getCondition() throws CoreException;
@ -84,8 +92,8 @@ public interface ICBreakpoint extends IBreakpoint
* Sets the condition associated with this breakpoint. * Sets the condition associated with this breakpoint.
* *
* @param condition the conditional expression * @param condition the conditional expression
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public void setCondition( String condition ) throws CoreException; public void setCondition( String condition ) throws CoreException;
@ -93,8 +101,8 @@ public interface ICBreakpoint extends IBreakpoint
* Returns the ignore count used by this breakpoint. * Returns the ignore count used by this breakpoint.
* *
* @return the ignore count used by this breakpoint * @return the ignore count used by this breakpoint
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public int getIgnoreCount() throws CoreException; public int getIgnoreCount() throws CoreException;
@ -102,8 +110,8 @@ public interface ICBreakpoint extends IBreakpoint
* Sets the ignore count attribute for this breakpoint. * Sets the ignore count attribute for this breakpoint.
* *
* @param ignoreCount the new ignore count * @param ignoreCount the new ignore count
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public void setIgnoreCount( int ignoreCount ) throws CoreException; public void setIgnoreCount( int ignoreCount ) throws CoreException;
@ -111,18 +119,36 @@ public interface ICBreakpoint extends IBreakpoint
* Returns the identifier of the thread this breakpoint is restricted in. * Returns the identifier of the thread this breakpoint is restricted in.
* *
* @return the thread identifier * @return the thread identifier
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public String getThreadId() throws CoreException; public String getThreadId() throws CoreException;
/** /**
* Restricts this breakpoint to suspend only in the given thread * Restricts this breakpoint to suspend only in the given thread when
* when encounterd in the given thread's target. * encounterd in the given thread's target.
* *
* @param threadId the thread identifier * @param threadId the thread identifier
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public void setThreadId( String threadId ) throws CoreException; public void setThreadId( String threadId ) throws CoreException;
/**
* Returns the source handle this breakpoint is set in.
*
* @return the source handle
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public String getSourceHandle() throws CoreException;
/**
* Sets the source handle of this breakpoint.
*
* @param sourceHandle the source handle
* @exception CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public void setSourceHandle( String sourceHandle ) throws CoreException;
} }

View file

@ -1,20 +1,22 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* * A breakpoint that suspends the execution when a function is entered.
* A breakpoint that suspend execution when a function is entered.
*
* @since Aug 21, 2002
*/ */
public interface ICFunctionBreakpoint extends ICLineBreakpoint public interface ICFunctionBreakpoint extends ICLineBreakpoint {
{
/** /**
* Breakpoint attribute storing the function this breakpoint suspends * Breakpoint attribute storing the function this breakpoint suspends
* execution at (value <code>"org.eclipse.cdt.debug.core.function"</code>). * execution at (value <code>"org.eclipse.cdt.debug.core.function"</code>).
@ -26,8 +28,8 @@ public interface ICFunctionBreakpoint extends ICLineBreakpoint
* Returns the function this breakpoint suspends execution in. * Returns the function this breakpoint suspends execution in.
* *
* @return the function this breakpoint suspends execution in * @return the function this breakpoint suspends execution in
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public String getFunction() throws CoreException; public String getFunction() throws CoreException;
@ -35,10 +37,17 @@ public interface ICFunctionBreakpoint extends ICLineBreakpoint
* Sets the function this breakpoint suspends execution in. * Sets the function this breakpoint suspends execution in.
* *
* @param function the function this breakpoint suspends execution in * @param function the function this breakpoint suspends execution in
* @exception CoreException if unable to access the property * @exception CoreException if unable to access the property on this breakpoint's
* on this breakpoint's underlying marker * underlying marker
*/ */
public void setFunction( String function ) throws CoreException; public void setFunction( String function ) throws CoreException;
/**
* Returns the source file of the function.
*
* @return the source file of the function
* @throws CoreException if unable to access the property on this breakpoint's
* underlying marker
*/
public String getFileName() throws CoreException; public String getFileName() throws CoreException;
} }

View file

@ -1,20 +1,21 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.ILineBreakpoint;
/** /**
* * A breakpoint that suspends the execution when a particular line of code
* A breakpoint that suspend execution when a particular line of code
* is reached. * is reached.
*
* @since Aug 21, 2002
*/ */
public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint {
{
} }

View file

@ -1,20 +1,22 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
*
* A watchpoint specific to the C/C++ debug model. * A watchpoint specific to the C/C++ debug model.
*
* @since Sep 4, 2002
*/ */
public interface ICWatchpoint extends ICBreakpoint public interface ICWatchpoint extends ICBreakpoint {
{
/** /**
* Watchpoint attribute storing the expression associated with this * Watchpoint attribute storing the expression associated with this
* watchpoint (value <code>"org.eclipse.cdt.debug.core.expression"</code>). * watchpoint (value <code>"org.eclipse.cdt.debug.core.expression"</code>).

View file

@ -1,18 +1,21 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core; package org.eclipse.cdt.debug.internal.core;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDICondition;
@ -49,14 +52,13 @@ import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.ISourceLocator;
/** /**
* Enter type comment. * The breakpoint manager manages all breakpoints set to the associated
* * debug target.
* @since Nov 3, 2003
*/ */
public class CBreakpointManager implements ICBreakpointManager, ICDIEventListener, IAdaptable public class CBreakpointManager implements ICDIEventListener, IAdaptable {
{
public class BreakpointMap private class BreakpointMap {
{
/** /**
* Maps CBreakpoints to CDI breakpoints. * Maps CBreakpoints to CDI breakpoints.
*/ */
@ -67,62 +69,51 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
*/ */
private HashMap fCDIBreakpoints; private HashMap fCDIBreakpoints;
protected BreakpointMap() protected BreakpointMap() {
{
fCBreakpoints = new HashMap( 10 ); fCBreakpoints = new HashMap( 10 );
fCDIBreakpoints = new HashMap( 10 ); fCDIBreakpoints = new HashMap( 10 );
} }
protected synchronized void put( ICBreakpoint breakpoint, ICDIBreakpoint cdiBreakpoint ) protected synchronized void put( ICBreakpoint breakpoint, ICDIBreakpoint cdiBreakpoint ) {
{
fCBreakpoints.put( breakpoint, cdiBreakpoint ); fCBreakpoints.put( breakpoint, cdiBreakpoint );
fCDIBreakpoints.put( cdiBreakpoint, breakpoint ); fCDIBreakpoints.put( cdiBreakpoint, breakpoint );
} }
protected synchronized ICDIBreakpoint getCDIBreakpoint( ICBreakpoint breakpoint ) protected synchronized ICDIBreakpoint getCDIBreakpoint( ICBreakpoint breakpoint ) {
{
return (ICDIBreakpoint)fCBreakpoints.get( breakpoint ); return (ICDIBreakpoint)fCBreakpoints.get( breakpoint );
} }
protected synchronized ICBreakpoint getCBreakpoint( ICDIBreakpoint cdiBreakpoint ) protected synchronized ICBreakpoint getCBreakpoint( ICDIBreakpoint cdiBreakpoint ) {
{
return (ICBreakpoint)fCDIBreakpoints.get( cdiBreakpoint ); return (ICBreakpoint)fCDIBreakpoints.get( cdiBreakpoint );
} }
protected void removeCBreakpoint( ICBreakpoint breakpoint ) protected void removeCBreakpoint( ICBreakpoint breakpoint ) {
{ if ( breakpoint != null ) {
if ( breakpoint != null )
{
ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)fCBreakpoints.remove( breakpoint ); ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)fCBreakpoints.remove( breakpoint );
if ( cdiBreakpoint != null ) if ( cdiBreakpoint != null )
fCDIBreakpoints.remove( cdiBreakpoint ); fCDIBreakpoints.remove( cdiBreakpoint );
} }
} }
protected void removeCDIBreakpoint( ICBreakpoint breakpoin, ICDIBreakpoint cdiBreakpoint ) protected void removeCDIBreakpoint( ICBreakpoint breakpoin, ICDIBreakpoint cdiBreakpoint ) {
{ if ( cdiBreakpoint != null ) {
if ( cdiBreakpoint != null )
{
ICBreakpoint breakpoint = (ICBreakpoint)fCDIBreakpoints.remove( cdiBreakpoint ); ICBreakpoint breakpoint = (ICBreakpoint)fCDIBreakpoints.remove( cdiBreakpoint );
if ( breakpoint != null ) if ( breakpoint != null )
fCBreakpoints.remove( breakpoint ); fCBreakpoints.remove( breakpoint );
} }
} }
protected ICBreakpoint[] getAllCBreakpoints() protected ICBreakpoint[] getAllCBreakpoints() {
{
Set set = fCBreakpoints.keySet(); Set set = fCBreakpoints.keySet();
return (ICBreakpoint[])set.toArray( new ICBreakpoint[set.size()]); return (ICBreakpoint[])set.toArray( new ICBreakpoint[set.size()] );
} }
protected ICDIBreakpoint[] getAllCDIBreakpoints() protected ICDIBreakpoint[] getAllCDIBreakpoints() {
{
Set set = fCDIBreakpoints.keySet(); Set set = fCDIBreakpoints.keySet();
return (ICDIBreakpoint[])set.toArray( new ICDIBreakpoint[set.size()]); return (ICDIBreakpoint[])set.toArray( new ICDIBreakpoint[set.size()] );
} }
protected void dispose() protected void dispose() {
{
fCBreakpoints.clear(); fCBreakpoints.clear();
fCDIBreakpoints.clear(); fCDIBreakpoints.clear();
} }
@ -132,8 +123,7 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
private BreakpointMap fMap; private BreakpointMap fMap;
public CBreakpointManager( CDebugTarget target ) public CBreakpointManager( CDebugTarget target ) {
{
super(); super();
setDebugTarget( target ); setDebugTarget( target );
fMap = new BreakpointMap(); fMap = new BreakpointMap();
@ -143,8 +133,7 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
public Object getAdapter( Class adapter ) public Object getAdapter( Class adapter ) {
{
if ( CBreakpointManager.class.equals( adapter ) ) if ( CBreakpointManager.class.equals( adapter ) )
return this; return this;
if ( CDebugTarget.class.equals( adapter ) ) if ( CDebugTarget.class.equals( adapter ) )
@ -156,31 +145,26 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return null; return null;
} }
public CDebugTarget getDebugTarget() public CDebugTarget getDebugTarget() {
{
return fDebugTarget; return fDebugTarget;
} }
private void setDebugTarget( CDebugTarget target ) private void setDebugTarget( CDebugTarget target ) {
{
fDebugTarget = target; fDebugTarget = target;
} }
protected ICDIBreakpointManager getCDIBreakpointManager() protected ICDIBreakpointManager getCDIBreakpointManager() {
{
return getDebugTarget().getCDISession().getBreakpointManager(); return getDebugTarget().getCDISession().getBreakpointManager();
} }
protected ICSourceLocator getCSourceLocator() protected ICSourceLocator getCSourceLocator() {
{
ISourceLocator locator = getDebugTarget().getLaunch().getSourceLocator(); ISourceLocator locator = getDebugTarget().getLaunch().getSourceLocator();
if ( locator instanceof IAdaptable ) if ( locator instanceof IAdaptable )
return (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ); return (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
return null; return null;
} }
public void dispose() public void dispose() {
{
getDebugTarget().getCDISession().getEventManager().removeEventListener( this ); getDebugTarget().getCDISession().getEventManager().removeEventListener( this );
removeAllBreakpoints(); removeAllBreakpoints();
getBreakpointMap().dispose(); getBreakpointMap().dispose();
@ -189,26 +173,20 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(org.eclipse.cdt.debug.core.cdi.event.ICDIEvent) * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(org.eclipse.cdt.debug.core.cdi.event.ICDIEvent)
*/ */
public void handleDebugEvents( ICDIEvent[] events ) public void handleDebugEvents( ICDIEvent[] events ) {
{ for( int i = 0; i < events.length; i++ ) {
for (int i = 0; i < events.length; i++)
{
ICDIEvent event = events[i]; ICDIEvent event = events[i];
ICDIObject source = event.getSource(); ICDIObject source = event.getSource();
if ( source != null && source.getTarget().equals( getDebugTarget().getCDITarget() ) ) if ( source != null && source.getTarget().equals( getDebugTarget().getCDITarget() ) ) {
{ if ( event instanceof ICDICreatedEvent ) {
if ( event instanceof ICDICreatedEvent )
{
if ( source instanceof ICDIBreakpoint ) if ( source instanceof ICDIBreakpoint )
handleBreakpointCreatedEvent( (ICDIBreakpoint)source ); handleBreakpointCreatedEvent( (ICDIBreakpoint)source );
} }
else if ( event instanceof ICDIDestroyedEvent ) else if ( event instanceof ICDIDestroyedEvent ) {
{
if ( source instanceof ICDIBreakpoint ) if ( source instanceof ICDIBreakpoint )
handleBreakpointDestroyedEvent( (ICDIBreakpoint)source ); handleBreakpointDestroyedEvent( (ICDIBreakpoint)source );
} }
else if ( event instanceof ICDIChangedEvent ) else if ( event instanceof ICDIChangedEvent ) {
{
if ( source instanceof ICDIBreakpoint ) if ( source instanceof ICDIBreakpoint )
handleBreakpointChangedEvent( (ICDIBreakpoint)source ); handleBreakpointChangedEvent( (ICDIBreakpoint)source );
} }
@ -216,27 +194,22 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
} }
} }
public boolean isTargetBreakpoint( ICBreakpoint breakpoint ) public boolean isTargetBreakpoint( ICBreakpoint breakpoint ) {
{
IResource resource = breakpoint.getMarker().getResource(); IResource resource = breakpoint.getMarker().getResource();
if ( breakpoint instanceof ICAddressBreakpoint ) if ( breakpoint instanceof ICAddressBreakpoint )
return supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ); return supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
if ( breakpoint instanceof ICLineBreakpoint ) if ( breakpoint instanceof ICLineBreakpoint ) {
{
ICSourceLocator sl = getSourceLocator(); ICSourceLocator sl = getSourceLocator();
if ( sl != null ) if ( sl != null )
return sl.contains( resource ); return sl.contains( resource );
} }
else else {
{
IProject project = resource.getProject(); IProject project = resource.getProject();
if ( project != null && project.exists() ) if ( project != null && project.exists() ) {
{
ICSourceLocator sl = getSourceLocator(); ICSourceLocator sl = getSourceLocator();
if ( sl != null ) if ( sl != null )
return sl.contains( project ); return sl.contains( project );
else else {
{
if ( project.equals( getExecFile().getProject() ) ) if ( project.equals( getExecFile().getProject() ) )
return true; return true;
return CDebugUtils.isReferencedProject( getExecFile().getProject(), project ); return CDebugUtils.isReferencedProject( getExecFile().getProject(), project );
@ -246,22 +219,17 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return true; return true;
} }
public boolean isCDIRegistered( ICBreakpoint breakpoint ) public boolean isCDIRegistered( ICBreakpoint breakpoint ) {
{ return (getBreakpointMap().getCDIBreakpoint( breakpoint ) != null);
return ( getBreakpointMap().getCDIBreakpoint( breakpoint ) != null );
} }
public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) {
{ return (getExecFile() != null && getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ));
return ( getExecFile() != null &&
getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ) );
} }
public IFile getCDIBreakpointFile( ICDIBreakpoint cdiBreakpoint ) public IFile getCDIBreakpointFile( ICDIBreakpoint cdiBreakpoint ) {
{
IBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); IBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
if ( breakpoint instanceof ICLineBreakpoint && !(breakpoint instanceof ICAddressBreakpoint) ) if ( breakpoint instanceof ICLineBreakpoint && !(breakpoint instanceof ICAddressBreakpoint) ) {
{
IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource(); IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource();
if ( resource instanceof IFile ) if ( resource instanceof IFile )
return (IFile)resource; return (IFile)resource;
@ -269,57 +237,44 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return null; return null;
} }
public ICBreakpoint getBreakpoint( ICDIBreakpoint cdiBreakpoint ) public ICBreakpoint getBreakpoint( ICDIBreakpoint cdiBreakpoint ) {
{
return getBreakpointMap().getCBreakpoint( cdiBreakpoint ); return getBreakpointMap().getCBreakpoint( cdiBreakpoint );
} }
public long getBreakpointAddress( ICBreakpoint breakpoint ) public long getBreakpointAddress( ICBreakpoint breakpoint ) {
{ if ( breakpoint != null ) {
if ( breakpoint != null )
{
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint instanceof ICDILocationBreakpoint ) if ( cdiBreakpoint instanceof ICDILocationBreakpoint ) {
{ try {
try
{
ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation(); ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation();
if ( location != null ) if ( location != null )
return location.getAddress(); return location.getAddress();
} }
catch( CDIException e ) catch( CDIException e ) {
{
} }
} }
} }
return 0; return 0;
} }
public void setBreakpoint( final ICBreakpoint breakpoint ) throws DebugException public void setBreakpoint( final ICBreakpoint breakpoint ) throws DebugException {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable()
{ public void run() {
public void run() try {
{
try
{
doSetBreakpoint( breakpoint ); doSetBreakpoint( breakpoint );
} }
catch( DebugException e ) catch( DebugException e ) {
{
} }
} }
}; };
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doSetBreakpoint( ICBreakpoint breakpoint ) throws DebugException protected void doSetBreakpoint( ICBreakpoint breakpoint ) throws DebugException {
{ try {
try
{
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint == null ) if ( cdiBreakpoint == null ) {
{
if ( breakpoint instanceof ICFunctionBreakpoint ) if ( breakpoint instanceof ICFunctionBreakpoint )
cdiBreakpoint = setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint ); cdiBreakpoint = setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint );
else if ( breakpoint instanceof ICAddressBreakpoint ) else if ( breakpoint instanceof ICAddressBreakpoint )
@ -335,113 +290,89 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
cdiBreakpoint.setEnabled( false ); cdiBreakpoint.setEnabled( false );
setBreakpointCondition( breakpoint ); setBreakpointCondition( breakpoint );
} }
catch( CoreException e ) catch( CoreException e ) {
{ requestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Set_breakpoint_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
requestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Set_breakpoint_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
catch( NumberFormatException e ) catch( NumberFormatException e ) {
{ requestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Set_breakpoint_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
requestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Set_breakpoint_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
catch( CDIException e ) catch( CDIException e ) {
{ targetRequestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Set_breakpoint_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
targetRequestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Set_breakpoint_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
} }
public void removeBreakpoint( final ICBreakpoint breakpoint ) throws DebugException public void removeBreakpoint( final ICBreakpoint breakpoint ) throws DebugException {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable() public void run() {
{ try {
public void run()
{
try
{
doRemoveBreakpoint( breakpoint ); doRemoveBreakpoint( breakpoint );
} }
catch( DebugException e ) catch( DebugException e ) {
{
} }
} }
}; };
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doRemoveBreakpoint( ICBreakpoint breakpoint ) throws DebugException protected void doRemoveBreakpoint( ICBreakpoint breakpoint ) throws DebugException {
{
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint != null ) if ( cdiBreakpoint != null ) {
{
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
try try {
{ bm.deleteBreakpoints( new ICDIBreakpoint[]{ cdiBreakpoint } );
bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoint } );
} }
catch( CDIException e ) catch( CDIException e ) {
{ targetRequestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Delete_breakpoint_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
targetRequestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Delete_breakpoint_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
} }
} }
public void changeBreakpointProperties( final ICBreakpoint breakpoint, final IMarkerDelta delta ) throws DebugException public void changeBreakpointProperties( final ICBreakpoint breakpoint, final IMarkerDelta delta ) throws DebugException {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable()
{ public void run() {
public void run() try {
{
try
{
doChangeBreakpointProperties( breakpoint, delta ); doChangeBreakpointProperties( breakpoint, delta );
} }
catch( DebugException e ) catch( DebugException e ) {
{
} }
} }
}; };
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doChangeBreakpointProperties( ICBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException protected void doChangeBreakpointProperties( ICBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException {
{
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
if ( cdiBreakpoint == null ) if ( cdiBreakpoint == null )
return; return;
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
try try {
{
boolean enabled = breakpoint.isEnabled(); boolean enabled = breakpoint.isEnabled();
boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true ); boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true );
int ignoreCount = breakpoint.getIgnoreCount(); int ignoreCount = breakpoint.getIgnoreCount();
int oldIgnoreCount = delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 ); int oldIgnoreCount = delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 );
String condition = breakpoint.getCondition(); String condition = breakpoint.getCondition();
String oldCondition = delta.getAttribute( ICBreakpoint.CONDITION, "" ); //$NON-NLS-1$ String oldCondition = delta.getAttribute( ICBreakpoint.CONDITION, "" ); //$NON-NLS-1$
if ( enabled != oldEnabled ) if ( enabled != oldEnabled ) {
{
cdiBreakpoint.setEnabled( enabled ); cdiBreakpoint.setEnabled( enabled );
} }
if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) ) if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) ) {
{
ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition ); ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition );
cdiBreakpoint.setCondition( cdiCondition ); cdiBreakpoint.setCondition( cdiCondition );
} }
} }
catch( CoreException e ) catch( CoreException e ) {
{ requestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Change_brkpt_properties_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
requestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Change_brkpt_properties_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
catch( CDIException e ) catch( CDIException e ) {
{ targetRequestFailed( CDebugCorePlugin.getResourceString( "internal.core.CBreakpointManager.Change_brkpt_properties_failed" ) + e.getMessage(), e ); //$NON-NLS-1$
targetRequestFailed( CDebugCorePlugin.getResourceString("internal.core.CBreakpointManager.Change_brkpt_properties_failed") + e.getMessage(), e ); //$NON-NLS-1$
} }
} }
private void handleBreakpointCreatedEvent( final ICDIBreakpoint cdiBreakpoint ) private void handleBreakpointCreatedEvent( final ICDIBreakpoint cdiBreakpoint ) {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable()
{ public void run() {
public void run()
{
if ( cdiBreakpoint instanceof ICDILocationBreakpoint ) if ( cdiBreakpoint instanceof ICDILocationBreakpoint )
doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint ); doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint );
else if ( cdiBreakpoint instanceof ICDIWatchpoint ) else if ( cdiBreakpoint instanceof ICDIWatchpoint )
@ -451,199 +382,145 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint ) protected void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint ) {
{
if ( cdiBreakpoint.isTemporary() ) if ( cdiBreakpoint.isTemporary() )
return; return;
ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
if ( breakpoint == null ) if ( breakpoint == null ) {
{ try {
try if ( cdiBreakpoint.getLocation().getFile() != null && cdiBreakpoint.getLocation().getFile().length() > 0 ) {
{
if ( cdiBreakpoint.getLocation().getFile() != null && cdiBreakpoint.getLocation().getFile().length() > 0 )
{
ICSourceLocator locator = getSourceLocator(); ICSourceLocator locator = getSourceLocator();
if ( locator != null ) if ( locator != null ) {
{
Object sourceElement = locator.findSourceElement( cdiBreakpoint.getLocation().getFile() ); Object sourceElement = locator.findSourceElement( cdiBreakpoint.getLocation().getFile() );
if ( sourceElement != null && sourceElement instanceof IFile ) if ( sourceElement != null && sourceElement instanceof IFile ) {
{
breakpoint = createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint ); breakpoint = createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint );
} }
else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) {
{
breakpoint = createAddressBreakpoint( cdiBreakpoint ); breakpoint = createAddressBreakpoint( cdiBreakpoint );
} }
} }
} }
else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) {
{
breakpoint = createAddressBreakpoint( cdiBreakpoint ); breakpoint = createAddressBreakpoint( cdiBreakpoint );
} }
} }
catch( CDIException e ) catch( CDIException e ) {
{
} }
catch( CoreException e ) catch( CoreException e ) {
{
} }
} }
if ( breakpoint != null ) if ( breakpoint != null ) {
{ try {
try
{
((CBreakpoint)breakpoint).incrementInstallCount(); ((CBreakpoint)breakpoint).incrementInstallCount();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugCorePlugin.log( e.getStatus() ); CDebugCorePlugin.log( e.getStatus() );
} }
} }
} }
protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint ) protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint ) {
{
ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiWatchpoint ); ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiWatchpoint );
if ( breakpoint == null ) if ( breakpoint == null ) {
{ try {
try breakpoint = createWatchpoint( cdiWatchpoint );
{
breakpoint = CDebugModel.createWatchpoint( getExecFile().getProject(),
cdiWatchpoint.isWriteType(),
cdiWatchpoint.isReadType(),
cdiWatchpoint.getWatchExpression(),
cdiWatchpoint.isEnabled(),
cdiWatchpoint.getCondition().getIgnoreCount(),
cdiWatchpoint.getCondition().getExpression(),
false );
getBreakpointMap().put( breakpoint, cdiWatchpoint );
((CBreakpoint)breakpoint).register( true );
} }
catch( CDIException e ) catch( CDIException e ) {
{
} }
catch( CoreException e ) catch( CoreException e ) {
{
} }
} }
if ( breakpoint != null ) if ( breakpoint != null ) {
{ try {
try
{
((CBreakpoint)breakpoint).incrementInstallCount(); ((CBreakpoint)breakpoint).incrementInstallCount();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugCorePlugin.log( e.getStatus() ); CDebugCorePlugin.log( e.getStatus() );
} }
} }
} }
private void handleBreakpointDestroyedEvent( final ICDIBreakpoint cdiBreakpoint ) private void handleBreakpointDestroyedEvent( final ICDIBreakpoint cdiBreakpoint ) {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable()
{ public void run() {
public void run()
{
doHandleBreakpointDestroyedEvent( cdiBreakpoint ); doHandleBreakpointDestroyedEvent( cdiBreakpoint );
} }
}; };
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doHandleBreakpointDestroyedEvent( ICDIBreakpoint cdiBreakpoint ) protected void doHandleBreakpointDestroyedEvent( ICDIBreakpoint cdiBreakpoint ) {
{
ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
if ( breakpoint != null ) if ( breakpoint != null ) {
{
getBreakpointMap().removeCDIBreakpoint( breakpoint, cdiBreakpoint ); getBreakpointMap().removeCDIBreakpoint( breakpoint, cdiBreakpoint );
try try {
{
((CBreakpoint)breakpoint).decrementInstallCount(); ((CBreakpoint)breakpoint).decrementInstallCount();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugCorePlugin.log( e.getStatus() ); CDebugCorePlugin.log( e.getStatus() );
} }
} }
} }
private void handleBreakpointChangedEvent( final ICDIBreakpoint cdiBreakpoint ) private void handleBreakpointChangedEvent( final ICDIBreakpoint cdiBreakpoint ) {
{ Runnable runnable = new Runnable() {
Runnable runnable = new Runnable()
{ public void run() {
public void run()
{
doHandleBreakpointChangedEvent( cdiBreakpoint ); doHandleBreakpointChangedEvent( cdiBreakpoint );
} }
}; };
CDebugCorePlugin.getDefault().asyncExec( runnable ); CDebugCorePlugin.getDefault().asyncExec( runnable );
} }
protected void doHandleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint ) protected void doHandleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint ) {
{
ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint ); ICBreakpoint breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
if ( breakpoint != null ) if ( breakpoint != null ) {
{ try {
try
{
breakpoint.setEnabled( cdiBreakpoint.isEnabled() ); breakpoint.setEnabled( cdiBreakpoint.isEnabled() );
breakpoint.setIgnoreCount( cdiBreakpoint.getCondition().getIgnoreCount() ); breakpoint.setIgnoreCount( cdiBreakpoint.getCondition().getIgnoreCount() );
breakpoint.setCondition( cdiBreakpoint.getCondition().getExpression() ); breakpoint.setCondition( cdiBreakpoint.getCondition().getExpression() );
} }
catch( CDIException e ) catch( CDIException e ) {
{
} }
catch( CoreException e ) catch( CoreException e ) {
{
} }
} }
} }
private void removeAllBreakpoints() private void removeAllBreakpoints() {
{
ICDIBreakpoint[] cdiBreakpoints = getBreakpointMap().getAllCDIBreakpoints(); ICDIBreakpoint[] cdiBreakpoints = getBreakpointMap().getAllCDIBreakpoints();
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
if ( cdiBreakpoints.length > 0 ) if ( cdiBreakpoints.length > 0 ) {
{ try {
try
{
bm.deleteBreakpoints( cdiBreakpoints ); bm.deleteBreakpoints( cdiBreakpoints );
} }
catch( CDIException e ) catch( CDIException e ) {
{
CDebugCorePlugin.log( e.getMessage() ); CDebugCorePlugin.log( e.getMessage() );
} }
ICBreakpoint[] breakpoints = getBreakpointMap().getAllCBreakpoints(); ICBreakpoint[] breakpoints = getBreakpointMap().getAllCBreakpoints();
for ( int i = 0; i < breakpoints.length; ++i ) for( int i = 0; i < breakpoints.length; ++i ) {
{ try {
try
{
((CBreakpoint)breakpoints[i]).decrementInstallCount(); ((CBreakpoint)breakpoints[i]).decrementInstallCount();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugCorePlugin.log( e.getMessage() ); CDebugCorePlugin.log( e.getMessage() );
} }
} }
} }
} }
private synchronized ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException private synchronized ICDIBreakpoint setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException {
{
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
String function = breakpoint.getFunction(); String function = breakpoint.getFunction();
String fileName = ( function != null && function.indexOf( "::" ) == -1 ) ? breakpoint.getFileName() : null; //$NON-NLS-1$ String fileName = (function != null && function.indexOf( "::" ) == -1) ? breakpoint.getFileName() : null; //$NON-NLS-1$
ICDILocation location = bm.createLocation( fileName, function, -1 ); ICDILocation location = bm.createLocation( fileName, function, -1 );
ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
getBreakpointMap().put( breakpoint, cdiBreakpoint ); getBreakpointMap().put( breakpoint, cdiBreakpoint );
return cdiBreakpoint; return cdiBreakpoint;
} }
private synchronized ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException private synchronized ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException {
{
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) ); ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) );
ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
@ -651,8 +528,7 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return cdiBreakpoint; return cdiBreakpoint;
} }
private synchronized ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException private synchronized ICDIBreakpoint setLineBreakpoint( ICLineBreakpoint breakpoint ) throws CDIException, CoreException {
{
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() ); ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() );
ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
@ -660,53 +536,43 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return cdiBreakpoint; return cdiBreakpoint;
} }
private synchronized ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException private synchronized ICDIBreakpoint setWatchpoint( ICWatchpoint watchpoint ) throws CDIException, CoreException {
{
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
int accessType = 0; int accessType = 0;
accessType |= ( watchpoint.isWriteType() ) ? ICDIWatchpoint.WRITE : 0; accessType |= (watchpoint.isWriteType()) ? ICDIWatchpoint.WRITE : 0;
accessType |= ( watchpoint.isReadType() ) ? ICDIWatchpoint.READ : 0; accessType |= (watchpoint.isReadType()) ? ICDIWatchpoint.READ : 0;
String expression = watchpoint.getExpression(); String expression = watchpoint.getExpression();
ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null ); ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null );
getBreakpointMap().put( watchpoint, cdiWatchpoint ); getBreakpointMap().put( watchpoint, cdiWatchpoint );
return cdiWatchpoint; return cdiWatchpoint;
} }
private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException {
{
ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint ); ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( breakpoint );
ICDIBreakpointManager bm = getCDIBreakpointManager(); ICDIBreakpointManager bm = getCDIBreakpointManager();
ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() ); ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
cdiBreakpoint.setCondition( condition ); cdiBreakpoint.setCondition( condition );
} }
private BreakpointMap getBreakpointMap() private BreakpointMap getBreakpointMap() {
{
return fMap; return fMap;
} }
protected void targetRequestFailed( String message, Throwable e ) throws DebugException protected void targetRequestFailed( String message, Throwable e ) throws DebugException {
{
requestFailed0( message, e, DebugException.TARGET_REQUEST_FAILED ); requestFailed0( message, e, DebugException.TARGET_REQUEST_FAILED );
} }
protected void requestFailed( String message, Throwable e ) throws DebugException protected void requestFailed( String message, Throwable e ) throws DebugException {
{
requestFailed0( message, e, DebugException.REQUEST_FAILED ); requestFailed0( message, e, DebugException.REQUEST_FAILED );
} }
private void requestFailed0( String message, Throwable e, int code ) throws DebugException private void requestFailed0( String message, Throwable e, int code ) throws DebugException {
{ throw new DebugException( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), code, message, e ) );
throw new DebugException( new Status( IStatus.ERROR,
CDebugModel.getPluginIdentifier(),
code,
message,
e ) );
} }
private ICLineBreakpoint createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException private ICLineBreakpoint createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
{ ICLineBreakpoint breakpoint = CDIDebugModel.createLineBreakpoint( cdiBreakpoint.getLocation().getFile(),
ICLineBreakpoint breakpoint = CDebugModel.createLineBreakpoint( file, file,
cdiBreakpoint.getLocation().getLineNumber(), cdiBreakpoint.getLocation().getLineNumber(),
cdiBreakpoint.isEnabled(), cdiBreakpoint.isEnabled(),
cdiBreakpoint.getCondition().getIgnoreCount(), cdiBreakpoint.getCondition().getIgnoreCount(),
@ -717,9 +583,11 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return breakpoint; return breakpoint;
} }
private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
{ IFile execFile = getExecFile();
ICAddressBreakpoint breakpoint = CDebugModel.createAddressBreakpoint( getExecFile(), String sourceHandle = execFile.getFullPath().toOSString();
ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle,
execFile,
cdiBreakpoint.getLocation().getAddress(), cdiBreakpoint.getLocation().getAddress(),
cdiBreakpoint.isEnabled(), cdiBreakpoint.isEnabled(),
cdiBreakpoint.getCondition().getIgnoreCount(), cdiBreakpoint.getCondition().getIgnoreCount(),
@ -730,14 +598,29 @@ public class CBreakpointManager implements ICBreakpointManager, ICDIEventListene
return breakpoint; return breakpoint;
} }
private ICSourceLocator getSourceLocator() private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException {
{ IFile execFile = getExecFile();
ISourceLocator locator = getDebugTarget().getLaunch().getSourceLocator(); String sourceHandle = execFile.getFullPath().toOSString();
return ( locator instanceof IAdaptable ) ? (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ) : null; ICWatchpoint watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
execFile.getProject(),
cdiWatchpoint.isWriteType(),
cdiWatchpoint.isReadType(),
cdiWatchpoint.getWatchExpression(),
cdiWatchpoint.isEnabled(),
cdiWatchpoint.getCondition().getIgnoreCount(),
cdiWatchpoint.getCondition().getExpression(),
false );
getBreakpointMap().put( watchpoint, cdiWatchpoint );
((CBreakpoint)watchpoint).register( true );
return watchpoint;
} }
private IFile getExecFile() private ICSourceLocator getSourceLocator() {
{ ISourceLocator locator = getDebugTarget().getLaunch().getSourceLocator();
return (locator instanceof IAdaptable) ? (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ) : null;
}
private IFile getExecFile() {
return getDebugTarget().getExecFile(); return getDebugTarget().getExecFile();
} }
} }

View file

@ -0,0 +1,34 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core;
/**
* Utilities used by C/C++ Debug Plugin's classes.
*/
public class CDebugUtils {
/**
* Returns the hexadecimal presentation of the given address.
*
* @param address an address to be converted to hex
* @return the hexadecimal presentation of the given address
*/
public static String toHexAddressString( long address ) {
String addressString = Long.toHexString( address );
StringBuffer sb = new StringBuffer( 10 );
sb.append( "0x" ); //$NON-NLS-1$
for( int i = 0; i < 8 - addressString.length(); ++i ) {
sb.append( '0' );
}
sb.append( addressString );
return sb.toString();
}
}

View file

@ -0,0 +1,33 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class BreakpointMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private BreakpointMessages() {
}
public static String getString( String key ) {
try {
return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,13 @@
CAddressBreakpoint.1=Address breakpoint:
CAddressBreakpoint.2=[address: {0}]
CBreakpoint.1=\ [ignore count: {0}]
CBreakpoint.2=\ if {0}
CFunctionBreakpoint.2=Function breakpoint:
CFunctionBreakpoint.3=\ [function: {0}]
CLineBreakpoint.1=Line breakpoint:
CLineBreakpoint.2=\ [line: {0}]
CWatchpoint.1=Write watchpoint
CWatchpoint.2=Read watchpoint
CWatchpoint.3=Access watchpoint
CWatchpoint.4=Watchpoint
CWatchpoint.5=\ at \'{0}\'

View file

@ -1,114 +1,113 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
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.cdt.debug.internal.core.CDebugUtils;
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;
import org.eclipse.debug.core.DebugException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
/** /**
* * A breakpoint that suspend the execution when a particular address is reached.
* Enter type comment.
*
* @since Aug 21, 2002
*/ */
public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint {
{
private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$ private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$
/** /**
* Constructor for CAddressBreakpoint. * Constructor for CAddressBreakpoint.
*/ */
public CAddressBreakpoint() public CAddressBreakpoint() {
{
} }
/** /**
* Constructor for CAddressBreakpoint. * Constructor for CAddressBreakpoint.
*/ */
public CAddressBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException public CAddressBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException {
{
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#getAddress() * @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#getAddress()
*/ */
public String getAddress() throws CoreException public String getAddress() throws CoreException {
{
return ensureMarker().getAttribute( ADDRESS, null ); return ensureMarker().getAttribute( ADDRESS, null );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#setAddress(long) * @see org.eclipse.cdt.debug.core.ICAddressBreakpoint#setAddress(long)
*/ */
public void setAddress( String address ) throws CoreException public void setAddress( String address ) throws CoreException {
{
setAttribute( ADDRESS, address ); setAttribute( ADDRESS, address );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
*/ */
public int getLineNumber() throws CoreException public int getLineNumber() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
*/ */
public int getCharStart() throws CoreException public int getCharStart() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_START, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
*/ */
public int getCharEnd() throws CoreException public int getCharEnd() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
} }
/** /**
* Returns the type of marker associated with this type of breakpoints * Returns the type of marker associated with this type of breakpoints
*/ */
public static String getMarkerType() public static String getMarkerType() {
{
return C_ADDRESS_BREAKPOINT; return C_ADDRESS_BREAKPOINT;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
protected String getMarkerMessage() throws CoreException protected String getMarkerMessage() throws CoreException {
{ StringBuffer sb = new StringBuffer( BreakpointMessages.getString( "CAddressBreakpoint.1" ) ); //$NON-NLS-1$
StringBuffer sb = new StringBuffer( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CAddressBreakpoint.Address_breakpoint") ); //$NON-NLS-1$
String name = ensureMarker().getResource().getName(); String name = ensureMarker().getResource().getName();
if ( name != null && name.length() > 0 ) if ( name != null && name.length() > 0 ) {
{
sb.append( ' ' ); sb.append( ' ' );
sb.append( name ); sb.append( name );
} }
try try {
{
long address = Long.parseLong( getAddress() ); long address = Long.parseLong( getAddress() );
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CAddressBreakpoint.address") ); //$NON-NLS-1$ sb.append( MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.2" ), new String[] { CDebugUtils.toHexAddressString( address ) } ) ); //$NON-NLS-1$
sb.append( CDebugUtils.toHexAddressString( address ) );
sb.append( ']' );
} }
catch( NumberFormatException e ) catch( NumberFormatException e ) {
{
} }
sb.append( getConditionText() ); sb.append( getConditionText() );
return sb.toString(); return sb.toString();

View file

@ -1,14 +1,19 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -21,43 +26,31 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.model.Breakpoint; import org.eclipse.debug.core.model.Breakpoint;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
/** /**
* * The base class for all C/C++ specific breakpoints.
* Enter type comment.
*
* @since Aug 21, 2002
*/ */
public abstract class CBreakpoint extends Breakpoint public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, IDebugEventSetListener {
implements ICBreakpoint,
IDebugEventSetListener
{
/** /**
* Constructor for CBreakpoint. * Constructor for CBreakpoint.
*/ */
public CBreakpoint() public CBreakpoint() {
{
} }
/** /**
* Constructor for CBreakpoint. * Constructor for CBreakpoint.
*/ */
public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws DebugException public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws CoreException {
{ IWorkspaceRunnable wr = new IWorkspaceRunnable() {
IWorkspaceRunnable wr= new IWorkspaceRunnable()
{ public void run( IProgressMonitor monitor ) throws CoreException {
public void run( IProgressMonitor monitor ) throws CoreException
{
// create the marker // create the marker
setMarker( resource.createMarker( markerType ) ); setMarker( resource.createMarker( markerType ) );
// set attributes // set attributes
ensureMarker().setAttributes( attributes ); ensureMarker().setAttributes( attributes );
//set the marker message //set the marker message
setAttribute( IMarker.MESSAGE, getMarkerMessage() ); setAttribute( IMarker.MESSAGE, getMarkerMessage() );
// add to breakpoint manager if requested // add to breakpoint manager if requested
register( add ); register( add );
} }
@ -65,21 +58,15 @@ public abstract class CBreakpoint extends Breakpoint
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 attributes, final boolean add ) throws DebugException {
{ IWorkspaceRunnable wr = new IWorkspaceRunnable() {
IWorkspaceRunnable wr= new IWorkspaceRunnable() public void run( IProgressMonitor monitor ) throws CoreException {
{
public void run( IProgressMonitor monitor ) throws CoreException
{
// create the marker // create the marker
setMarker( resource.createMarker( markerType ) ); setMarker( resource.createMarker( markerType ) );
// set attributes // set attributes
ensureMarker().setAttributes( attributes ); ensureMarker().setAttributes( attributes );
//set the marker message //set the marker message
setAttribute( IMarker.MESSAGE, getMarkerMessage() ); setAttribute( IMarker.MESSAGE, getMarkerMessage() );
// add to breakpoint manager if requested // add to breakpoint manager if requested
register( add ); register( add );
} }
@ -87,196 +74,198 @@ public abstract class CBreakpoint extends Breakpoint
run( wr ); run( wr );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier() * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
*/ */
public String getModelIdentifier() public String getModelIdentifier() {
{ return CDIDebugModel.getPluginIdentifier();
return CDebugModel.getPluginIdentifier();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#isInstalled() * @see org.eclipse.cdt.debug.core.ICBreakpoint#isInstalled()
*/ */
public boolean isInstalled() throws CoreException public boolean isInstalled() throws CoreException {
{
return ensureMarker().getAttribute( INSTALL_COUNT, 0 ) > 0; return ensureMarker().getAttribute( INSTALL_COUNT, 0 ) > 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#getCondition() * @see org.eclipse.cdt.debug.core.ICBreakpoint#getCondition()
*/ */
public String getCondition() throws CoreException public String getCondition() throws CoreException {
{
return ensureMarker().getAttribute( CONDITION, "" ); //$NON-NLS-1$ return ensureMarker().getAttribute( CONDITION, "" ); //$NON-NLS-1$
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#setCondition(String) * @see org.eclipse.cdt.debug.core.ICBreakpoint#setCondition(String)
*/ */
public void setCondition( String condition ) throws CoreException public void setCondition( String condition ) throws CoreException {
{
setAttribute( CONDITION, condition ); setAttribute( CONDITION, condition );
setAttribute( IMarker.MESSAGE, getMarkerMessage() ); setAttribute( IMarker.MESSAGE, getMarkerMessage() );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#getIgnoreCount() * @see org.eclipse.cdt.debug.core.ICBreakpoint#getIgnoreCount()
*/ */
public int getIgnoreCount() throws CoreException public int getIgnoreCount() throws CoreException {
{
return ensureMarker().getAttribute( IGNORE_COUNT, 0 ); return ensureMarker().getAttribute( IGNORE_COUNT, 0 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#setIgnoreCount(int) * @see org.eclipse.cdt.debug.core.ICBreakpoint#setIgnoreCount(int)
*/ */
public void setIgnoreCount( int ignoreCount ) throws CoreException public void setIgnoreCount( int ignoreCount ) throws CoreException {
{
setAttribute( IGNORE_COUNT, ignoreCount ); setAttribute( IGNORE_COUNT, ignoreCount );
setAttribute( IMarker.MESSAGE, getMarkerMessage() ); setAttribute( IMarker.MESSAGE, getMarkerMessage() );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#getThreadId() * @see org.eclipse.cdt.debug.core.ICBreakpoint#getThreadId()
*/ */
public String getThreadId() throws CoreException public String getThreadId() throws CoreException {
{
return ensureMarker().getAttribute( THREAD_ID, null ); return ensureMarker().getAttribute( THREAD_ID, null );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICBreakpoint#setThreadId(String) * @see org.eclipse.cdt.debug.core.ICBreakpoint#setThreadId(String)
*/ */
public void setThreadId( String threadId ) throws CoreException public void setThreadId( String threadId ) throws CoreException {
{
setAttribute( THREAD_ID, threadId ); setAttribute( THREAD_ID, threadId );
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getSourceHandle()
*/
public String getSourceHandle() throws CoreException {
return ensureMarker().getAttribute( SOURCE_HANDLE, null );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setSourceHandle(java.lang.String)
*/
public void setSourceHandle( String sourceHandle ) throws CoreException {
setAttribute( SOURCE_HANDLE, sourceHandle );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(DebugEvent[]) * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(DebugEvent[])
*/ */
public void handleDebugEvents( DebugEvent[] events ) public void handleDebugEvents( DebugEvent[] events ) {
{
} }
/** /**
* Execute the given workspace runnable * Execute the given workspace runnable
*/ */
protected void run( IWorkspaceRunnable wr ) throws DebugException protected void run( IWorkspaceRunnable wr ) throws DebugException {
{ try {
try
{
ResourcesPlugin.getWorkspace().run( wr, null ); ResourcesPlugin.getWorkspace().run( wr, null );
} }
catch ( CoreException e ) catch( CoreException e ) {
{
throw new DebugException( e.getStatus() ); throw new DebugException( e.getStatus() );
} }
} }
/** /**
* Add this breakpoint to the breakpoint manager, * Add this breakpoint to the breakpoint manager, or sets it as
* or sets it as unregistered. * unregistered.
*/ */
public void register( boolean register ) throws CoreException public void register( boolean register ) throws CoreException {
{ if ( register ) {
if ( register )
{
DebugPlugin.getDefault().getBreakpointManager().addBreakpoint( this ); DebugPlugin.getDefault().getBreakpointManager().addBreakpoint( this );
} }
/* /*
else * else { setRegistered( false ); }
{ */
setRegistered( false );
}
*/
} }
protected String getMarkerMessage() throws CoreException abstract protected String getMarkerMessage() throws CoreException;
{
return null;
}
/** /**
* Resets the install count of this breakpoint * Resets the install count of this breakpoint
*/ */
public synchronized void resetInstallCount() throws CoreException public synchronized void resetInstallCount() throws CoreException {
{
setAttribute( INSTALL_COUNT, 0 ); setAttribute( INSTALL_COUNT, 0 );
} }
/** /**
* Increments the install count of this breakpoint * Increments the install count of this breakpoint
*/ */
public synchronized void incrementInstallCount() throws CoreException public synchronized void incrementInstallCount() throws CoreException {
{
int count = getInstallCount(); int count = getInstallCount();
setAttribute( INSTALL_COUNT, count + 1 ); setAttribute( INSTALL_COUNT, count + 1 );
} }
/** /**
* Returns the <code>INSTALL_COUNT</code> attribute of this breakpoint * Returns the <code>INSTALL_COUNT</code> attribute of this breakpoint or
* or 0 if the attribute is not set. * 0 if the attribute is not set.
*/ */
public int getInstallCount() throws CoreException public int getInstallCount() throws CoreException {
{
return ensureMarker().getAttribute( INSTALL_COUNT, 0 ); return ensureMarker().getAttribute( INSTALL_COUNT, 0 );
} }
/** /**
* Decrements the install count of this breakpoint. * Decrements the install count of this breakpoint.
*/ */
public synchronized void decrementInstallCount() throws CoreException public synchronized void decrementInstallCount() throws CoreException {
{
int count = getInstallCount(); int count = getInstallCount();
if ( count > 0 ) if ( count > 0 ) {
{
setAttribute( INSTALL_COUNT, count - 1 ); setAttribute( INSTALL_COUNT, count - 1 );
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.Breakpoint#ensureMarker() * @see org.eclipse.debug.core.model.Breakpoint#ensureMarker()
*/ */
protected IMarker ensureMarker() throws DebugException protected IMarker ensureMarker() throws DebugException {
{
return super.ensureMarker(); return super.ensureMarker();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.Breakpoint#setAttribute(String, Object) * @see org.eclipse.debug.core.model.Breakpoint#setAttribute(String, Object)
*/ */
protected void setAttribute( String attributeName, Object value ) throws CoreException protected void setAttribute( String attributeName, Object value ) throws CoreException {
{
super.setAttribute( attributeName, value ); super.setAttribute( attributeName, value );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.model.ICBreakpoint#isConditional() * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#isConditional()
*/ */
public boolean isConditional() throws CoreException public boolean isConditional() throws CoreException {
{ return ((getCondition() != null && getCondition().trim().length() > 0) || getIgnoreCount() > 0);
return ( (getCondition() != null && getCondition().trim().length() > 0) || getIgnoreCount() > 0 );
} }
protected String getConditionText() throws CoreException protected String getConditionText() throws CoreException {
{
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( " [" ); //$NON-NLS-1$
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CBreakpoint.ignore_count") ); //$NON-NLS-1$
sb.append( ' ' );
sb.append( ignoreCount );
sb.append( ']' );
} }
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( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CBreakpoint.if") ); //$NON-NLS-1$
sb.append( condition );
} }
return sb.toString(); return sb.toString();
} }

View file

@ -1,10 +1,16 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
@ -12,17 +18,12 @@ import org.eclipse.core.resources.IFile;
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;
import org.eclipse.debug.core.DebugException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
/** /**
* * A breakpoint that suspends the execution when a function is entered.
* Enter type comment.
*
* @since Aug 21, 2002
*/ */
public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint {
{
private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$ private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$
/** /**
@ -35,99 +36,96 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp
/** /**
* Constructor for CFunctionBreakpoint. * Constructor for CFunctionBreakpoint.
*/ */
public CFunctionBreakpoint() public CFunctionBreakpoint() {
{
} }
/** /**
* Constructor for CFunctionBreakpoint. * Constructor for CFunctionBreakpoint.
*/ */
public CFunctionBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException public CFunctionBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException {
{
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#getFunction() * @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#getFunction()
*/ */
public String getFunction() throws CoreException public String getFunction() throws CoreException {
{
return ensureMarker().getAttribute( FUNCTION, null ); return ensureMarker().getAttribute( FUNCTION, null );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#setFunction(String) * @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#setFunction(String)
*/ */
public void setFunction( String function ) throws CoreException public void setFunction( String function ) throws CoreException {
{
setAttribute( FUNCTION, function ); setAttribute( FUNCTION, function );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
*/ */
public int getLineNumber() throws CoreException public int getLineNumber() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
*/ */
public int getCharStart() throws CoreException public int getCharStart() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_START, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
*/ */
public int getCharEnd() throws CoreException public int getCharEnd() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
} }
/** /**
* Returns the type of marker associated with this type of breakpoints * Returns the type of marker associated with this type of breakpoints
*/ */
public static String getMarkerType() public static String getMarkerType() {
{
return C_FUNCTION_BREAKPOINT; return C_FUNCTION_BREAKPOINT;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint#getFileName() * @see org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint#getFileName()
*/ */
public String getFileName() throws CoreException public String getFileName() throws CoreException {
{
IResource resource = ensureMarker().getResource(); IResource resource = ensureMarker().getResource();
if ( resource instanceof IFile ) if ( resource instanceof IFile ) {
{
return ((IFile)resource).getLocation().lastSegment(); return ((IFile)resource).getLocation().lastSegment();
} }
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
protected String getMarkerMessage() throws CoreException protected String getMarkerMessage() throws CoreException {
{ StringBuffer sb = new StringBuffer( BreakpointMessages.getString( "CFunctionBreakpoint.2" ) ); //$NON-NLS-1$
StringBuffer sb = new StringBuffer( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CFunctionBreakpoint.Function_breakpoint") ); //$NON-NLS-1$
String name = ensureMarker().getResource().getName(); String name = ensureMarker().getResource().getName();
if ( name != null && name.length() > 0 ) if ( name != null && name.length() > 0 ) {
{
sb.append( ' ' ); sb.append( ' ' );
sb.append( name ); sb.append( name );
} }
String function = getFunction(); String function = getFunction();
if ( function != null && function.trim().length() > 0 ) if ( function != null && function.trim().length() > 0 ) {
{ sb.append( MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.3" ), new String[] { function.trim() } ) ); //$NON-NLS-1$
sb.append( " [" ); //$NON-NLS-1$
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CFunctionBreakpoint.function") ); //$NON-NLS-1$
sb.append( ' ' );
sb.append( function.trim() );
sb.append( ']' );
} }
sb.append( getConditionText() ); sb.append( getConditionText() );
return sb.toString(); return sb.toString();

View file

@ -1,96 +1,93 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
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;
import org.eclipse.debug.core.DebugException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
/** /**
* * A breakpoint that suspends the execution when a particular line of code is
* Enter type comment. * reached.
*
* @since Aug 21, 2002
*/ */
public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint {
{
private static final String C_LINE_BREAKPOINT = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$ private static final String C_LINE_BREAKPOINT = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$
/** /**
* Constructor for CLineBreakpoint. * Constructor for CLineBreakpoint.
*/ */
public CLineBreakpoint() public CLineBreakpoint() {
{
} }
/** /**
* Constructor for CLineBreakpoint. * Constructor for CLineBreakpoint.
*/ */
public CLineBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException public CLineBreakpoint( IResource resource, Map attributes, boolean add ) throws CoreException {
{
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber() * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
*/ */
public int getLineNumber() throws CoreException public int getLineNumber() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
*/ */
public int getCharStart() throws CoreException public int getCharStart() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_START, -1 );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd() * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
*/ */
public int getCharEnd() throws CoreException public int getCharEnd() throws CoreException {
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
} }
/** /**
* Returns the type of marker associated with this type of breakpoints * Returns the type of marker associated with this type of breakpoints
*/ */
public static String getMarkerType() public static String getMarkerType() {
{
return C_LINE_BREAKPOINT; return C_LINE_BREAKPOINT;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
protected String getMarkerMessage() throws CoreException protected String getMarkerMessage() throws CoreException {
{ StringBuffer sb = new StringBuffer( BreakpointMessages.getString( "CLineBreakpoint.1" ) ); //$NON-NLS-1$
StringBuffer sb = new StringBuffer( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CLineBreakpoint.Line_breakpoint") ); //$NON-NLS-1$
String fileName = ensureMarker().getResource().getName(); String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) if ( fileName != null && fileName.length() > 0 ) {
{
sb.append( ' ' ); sb.append( ' ' );
sb.append( fileName ); sb.append( fileName );
} }
int lineNumber = getLineNumber(); int lineNumber = getLineNumber();
if ( lineNumber > 0 ) if ( lineNumber > 0 ) {
{ sb.append( MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.2" ), new Integer[] { new Integer( lineNumber ) } ) ); //$NON-NLS-1$
sb.append( " [" ); //$NON-NLS-1$
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CLineBreakpoint.line") ); //$NON-NLS-1$
sb.append( ' ' );
sb.append( lineNumber );
sb.append( ']' );
} }
sb.append( getConditionText() ); sb.append( getConditionText() );
return sb.toString(); return sb.toString();

View file

@ -1,104 +1,100 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints; package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
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 org.eclipse.debug.core.DebugException;
/** /**
* * A watchpoint specific to the C/C++ debug model.
* Enter type comment.
*
* @since Sep 4, 2002
*/ */
public class CWatchpoint extends CBreakpoint implements ICWatchpoint public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
{
private static final String C_WATCHPOINT = "org.eclipse.cdt.debug.core.cWatchpointMarker"; //$NON-NLS-1$ private static final String C_WATCHPOINT = "org.eclipse.cdt.debug.core.cWatchpointMarker"; //$NON-NLS-1$
/** /**
* Constructor for CWatchpoint. * Constructor for CWatchpoint.
*/ */
public CWatchpoint() public CWatchpoint() {
{
} }
/** /**
* Constructor for CWatchpoint. * Constructor for CWatchpoint.
*/ */
public CWatchpoint( IResource resource, Map attributes, boolean add ) throws DebugException public CWatchpoint( IResource resource, Map attributes, boolean add ) throws CoreException {
{
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#isWriteType() * @see org.eclipse.cdt.debug.core.ICWatchpoint#isWriteType()
*/ */
public boolean isWriteType() throws CoreException public boolean isWriteType() throws CoreException {
{
return ensureMarker().getAttribute( WRITE, true ); return ensureMarker().getAttribute( WRITE, true );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#isReadType() * @see org.eclipse.cdt.debug.core.ICWatchpoint#isReadType()
*/ */
public boolean isReadType() throws CoreException public boolean isReadType() throws CoreException {
{
return ensureMarker().getAttribute( READ, false ); return ensureMarker().getAttribute( READ, false );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#getExpression() * @see org.eclipse.cdt.debug.core.ICWatchpoint#getExpression()
*/ */
public String getExpression() throws CoreException public String getExpression() throws CoreException {
{
return ensureMarker().getAttribute( EXPRESSION, "" ); //$NON-NLS-1$ return ensureMarker().getAttribute( EXPRESSION, "" ); //$NON-NLS-1$
} }
/** /**
* Returns the type of marker associated with this type of breakpoints * Returns the type of marker associated with this type of breakpoints
*/ */
public static String getMarkerType() public static String getMarkerType() {
{
return C_WATCHPOINT; return C_WATCHPOINT;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
protected String getMarkerMessage() throws CoreException protected String getMarkerMessage() throws CoreException {
{
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if ( isWriteType() && !isReadType() ) if ( isWriteType() && !isReadType() )
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CWatchpoint.Write_watchpoint") ); //$NON-NLS-1$ sb.append( BreakpointMessages.getString( "CWatchpoint.1" ) ); //$NON-NLS-1$
else if ( !isWriteType() && isReadType() ) else if ( !isWriteType() && isReadType() )
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CWatchpoint.Read_watchpoint") ); //$NON-NLS-1$ sb.append( BreakpointMessages.getString( "CWatchpoint.2" ) ); //$NON-NLS-1$
else if ( isWriteType() && isReadType() ) else if ( isWriteType() && isReadType() )
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CWatchpoint.Access_watchpoint") ); //$NON-NLS-1$ sb.append( BreakpointMessages.getString( "CWatchpoint.3" ) ); //$NON-NLS-1$
else else
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CWatchpoint.Watchpoint") ); //$NON-NLS-1$ sb.append( BreakpointMessages.getString( "CWatchpoint.4" ) ); //$NON-NLS-1$
sb.append( ' ' ); sb.append( ' ' );
String fileName = ensureMarker().getResource().getName(); String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) if ( fileName != null && fileName.length() > 0 ) {
{
sb.append( ' ' ); sb.append( ' ' );
sb.append( fileName ); sb.append( fileName );
} }
String expression = getExpression(); String expression = getExpression();
if ( expression != null && expression.length() > 0 ) if ( expression != null && expression.length() > 0 ) {
{ sb.append( MessageFormat.format( BreakpointMessages.getString( "CWatchpoint.5" ), new String[]{ expression } ) ); //$NON-NLS-1$
sb.append( " " ); //$NON-NLS-1$
sb.append( CDebugCorePlugin.getResourceString("internal.core.breakpoints.CWatchpoint.at") ); //$NON-NLS-1$
sb.append( " \'" ); //$NON-NLS-1$
sb.append( expression );
sb.append( '\'' );
} }
sb.append( getConditionText() ); sb.append( getConditionText() );
return sb.toString(); return sb.toString();

View file

@ -19,7 +19,6 @@ import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.ICMemoryManager; import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.ICRegisterManager; import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager; import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
@ -991,7 +990,7 @@ public class CDebugTarget extends CDebugElement
return this; return this;
if ( adapter.equals( IJumpToAddress.class ) ) if ( adapter.equals( IJumpToAddress.class ) )
return this; return this;
if ( adapter.equals( ICBreakpointManager.class ) ) if ( adapter.equals( CBreakpointManager.class ) )
return getBreakpointManager(); return getBreakpointManager();
if ( adapter.equals( DisassemblyManager.class ) ) if ( adapter.equals( DisassemblyManager.class ) )
return getDisassemblyManager(); return getDisassemblyManager();

View file

@ -1,3 +1,15 @@
2004-04-12 Mikhail Khodjaiants
Implementing retargettable breakpoint related actions.
* AddAddressBreakpointActionDelegate.java
* AddWatchpointActionDelegate.java
* ManageBreakpointRulerAction.java
* ManageBreakpointRulerActionDelegate.java
* ManageFunctionBreakpointActionDelegate.java
* ToggleBreakpointAdapter.java
* DisassemblyMarkerAnnotationModel.java
* plugin.properties
* plugin.xml
2004-04-11 Mikhail Khodjaiants 2004-04-11 Mikhail Khodjaiants
Implementation of the "Run To Line" retargettable action. Implementation of the "Run To Line" retargettable action.
* plugin.xml * plugin.xml

View file

@ -28,7 +28,7 @@ SwitchToDisassemblyAction.tooltip=Disassembly Mode On/Off
ShowDebuggerConsoleAction.label=Show Debugger Console ShowDebuggerConsoleAction.label=Show Debugger Console
ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection
AddBreakpoint.label=Add/Remove &Breakpoint AddBreakpoint.label=Add &Breakpoint
EnableBreakpoint.label=T&oggle Breakpoint EnableBreakpoint.label=T&oggle Breakpoint
BreakpointProperties.label=Breakpoint P&roperties... BreakpointProperties.label=Breakpoint P&roperties...
GlobalManageBreakpointAction.label=Add/Remove Brea&kpoint (C/C++) GlobalManageBreakpointAction.label=Add/Remove Brea&kpoint (C/C++)

View file

@ -69,8 +69,8 @@
<view <view
relative="org.eclipse.debug.ui.VariableView" relative="org.eclipse.debug.ui.VariableView"
visible="false" visible="false"
id="org.eclipse.cdt.debug.ui.MemoryView" relationship="stack"
relationship="stack"> id="org.eclipse.cdt.debug.ui.MemoryView">
</view> </view>
<viewShortcut <viewShortcut
id="org.eclipse.cdt.debug.ui.MemoryView"> id="org.eclipse.cdt.debug.ui.MemoryView">
@ -78,8 +78,8 @@
<view <view
relative="org.eclipse.debug.ui.VariableView" relative="org.eclipse.debug.ui.VariableView"
visible="false" visible="false"
id="org.eclipse.cdt.debug.ui.SharedLibrariesView" relationship="stack"
relationship="stack"> id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
</view> </view>
<viewShortcut <viewShortcut
id="org.eclipse.cdt.debug.ui.SharedLibrariesView"> id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
@ -87,8 +87,8 @@
<view <view
relative="org.eclipse.debug.ui.VariableView" relative="org.eclipse.debug.ui.VariableView"
visible="false" visible="false"
id="org.eclipse.cdt.debug.ui.SignalsView" relationship="stack"
relationship="stack"> id="org.eclipse.cdt.debug.ui.SignalsView">
</view> </view>
<viewShortcut <viewShortcut
id="org.eclipse.cdt.debug.ui.SignalsView"> id="org.eclipse.cdt.debug.ui.SignalsView">
@ -177,20 +177,6 @@
</pluginState> </pluginState>
</enablement> </enablement>
</action> </action>
<action
label="%GlobalManageBreakpointAction.label"
icon="icons/full/obj16/brkp_obj.gif"
helpContextId="manage_breakpoint_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointActionDelegate"
menubarPath="org.eclipse.ui.run/cBreakpointGroup"
id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
<action <action
label="%AddAddressBreakpointAction.label" label="%AddAddressBreakpointAction.label"
icon="icons/full/obj16/addrbrkp_obj.gif" icon="icons/full/obj16/addrbrkp_obj.gif"
@ -277,8 +263,8 @@
</action> </action>
<action <action
label="%SwitchToDisassemblyAction.label" label="%SwitchToDisassemblyAction.label"
icon="icons/full/clcl16/disassembly.gif"
style="toggle" style="toggle"
icon="icons/full/clcl16/disassembly.gif"
helpContextId="switch_to_disassembly_action_context" helpContextId="switch_to_disassembly_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate"
menubarPath="renderGroup" menubarPath="renderGroup"
@ -673,8 +659,8 @@
label="%LoadSymbolsAction.label" label="%LoadSymbolsAction.label"
icon="icons/full/clcl16/load_symbols_co.gif" icon="icons/full/clcl16/load_symbols_co.gif"
helpContextId="load_symbols_action_context" helpContextId="load_symbols_action_context"
tooltip="%LoadSymbolsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate"
tooltip="%LoadSymbolsAction.tooltip"
menubarPath="sharedLibrariesGroup" menubarPath="sharedLibrariesGroup"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate">
@ -693,8 +679,8 @@
label="%SignalAction.label" label="%SignalAction.label"
icon="icons/full/clcl16/signal_co.gif" icon="icons/full/clcl16/signal_co.gif"
helpContextId="signal_action_context" helpContextId="signal_action_context"
tooltip="%SignalAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate"
tooltip="%SignalAction.tooltip"
menubarPath="additions" menubarPath="additions"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate">
@ -709,8 +695,8 @@
label="%SignalPropertiesAction.label" label="%SignalPropertiesAction.label"
style="pulldown" style="pulldown"
helpContextId="signal_properties_action_context" helpContextId="signal_properties_action_context"
tooltip="%SignalPropertiesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.SignalPropertiesActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.SignalPropertiesActionDelegate"
tooltip="%SignalPropertiesAction.tooltip"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.ui.SignalPropertiesAction"> id="org.eclipse.cdt.debug.ui.SignalPropertiesAction">
<enablement> <enablement>
@ -746,8 +732,8 @@
<action <action
label="%RestoreDefaultTypeAction.label" label="%RestoreDefaultTypeAction.label"
helpContextId="restore_default_type_action_context" helpContextId="restore_default_type_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"
tooltip="%RestoreDefaultTypeAction.tooltip" tooltip="%RestoreDefaultTypeAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"
menubarPath="additions" menubarPath="additions"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
@ -762,8 +748,8 @@
label="%CastToTypeAction.label" label="%CastToTypeAction.label"
icon="icons/full/clcl16/casttotype_co.gif" icon="icons/full/clcl16/casttotype_co.gif"
helpContextId="cast_to_type_action_context" helpContextId="cast_to_type_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"
tooltip="%CastToTypeAction.tooltip" tooltip="%CastToTypeAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"
menubarPath="additions" menubarPath="additions"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate">
@ -778,8 +764,8 @@
label="%CastToArrayAction.label" label="%CastToArrayAction.label"
icon="icons/full/clcl16/showasarray_co.gif" icon="icons/full/clcl16/showasarray_co.gif"
helpContextId="cast_to_array_action_context" helpContextId="cast_to_array_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"
tooltip="%CastToArrayAction.tooltip" tooltip="%CastToArrayAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"
menubarPath="additions" menubarPath="additions"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate">
@ -798,8 +784,8 @@
label="%ManageFunctionBreakpointAction.label" label="%ManageFunctionBreakpointAction.label"
icon="icons/full/obj16/funbrkp_obj.gif" icon="icons/full/obj16/funbrkp_obj.gif"
helpContextId="manage_function_breakpoint_action_context" helpContextId="manage_function_breakpoint_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"
tooltip="%ManageFunctionBreakpointAction.tooltip" tooltip="%ManageFunctionBreakpointAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"
menubarPath="additions" menubarPath="additions"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate">
@ -818,8 +804,8 @@
label="%DisableVariablesAction.label" label="%DisableVariablesAction.label"
icon="icons/full/clcl16/disabled_co.gif" icon="icons/full/clcl16/disabled_co.gif"
helpContextId="disable_variables_action_context" helpContextId="disable_variables_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate"
tooltip="%DisableVariablesAction.tooltip" tooltip="%DisableVariablesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate"
menubarPath="variableGroup" menubarPath="variableGroup"
enablesFor="2+" enablesFor="2+"
id="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate">
@ -831,8 +817,8 @@
label="%EnableVariablesAction.label" label="%EnableVariablesAction.label"
icon="icons/full/clcl16/enabled_co.gif" icon="icons/full/clcl16/enabled_co.gif"
helpContextId="enable_variables_action_context" helpContextId="enable_variables_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate"
tooltip="%EnableVariablesAction.tooltip" tooltip="%EnableVariablesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate"
menubarPath="variableGroup" menubarPath="variableGroup"
enablesFor="2+" enablesFor="2+"
id="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate">
@ -855,8 +841,8 @@
disabledIcon="icons/full/dlcl16/restart.gif" disabledIcon="icons/full/dlcl16/restart.gif"
enablesFor="1" enablesFor="1"
icon="icons/full/elcl16/restart.gif" icon="icons/full/elcl16/restart.gif"
label="%RestartAction.label"
helpContextId="restart_action_context" helpContextId="restart_action_context"
label="%RestartAction.label"
tooltip="%RestartAction.tooltip"> tooltip="%RestartAction.tooltip">
<enablement> <enablement>
<pluginState <pluginState
@ -874,8 +860,8 @@
disabledIcon="icons/full/dlcl16/disassembly.gif" disabledIcon="icons/full/dlcl16/disassembly.gif"
enablesFor="1" enablesFor="1"
icon="icons/full/elcl16/disassembly.gif" icon="icons/full/elcl16/disassembly.gif"
label="%SwitchToDisassemblyAction.label"
helpContextId="switch_to_disassembly_action_context" helpContextId="switch_to_disassembly_action_context"
label="%SwitchToDisassemblyAction.label"
tooltip="%SwitchToDisassemblyAction.tooltip"> tooltip="%SwitchToDisassemblyAction.tooltip">
<enablement> <enablement>
<pluginState <pluginState
@ -890,11 +876,11 @@
id="org.eclipse.cdt.debug.ui.debugView.menu"> id="org.eclipse.cdt.debug.ui.debugView.menu">
<action <action
label="%ShowFullPathsAction.label" label="%ShowFullPathsAction.label"
style="toggle"
icon="icons/full/clcl16/show_paths.gif" icon="icons/full/clcl16/show_paths.gif"
style="toggle"
helpContextId="show_full_paths_context" helpContextId="show_full_paths_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip" tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
menubarPath="cDebugActions" menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"> id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement> <enablement>
@ -914,11 +900,11 @@
id="org.eclipse.cdt.debug.ui.breakpointView.menu"> id="org.eclipse.cdt.debug.ui.breakpointView.menu">
<action <action
label="%ShowFullPathsAction.label" label="%ShowFullPathsAction.label"
style="toggle"
icon="icons/full/clcl16/show_paths.gif" icon="icons/full/clcl16/show_paths.gif"
style="toggle"
helpContextId="show_full_paths_context" helpContextId="show_full_paths_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip" tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
menubarPath="cDebugActions" menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"> id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement> <enablement>
@ -940,8 +926,8 @@
disabledIcon="icons/full/dlcl16/watch_globals.gif" disabledIcon="icons/full/dlcl16/watch_globals.gif"
enablesFor="1" enablesFor="1"
icon="icons/full/elcl16/watch_globals.gif" icon="icons/full/elcl16/watch_globals.gif"
label="%AddGlobalsAction.label"
helpContextId="add_globals_action_context" helpContextId="add_globals_action_context"
label="%AddGlobalsAction.label"
tooltip="%AddGlobalsAction.tooltip"> tooltip="%AddGlobalsAction.tooltip">
<enablement> <enablement>
<pluginState <pluginState
@ -956,11 +942,11 @@
id="org.eclipse.debug.ui.sharedLibrariesView.menu"> id="org.eclipse.debug.ui.sharedLibrariesView.menu">
<action <action
label="%ShowFullPathsAction.label" label="%ShowFullPathsAction.label"
icon="icons/full/clcl16/show_paths.gif"
style="toggle" style="toggle"
icon="icons/full/clcl16/show_paths.gif"
helpContextId="show_full_paths_context" helpContextId="show_full_paths_context"
tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction" class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip"
menubarPath="cDebugActions" menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"> id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement> <enablement>
@ -1051,20 +1037,20 @@
<extension <extension
point="org.eclipse.debug.core.statusHandlers"> point="org.eclipse.debug.core.statusHandlers">
<statusHandler <statusHandler
code="10000"
plugin="org.eclipse.cdt.debug.core" plugin="org.eclipse.cdt.debug.core"
code="10000"
class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler" class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"> id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler">
</statusHandler> </statusHandler>
<statusHandler <statusHandler
code="10001"
plugin="org.eclipse.cdt.debug.core" plugin="org.eclipse.cdt.debug.core"
code="10001"
class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler" class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"> id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler">
</statusHandler> </statusHandler>
<statusHandler <statusHandler
code="10002"
plugin="org.eclipse.cdt.debug.core" plugin="org.eclipse.cdt.debug.core"
code="10002"
class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler" class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"> id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler">
</statusHandler> </statusHandler>
@ -1121,16 +1107,16 @@
point="org.eclipse.ui.editors"> point="org.eclipse.ui.editors">
<editor <editor
name="%DisassemblyEditor.name" name="%DisassemblyEditor.name"
extensions="dasm"
icon="icons/full/obj16/disassembly_obj.gif" icon="icons/full/obj16/disassembly_obj.gif"
extensions="dasm"
class="org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditor" class="org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditor"
id="org.eclipse.cdt.debug.ui.DisassemblyEditor"> id="org.eclipse.cdt.debug.ui.DisassemblyEditor">
</editor> </editor>
<editor <editor
name="%CDebugEditor.name" name="%CDebugEditor.name"
icon="icons/full/obj16/filenotfound_obj.gif" icon="icons/full/obj16/filenotfound_obj.gif"
class="org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor" contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
class="org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor"
id="org.eclipse.cdt.debug.ui.editor.CDebugEditor"> id="org.eclipse.cdt.debug.ui.editor.CDebugEditor">
</editor> </editor>
</extension> </extension>
@ -1152,8 +1138,8 @@
<context <context
name="Debugging C/C++" name="Debugging C/C++"
description="Debugging C/C++ Programs" description="Debugging C/C++ Programs"
id="org.eclipse.cdt.debug.ui.debugging" parentId="org.eclipse.debug.ui.debugging"
parentId="org.eclipse.debug.ui.debugging"> id="org.eclipse.cdt.debug.ui.debugging">
</context> </context>
</extension> </extension>
<extension <extension
@ -1185,8 +1171,8 @@
<extension <extension
point="org.eclipse.ui.editors.annotationTypes"> point="org.eclipse.ui.editors.annotationTypes">
<type <type
super="org.eclipse.debug.core.breakpoint"
markerType="org.eclipse.cdt.debug.core.cBreakpointMarker" markerType="org.eclipse.cdt.debug.core.cBreakpointMarker"
super="org.eclipse.debug.core.breakpoint"
name="org.eclipse.cdt.debug.core.breakpoint"> name="org.eclipse.cdt.debug.core.breakpoint">
</type> </type>
</extension> </extension>

View file

@ -71,12 +71,12 @@ public class AddAddressBreakpointActionDelegate extends AbstractListenerActionDe
new AddressValidator() ); new AddressValidator() );
if ( dialog.open() == Window.OK ) if ( dialog.open() == Window.OK )
{ {
CDebugModel.createAddressBreakpoint( ((IExecFileInfo)getDebugTarget( element ).getAdapter( IExecFileInfo.class )).getExecFile(), // CDebugModel.createAddressBreakpoint( ((IExecFileInfo)getDebugTarget( element ).getAdapter( IExecFileInfo.class )).getExecFile(),
parseValue( dialog.getValue().trim() ), // parseValue( dialog.getValue().trim() ),
true, // true,
0, // 0,
"", //$NON-NLS-1$ // "", //$NON-NLS-1$
true ); // true );
} }
} }

View file

@ -1,11 +1,16 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -34,35 +39,34 @@ import org.eclipse.ui.texteditor.ITextEditor;
* *
* @since Sep 4, 2002 * @since Sep 4, 2002
*/ */
public class AddWatchpointActionDelegate extends ActionDelegate public class AddWatchpointActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener {
implements IWorkbenchWindowActionDelegate,
IPartListener
{
private boolean fInitialized = false; private boolean fInitialized = false;
private IAction fAction = null; private IAction fAction = null;
private ITextEditor fTextEditor = null; private ITextEditor fTextEditor = null;
private IWorkbenchWindow fWorkbenchWindow = null; private IWorkbenchWindow fWorkbenchWindow = null;
private IProject fProject = null; private IProject fProject = null;
/** /**
* Constructor for AddWatchpointActionDelegate. * Constructor for AddWatchpointActionDelegate.
*/ */
public AddWatchpointActionDelegate() public AddWatchpointActionDelegate() {
{
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/ */
public void dispose() public void dispose() {
{
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
*/ */
public void init( IWorkbenchWindow window ) public void init( IWorkbenchWindow window ) {
{
setWorkbenchWindow( window ); setWorkbenchWindow( window );
window.getPartService().addPartListener( this ); window.getPartService().addPartListener( this );
} }
@ -70,41 +74,28 @@ public class AddWatchpointActionDelegate extends ActionDelegate
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(IAction) * @see org.eclipse.ui.IActionDelegate#run(IAction)
*/ */
public void run( IAction action ) public void run( IAction action ) {
{
String expression = getSelectedExpression(); String expression = getSelectedExpression();
AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), true, false, expression );
true,
false,
expression );
if ( dlg.open() != Window.OK ) if ( dlg.open() != Window.OK )
return; return;
if ( getTextEditor() != null ) if ( getTextEditor() != null ) {
{
update(); update();
addWatchpoint( getTextEditor().getEditorInput(), addWatchpoint( getTextEditor().getEditorInput(), dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression() );
dlg.getWriteAccess(),
dlg.getReadAccess(),
dlg.getExpression() );
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
*/ */
public void selectionChanged( IAction action, ISelection selection ) public void selectionChanged( IAction action, ISelection selection ) {
{ if ( !fInitialized ) {
if ( !fInitialized )
{
setAction( action ); setAction( action );
if ( getWorkbenchWindow() != null ) if ( getWorkbenchWindow() != null ) {
{
IWorkbenchPage page = getWorkbenchWindow().getActivePage(); IWorkbenchPage page = getWorkbenchWindow().getActivePage();
if ( page != null ) if ( page != null ) {
{
IEditorPart part = page.getActiveEditor(); IEditorPart part = page.getActiveEditor();
if ( part instanceof ITextEditor ) if ( part instanceof ITextEditor ) {
{
setTextEditor( (ITextEditor)part ); setTextEditor( (ITextEditor)part );
} }
} }
@ -113,53 +104,42 @@ public class AddWatchpointActionDelegate extends ActionDelegate
} }
} }
protected IAction getAction() protected IAction getAction() {
{
return fAction; return fAction;
} }
protected void setAction( IAction action ) protected void setAction( IAction action ) {
{
fAction = action; fAction = action;
} }
protected IWorkbenchWindow getWorkbenchWindow() protected IWorkbenchWindow getWorkbenchWindow() {
{
return fWorkbenchWindow; return fWorkbenchWindow;
} }
protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) {
{
fWorkbenchWindow = workbenchWindow; fWorkbenchWindow = workbenchWindow;
} }
protected ITextEditor getTextEditor() protected ITextEditor getTextEditor() {
{
return fTextEditor; return fTextEditor;
} }
protected void setTextEditor( ITextEditor editor ) protected void setTextEditor( ITextEditor editor ) {
{
fTextEditor = editor; fTextEditor = editor;
if ( fTextEditor != null ) if ( fTextEditor != null ) {
{
IEditorInput input = fTextEditor.getEditorInput(); IEditorInput input = fTextEditor.getEditorInput();
IFile file = ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null; IFile file = (input != null && input instanceof IFileEditorInput) ? ((IFileEditorInput)input).getFile() : null;
setProject( ( file != null ) ? file.getProject() : null ); setProject( (file != null) ? file.getProject() : null );
} }
setEnabledState( editor ); setEnabledState( editor );
} }
protected String getSelectedExpression() protected String getSelectedExpression() {
{ if ( getTextEditor() != null ) {
if ( getTextEditor() != null )
{
ISelectionProvider sp = getTextEditor().getSelectionProvider(); ISelectionProvider sp = getTextEditor().getSelectionProvider();
if ( sp != null ) if ( sp != null ) {
{
ISelection s = sp.getSelection(); ISelection s = sp.getSelection();
if ( s instanceof ITextSelection ) if ( s instanceof ITextSelection ) {
{
return ((ITextSelection)s).getText().trim(); return ((ITextSelection)s).getText().trim();
} }
} }
@ -167,70 +147,51 @@ public class AddWatchpointActionDelegate extends ActionDelegate
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
protected void update( ISelection selection ) protected void update( ISelection selection ) {
{
setEnabledState( getTextEditor() ); setEnabledState( getTextEditor() );
} }
protected void update() protected void update() {
{
IAction action = getAction(); IAction action = getAction();
if ( action != null ) if ( action != null ) {
{
action.setEnabled( getTextEditor() != null ); action.setEnabled( getTextEditor() != null );
} }
} }
protected void setEnabledState( ITextEditor editor ) protected void setEnabledState( ITextEditor editor ) {
{ if ( getAction() != null ) {
if ( getAction() != null )
{
getAction().setEnabled( editor != null ); getAction().setEnabled( editor != null );
} }
} }
protected IProject getProject() protected IProject getProject() {
{
return fProject; return fProject;
} }
protected void setProject( IProject project ) protected void setProject( IProject project ) {
{
fProject = project; fProject = project;
} }
protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) {
{
if ( getProject() == null ) if ( getProject() == null )
return; return;
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput ); IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier(); WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
if ( wev.isValidExpression( document, expression ) ) if ( wev.isValidExpression( document, expression ) ) {
{ try {
try CDIDebugModel.createWatchpoint( "", getProject(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
{
CDebugModel.createWatchpoint( getProject(),
write,
read,
expression,
true,
0,
"", //$NON-NLS-1$
true );
} }
catch( CoreException ce ) catch( CoreException ce ) {
{ CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString( "internal.ui.actions.AddWatchpointActionDelegate.Cannot_add_watchpoint" ), ce ); //$NON-NLS-1$
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.AddWatchpointActionDelegate.Cannot_add_watchpoint"), ce ); //$NON-NLS-1$
} }
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
*/ */
public void partActivated( IWorkbenchPart part ) public void partActivated( IWorkbenchPart part ) {
{ if ( part instanceof ITextEditor ) {
if ( part instanceof ITextEditor )
{
setTextEditor( (ITextEditor)part ); setTextEditor( (ITextEditor)part );
} }
} }
@ -238,20 +199,16 @@ public class AddWatchpointActionDelegate extends ActionDelegate
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
*/ */
public void partBroughtToTop( IWorkbenchPart part ) public void partBroughtToTop( IWorkbenchPart part ) {
{
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
*/ */
public void partClosed( IWorkbenchPart part ) public void partClosed( IWorkbenchPart part ) {
{ if ( part == getTextEditor() ) {
if ( part == getTextEditor() )
{
setTextEditor( null ); setTextEditor( null );
if ( getAction() != null ) if ( getAction() != null ) {
{
getAction().setEnabled( false ); getAction().setEnabled( false );
} }
} }
@ -260,19 +217,15 @@ public class AddWatchpointActionDelegate extends ActionDelegate
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
*/ */
public void partDeactivated( IWorkbenchPart part ) public void partDeactivated( IWorkbenchPart part ) {
{
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
*/ */
public void partOpened( IWorkbenchPart part ) public void partOpened( IWorkbenchPart part ) {
{ if ( part instanceof ITextEditor ) {
if ( part instanceof ITextEditor ) if ( getTextEditor() == null ) {
{
if ( getTextEditor() == null )
{
setTextEditor( (ITextEditor)part ); setTextEditor( (ITextEditor)part );
} }
} }

View file

@ -1,317 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.texteditor.ITextEditor;
/**
*
* Action for adding/removing breakpoints at a line in the source file
* shown in the active C/C++ Editor.
*
* @since Sep 3, 2002
*/
public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDelegate,
IPartListener
{
private boolean fInitialized = false;
private IAction fAction = null;
private int fLineNumber;
private ITextEditor fTextEditor = null;
private IWorkbenchWindow fWorkbenchWindow = null;
private IFile fFile = null;
/**
* Constructor for ManageBreakpointActionDelegate.
*/
public ManageBreakpointActionDelegate()
{
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose()
{
getWorkbenchWindow().getPartService().removePartListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
*/
public void init( IWorkbenchWindow window )
{
setWorkbenchWindow( window );
window.getPartService().addPartListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
*/
public void partActivated( IWorkbenchPart part )
{
if ( part instanceof ITextEditor )
{
setTextEditor( (ITextEditor)part );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
*/
public void partBroughtToTop( IWorkbenchPart part )
{
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
*/
public void partClosed( IWorkbenchPart part )
{
if ( part == getTextEditor() )
{
setTextEditor( null );
if ( getAction() != null )
{
getAction().setEnabled( false );
}
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
*/
public void partDeactivated( IWorkbenchPart part )
{
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
*/
public void partOpened( IWorkbenchPart part )
{
if ( part instanceof ITextEditor )
{
if ( getTextEditor() == null )
{
setTextEditor( (ITextEditor)part );
}
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run( IAction action )
{
if ( getTextEditor() != null )
{
update();
manageBreakpoint( getTextEditor().getEditorInput() );
}
}
protected void update( ISelection selection )
{
setEnabledState( getTextEditor() );
}
protected void update()
{
IAction action = getAction();
if ( action != null )
{
if ( getTextEditor() != null )
{
breakpointExists( getTextEditor().getEditorInput() );
}
action.setEnabled( getTextEditor() != null && getFile() != null );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged( IAction action, ISelection selection )
{
if ( !fInitialized )
{
setAction( action );
if ( getWorkbenchWindow() != null )
{
IWorkbenchPage page = getWorkbenchWindow().getActivePage();
if ( page != null )
{
IEditorPart part = page.getActiveEditor();
if ( part instanceof ITextEditor )
{
setTextEditor( (ITextEditor)part );
update( getTextEditor().getSelectionProvider().getSelection() );
}
}
}
fInitialized = true;
}
update( selection );
}
/**
* Manages a breakpoint.
*/
protected void manageBreakpoint( IEditorInput editorInput )
{
ISelectionProvider sp = getTextEditor().getSelectionProvider();
if ( sp == null || getFile() == null )
{
beep();
return;
}
ISelection selection = sp.getSelection();
if ( selection instanceof ITextSelection )
{
if ( getFile() == null )
return;
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine());
if ( lineNumber > -1 )
{
try
{
ICLineBreakpoint breakpoint = CDebugModel.lineBreakpointExists( getFile().getLocation().toOSString(), lineNumber );
if ( breakpoint != null )
{
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
}
else
{
CDebugModel.createLineBreakpoint( getFile(),
lineNumber,
true,
0,
"", //$NON-NLS-1$
true );
}
}
catch( CoreException ce )
{
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointActionDelegate.Cannot_add_breakpoint"), ce ); //$NON-NLS-1$
}
}
}
}
/**
* Determines if a breakpoint exists on the line of the current selection.
*/
protected boolean breakpointExists(IEditorInput editorInput)
{
if ( getFile() != null )
{
try
{
return CDebugModel.lineBreakpointExists( getFile().getLocation().toOSString(), getLineNumber() ) == null;
}
catch (CoreException ce)
{
CDebugUIPlugin.log( ce );
}
}
return false;
}
protected IWorkbenchWindow getWorkbenchWindow()
{
return fWorkbenchWindow;
}
protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow )
{
fWorkbenchWindow = workbenchWindow;
}
protected ITextEditor getTextEditor()
{
return fTextEditor;
}
protected void setTextEditor( ITextEditor editor )
{
fTextEditor = editor;
if ( fTextEditor != null )
{
IEditorInput input = fTextEditor.getEditorInput();
setFile( ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null );
}
setEnabledState( editor );
}
protected void setEnabledState( ITextEditor editor )
{
if ( getAction() != null )
{
getAction().setEnabled( editor != null );
}
}
protected void beep()
{
if ( CDebugUIPlugin.getActiveWorkbenchShell() != null )
{
CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep();
}
}
protected int getLineNumber()
{
return fLineNumber;
}
protected void setLineNumber( int lineNumber )
{
fLineNumber = lineNumber;
}
protected IAction getAction()
{
return fAction;
}
protected void setAction( IAction action )
{
fAction = action;
}
protected IFile getFile()
{
return fFile;
}
protected void setFile( IFile file )
{
fFile = file;
}
}

View file

@ -1,17 +1,19 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
@ -19,37 +21,29 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.IUpdate;
/** public class ManageBreakpointRulerAction extends Action {
*
* Enter type comment.
*
* @since Aug 23, 2002
*/
public class ManageBreakpointRulerAction extends Action implements IUpdate
{
private IVerticalRulerInfo fRuler; private IVerticalRulerInfo fRuler;
private ITextEditor fTextEditor; private ITextEditor fTextEditor;
private List fMarkers; private ToggleBreakpointAdapter fBreakpointAdapter;
private String fAddLabel;
private String fRemoveLabel;
/** /**
* Constructor for ManageBreakpointRulerAction. * Constructor for ManageBreakpointRulerAction.
@ -57,80 +51,86 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* @param ruler * @param ruler
* @param editor * @param editor
*/ */
public ManageBreakpointRulerAction( IVerticalRulerInfo ruler, ITextEditor editor ) public ManageBreakpointRulerAction( IVerticalRulerInfo ruler, ITextEditor editor ) {
{ super( "Toggle &Breakpoint" );
fRuler = ruler; fRuler = ruler;
fTextEditor = editor; fTextEditor = editor;
fAddLabel = CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointRulerAction.Add_Breakpoint"); //$NON-NLS-1$ fBreakpointAdapter = new ToggleBreakpointAdapter();
fRemoveLabel = CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointRulerAction.Remove_Breakpoint"); //$NON-NLS-1$
} }
/* (non-Javadoc) /**
* @see org.eclipse.ui.texteditor.IUpdate#update() * Disposes this action
*/ */
public void update() public void dispose() {
{ fTextEditor = null;
fMarkers = getMarkers(); fRuler = null;
setText( fMarkers.isEmpty() ? fAddLabel : fRemoveLabel );
} }
/** /**
* @see Action#run() * @see Action#run()
*/ */
public void run() public void run() {
{ try {
if ( fMarkers.isEmpty() ) List list = getMarkers();
{ if ( list.isEmpty() ) {
addMarker(); // create new markers
IDocument document = getDocument();
int lineNumber = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
IRegion line = document.getLineInformation( lineNumber );
ITextSelection selection = new TextSelection( document, line.getOffset(), line.getLength() );
fBreakpointAdapter.toggleLineBreakpoints( fTextEditor, selection );
} }
else else {
{ // remove existing breakpoints of any type
removeMarkers( fMarkers ); IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
Iterator iterator = list.iterator();
while( iterator.hasNext() ) {
IMarker marker = (IMarker)iterator.next();
IBreakpoint breakpoint = manager.getBreakpoint( marker );
if ( breakpoint != null ) {
breakpoint.delete();
}
}
}
}
catch( BadLocationException e ) {
DebugUIPlugin.errorDialog( getTextEditor().getSite().getShell(),
"Error",
"Operation failed",
e );
}
catch( CoreException e ) {
DebugUIPlugin.errorDialog( getTextEditor().getSite().getShell(),
"Error",
"Operation failed",
e.getStatus() );
} }
} }
protected List getMarkers() protected List getMarkers() {
{
List breakpoints = new ArrayList(); List breakpoints = new ArrayList();
IResource resource = ToggleBreakpointAdapter.getResource( fTextEditor );
IResource resource = getResource();
IDocument document = getDocument(); IDocument document = getDocument();
AbstractMarkerAnnotationModel model = getAnnotationModel(); AbstractMarkerAnnotationModel model = getAnnotationModel();
if ( model != null ) {
if ( model != null ) try {
{
try
{
IMarker[] markers = null; IMarker[] markers = null;
if ( resource instanceof IFile && !(getTextEditor().getEditorInput() instanceof DisassemblyEditorInput) ) if ( resource instanceof IFile )
{ markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE );
markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER, else {
true,
IResource.DEPTH_INFINITE );
}
else
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
markers = root.findMarkers( IBreakpoint.BREAKPOINT_MARKER, markers = root.findMarkers( IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE );
true,
IResource.DEPTH_INFINITE );
} }
if ( markers != null ) {
if ( markers != null )
{
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
for ( int i = 0; i < markers.length; i++ ) for( int i = 0; i < markers.length; i++ ) {
{
IBreakpoint breakpoint = breakpointManager.getBreakpoint( markers[i] ); IBreakpoint breakpoint = breakpointManager.getBreakpoint( markers[i] );
if ( breakpoint != null && if ( breakpoint != null && breakpointManager.isRegistered( breakpoint ) && includesRulerLine( model.getMarkerPosition( markers[i] ), document ) )
breakpointManager.isRegistered( breakpoint ) &&
includesRulerLine( model.getMarkerPosition( markers[i] ), document ) )
breakpoints.add( markers[i] ); breakpoints.add( markers[i] );
} }
} }
} }
catch( CoreException x ) catch( CoreException x ) {
{
CDebugUIPlugin.log( x.getStatus() ); CDebugUIPlugin.log( x.getStatus() );
} }
} }
@ -143,8 +143,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* *
* @return the resource for which to create the marker or <code>null</code> * @return the resource for which to create the marker or <code>null</code>
*/ */
protected IResource getResource() protected IResource getResource() {
{
IEditorInput input = fTextEditor.getEditorInput(); IEditorInput input = fTextEditor.getEditorInput();
IResource resource = (IResource)input.getAdapter( IFile.class ); IResource resource = (IResource)input.getAdapter( IFile.class );
if ( resource == null ) if ( resource == null )
@ -159,21 +158,16 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* @param document the document the position refers to * @param document the document the position refers to
* @return <code>true</code> if the line is included by the given position * @return <code>true</code> if the line is included by the given position
*/ */
protected boolean includesRulerLine( Position position, IDocument document ) protected boolean includesRulerLine( Position position, IDocument document ) {
{ if ( position != null ) {
if ( position != null ) try {
{
try
{
int markerLine = document.getLineOfOffset( position.getOffset() ); int markerLine = document.getLineOfOffset( position.getOffset() );
int line = fRuler.getLineOfLastMouseButtonActivity(); int line = fRuler.getLineOfLastMouseButtonActivity();
if ( line == markerLine ) if ( line == markerLine ) {
{
return true; return true;
} }
} }
catch( BadLocationException x ) catch( BadLocationException x ) {
{
} }
} }
return false; return false;
@ -184,8 +178,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* *
* @return this action's vertical ruler * @return this action's vertical ruler
*/ */
protected IVerticalRulerInfo getVerticalRulerInfo() protected IVerticalRulerInfo getVerticalRulerInfo() {
{
return fRuler; return fRuler;
} }
@ -194,8 +187,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* *
* @return this action's editor * @return this action's editor
*/ */
protected ITextEditor getTextEditor() protected ITextEditor getTextEditor() {
{
return fTextEditor; return fTextEditor;
} }
@ -204,12 +196,10 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* *
* @return the marker annotation model * @return the marker annotation model
*/ */
protected AbstractMarkerAnnotationModel getAnnotationModel() protected AbstractMarkerAnnotationModel getAnnotationModel() {
{
IDocumentProvider provider = fTextEditor.getDocumentProvider(); IDocumentProvider provider = fTextEditor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel( fTextEditor.getEditorInput() ); IAnnotationModel model = provider.getAnnotationModel( fTextEditor.getEditorInput() );
if ( model instanceof AbstractMarkerAnnotationModel ) if ( model instanceof AbstractMarkerAnnotationModel ) {
{
return (AbstractMarkerAnnotationModel)model; return (AbstractMarkerAnnotationModel)model;
} }
return null; return null;
@ -220,92 +210,8 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
* *
* @return the document of the editor's input * @return the document of the editor's input
*/ */
protected IDocument getDocument() protected IDocument getDocument() {
{
IDocumentProvider provider = fTextEditor.getDocumentProvider(); IDocumentProvider provider = fTextEditor.getDocumentProvider();
return provider.getDocument( fTextEditor.getEditorInput() ); return provider.getDocument( fTextEditor.getEditorInput() );
} }
protected void addMarker()
{
IEditorInput editorInput = getTextEditor().getEditorInput();
int rulerLine = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
try
{
if ( editorInput instanceof IFileEditorInput )
{
createLineBreakpoint( (IFileEditorInput)editorInput, rulerLine );
}
else if ( editorInput.getAdapter( DisassemblyEditorInput.class ) != null )
{
createAddressBreakpoint( (DisassemblyEditorInput)editorInput.getAdapter( DisassemblyEditorInput.class ), rulerLine );
}
}
catch( DebugException e )
{
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointRulerAction.Cannot_add_breakpoint"), e ); //$NON-NLS-1$
}
catch( CoreException e )
{
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointRulerAction.Cannot_add_breakpoint"), e ); //$NON-NLS-1$
}
}
private void createLineBreakpoint( IFileEditorInput editorInput, int rulerLine ) throws CoreException
{
IDocument document = getDocument();
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidLineBreakpointLocation( document, rulerLine );
if ( lineNumber > -1 )
{
String fileName = editorInput.getFile().getLocation().toString();
if ( fileName != null )
{
if ( CDebugModel.lineBreakpointExists( fileName, lineNumber ) == null )
{
CDebugModel.createLineBreakpoint( editorInput.getFile(), lineNumber, true, 0, "", true ); //$NON-NLS-1$
}
}
}
}
private void createAddressBreakpoint( DisassemblyEditorInput editorInput, int rulerLine ) throws CoreException
{
IDocument document = getDocument();
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidAddressBreakpointLocation( document, rulerLine );
if ( lineNumber > -1 )
{
IResource resource = (IResource)editorInput.getAdapter( IResource.class );
if ( resource != null )
{
if ( editorInput.getStorage() != null )
{
long address = ((IDisassemblyStorage)editorInput.getStorage()).getAddress( lineNumber );
if ( address != 0 && CDebugModel.addressBreakpointExists( resource, address ) == null )
{
CDebugModel.createAddressBreakpoint( resource, address, true, 0, "", true ); //$NON-NLS-1$
}
}
}
}
}
protected void removeMarkers( List markers )
{
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
try
{
Iterator e = markers.iterator();
while( e.hasNext() )
{
IBreakpoint breakpoint = breakpointManager.getBreakpoint( (IMarker)e.next() );
breakpointManager.removeBreakpoint( breakpoint, true );
}
}
catch( CoreException e )
{
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageBreakpointRulerAction.Cannot_remove_breakpoint"), e ); //$NON-NLS-1$
}
}
} }

View file

@ -1,29 +1,45 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;
/** public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDelegate {
*
* Enter type comment. private ManageBreakpointRulerAction fTargetAction;
* private IEditorPart fActiveEditor;
* @since Aug 23, 2002
*/
public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDelegate
{
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo) * @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
*/ */
public IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) public IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) {
{ fTargetAction = new ManageBreakpointRulerAction( rulerInfo, editor );
return new ManageBreakpointRulerAction( rulerInfo, editor ); return fTargetAction;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
*/
public void setActiveEditor( IAction callerAction, IEditorPart targetEditor ) {
if ( fActiveEditor != null ) {
if ( fTargetAction != null ) {
fTargetAction.dispose();
fTargetAction = null;
}
}
fActiveEditor = targetEditor;
super.setActiveEditor( callerAction, targetEditor );
} }
} }

View file

@ -98,22 +98,22 @@ public class ManageFunctionBreakpointActionDelegate extends ActionDelegate
private void manageBreakpoint( IFunction function ) private void manageBreakpoint( IFunction function )
{ {
try // try
{ // {
ICFunctionBreakpoint breakpoint = CDebugModel.functionBreakpointExists( function ); // ICFunctionBreakpoint breakpoint = CDebugModel.functionBreakpointExists( function );
if ( breakpoint != null ) // if ( breakpoint != null )
{ // {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); // DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
} // }
else // else
{ // {
CDebugModel.createFunctionBreakpoint( function, true, 0, "", true ); //$NON-NLS-1$ // CDebugModel.createFunctionBreakpoint( function, true, 0, "", true ); //$NON-NLS-1$
} // }
} // }
catch( CoreException e ) // catch( CoreException e )
{ // {
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageFunctionBreakpointActionDelegate.Cannot_add_breakpoint"), e ); //$NON-NLS-1$ // CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageFunctionBreakpointActionDelegate.Cannot_add_breakpoint"), e ); //$NON-NLS-1$
} // }
} }
private IFunction getFunction() private IFunction getFunction()
@ -123,22 +123,22 @@ public class ManageFunctionBreakpointActionDelegate extends ActionDelegate
private void manageBreakpoint( IMethod method ) private void manageBreakpoint( IMethod method )
{ {
try // try
{ // {
ICFunctionBreakpoint breakpoint = CDebugModel.methodBreakpointExists( method ); // ICFunctionBreakpoint breakpoint = CDebugModel.methodBreakpointExists( method );
if ( breakpoint != null ) // if ( breakpoint != null )
{ // {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); // DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
} // }
else // else
{ // {
CDebugModel.createMethodBreakpoint( method, true, 0, "", true ); //$NON-NLS-1$ // CDebugModel.createMethodBreakpoint( method, true, 0, "", true ); //$NON-NLS-1$
} // }
} // }
catch( CoreException e ) // catch( CoreException e )
{ // {
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageFunctionBreakpointActionDelegate.Cannot_add_breakpoint"), e ); //$NON-NLS-1$ // CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.ManageFunctionBreakpointActionDelegate.Cannot_add_breakpoint"), e ); //$NON-NLS-1$
} // }
} }
private IMethod getMethod() private IMethod getMethod()

View file

@ -10,13 +10,31 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
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.ICDebugUIConstants;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditor;
/** /**
@ -28,7 +46,50 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/ */
public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
// TODO Auto-generated method stub IEditorPart editorPart = (IEditorPart)part;
IEditorInput input = editorPart.getEditorInput();
String errorMessage = null;
if ( input == null ) {
errorMessage = "Empty editor";
}
else {
final ITextEditor textEditor = (ITextEditor)editorPart;
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
if ( document == null ) {
errorMessage = "Missing document";
}
else {
IResource resource = getResource( textEditor );
if ( resource == null ) {
errorMessage = "Missing resource";
}
else {
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() );
if ( lineNumber == -1 ) {
errorMessage = "Invalid line";
}
else {
String sourceHandle = getSourceHandle( input );
ICLineBreakpoint breakpoint = CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber );
if ( breakpoint != null ) {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
}
else {
CDIDebugModel.createLineBreakpoint( sourceHandle,
resource,
lineNumber,
true,
0,
"", //$NON-NLS-1$
true );
}
return;
}
}
}
}
throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -49,22 +110,70 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/ */
public boolean canToggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) { public boolean canToggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) {
// TODO for now return false;
return ( selection instanceof ITextSelection );
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/ */
public void toggleWatchpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { public void toggleWatchpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
// TODO Auto-generated method stub IEditorPart editorPart = (IEditorPart)part;
IEditorInput input = editorPart.getEditorInput();
String errorMessage = null;
if ( input == null ) {
errorMessage = "Empty editor";
}
else {
final ITextEditor textEditor = (ITextEditor)editorPart;
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
if ( document == null ) {
errorMessage = "Missing document";
}
else {
IResource resource = getResource( textEditor );
if ( resource == null ) {
errorMessage = "Missing resource";
}
else {
if ( !(resource instanceof IWorkspaceRoot) )
resource = resource.getProject();
String expression = ( selection instanceof TextSelection ) ? ((TextSelection)selection).getText().trim() : ""; //$NON-NLS-1$
AddWatchpointDialog dlg = new AddWatchpointDialog( textEditor.getSite().getShell(), true, false, expression );
if ( dlg.open() != Window.OK )
return;
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
if ( !wev.isValidExpression( document, expression ) ) {
errorMessage = "Invalid expression: " + expression;
}
else {
String sourceHandle = getSourceHandle( input );
ICWatchpoint watchpoint = CDIDebugModel.watchpointExists( sourceHandle, resource, expression );
if ( watchpoint != null ) {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( watchpoint, true );
}
else {
CDIDebugModel.createWatchpoint( sourceHandle,
resource,
dlg.getWriteAccess(),
dlg.getReadAccess(),
expression,
true,
0,
"", //$NON-NLS-1$
true );
}
return;
}
}
}
}
throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/ */
public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) { public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
// TODO for now
return ( selection instanceof ITextSelection ); return ( selection instanceof ITextSelection );
} }
@ -82,4 +191,26 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep(); CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep();
} }
} }
protected static IResource getResource( IEditorPart editor ) {
IResource resource;
IEditorInput editorInput = editor.getEditorInput();
if ( editorInput instanceof IFileEditorInput ) {
resource = ((IFileEditorInput)editorInput).getFile();
}
else {
resource = ResourcesPlugin.getWorkspace().getRoot();
}
return resource;
}
private String getSourceHandle( IEditorInput input ) throws CoreException {
if ( input instanceof IFileEditorInput ) {
return ((IFileEditorInput)input).getFile().getFullPath().toOSString();
}
if ( input instanceof IStorageEditorInput ) {
return ((IStorageEditorInput)input).getStorage().getName();
}
return ""; //$NON-NLS-1$
}
} }

View file

@ -7,13 +7,12 @@ package org.eclipse.cdt.debug.internal.ui.editors;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage; import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IMarkerDelta;
@ -34,7 +33,6 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/** /**
* Enter type comment. * Enter type comment.
@ -242,21 +240,21 @@ public class DisassemblyMarkerAnnotationModel extends AbstractMarkerAnnotationMo
private Position createPositionFromLineBreakpoint( IMarker marker ) private Position createPositionFromLineBreakpoint( IMarker marker )
{ {
if ( fStorage != null ) // if ( fStorage != null )
{ // {
IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); // IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker );
if ( breakpoint instanceof ICBreakpoint ) // if ( breakpoint instanceof ICBreakpoint )
{ // {
IDebugTarget target = fStorage.getDebugTarget(); // IDebugTarget target = fStorage.getDebugTarget();
if ( target != null && target.getAdapter( ICBreakpointManager.class ) != null ) // if ( target != null && target.getAdapter( ICBreakpointManager.class ) != null )
{ // {
ICBreakpointManager bm = (ICBreakpointManager)target.getAdapter( ICBreakpointManager.class ); // ICBreakpointManager bm = (ICBreakpointManager)target.getAdapter( ICBreakpointManager.class );
long address = bm.getBreakpointAddress( (ICBreakpoint)breakpoint ); // long address = bm.getBreakpointAddress( (ICBreakpoint)breakpoint );
if ( address != 0 ) // if ( address != 0 )
return createPositionFromAddress( address ); // return createPositionFromAddress( address );
} // }
} // }
} // }
return null; return null;
} }