mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
Bug 314628: Always restore the target state even if a failure has happened.
This commit is contained in:
parent
54d5da166c
commit
69444100a5
4 changed files with 59 additions and 1 deletions
|
@ -994,6 +994,11 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void rollBack(RequestMonitor rm) {
|
||||||
|
Sequence.Step restoreStep = new RestoreTargetStateStep();
|
||||||
|
restoreStep.execute(rm);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@ public interface IMIRunControl extends IRunControl2
|
||||||
* to receive commands. Once the specified steps are executed, the target should be
|
* to receive commands. Once the specified steps are executed, the target should be
|
||||||
* returned to its original availability.
|
* returned to its original availability.
|
||||||
*
|
*
|
||||||
* This can is of value for breakpoints commands; e.g., breakpoints need to be inserted
|
* This is of value for breakpoints commands; e.g., breakpoints need to be inserted
|
||||||
* even when the target is running, so this call would suspend the target, insert the
|
* even when the target is running, so this call would suspend the target, insert the
|
||||||
* breakpoint, and resume the target again.
|
* breakpoint, and resume the target again.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1012,6 +1012,11 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void rollBack(RequestMonitor rm) {
|
||||||
|
Sequence.Step restoreStep = new RestoreTargetStateStep();
|
||||||
|
restoreStep.execute(rm);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1238,6 +1238,54 @@ public class MIBreakpointsTest extends BaseTestCase {
|
||||||
((MIBreakpointHitEvent)event).getNumber() == ref.getReference());
|
((MIBreakpointHitEvent)event).getNumber() == ref.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// insertInvalidBreakpoint_WhileTargetRunning
|
||||||
|
// Set an invalid breakpoint while the target is running, then set a valid
|
||||||
|
// breakpoint and make sure the second breakpoints eventually gets hit.
|
||||||
|
//
|
||||||
|
// We had a problem where an invalid breakpoint set when the target was running
|
||||||
|
// would leave us in a bad state (Bug 314628)
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
@Test
|
||||||
|
public void insertInvalidBreakpoint_WhileTargetRunning() throws Throwable {
|
||||||
|
|
||||||
|
// Create a line breakpoint
|
||||||
|
Map<String, Object> breakpoint = new HashMap<String, Object>();
|
||||||
|
breakpoint.put(BREAKPOINT_TYPE_TAG, BREAKPOINT_TAG);
|
||||||
|
breakpoint.put(FILE_NAME_TAG, "Bad file name");
|
||||||
|
breakpoint.put(LINE_NUMBER_TAG, LINE_NUMBER_5);
|
||||||
|
|
||||||
|
// Run the program. It will make a two second sleep() call, during which time...
|
||||||
|
SyncUtil.resume();
|
||||||
|
|
||||||
|
// ...we install the bad breakpoint and check that it failed
|
||||||
|
insertBreakpoint(fBreakpointsDmc, breakpoint);
|
||||||
|
assertTrue(fWait.getMessage(), !fWait.isOK());
|
||||||
|
|
||||||
|
// Now install a proper breakpoint an see that it hits without having to resume
|
||||||
|
// the target. This will show that the target was still properly running.
|
||||||
|
breakpoint.put(FILE_NAME_TAG, SOURCE_FILE);
|
||||||
|
MIBreakpointDMContext ref = (MIBreakpointDMContext) insertBreakpoint(fBreakpointsDmc, breakpoint);
|
||||||
|
|
||||||
|
// Wait for breakpoint to hit.
|
||||||
|
MIStoppedEvent event = waitForBreakpointEventsAfterBreakpointOperationWhileTargetRunning(true, 2);
|
||||||
|
|
||||||
|
// Ensure the correct BreakpointEvent was received
|
||||||
|
MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref);
|
||||||
|
assertTrue("BreakpointEvent problem: expected " + 2 + " BREAKPOINT event(s), received "
|
||||||
|
+ fBreakpointEventCount, fBreakpointEventCount == 2);
|
||||||
|
assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_HIT event(s), received "
|
||||||
|
+ getBreakpointEventCount(BP_HIT), getBreakpointEventCount(BP_HIT) == 1);
|
||||||
|
assertTrue("BreakpointService problem: breakpoint mismatch",
|
||||||
|
fBreakpointRef == breakpoint1.getNumber());
|
||||||
|
clearEventCounters();
|
||||||
|
|
||||||
|
assertTrue("Did not stop because of breakpoint, but stopped because of: " +
|
||||||
|
event.getClass().getCanonicalName(), event instanceof MIBreakpointHitEvent);
|
||||||
|
assertTrue("Did not stop because of the correct breakpoint at line " + LINE_NUMBER_5,
|
||||||
|
((MIBreakpointHitEvent)event).getNumber() == ref.getReference());
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Add Watchpoint tests
|
// Add Watchpoint tests
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Reference in a new issue