1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 118274: Condition is not shown in the tooltip of conditional breakpoint.

This commit is contained in:
Mikhail Khodjaiants 2006-05-12 21:08:52 +00:00
parent 3ca4a76b93
commit d408c25da3
11 changed files with 177 additions and 170 deletions

View file

@ -1,3 +1,13 @@
2006-05-12 Mikhail Khodjaiants
Bug 118274: Condition is not shown in the tooltip of conditional breakpoint.
* CDebugUtils.java
* DebugCoreMessages.properties
* BreakpointMessages.properties
* CAddressBreakpoint.java
* CFunctionBreakpoint.java
* CLineBreakpoint.java
* CWatchpoint.java
2006-03-27 Mikhail Khodjaiants
Moved the extraction of the stop symbol to the launch.
* CDIDebugModel.java

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.core;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@ -23,13 +24,21 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.debug.core.cdi.CDIException;
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.ICValue;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IBreakpoint;
import org.w3c.dom.Document;
/**
@ -286,4 +295,129 @@ public class CDebugUtils {
}
}
}
public static String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException {
if ( breakpoint instanceof ICAddressBreakpoint ) {
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICFunctionBreakpoint ) {
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICLineBreakpoint ) {
return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICWatchpoint ) {
return getWatchpointText( (ICWatchpoint)breakpoint, qualified );
}
return ""; //$NON-NLS-1$
}
protected static String getLineBreakpointText( ICLineBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendLineNumber( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected static String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( watchpoint, label, qualified );
appendWatchExpression( watchpoint, label );
appendIgnoreCount( watchpoint, label );
appendCondition( watchpoint, label );
return label.toString();
}
protected static String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendAddress( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected static String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendFunction( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected static StringBuffer appendSourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException {
String handle = breakpoint.getSourceHandle();
if ( !isEmpty( handle ) ) {
IPath path = new Path( handle );
if ( path.isValidPath( handle ) ) {
label.append( qualified ? path.toOSString() : path.lastSegment() );
}
}
return label;
}
protected static StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException {
int lineNumber = breakpoint.getLineNumber();
if ( lineNumber > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.0" ), new String[]{ Integer.toString( lineNumber ) } ) ); //$NON-NLS-1$
}
return label;
}
protected static StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException {
try {
label.append( ' ' );
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.1" ), new String[]{ breakpoint.getAddress() } ) ); //$NON-NLS-1$
}
catch( NumberFormatException e ) {
}
return label;
}
protected static StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException {
String function = breakpoint.getFunction();
if ( function != null && function.trim().length() > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.2" ), new String[]{ function.trim() } ) ); //$NON-NLS-1$
}
return label;
}
protected static StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException {
int ignoreCount = breakpoint.getIgnoreCount();
if ( ignoreCount > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.3" ), new String[]{ Integer.toString( ignoreCount ) } ) ); //$NON-NLS-1$
}
return label;
}
protected static void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException {
String condition = breakpoint.getCondition();
if ( condition != null && condition.length() > 0 ) {
buffer.append( ' ' );
buffer.append( DebugCoreMessages.getString( "CDebugUtils.4" ) ); //$NON-NLS-1$
buffer.append( ' ' );
buffer.append( condition );
}
}
private static void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException {
String expression = watchpoint.getExpression();
if ( expression != null && expression.length() > 0 ) {
label.append( ' ' );
label.append( DebugCoreMessages.getString( "CDebugUtils.5" ) ); //$NON-NLS-1$
label.append( " \'" ); //$NON-NLS-1$
label.append( expression );
label.append( '\'' );
}
}
private static boolean isEmpty( String string ) {
return ( string == null || string.trim().length() == 0 );
}
}

View file

@ -10,4 +10,10 @@
###############################################################################
CDebugCorePlugin.0=No such debugger
CDebugModel.0=Unable to set temporary breakpoint in main.\nReason: {0}\nContinue?
CDebugUtils.0=[line: {0}]
CDebugUtils.1=[address: {0}]
CDebugUtils.2=[function: {0}]
CDebugUtils.3=[ignore count: {0}]
CDebugUtils.4=if
CDebugUtils.5=at
CDIDebugModel.0=Unable to parser binary information from file

View file

@ -10,32 +10,25 @@
###############################################################################
# The marker message of an address breakpoint.
# Format: Address breakpoint: <file name>[address: <address>] <condition>
CAddressBreakpoint.0=Address breakpoint:{0}[address: {1}]{2}
CAddressBreakpoint.0=Address breakpoint: {0}
CBreakpoint.1=\ [ignore count: {0}]
CBreakpoint.2=\ if {0}
# The marker message of a function breakpoint.
# Format: Function breakpoint: <file name>[function: <function name>] <condition>
CFunctionBreakpoint.0=Function breakpoint:{0}[function: {1}]{2}
CFunctionBreakpoint.0=Function breakpoint: {0}
# The marker message of a line breakpoint.
# Format: Line breakpoint: <file name>[line: <line number>] <condition>
CLineBreakpoint.0=Line breakpoint:{0}[line: {1}]
CLineBreakpoint.0=Line breakpoint: {0}
# The marker message of a write watchpoint.
# Format: Write watchpoint: <file name> at <expression> <condition>
CWatchpoint.0=Write watchpoint{0}at{1}{2}
CWatchpoint.0=Write watchpoint: {0}
# The marker message of a read watchpoint.
# Format: Read watchpoint: <file name> at <expression> <condition>
CWatchpoint.1=Read watchpoint{0}at{1}{2}
CWatchpoint.1=Read watchpoint: {0}
# The marker message of an access watchpoint.
# Format: Access watchpoint: <file name> at <expression> <condition>
CWatchpoint.2=Access watchpoint{0}at{1}{2}
CWatchpoint.2=Access watchpoint: {0}
# The marker message of a watchpoint.
# Format: Watchpoint: <file name> at <expression> <condition>
CWatchpoint.3=Watchpoint{0}at{1}{2}
CWatchpoint.3=Watchpoint: {0}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@ -50,10 +51,6 @@ public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddr
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/
protected String getMarkerMessage() throws CoreException {
String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) {
fileName = ' ' + fileName + ' ';
}
return MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.0" ), new String[] { fileName, getAddress(), getConditionText() } ); //$NON-NLS-1$
return MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@ -48,10 +49,6 @@ public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFun
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/
protected String getMarkerMessage() throws CoreException {
String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) {
fileName = ' ' + fileName + ' ';
}
return MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.0" ), new String[] { fileName, getFunction(), getConditionText() } ); //$NON-NLS-1$
return MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@ -48,10 +49,6 @@ public class CLineBreakpoint extends AbstractLineBreakpoint {
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/
protected String getMarkerMessage() throws CoreException {
String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) {
fileName = ' ' + fileName + ' ';
}
return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), new Object[] { fileName, new Integer( getLineNumber() ), getConditionText() } ); //$NON-NLS-1$
return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat;
import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
@ -69,21 +70,14 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/
protected String getMarkerMessage() throws CoreException {
String fileName = ensureMarker().getResource().getName();
if ( fileName != null && fileName.length() > 0 ) {
fileName = ' ' + fileName + ' ';
}
String expression = getExpression();
if ( expression != null && expression.length() > 0 ) {
expression = " '" + expression + "' "; //$NON-NLS-1$ //$NON-NLS-2$
}
String format = BreakpointMessages.getString( "CWatchpoint.3" ); //$NON-NLS-1$
if ( isWriteType() && !isReadType() )
return MessageFormat.format( BreakpointMessages.getString( "CWatchpoint.0" ), new String[] { fileName, expression, getConditionText() } ); //$NON-NLS-1$
format = BreakpointMessages.getString( "CWatchpoint.0" ); //$NON-NLS-1$
else if ( !isWriteType() && isReadType() )
return MessageFormat.format( BreakpointMessages.getString( "CWatchpoint.1" ), new String[] { fileName, expression, getConditionText() } ); //$NON-NLS-1$
format = BreakpointMessages.getString( "CWatchpoint.1" ); //$NON-NLS-1$
else if ( isWriteType() && isReadType() )
return MessageFormat.format( BreakpointMessages.getString( "CWatchpoint.2" ), new String[] { fileName, expression, getConditionText() } ); //$NON-NLS-1$
return MessageFormat.format( BreakpointMessages.getString( "CWatchpoint.3" ), new String[] { fileName, expression, getConditionText() } ); //$NON-NLS-1$
format = BreakpointMessages.getString( "CWatchpoint.2" ); //$NON-NLS-1$
return MessageFormat.format( format, new String[] { CDebugUtils.getBreakpointText( this, false ) } );
}
/* (non-Javadoc)

View file

@ -1,3 +1,9 @@
2006-05-12 Mikhail Khodjaiants
Bug 118274: Condition is not shown in the tooltip of conditional breakpoint.
Moved the "getBreakpointText" method and related methods to CDebugUtils.
* CDebugModelPresentation.java
* CDebugUIMessages.properties
2006-05-12 Mikhail Khodjaiants
Bug 109449: Sort globals in "Add Globals" dialog.
* AddGlobalsActionDelegate.java

View file

@ -372,12 +372,12 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if ( element instanceof IMarker ) {
IBreakpoint breakpoint = getBreakpoint( (IMarker)element );
if ( breakpoint != null ) {
return getBreakpointText( breakpoint, showQualified );
return CDebugUtils.getBreakpointText( breakpoint, showQualified );
}
return null;
}
if ( element instanceof IBreakpoint ) {
return getBreakpointText( (IBreakpoint)element, showQualified );
return CDebugUtils.getBreakpointText( (IBreakpoint)element, showQualified );
}
if ( element instanceof IDebugTarget )
label.append( getTargetText( (IDebugTarget)element, showQualified ) );
@ -453,127 +453,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker );
}
protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException {
if ( breakpoint instanceof ICAddressBreakpoint ) {
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICFunctionBreakpoint ) {
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICLineBreakpoint ) {
return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
}
if ( breakpoint instanceof ICWatchpoint ) {
return getWatchpointText( (ICWatchpoint)breakpoint, qualified );
}
return ""; //$NON-NLS-1$
}
protected String getLineBreakpointText( ICLineBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendLineNumber( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( watchpoint, label, qualified );
appendWatchExpression( watchpoint, label );
appendIgnoreCount( watchpoint, label );
appendCondition( watchpoint, label );
return label.toString();
}
protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendAddress( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException {
StringBuffer label = new StringBuffer();
appendSourceName( breakpoint, label, qualified );
appendFunction( breakpoint, label );
appendIgnoreCount( breakpoint, label );
appendCondition( breakpoint, label );
return label.toString();
}
protected StringBuffer appendSourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException {
String handle = breakpoint.getSourceHandle();
if ( !isEmpty( handle ) ) {
IPath path = new Path( handle );
if ( path.isValidPath( handle ) ) {
label.append( qualified ? path.toOSString() : path.lastSegment() );
}
}
return label;
}
protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException {
int lineNumber = breakpoint.getLineNumber();
if ( lineNumber > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.26" ), new String[]{ Integer.toString( lineNumber ) } ) ); //$NON-NLS-1$
}
return label;
}
protected StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException {
try {
label.append( ' ' );
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.27" ), new String[]{ breakpoint.getAddress() } ) ); //$NON-NLS-1$
}
catch( NumberFormatException e ) {
}
return label;
}
protected StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException {
String function = breakpoint.getFunction();
if ( function != null && function.trim().length() > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.28" ), new String[]{ function.trim() } ) ); //$NON-NLS-1$
}
return label;
}
protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException {
int ignoreCount = breakpoint.getIgnoreCount();
if ( ignoreCount > 0 ) {
label.append( ' ' );
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.29" ), new String[]{ Integer.toString( ignoreCount ) } ) ); //$NON-NLS-1$
}
return label;
}
protected void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException {
String condition = breakpoint.getCondition();
if ( condition != null && condition.length() > 0 ) {
buffer.append( ' ' );
buffer.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.30" ) ); //$NON-NLS-1$
buffer.append( ' ' );
buffer.append( condition );
}
}
private void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException {
String expression = watchpoint.getExpression();
if ( expression != null && expression.length() > 0 ) {
label.append( ' ' );
label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.31" ) ); //$NON-NLS-1$
label.append( " \'" ); //$NON-NLS-1$
label.append( expression );
label.append( '\'' );
}
}
private ImageDescriptor[] computeBreakpointOverlays( ICBreakpoint breakpoint ) {
ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null };
try {

View file

@ -38,11 +38,5 @@ CDTDebugModelPresentation.22=(disabled)
CDTDebugModelPresentation.23=Infinity
CDTDebugModelPresentation.24=-Infinity
CDTDebugModelPresentation.25=(disabled)
CDTDebugModelPresentation.26=[line: {0}]
CDTDebugModelPresentation.27=[address: {0}]
CDTDebugModelPresentation.28=[function: {0}]
CDTDebugModelPresentation.29=[ignore count: {0}]
CDTDebugModelPresentation.30=if
CDTDebugModelPresentation.31=at
CBreakpointWorkbenchAdapterFactory.0=C/C++ breakpoint
CBreakpointWorkbenchAdapterFactory.1=C/C++ watchpoint