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

Pass the current stack frame to the registers manager to provide the evaluation context.

This commit is contained in:
Mikhail Khodjaiants 2004-10-07 20:01:23 +00:00
parent 654fb767a2
commit 171d390269
8 changed files with 168 additions and 187 deletions

View file

@ -1,3 +1,13 @@
2004-10-07 Mikhail Khodjaiants
Pass the current stack frame to the registers manager to provide the evaluation context.
* ICRegisterManager.java
* IDummyStackFrame.java
* CRegisterManager.java
* CDebugTarget.java
* CDummyStackFrame.java
* CRegisterGroup.java
* CStackFrame.java
2004-10-07 Mikhail Khodjaiants 2004-10-07 Mikhail Khodjaiants
Provide a context for expression evaluation. Provide a context for expression evaluation.
* ICValue.java * ICValue.java

View file

@ -8,31 +8,19 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.core; package org.eclipse.cdt.debug.core;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IRegisterGroup;
/** /**
* Enter type comment. * Provides the access to the register groups' management functions.
*
* @since Mar 31, 2003
*/ */
public interface ICRegisterManager extends ICUpdateManager, IAdaptable public interface ICRegisterManager extends ICUpdateManager, IAdaptable {
{
void initialize();
IRegisterGroup[] getRegisterGroups() throws DebugException;
void addRegisterGroup( IRegisterGroup group ); void addRegisterGroup( IRegisterGroup group );
void removeRegisterGroup( IRegisterGroup group ); void removeRegisterGroup( IRegisterGroup group );
void removeAllRegisterGroups(); void removeAllRegisterGroups();
}
void reset();
void dispose();
}

View file

@ -11,10 +11,8 @@
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
/** /**
* Enter type comment. * Represents a dummy stack frame used to indicate that the stack depth is greater
* * than the number of displayed frames.
* @since: Nov 13, 2002
*/ */
public interface IDummyStackFrame public interface IDummyStackFrame {
{ }
}

View file

