1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

The "IStackFrameInfo" interface is removed and it's methods moved to "ICStackFrame".

This commit is contained in:
Mikhail Khodjaiants 2004-05-20 22:23:20 +00:00
parent 95d5594fd0
commit f6719903b6
11 changed files with 366 additions and 513 deletions

View file

@ -1,3 +1,10 @@
2004-05-20 Mikhail Khodjaiants
The "IStackFrameInfo" interface is removed and it's methods moved to "ICStackFrame".
* ICStackFrameInfo: removed
* CStackFrame.java
* CSourceLocator.java
* CSourceManager.java
2004-05-19 Mikhail Khodjaiants 2004-05-19 Mikhail Khodjaiants
Added the support of watch expressions. Added the support of watch expressions.
* CDIDebugModel.java * CDIDebugModel.java

View file

@ -1,63 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.model.IVariable;
/**
*
* Provides the access to the stack frame information.
*
* @since Aug 16, 2002
*/
public interface IStackFrameInfo
{
/**
* Returns the address of this stack frame.
*
* @return the address of this stack frame
*/
long getAddress();
/**
* Returns the source file of this stack frame or <code>null</code>
* if the source file is unknown.
*
* @return the source file of this stack frame
*/
String getFile();
/**
* Returns the function of this stack frame or <code>null</code>
* if the function is unknown.
*
* @return the function of this stack frame
*/
String getFunction();
/**
* Returns the line number of this stack frame or <code>0</code>
* if the line number is unknown.
*
* @return the line number of this stack frame
*/
int getFrameLineNumber();
/**
* Returns the level of this stack frame.
*
* @return the level of this stack frame
*/
int getLevel();
/**
* Returns the arguments of this stack frame.
*
* @return the arguments of this stack frame
*/
IVariable[] getArguments();
}

View file

