1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 17:25:38 +02:00

Bug 118272: Invalid stack trace when stepping out of function.

This commit is contained in:
Mikhail Khodjaiants 2005-11-28 21:07:36 +00:00
parent e10de4fc65
commit a7d1231811
2 changed files with 18 additions and 7 deletions

View file

@ -1,3 +1,7 @@
2005-11-28 Mikhail Khodjaiants
Bug 118272: Invalid stack trace when stepping out of function.
* CThread.java
2005-11-07 Mikhail Khodjaiants
Bug 115385: Pointer to a structure is not updated correctly
* CVariable.java

View file

@ -143,31 +143,35 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
fStackFrames = new ArrayList();
}
else if ( refreshChildren ) {
// If the last frame is dummy remove it
if ( fStackFrames.size() > 0 ) {
Object frame = fStackFrames.get( fStackFrames.size() - 1 );
if ( frame instanceof IDummyStackFrame ) {
fStackFrames.remove( frame );
}
}
// Retrieve stack frames from the backend
int depth = getStackDepth();
ICDIStackFrame[] frames = (depth != 0) ? getCDIStackFrames( 0, (depth > getMaxStackDepth()) ? getMaxStackDepth() : depth ) : new ICDIStackFrame[0];
ICDIStackFrame[] frames = ( depth != 0 ) ? getCDIStackFrames( 0, ( depth >= getMaxStackDepth() ) ? getMaxStackDepth() - 1 : depth ) : new ICDIStackFrame[0];
if ( fStackFrames.isEmpty() ) {
if ( frames.length > 0 ) {
addStackFrames( frames, 0, frames.length );
addStackFrames( frames, 0, frames.length, false );
}
}
else if ( depth < getLastStackDepth() ) {
// stepping out of the last frame
disposeStackFrames( 0, getLastStackDepth() - depth );
if ( frames.length > 0 ) {
updateStackFrames( frames, 0, fStackFrames, fStackFrames.size() );
if ( fStackFrames.size() < frames.length ) {
addStackFrames( frames, fStackFrames.size(), frames.length - fStackFrames.size() );
addStackFrames( frames, fStackFrames.size(), frames.length - fStackFrames.size(), true );
}
}
}
else if ( depth > getLastStackDepth() ) {
// stepping into a new frame
disposeStackFrames( frames.length - depth + getLastStackDepth(), depth - getLastStackDepth() );
addStackFrames( frames, 0, depth - getLastStackDepth() );
addStackFrames( frames, 0, depth - getLastStackDepth(), false );
updateStackFrames( frames, depth - getLastStackDepth(), fStackFrames, frames.length - depth + getLastStackDepth() );
}
else { // depth == getLastStackDepth()
@ -178,7 +182,7 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
ICDIStackFrame oldTopFrame = (fStackFrames.size() > 0) ? ((CStackFrame)fStackFrames.get( 0 )).getLastCDIStackFrame() : null;
if ( !CStackFrame.equalFrame( newTopFrame, oldTopFrame ) ) {
disposeStackFrames( 0, fStackFrames.size() );
addStackFrames( frames, 0, frames.length );
addStackFrames( frames, 0, frames.length, false );
}
else // we are in the same frame
{
@ -245,10 +249,13 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
}
}
protected void addStackFrames( ICDIStackFrame[] newFrames, int startIndex, int length ) {
protected void addStackFrames( ICDIStackFrame[] newFrames, int startIndex, int length, boolean append ) {
if ( newFrames.length >= startIndex + length ) {
for( int i = 0; i < length; ++i ) {
fStackFrames.add( i, new CStackFrame( this, newFrames[startIndex + i] ) );
if ( append )
fStackFrames.add( new CStackFrame( this, newFrames[startIndex + i] ) );
else
fStackFrames.add( i, new CStackFrame( this, newFrames[startIndex + i] ) );
}
}
}