@ -8,13 +8,11 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.core; package org.eclipse.cdt.debug.internal.core;
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.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConstants; import org.eclipse.cdt.debug.core.ICDebugConstants;
import org.eclipse.cdt.debug.core.ICRegisterManager; import org.eclipse.cdt.debug.core.ICRegisterManager;
@ -23,34 +21,36 @@ import org.eclipse.cdt.debug.core.cdi.ICDIManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CRegisterGroup; import org.eclipse.cdt.debug.internal.core.model.CRegisterGroup;
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IRegisterGroup;
/** /**
* Enter type comment. * Manages all register groups in a debug target.
*
* @since Mar 31, 2003
*/ */
public class CRegisterManager extends CUpdateManager implements ICRegisterManager public class CRegisterManager extends CUpdateManager implements ICRegisterManager {
{
/** /**
* Collection of register groups added to this target. Values are of type <code>CRegisterGroup</code>. * Collection of register groups added to this target. Values are of type <code>CRegisterGroup</code>.
*/ */
private List fRegisterGroups; private List fRegisterGroups;
/** /**
* * The last stack frame.
*/ */
public CRegisterManager( CDebugTarget target ) private CStackFrame fStackFrame;
{
/**
* Constructor for CRegisterManager.
*/
public CRegisterManager( CDebugTarget target ) {
super( target ); super( target );
} }
/* (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 ( ICRegisterManager.class.equals( adapter ) ) if ( ICRegisterManager.class.equals( adapter ) )
return this; return this;
if ( CRegisterManager.class.equals( adapter ) ) if ( CRegisterManager.class.equals( adapter ) )
@ -58,11 +58,8 @@ public class CRegisterManager extends CUpdateManager implements ICRegisterManage
return super.getAdapter( adapter ); return super.getAdapter( adapter );
} }
/* (non-Javadoc) public void dispose() {
* @see org.eclipse.cdt.debug.core.ICRegisterManager#dispose() setStackFrame( null );
*/
public void dispose()
{
removeAllRegisterGroups(); removeAllRegisterGroups();
super.dispose(); super.dispose();
} }
@ -70,25 +67,16 @@ public class CRegisterManager extends CUpdateManager implements ICRegisterManage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICRegisterManager#addRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup) * @see org.eclipse.cdt.debug.core.ICRegisterManager#addRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup)
*/ */
public void addRegisterGroup( IRegisterGroup group ) public void addRegisterGroup( IRegisterGroup group ) {
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc) public IRegisterGroup[] getRegisterGroups( CStackFrame frame ) throws DebugException {
* @see org.eclipse.cdt.debug.core.ICRegisterManager#getRegisterGroups() setStackFrame( frame );
*/
public IRegisterGroup[] getRegisterGroups() throws DebugException
{
return (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] ); return (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] );
} }
/* (non-Javadoc) public void initialize() {
* @see org.eclipse.cdt.debug.core.ICRegisterManager#initialize()
*/
public void initialize()
{
fRegisterGroups = new ArrayList( 20 ); fRegisterGroups = new ArrayList( 20 );
boolean autoRefresh = CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_REGISTERS_AUTO_REFRESH ); boolean autoRefresh = CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_REGISTERS_AUTO_REFRESH );
if ( getCDIManager() != null ) if ( getCDIManager() != null )
@ -99,11 +87,9 @@ public class CRegisterManager extends CUpdateManager implements ICRegisterManage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICRegisterManager#removeAllRegisterGroups() * @see org.eclipse.cdt.debug.core.ICRegisterManager#removeAllRegisterGroups()
*/ */
public void removeAllRegisterGroups() public void removeAllRegisterGroups() {
{
Iterator it = fRegisterGroups.iterator(); Iterator it = fRegisterGroups.iterator();
while( it.hasNext() ) while( it.hasNext() ) {
{
((CRegisterGroup)it.next()).dispose(); ((CRegisterGroup)it.next()).dispose();
} }
fRegisterGroups.clear(); fRegisterGroups.clear();
@ -112,44 +98,25 @@ public class CRegisterManager extends CUpdateManager implements ICRegisterManage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICRegisterManager#removeRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup) * @see org.eclipse.cdt.debug.core.ICRegisterManager#removeRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup)
*/ */
public void removeRegisterGroup( IRegisterGroup group ) public void removeRegisterGroup( IRegisterGroup group ) {
{
fRegisterGroups.remove( group ); fRegisterGroups.remove( group );
} }
private void createMainRegisterGroup() private void createMainRegisterGroup() {
{
ICDIRegisterObject[] regObjects = null; ICDIRegisterObject[] regObjects = null;
try try {
{
regObjects = getDebugTarget().getCDISession().getRegisterManager().getRegisterObjects(); regObjects = getDebugTarget().getCDISession().getRegisterManager().getRegisterObjects();
} }
catch( CDIException e ) catch( CDIException e ) {
{
CDebugCorePlugin.log( e ); CDebugCorePlugin.log( e );
} }
if ( regObjects != null ) if ( regObjects != null ) {
{
fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), "Main", regObjects ) ); //$NON-NLS-1$ fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), "Main", regObjects ) ); //$NON-NLS-1$
} }
} }
/* (non-Javadoc) protected ICDIManager getCDIManager() {
* @see org.eclipse.cdt.debug.core.ICRegisterManager#reset() if ( getDebugTarget() != null ) {
*/
public void reset()
{
Iterator it = fRegisterGroups.iterator();
while( it.hasNext() )
{
((CRegisterGroup)it.next()).resetChangeFlags();
}
}
protected ICDIManager getCDIManager()
{
if ( getDebugTarget() != null )
{
return getDebugTarget().getCDISession().getRegisterManager(); return getDebugTarget().getCDISession().getRegisterManager();
} }
return null; return null;
@ -161,4 +128,12 @@ public class CRegisterManager extends CUpdateManager implements ICRegisterManage
((CRegisterGroup)it.next()).targetSuspended(); ((CRegisterGroup)it.next()).targetSuspended();
} }
} }
public CStackFrame getStackFrame() {
return fStackFrame;
}
private void setStackFrame( CStackFrame stackFrame ) {
fStackFrame = stackFrame;
}
} }