@ -15,15 +15,13 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
@ -42,6 +40,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IStackFrame;
import org.osgi.framework.Bundle;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -103,11 +102,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/ */
public Object getSourceElement( IStackFrame stackFrame ) public Object getSourceElement( IStackFrame stackFrame )
{ {
if ( stackFrame != null && stackFrame.getAdapter( IStackFrameInfo.class ) != null ) return getInput( stackFrame );
{
return getInput( (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ) );
}
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -115,43 +110,47 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/ */
public int getLineNumber( IStackFrame frame ) public int getLineNumber( IStackFrame frame )
{ {
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class ); return ( frame instanceof ICStackFrame ) ? ((ICStackFrame)frame).getFrameLineNumber() : 0;
return ( info != null ) ? info.getFrameLineNumber() : 0;
} }
protected Object getInput( IStackFrameInfo info ) protected Object getInput( IStackFrame f )
{ {
LinkedList list = new LinkedList(); if ( f instanceof ICStackFrame )
if ( info != null )
{ {
Object result = null; ICStackFrame frame = (ICStackFrame)f;
String fileName = info.getFile(); LinkedList list = new LinkedList();
if ( fileName != null && fileName.length() > 0 ) if ( frame != null )
{ {
ICSourceLocation[] locations = getSourceLocations(); Object result = null;
for ( int i = 0; i < locations.length; ++i ) String fileName = frame.getFile();
if ( fileName != null && fileName.length() > 0 )
{ {
try ICSourceLocation[] locations = getSourceLocations();
for ( int i = 0; i < locations.length; ++i )
{ {
result = locations[i].findSourceElement( fileName ); try
} {
catch( CoreException e ) result = locations[i].findSourceElement( fileName );
{ }
// do nothing catch( CoreException e )
} {
if ( result != null ) // do nothing
{ }
if ( result instanceof List ) if ( result != null )
list.addAll( (List)result ); {
else if ( result instanceof List )
list.add( result ); list.addAll( (List)result );
if ( !searchForDuplicateFiles() ) else
break; list.add( result );
if ( !searchForDuplicateFiles() )
break;
}
} }
} }
} }
} return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null; }
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -415,7 +414,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
private void addAdditionalLocations( Element root, List sourceLocations ) throws CoreException private void addAdditionalLocations( Element root, List sourceLocations ) throws CoreException
{ {
ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader(); Bundle bundle = CDebugCorePlugin.getDefault().getBundle();
MultiStatus status = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(), MultiStatus status = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(),
CDebugCorePlugin.INTERNAL_ERROR, CDebugCorePlugin.INTERNAL_ERROR,
@ -442,7 +441,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
Class clazz = null; Class clazz = null;
try try
{ {
clazz = classLoader.loadClass( className ); clazz = bundle.loadClass( className );
} }
catch( ClassNotFoundException e ) catch( ClassNotFoundException e )
{ {
@ -483,7 +482,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
private void addOldLocations( Element root, List sourceLocations ) throws CoreException private void addOldLocations( Element root, List sourceLocations ) throws CoreException
{ {
ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader(); Bundle bundle = CDebugCorePlugin.getDefault().getBundle();
NodeList list = root.getChildNodes(); NodeList list = root.getChildNodes();
int length = list.getLength(); int length = list.getLength();
@ -506,7 +505,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
Class clazz = null; Class clazz = null;
try try
{ {
clazz = classLoader.loadClass( className ); clazz = bundle.loadClass( className );
} }
catch( ClassNotFoundException e ) catch( ClassNotFoundException e )
{ {

View file

@ -10,7 +10,7 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.internal.core.sourcelookup; package org.eclipse.cdt.debug.internal.core.sourcelookup;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
@ -54,9 +54,8 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato
if ( getCSourceLocator() != null ) { if ( getCSourceLocator() != null ) {
return getCSourceLocator().getLineNumber( frame ); return getCSourceLocator().getLineNumber( frame );
} }
IStackFrameInfo info = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class ); if ( frame instanceof ICStackFrame ) {
if ( info != null ) { return ((ICStackFrame)frame).getFrameLineNumber();
return info.getFrameLineNumber();
} }
return 0; return 0;
} }

View file

@ -1,3 +1,11 @@
2004-05-20 Mikhail Khodjaiants
The "IStackFrameInfo" interface is removed and it's methods moved to "ICStackFrame".
* CDTDebugModelPresentation.java
* FileNotFoundElement.java
* DefaultSourceLocator.java
* SourceLookupBlock.java
* SourceLookupLabelProvider.java
2004-05-19 Mikhail Khodjaiants 2004-05-19 Mikhail Khodjaiants
Added the support of watch expressions. Added the support of watch expressions.
* CDTDebugModelPresentation.java * CDTDebugModelPresentation.java

View file

@ -8,7 +8,6 @@ package org.eclipse.cdt.debug.internal.ui;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
@ -26,12 +25,12 @@ import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary; import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDummyStackFrame; import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
import org.eclipse.cdt.debug.core.model.IState; import org.eclipse.cdt.debug.core.model.IState;
import org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor; import org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor;
import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate; import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate;
@ -60,7 +59,6 @@ import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.core.model.IWatchExpression; import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugModelPresentation;
@ -516,16 +514,16 @@ public class CDTDebugModelPresentation extends LabelProvider
return getFormattedString( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Thread_threadName_suspended"), thread.getName() ); //$NON-NLS-1$ return getFormattedString( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Thread_threadName_suspended"), thread.getName() ); //$NON-NLS-1$
} }
protected String getStackFrameText( IStackFrame stackFrame, boolean qualified ) throws DebugException protected String getStackFrameText( IStackFrame f, boolean qualified ) throws DebugException
{ {
IStackFrameInfo info = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ); if ( f instanceof ICStackFrame )
if ( info != null )
{ {
ICStackFrame frame = (ICStackFrame)f;
StringBuffer label = new StringBuffer(); StringBuffer label = new StringBuffer();
label.append( info.getLevel() ); label.append( frame.getLevel() );
label.append( ' ' ); label.append( ' ' );
String function = info.getFunction(); String function = frame.getFunction();
if ( function != null ) if ( function != null )
{ {
function = function.trim(); function = function.trim();
@ -533,16 +531,16 @@ public class CDTDebugModelPresentation extends LabelProvider
{ {
label.append( function ); label.append( function );
label.append( "() " ); //$NON-NLS-1$ label.append( "() " ); //$NON-NLS-1$
if ( info.getFile() != null ) if ( frame.getFile() != null )
{ {
IPath path = new Path( info.getFile() ); IPath path = new Path( frame.getFile() );
if ( !path.isEmpty() ) if ( !path.isEmpty() )
{ {
label.append( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.at")+" " ); //$NON-NLS-1$ //$NON-NLS-2$ label.append( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.at")+" " ); //$NON-NLS-1$ //$NON-NLS-2$
label.append( ( qualified ? path.toOSString() : path.lastSegment() ) ); label.append( ( qualified ? path.toOSString() : path.lastSegment() ) );
label.append( ":" ); //$NON-NLS-1$ label.append( ":" ); //$NON-NLS-1$
if ( info.getFrameLineNumber() != 0 ) if ( frame.getFrameLineNumber() != 0 )
label.append( info.getFrameLineNumber() ); label.append( frame.getFrameLineNumber() );
} }
} }
} }
@ -551,8 +549,8 @@ public class CDTDebugModelPresentation extends LabelProvider
label.append( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Symbol_not_available") ); //$NON-NLS-1$ label.append( CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Symbol_not_available") ); //$NON-NLS-1$
return label.toString(); return label.toString();
} }
return ( stackFrame.getAdapter( IDummyStackFrame.class ) != null ) ? return ( f.getAdapter( IDummyStackFrame.class ) != null ) ?
getDummyStackFrameLabel( stackFrame ) : stackFrame.getName(); getDummyStackFrameLabel( f ) : f.getName();
} }
private String getDummyStackFrameLabel( IStackFrame stackFrame ) private String getDummyStackFrameLabel( IStackFrame stackFrame )

View file

@ -5,7 +5,7 @@
*/ */
package org.eclipse.cdt.debug.internal.ui.editors; package org.eclipse.cdt.debug.internal.ui.editors;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
@ -30,13 +30,16 @@ public class FileNotFoundElement
public IPath getFullPath() public IPath getFullPath()
{ {
IStackFrameInfo frameInfo = (IStackFrameInfo)fStackFrame.getAdapter( IStackFrameInfo.class ); if ( fStackFrame instanceof ICStackFrame )
if ( frameInfo != null && frameInfo.getFile() != null && frameInfo.getFile().length() > 0 )
{ {
Path path = new Path( frameInfo.getFile() ); String fn = ((ICStackFrame)fStackFrame).getFile();
if ( path.isValidPath( frameInfo.getFile() ) ) if ( fn != null && fn.trim().length() > 0 )
{ {
return path; Path path = new Path( fn );
if ( path.isValidPath( fn ) )
{
return path;
}
} }
} }
return null; return null;

View file

@ -11,16 +11,14 @@ import java.io.StringReader;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory;
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
@ -294,8 +292,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
} }
if ( res == null ) if ( res == null )
{ {
IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ); if ( stackFrame instanceof ICStackFrame && !isEmpty( ((ICStackFrame)stackFrame).getFile() ) )
if ( frameInfo != null && frameInfo.getFile() != null && frameInfo.getFile().length() > 0 )
{ {
res = new FileNotFoundElement( stackFrame ); res = new FileNotFoundElement( stackFrame );
} }
@ -367,11 +364,10 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
private String getFileName( IStackFrame frame ) private String getFileName( IStackFrame frame )
{ {
IStackFrameInfo frameInfo = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class ); if ( frame instanceof ICStackFrame )
if ( frameInfo != null )
{ {
String name = frameInfo.getFile(); String name = ((ICStackFrame)frame).getFile();
if ( name != null && name.trim().length() > 0 ) if ( !isEmpty( name ) )
return name.trim(); return name.trim();
} }
return null; return null;
@ -404,7 +400,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
private boolean isEmpty( String string ) private boolean isEmpty( String string )
{ {
return string == null || string.length() == 0; return string == null || string.trim().length() == 0;
} }
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException private IProject getProject( ILaunchConfiguration configuration ) throws CoreException

View file

@ -434,7 +434,7 @@ public class SourceLookupBlock implements Observer
field.setDialogFieldListener( field.setDialogFieldListener(
new IDialogFieldListener() new IDialogFieldListener()
{ {
public void dialogFieldChanged( DialogField field ) public void dialogFieldChanged( DialogField f )
{ {
doCheckStateChanged(); doCheckStateChanged();
} }
@ -448,12 +448,12 @@ public class SourceLookupBlock implements Observer
new SourceListDialogField( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Additional_Source_Locations"), //$NON-NLS-1$ new SourceListDialogField( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Additional_Source_Locations"), //$NON-NLS-1$
new IListAdapter() new IListAdapter()
{ {
public void customButtonPressed( DialogField field, int index ) public void customButtonPressed( DialogField f, int index )
{ {
doAddedSourceButtonPressed( index ); doAddedSourceButtonPressed( index );
} }
public void selectionChanged(DialogField field) public void selectionChanged(DialogField f)
{ {
} }
} ); } );

View file

@ -22,10 +22,9 @@ public class SourceLookupLabelProvider extends LabelProvider implements ITableLa
{ {
if ( element instanceof IProjectSourceLocation ) if ( element instanceof IProjectSourceLocation )
{ {
if ( ((IProjectSourceLocation)element).getProject().isOpen() ) return ( ((IProjectSourceLocation)element).getProject().isOpen() ) ?
return CDebugImages.get( CDebugImages.IMG_OBJS_PROJECT ); CDebugImages.get( CDebugImages.IMG_OBJS_PROJECT ) :
else CDebugImages.get( CDebugImages.IMG_OBJS_CLOSED_PROJECT );
return CDebugImages.get( CDebugImages.IMG_OBJS_CLOSED_PROJECT );
} }
if ( element instanceof IDirectorySourceLocation ) if ( element instanceof IDirectorySourceLocation )
{ {