From d034f60b19e5559f6aa7fa94ff3839bd03a692de Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 5 Feb 2011 04:27:36 +0000 Subject: [PATCH] Bug 335324 - [multi-process][breakpoints] Make the container (process) the breakpointTarget context --- .../gdb/launching/FinalLaunchSequence.java | 8 +++++--- .../cdt/dsf/gdb/service/GDBProcesses_7_2.java | 8 ++++++-- .../dsf/gdb/service/GDBRunControl_7_0_NS.java | 19 ++++++++++++++++++- .../StartOrRestartProcessSequence_7_0.java | 18 ++++++++++-------- .../service/command/GDBControlDMContext.java | 6 +++--- .../dsf/mi/service/IMIContainerDMContext.java | 6 ++++-- .../cdt/dsf/mi/service/MIRunControl.java | 13 ++++++++++++- .../core/GDBJtagDSFFinalLaunchSequence.java | 7 +++++-- 8 files changed, 63 insertions(+), 22 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index 9637859dbc3..4b0fd4dc2e7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Ericsson and others. + * Copyright (c) 2008, 2011 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,6 +40,7 @@ import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext; import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.mi.service.CSourceLookup; +import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; import org.eclipse.cdt.dsf.mi.service.MIProcesses; @@ -674,9 +675,10 @@ public class FinalLaunchSequence extends ReflectionSequence { public void stepStartTrackingBreakpoints(final RequestMonitor requestMonitor) { if (fSessionType != SessionType.CORE) { MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class); - IBreakpointsTargetDMContext breakpointDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext(); + IMIContainerDMContext containerDmc = fProcService.createContainerContextFromGroupId(fCommandControl.getContext(), null); + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); - bpmService.startTrackingBreakpoints(breakpointDmc, requestMonitor); + bpmService.startTrackingBreakpoints(bpTargetDmc, requestMonitor); } else { requestMonitor.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java index 9a808c4682c..d0ff5f39d5e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 TUBITAK BILGEM-ITI and others. + * Copyright (c) 2010, 2011 TUBITAK BILGEM-ITI and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,7 @@ import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext; +import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; @@ -99,7 +100,10 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 { @Override protected void handleSuccess() { rm.setData(containerDmc); - rm.done(); + + // Start tracking this process' breakpoints. + MIBreakpointsManager bpmService = getServicesTracker().getService(MIBreakpointsManager.class); + bpmService.startTrackingBreakpoints(containerDmc, rm); } }); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java index e3372bcf14a..01744b2aa7c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java @@ -41,6 +41,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl2; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommand; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.service.command.events.MITracepointSelectedEvent; @@ -948,9 +949,25 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo @Override public void execute(final RequestMonitor rm) { + fContainerDmcToSuspend = DMContexts.getAncestorOfType(fCtx, IContainerDMContext.class); + if (fContainerDmcToSuspend != null) { + // In non-stop, we don't actually need this particular process to be suspended, + // all we need is one of any of the processes to be suspended. + // However, for efficiency, we can first check if the process in question + // is suspended. + if (isSuspended(fContainerDmcToSuspend)) { + fTargetAvailable = true; + rm.done(); + return; + } + } + + // If we get here, we have to get the list of processes to know if any of + // them is suspended. + ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(fCtx, ICommandControlDMContext.class); IProcesses processControl = getServicesTracker().getService(IProcesses.class); processControl.getProcessesBeingDebugged( - fCtx, + controlDmc, new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleSuccess() { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java index faad1931c06..bdd8c161e43 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ReflectionSequence; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommand; @@ -202,10 +203,11 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT); + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(getContainerContext(), IBreakpointsTargetDMContext.class); + fCommandControl.queueCommand( - fCommandFactory.createMIBreakInsert((IBreakpointsTargetDMContext)fCommandControl.getContext(), - true, false, null, 0, userStopSymbol, 0), - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { + fCommandFactory.createMIBreakInsert(bpTargetDmc, true, false, null, 0, userStopSymbol, 0), + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { @Override public void handleSuccess() { if (getData() != null) { @@ -231,10 +233,12 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { @Execute public void stepSetBreakpointForReverse(final RequestMonitor rm) { if (fReverseEnabled) { + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(getContainerContext(), IBreakpointsTargetDMContext.class); + fCommandControl.queueCommand( - fCommandFactory.createMIBreakInsert((IBreakpointsTargetDMContext)fCommandControl.getContext(), - true, false, null, 0, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT, 0), - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { + fCommandFactory.createMIBreakInsert(bpTargetDmc, true, false, null, 0, + ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT, 0), + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm) { @Override public void handleSuccess() { if (getData() != null) { @@ -291,8 +295,6 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { GDBRunControl_7_0 reverseService = fTracker.getService(GDBRunControl_7_0.class); if (reverseService != null) { reverseService.setReverseModeEnabled(false); - } else { - assert false : "Missing reverse runControl service"; //$NON-NLS-1$ } } rm.done(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java index 9337bc1ef76..160e688936f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems and others. + * Copyright (c) 2007, 2011 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,10 +7,10 @@ * * Contributors: * Wind River Systems - initial API and implementation + * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 335324) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service.command; -import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext; import org.eclipse.cdt.dsf.debug.service.IModules.ISymbolDMContext; import org.eclipse.cdt.dsf.debug.service.ISignals.ISignalsDMContext; @@ -22,7 +22,7 @@ import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext; * */ public class GDBControlDMContext extends MIControlDMContext - implements ISymbolDMContext, IBreakpointsTargetDMContext, ISourceLookupDMContext, + implements ISymbolDMContext, ISourceLookupDMContext, ISignalsDMContext, IDisassemblyDMContext, ITraceTargetDMContext { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIContainerDMContext.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIContainerDMContext.java index 3589d975ca2..6dcc3e36049 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIContainerDMContext.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIContainerDMContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Ericsson and others. + * Copyright (c) 2008, 2011 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,9 +7,11 @@ * * Contributors: * Ericsson - initial API and implementation + * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 335324) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; /** @@ -18,7 +20,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; * identifier. These thread groups are the basis for this context. * @since 1.1 */ -public interface IMIContainerDMContext extends IContainerDMContext +public interface IMIContainerDMContext extends IContainerDMContext, IBreakpointsTargetDMContext { /** * Returns the GDB/MI thread group identifier of this context. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java index 34b99340dcd..50aaa923584 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java @@ -38,6 +38,7 @@ import org.eclipse.cdt.dsf.debug.service.command.BufferedCommandControl; import org.eclipse.cdt.dsf.debug.service.command.CommandCache; import org.eclipse.cdt.dsf.debug.service.command.ICommand; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.service.command.events.MITracepointSelectedEvent; @@ -967,9 +968,19 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I @Override public void execute(final RequestMonitor rm) { + fContainerDmc = DMContexts.getAncestorOfType(fCtx, IContainerDMContext.class); + if (fContainerDmc != null) { + // In all-stop, if any process is suspended, then all of them are suspended + // so we only need to check this process. + fTargetAvailable = isSuspended(fContainerDmc); + rm.done(); + return; + } + + ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(fCtx, ICommandControlDMContext.class); IProcesses processControl = getServicesTracker().getService(IProcesses.class); processControl.getProcessesBeingDebugged( - fCtx, + controlDmc, new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleSuccess() { diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java index 176b5f32f3e..43d2a7d6dab 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java @@ -37,6 +37,7 @@ import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext; @@ -47,6 +48,7 @@ import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.mi.service.CSourceLookup; +import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; @@ -605,9 +607,10 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { public void execute(final RequestMonitor requestMonitor) { if (fSessionType != SessionType.CORE) { MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class); - IBreakpointsTargetDMContext breakpointDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext(); + IMIContainerDMContext containerDmc = fProcService.createContainerContextFromGroupId(fCommandControl.getContext(), null); + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); - bpmService.startTrackingBreakpoints(breakpointDmc, requestMonitor); + bpmService.startTrackingBreakpoints(bpTargetDmc, requestMonitor); } else { requestMonitor.done(); }