View file

@ -1387,10 +1387,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getLaunch().getSourceLocator(); return getLaunch().getSourceLocator();
} }
protected void resetRegisters() {
getRegisterManager().reset();
}
protected CMemoryManager getMemoryManager() { protected CMemoryManager getMemoryManager() {
return fMemoryManager; return fMemoryManager;
} }
@ -1627,8 +1623,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
fRegisterManager = registerManager; fRegisterManager = registerManager;
} }
public IRegisterGroup[] getRegisterGroups() throws DebugException { public IRegisterGroup[] getRegisterGroups( CStackFrame frame ) throws DebugException {
return getRegisterManager().getRegisterGroups(); return getRegisterManager().getRegisterGroups( frame );
} }
protected void disposeSourceManager() { protected void disposeSourceManager() {

View file

@ -18,12 +18,10 @@ import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.core.model.IVariable;
/** /**
* Enter type comment. * Implementation of the dummy stack frame.
*
* @since: Nov 13, 2002
*/ */
public class CDummyStackFrame extends CDebugElement implements IStackFrame, IDummyStackFrame public class CDummyStackFrame extends CDebugElement implements IStackFrame, IDummyStackFrame {
{
/** /**
* Containing thread. * Containing thread.
*/ */
@ -31,198 +29,222 @@ public class CDummyStackFrame extends CDebugElement implements IStackFrame, IDum
/** /**
* Constructor for CDummyStackFrame. * Constructor for CDummyStackFrame.
*
* @param target * @param target
*/ */
public CDummyStackFrame( CThread thread ) public CDummyStackFrame( CThread thread ) {
{
super( (CDebugTarget)thread.getDebugTarget() ); super( (CDebugTarget)thread.getDebugTarget() );
setThread( thread ); setThread( thread );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getThread() * @see org.eclipse.debug.core.model.IStackFrame#getThread()
*/ */
public IThread getThread() public IThread getThread() {
{
return fThread; return fThread;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getVariables() * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
*/ */
public IVariable[] getVariables() throws DebugException public IVariable[] getVariables() throws DebugException {
{
return new IVariable[0]; return new IVariable[0];
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#hasVariables() * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
*/ */
public boolean hasVariables() throws DebugException public boolean hasVariables() throws DebugException {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getLineNumber() * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
*/ */
public int getLineNumber() throws DebugException public int getLineNumber() throws DebugException {
{
return 0; return 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getCharStart() * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
*/ */
public int getCharStart() throws DebugException public int getCharStart() throws DebugException {
{
return 0; return 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getCharEnd() * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
*/ */
public int getCharEnd() throws DebugException public int getCharEnd() throws DebugException {
{
return 0; return 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getName() * @see org.eclipse.debug.core.model.IStackFrame#getName()
*/ */
public String getName() throws DebugException public String getName() throws DebugException {
{
return "..."; //$NON-NLS-1$ return "..."; //$NON-NLS-1$
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups() * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
*/ */
public IRegisterGroup[] getRegisterGroups() throws DebugException public IRegisterGroup[] getRegisterGroups() throws DebugException {
{ return new IRegisterGroup[0];
return ((CDebugTarget)getDebugTarget()).getRegisterGroups();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups() * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
*/ */
public boolean hasRegisterGroups() throws DebugException public boolean hasRegisterGroups() throws DebugException {
{ return false;
return ((CDebugTarget)getDebugTarget()).getRegisterGroups().length > 0;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#canStepInto() * @see org.eclipse.debug.core.model.IStep#canStepInto()
*/ */
public boolean canStepInto() public boolean canStepInto() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#canStepOver() * @see org.eclipse.debug.core.model.IStep#canStepOver()
*/ */
public boolean canStepOver() public boolean canStepOver() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#canStepReturn() * @see org.eclipse.debug.core.model.IStep#canStepReturn()
*/ */
public boolean canStepReturn() public boolean canStepReturn() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#isStepping() * @see org.eclipse.debug.core.model.IStep#isStepping()
*/ */
public boolean isStepping() public boolean isStepping() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#stepInto() * @see org.eclipse.debug.core.model.IStep#stepInto()
*/ */
public void stepInto() throws DebugException public void stepInto() throws DebugException {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#stepOver() * @see org.eclipse.debug.core.model.IStep#stepOver()
*/ */
public void stepOver() throws DebugException public void stepOver() throws DebugException {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IStep#stepReturn() * @see org.eclipse.debug.core.model.IStep#stepReturn()
*/ */
public void stepReturn() throws DebugException public void stepReturn() throws DebugException {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISuspendResume#canResume() * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
*/ */
public boolean canResume() public boolean canResume() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
*/ */
public boolean canSuspend() public boolean canSuspend() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
*/ */
public boolean isSuspended() public boolean isSuspended() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISuspendResume#resume() * @see org.eclipse.debug.core.model.ISuspendResume#resume()
*/ */
public void resume() throws DebugException public void resume() throws DebugException {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISuspendResume#suspend() * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
*/ */
public void suspend() throws DebugException public void suspend() throws DebugException {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ITerminate#canTerminate() * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
*/ */
public boolean canTerminate() public boolean canTerminate() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ITerminate#isTerminated() * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
*/ */
public boolean isTerminated() public boolean isTerminated() {
{
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ITerminate#terminate() * @see org.eclipse.debug.core.model.ITerminate#terminate()
*/ */
public void terminate() throws DebugException public void terminate() throws DebugException {
{
} }
/** /**
@ -230,20 +252,20 @@ public class CDummyStackFrame extends CDebugElement implements IStackFrame, IDum
* *
* @param thread the containing thread * @param thread the containing thread
*/ */
protected void setThread( CThread thread ) protected void setThread( CThread thread ) {
{
fThread = thread; fThread = thread;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/ */
public Object getAdapter( Class adapter ) public Object getAdapter( Class adapter ) {
{
if ( adapter.equals( IDummyStackFrame.class ) ) if ( adapter.equals( IDummyStackFrame.class ) )
return this; return this;
if ( adapter.equals( IStackFrame.class ) ) if ( adapter.equals( IStackFrame.class ) )
return this; return this;
return super.getAdapter(adapter); return super.getAdapter( adapter );
} }
} }

View file

@ -89,14 +89,6 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
return register; return register;
} }
public void resetChangeFlags() {
for ( int i = 0; i < fRegisters.length; ++i ) {
if ( fRegisters[i] != null ) {
((CRegister)fRegisters[i]).setChanged( false );
}
}
}
public void targetSuspended() { public void targetSuspended() {
for ( int i = 0; i < fRegisters.length; ++i ) { for ( int i = 0; i < fRegisters.length; ++i ) {
if ( fRegisters[i] != null && ((CRegister)fRegisters[i]).hasErrors() ) { if ( fRegisters[i] != null && ((CRegister)fRegisters[i]).hasErrors() ) {

View file

@ -216,14 +216,14 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
* @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups() * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
*/ */
public IRegisterGroup[] getRegisterGroups() throws DebugException { public IRegisterGroup[] getRegisterGroups() throws DebugException {
return ((CDebugTarget)getDebugTarget()).getRegisterGroups(); return ((CDebugTarget)getDebugTarget()).getRegisterGroups( this );
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups() * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
*/ */
public boolean hasRegisterGroups() throws DebugException { public boolean hasRegisterGroups() throws DebugException {
return ((CDebugTarget)getDebugTarget()).getRegisterGroups().length > 0; return ((CDebugTarget)getDebugTarget()).getRegisterGroups( this ).length > 0;
} }
/* (non-Javadoc) /* (non-Javadoc)