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

More implementation.

This commit is contained in:
Mikhail Khodjaiants 2002-08-15 22:22:42 +00:00
parent cc9642e5a1
commit a5a6ab9bbc
5 changed files with 120 additions and 13 deletions

View file

@ -109,7 +109,7 @@ public class CDebugModel
try
{
ICDIBreakpoint bkpt = cdiTarget.getSession().getBreakpointManager().
setLocationBreakpoint( ICDIBreakpoint.TEMPORARY,
setLocationBreakpoint( ICDIBreakpoint.REGULAR, //ICDIBreakpoint.TEMPORARY,
location,
null,
null );

View file

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
@ -439,6 +440,43 @@ public class CDebugTarget extends CDebugElement
{
}
/**
* Refreshes the thread list.
*
*/
protected synchronized void refreshThreads()
{
ArrayList list = new ArrayList( 5 );
try
{
ICDIThread[] cdiThreads = getCDITarget().getThreads();
for ( int i = 0; i < cdiThreads.length; ++i )
{
CThread thread = findThread( cdiThreads[i] );
if ( thread == null )
{
thread = createThread( cdiThreads[i] );
}
else
{
getThreadList().remove( thread );
}
list.add( thread );
}
Iterator it = getThreadList().iterator();
while( it.hasNext() )
{
((CThread)it.next()).terminated();
}
getThreadList().clear();
setThreadList( list );
}
catch( CDIException e )
{
CDebugCorePlugin.log( e );
}
}
/**
* Notifies threads that they have been resumed
*/
@ -949,6 +987,13 @@ public class CDebugTarget extends CDebugElement
setCurrentStateId( IState.SUSPENDED );
ICDISessionObject reason = event.getReason();
setCurrentStateInfo( reason );
refreshThreads();
if ( event.getSource() instanceof ICDIThread )
{
CThread thread = findThread( (ICDIThread)event.getSource() );
if ( thread != null )
thread.handleDebugEvent( event );
}
if ( reason instanceof ICDIEndSteppingRange )
{
handleEndSteppingRange( (ICDIEndSteppingRange)reason );
@ -988,9 +1033,10 @@ public class CDebugTarget extends CDebugElement
private void handleExitedEvent( ICDIExitedEvent event )
{
removeAllThreads();
setCurrentStateId( IState.EXITED );
setCurrentStateInfo( event.getExitInfo() );
fireChangeEvent( DebugEvent.STATE );
fireChangeEvent( DebugEvent.CONTENT );
}
private void handleTerminatedEvent( ICDIDestroyedEvent event )

View file

@ -200,7 +200,16 @@ public class CStackFrame extends CDebugElement
*/
public String getName() throws DebugException
{
return null;
ICDILocation location = getCDIStackFrame().getLocation();
String name = new String();
if ( location.getFunction() != null )
name += location.getFunction() + "() ";
if ( location.getFile() != null )
name += "at " + location.getFile() + ":" ;
if ( location.getLineNumber() != 0 )
name += location.getLineNumber();
return name.toString();
}
/* (non-Javadoc)
@ -477,7 +486,7 @@ public class CStackFrame extends CDebugElement
{
//return ( frameOne.getParent().equals( frameTwo.getParent() ) &&
// frameOne.getLocation().equals( frameTwo.getLocation() ) );
return (frameOne.getLocation().equals(frameTwo.getLocation()));
return ( frameOne != null && frameTwo != null && frameOne.getLocation().equals( frameTwo.getLocation() ) );
}
protected boolean exists() throws DebugException
@ -517,7 +526,7 @@ public class CStackFrame extends CDebugElement
List list = new ArrayList();
try
{
list.add( Arrays.asList( getCDIStackFrame().getLocalVariables() ) );
list.addAll( Arrays.asList( getCDIStackFrame().getLocalVariables() ) );
}
catch( CDIException e )
{
@ -536,7 +545,7 @@ public class CStackFrame extends CDebugElement
List list = new ArrayList();
try
{
list.add( Arrays.asList( getCDIStackFrame().getArguments() ) );
list.addAll( Arrays.asList( getCDIStackFrame().getArguments() ) );
}
catch( CDIException e )
{
@ -548,8 +557,8 @@ public class CStackFrame extends CDebugElement
protected List getAllCDIVariables() throws DebugException
{
List list = new ArrayList();
list.add( getCDIArguments() );
list.add( getCDILocalVariables() );
list.addAll( getCDIArguments() );
list.addAll( getCDILocalVariables() );
return list;
}

View file

@ -159,9 +159,8 @@ public class CThread extends CDebugElement
fStackFrames = createAllStackFrames();
if ( fStackFrames.isEmpty() )
{
fRefreshChildren = false; // ????
//leave fRefreshChildren == true
//bug 6393
// ?????
return fStackFrames;
}
}
@ -359,7 +358,7 @@ public class CThread extends CDebugElement
*/
public String getName() throws DebugException
{
return "Thread " + getCDIThread().toString();
return getCDIThread().toString();
}
/* (non-Javadoc)
@ -428,7 +427,7 @@ public class CThread extends CDebugElement
*/
public boolean canResume()
{
return isSuspended() && !getDebugTarget().isSuspended();
return isSuspended();
}
/* (non-Javadoc)

View file

@ -6,12 +6,14 @@
package org.eclipse.cdt.debug.internal.ui;
import java.text.MessageFormat;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.IState;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IDisconnect;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.ITerminate;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue;
@ -110,6 +112,12 @@ public class CDTDebugModelPresentation extends LabelProvider
StringBuffer label = new StringBuffer();
try
{
if ( element instanceof IStackFrame )
{
label.append( getStackFrameText( (IStackFrame)element ) );
return label.toString();
}
if ( element instanceof IDebugTarget )
label.append( getTargetText( (IDebugTarget)element, showQualified ) );
else if ( element instanceof IThread )
@ -161,11 +169,56 @@ public class CDTDebugModelPresentation extends LabelProvider
protected String getTargetText( IDebugTarget target, boolean qualified ) throws DebugException
{
if ( target instanceof IState )
{
switch( ((IState)target).getCurrentStateId() )
{
case IState.EXITED:
return getFormattedString( "{0} (Exited)", target.getName() );
}
}
return target.getName();
}
protected String getThreadText( IThread thread, boolean qualified ) throws DebugException
{
return thread.getName();
if ( thread.isTerminated() )
{
return getFormattedString( "Thread [{0}] (Terminated)", thread.getName() );
}
if ( thread.isStepping() )
{
return getFormattedString( "Thread [{0}] (Stepping)", thread.getName());
}
if ( !thread.isSuspended() )
{
return getFormattedString( "Thread [{0}] (Running)", thread.getName() );
}
return getFormattedString( "Thread [{0}] (Suspended)", thread.getName() );
}
protected String getStackFrameText( IStackFrame stackFrame ) throws DebugException
{
return stackFrame.getName();
}
/**
* Plug in the single argument to the resource String for the key to
* get a formatted resource String.
*
*/
public static String getFormattedString( String key, String arg )
{
return getFormattedString( key, new String[]{ arg } );
}
/**
* Plug in the arguments to the resource String for the key to get
* a formatted resource String.
*
*/
public static String getFormattedString(String string, String[] args)
{
return MessageFormat.format( string, args );
}
}