1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 320044: New breakpoints are got installed in dead process.

This commit is contained in:
Ling Wang 2010-07-16 19:12:32 +00:00
parent fa8ceee23e
commit 682b0c44dc

View file

@ -181,6 +181,12 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>> fPlatformBPs = private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>> fPlatformBPs =
new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>>(); new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>>();
/**
* BreakpointsTargetDMContext's that are being removed from {@link #fPlatformBPs}.
* See where this is used for more.
*/
private List<IBreakpointsTargetDMContext> fBPTargetDMCsBeingRemoved = new ArrayList<IBreakpoints.IBreakpointsTargetDMContext>();
/** /**
* Mapping of platform breakpoints to all their attributes (standard ones and * Mapping of platform breakpoints to all their attributes (standard ones and
* extended ones) from UI. This will be used to check what attributes have * extended ones) from UI. This will be used to check what attributes have
@ -358,8 +364,8 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
// We need to use a background thread for this operation because we are // We need to use a background thread for this operation because we are
// accessing the resources system to retrieve the breakpoint attributes. // accessing the resources system to retrieve the breakpoint attributes.
// Accessing the resources system potentially requires using global locks. // Accessing the resources system potentially requires using global locks.
// Also we will be calling IBreakpointAttributeTranslator which is prohibited // Also we will be calling some IBreakpointAttributeTranslator2 methods
// from being called on the session executor thread. // that are prohibited from being called on the session executor thread.
new Job("Install initial breakpoint list.") { //$NON-NLS-1$ new Job("Install initial breakpoint list.") { //$NON-NLS-1$
{ setSystem(true); } { setSystem(true); }
@ -379,28 +385,51 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
* @param rm Completion callback. * @param rm Completion callback.
*/ */
public void stopTrackingBreakpoints(final IBreakpointsTargetDMContext dmc, final RequestMonitor rm) { public void stopTrackingBreakpoints(final IBreakpointsTargetDMContext dmc, final RequestMonitor rm) {
// - Remove the target breakpoints for the given execution context // - Remove the target breakpoints for the given DMC
// - Update the maps // - Remove the given DMC from the internal maps.
//
// Remove the breakpoints for given DMC from the internal maps.
Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc); Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
if (platformBPs == null || platformBPs.size() == 0) { if (platformBPs == null) {
rm.setStatus(new Status(IStatus.INFO /* NOT error */, getPluginID(), INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$ rm.setStatus(new Status(IStatus.INFO /* NOT error */, getPluginID(), INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$
rm.done(); rm.done();
return; return;
} }
if (platformBPs.size() == 0) {
fPlatformBPs.remove(dmc); // dmc tracked but no bps installed for it.
rm.done();
return;
}
// The stopTrackingBreakpoints() may be called twice for the same DMC
// on debugger termination (one on process death and one on debugger shutdown).
// This is to prevent double killing.
if (fBPTargetDMCsBeingRemoved.contains(dmc)) { // "stop" is already underway
rm.done();
return;
}
fBPTargetDMCsBeingRemoved.add(dmc);
// Just remove the IBreakpoints installed for the "dmc". // Just remove the IBreakpoints installed for the "dmc".
final IBreakpoint[] bps = platformBPs.keySet().toArray(new IBreakpoint[platformBPs.size()]); final IBreakpoint[] bps = platformBPs.keySet().toArray(new IBreakpoint[platformBPs.size()]);
new Job("Uninstall target breakpoints list.") { //$NON-NLS-1$ new Job("Uninstall target breakpoints list.") { //$NON-NLS-1$
{ setSystem(true); } { setSystem(true); }
// Get the stored breakpoints from the platform BreakpointManager
// and install them on the target
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
doBreakpointsRemoved(bps, dmc, rm); doBreakpointsRemoved(bps, dmc, new RequestMonitor(getExecutor(), rm){
@Override
protected void handleCompleted() {
// Regardless of success or failure in removing the breakpoints,
// we should stop tracking breakpoints for the "dmc" by removing it
// from the map.
fPlatformBPs.remove(dmc);
fBPTargetDMCsBeingRemoved.remove(dmc);
super.handleCompleted();
}});
return Status.OK_STATUS; return Status.OK_STATUS;
} }
}.schedule(); }.schedule();
@ -536,8 +565,11 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
* breakpoint, there could be multiple corresponding back-end breakpoints. * breakpoint, there could be multiple corresponding back-end breakpoints.
* *
* @param dmc * @param dmc
* the context for which to remove the breakpoint.
* @param breakpoint * @param breakpoint
* @param drm * @param drm
* contains list of Target breakpoints that are removed
* regardless of success or failure in the removal.
*/ */
private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint, private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint,
final DataRequestMonitor<List<TargetBP>> drm) final DataRequestMonitor<List<TargetBP>> drm)
@ -576,6 +608,7 @@ public class BreakpointsMediator2 extends AbstractDsfService implements IBreakpo
new RequestMonitor(getExecutor(), countingRm) { new RequestMonitor(getExecutor(), countingRm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
// Remember result of the removal, success or failure.
bp.setStatus(getStatus()); bp.setStatus(getStatus());
if (isSuccess()) { if (isSuccess()) {
bp.setTargetBreakpoint(null); bp.setTargetBreakpoint(null);