mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[240092] Move getSessionType() and getIsAttachSession() from IGDBControl to IGDBBackend. Also, remove IGDBControl.getExecutablePath() since IGDBBackend.getProgramPath() did the same thing.
This commit is contained in:
parent
0113d94674
commit
cd35fa70ba
11 changed files with 60 additions and 73 deletions
|
@ -23,6 +23,7 @@ import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
|||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.IGDBBackend;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.command.IGDBControl;
|
||||
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
@ -76,8 +77,9 @@ public class GdbRestartCommand implements IRestart {
|
|||
@Override
|
||||
protected void execute(final DataRequestMonitor<Object> rm) {
|
||||
final IGDBControl gdbControl = fTracker.getService(IGDBControl.class);
|
||||
if (gdbControl != null) {
|
||||
execPathRef.set(gdbControl.getExecutablePath());
|
||||
final IGDBBackend backend = fTracker.getService(IGDBBackend.class);
|
||||
if (gdbControl != null && backend != null) {
|
||||
execPathRef.set(backend.getProgramPath());
|
||||
gdbControl.initInferiorInputOutput(new RequestMonitor(fExecutor, rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
|
|||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.gdb.internal.provisional.breakpoints.CBreakpointGdbThreadsFilterExtension;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.command.IGDBControl;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.IGDBBackend;
|
||||
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.dd.mi.service.IMIExecutionDMContext;
|
||||
import org.eclipse.dd.mi.service.IMIProcesses;
|
||||
|
@ -468,14 +468,14 @@ public class GdbThreadFilterEditor {
|
|||
return;
|
||||
}
|
||||
|
||||
ServiceTracker tracker = new ServiceTracker(GdbUIPlugin.getBundleContext(), IGDBControl.class
|
||||
ServiceTracker tracker = new ServiceTracker(GdbUIPlugin.getBundleContext(), IGDBBackend.class
|
||||
.getName(), null);
|
||||
tracker.open();
|
||||
IGDBControl gdbControl = (IGDBControl) tracker.getService();
|
||||
if (gdbControl != null) {
|
||||
rm.setData(gdbControl.getExecutablePath().toOSString());
|
||||
IGDBBackend backend = (IGDBBackend) tracker.getService();
|
||||
if (backend != null) {
|
||||
rm.setData(backend.getProgramPath().toOSString());
|
||||
} else {
|
||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control not accessible.")); //$NON-NLS-1$
|
||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Backend not accessible.")); //$NON-NLS-1$
|
||||
}
|
||||
rm.done();
|
||||
tracker.close();
|
||||
|
|
|
@ -146,7 +146,7 @@ public class FinalLaunchSequence extends Sequence {
|
|||
return;
|
||||
}
|
||||
|
||||
final IPath execPath = fCommandControl.getExecutablePath();
|
||||
final IPath execPath = fGDBBackend.getProgramPath();
|
||||
if (!noFileCommand && execPath != null && !execPath.isEmpty()) {
|
||||
fCommandControl.queueCommand(
|
||||
new MIFileExecAndSymbols(fCommandControl.getContext(),
|
||||
|
|
|
@ -77,6 +77,9 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
private List<String> fSharedLibPaths;
|
||||
private String fProgramArguments;
|
||||
|
||||
private SessionType fSessionType;
|
||||
private Boolean fAttach;
|
||||
|
||||
/**
|
||||
* Unique ID of this service instance.
|
||||
*/
|
||||
|
@ -322,6 +325,20 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
return fGDBExitValue;
|
||||
}
|
||||
|
||||
public SessionType getSessionType() {
|
||||
if (fSessionType == null) {
|
||||
fSessionType = LaunchUtils.getSessionType(fLaunchConfiguration);
|
||||
}
|
||||
return fSessionType;
|
||||
}
|
||||
|
||||
public boolean getIsAttachSession() {
|
||||
if (fAttach == null) {
|
||||
fAttach = LaunchUtils.getIsAttach(fLaunchConfiguration);
|
||||
}
|
||||
return fAttach;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BundleContext getBundleContext() {
|
||||
return GdbPlugin.getBundleContext();
|
||||
|
|
|
@ -141,7 +141,10 @@ public class GDBProcesses extends MIProcesses {
|
|||
|
||||
String name = fProcessNames.get(pid);
|
||||
// If we still don't find the name in our list, return the default name of our program
|
||||
if (name == null) name = fGdb.getExecutablePath().lastSegment();
|
||||
if (name == null) {
|
||||
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
|
||||
name = backend.getProgramPath().lastSegment();
|
||||
}
|
||||
rm.setData(new MIThreadDMData(name, pidStr));
|
||||
rm.done();
|
||||
} else {
|
||||
|
@ -230,7 +233,8 @@ public class GDBProcesses extends MIProcesses {
|
|||
@Override
|
||||
public void getRunningProcesses(IDMContext dmc, final DataRequestMonitor<IProcessDMContext[]> rm) {
|
||||
final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
|
||||
if (fGdb.getSessionType() == SessionType.LOCAL) {
|
||||
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
|
||||
if (backend.getSessionType() == SessionType.LOCAL) {
|
||||
IProcessList list = null;
|
||||
try {
|
||||
list = CCorePlugin.getDefault().getProcessList();
|
||||
|
|
|
@ -543,7 +543,8 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
}
|
||||
|
||||
public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||
rm.setData(fCommandControl.getIsAttachSession());
|
||||
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
|
||||
rm.setData(backend.getIsAttachSession());
|
||||
rm.done();
|
||||
}
|
||||
|
||||
|
@ -571,7 +572,8 @@ public class GDBProcesses_7_0 extends AbstractDsfService
|
|||
}
|
||||
|
||||
public void canDetachDebuggerFromProcess(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||
rm.setData(fCommandControl.getIsAttachSession() && fCommandControl.isConnected());
|
||||
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
|
||||
rm.setData(backend.getIsAttachSession() && fCommandControl.isConnected());
|
||||
rm.done();
|
||||
}
|
||||
|
||||
|
|
|
@ -84,4 +84,14 @@ public interface IGDBBackend extends IMIBackend {
|
|||
* Sends an interrupt signal to the GDB process.
|
||||
*/
|
||||
public void interrupt();
|
||||
|
||||
/**
|
||||
* @return The type of the session currently ongoing with the backend
|
||||
*/
|
||||
public SessionType getSessionType();
|
||||
|
||||
/**
|
||||
* @return true if the ongoing session is attaching to a remote target.
|
||||
*/
|
||||
public boolean getIsAttachSession();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
|
@ -38,7 +37,6 @@ import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
|||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchUtils;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.IGDBBackend;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.SessionType;
|
||||
import org.eclipse.dd.mi.service.IMIBackend;
|
||||
|
@ -98,10 +96,6 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
private GDBControlDMContext fControlDmc;
|
||||
|
||||
private SessionType fSessionType;
|
||||
|
||||
private boolean fAttach;
|
||||
|
||||
private IGDBBackend fMIBackend;
|
||||
|
||||
private boolean fConnected = true;
|
||||
|
@ -115,8 +109,6 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
public GDBControl(DsfSession session, ILaunchConfiguration config) {
|
||||
super(session, false);
|
||||
fSessionType = LaunchUtils.getSessionType(config);
|
||||
fAttach = LaunchUtils.getIsAttach(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,14 +175,6 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
return fControlDmc;
|
||||
}
|
||||
|
||||
public SessionType getSessionType() {
|
||||
return fSessionType;
|
||||
}
|
||||
|
||||
public boolean getIsAttachSession() {
|
||||
return fAttach;
|
||||
}
|
||||
|
||||
public void terminate(final RequestMonitor rm) {
|
||||
// Schedule a runnable to be executed 2 seconds from now.
|
||||
// If we don't get a response to the quit command, this
|
||||
|
@ -233,7 +217,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
* be used instead; this decision is based on the type of session.
|
||||
*/
|
||||
public void initInferiorInputOutput(final RequestMonitor requestMonitor) {
|
||||
if (fSessionType == SessionType.REMOTE || fAttach) {
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE || fMIBackend.getIsAttachSession()) {
|
||||
// These types do not use a PTY
|
||||
fPty = null;
|
||||
requestMonitor.done();
|
||||
|
@ -263,7 +247,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
|
||||
public boolean canRestart() {
|
||||
if (fAttach) return false;
|
||||
if (fMIBackend.getIsAttachSession()) return false;
|
||||
|
||||
// Before GDB6.8, the Linux gdbserver would restart a new
|
||||
// process when getting a -exec-run but the communication
|
||||
|
@ -271,7 +255,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
// with GDB6.8 the program restarts properly one time,
|
||||
// but on a second attempt, gdbserver crashes.
|
||||
// So, lets just turn off the Restart for Remote debugging
|
||||
if (fSessionType == SessionType.REMOTE) return false;
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -295,7 +279,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
* Insert breakpoint at entry if set, and start or restart the program.
|
||||
*/
|
||||
protected void startOrRestart(final GdbLaunch launch, boolean restart, final RequestMonitor requestMonitor) {
|
||||
if (fAttach) {
|
||||
if (fMIBackend.getIsAttachSession()) {
|
||||
// When attaching to a running process, we do not need to set a breakpoint or
|
||||
// start the program; it is left up to the user.
|
||||
requestMonitor.done();
|
||||
|
@ -309,7 +293,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
final IContainerDMContext containerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
||||
|
||||
final MICommand<MIInfo> execCommand;
|
||||
if (fSessionType == SessionType.REMOTE) {
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE) {
|
||||
// When doing remote debugging, we use -exec-continue instead of -exec-run
|
||||
execCommand = new MIExecContinue(containerDmc);
|
||||
} else {
|
||||
|
@ -386,9 +370,6 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
return fInferiorProcess;
|
||||
}
|
||||
|
||||
public IPath getExecutablePath() { return fMIBackend.getProgramPath(); }
|
||||
|
||||
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||
// Handle our "GDB Exited" event and stop processing commands.
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
|
@ -38,7 +37,6 @@ import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
|||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchUtils;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.IGDBBackend;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.SessionType;
|
||||
import org.eclipse.dd.mi.service.IMIBackend;
|
||||
|
@ -97,10 +95,6 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
private GDBControlDMContext fControlDmc;
|
||||
|
||||
private SessionType fSessionType;
|
||||
|
||||
private boolean fAttach;
|
||||
|
||||
private IGDBBackend fMIBackend;
|
||||
|
||||
private boolean fConnected = true;
|
||||
|
@ -114,8 +108,6 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
public GDBControl_7_0(DsfSession session, ILaunchConfiguration config) {
|
||||
super(session, true);
|
||||
fSessionType = LaunchUtils.getSessionType(config);
|
||||
fAttach = LaunchUtils.getIsAttach(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -181,14 +173,6 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
return fControlDmc;
|
||||
}
|
||||
|
||||
public SessionType getSessionType() {
|
||||
return fSessionType;
|
||||
}
|
||||
|
||||
public boolean getIsAttachSession() {
|
||||
return fAttach;
|
||||
}
|
||||
|
||||
public void terminate(final RequestMonitor rm) {
|
||||
// Schedule a runnable to be executed 2 seconds from now.
|
||||
// If we don't get a response to the quit command, this
|
||||
|
@ -207,9 +191,8 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
},
|
||||
2, TimeUnit.SECONDS);
|
||||
|
||||
MIGDBExit cmd = new MIGDBExit(fControlDmc);
|
||||
queueCommand(
|
||||
cmd,
|
||||
new MIGDBExit(fControlDmc),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
|
@ -232,7 +215,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
* be used instead; this decision is based on the type of session.
|
||||
*/
|
||||
public void initInferiorInputOutput(final RequestMonitor requestMonitor) {
|
||||
if (fSessionType == SessionType.REMOTE || fAttach) {
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE || fMIBackend.getIsAttachSession()) {
|
||||
// These types do not use a PTY
|
||||
fPty = null;
|
||||
requestMonitor.done();
|
||||
|
@ -262,7 +245,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
|
||||
public boolean canRestart() {
|
||||
if (fAttach) return false;
|
||||
if (fMIBackend.getIsAttachSession()) return false;
|
||||
|
||||
// Before GDB6.8, the Linux gdbserver would restart a new
|
||||
// process when getting a -exec-run but the communication
|
||||
|
@ -270,7 +253,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
// with GDB6.8 the program restarts properly one time,
|
||||
// but on a second attempt, gdbserver crashes.
|
||||
// So, lets just turn off the Restart for Remote debugging
|
||||
if (fSessionType == SessionType.REMOTE) return false;
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -294,7 +277,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
* Insert breakpoint at entry if set, and start or restart the program.
|
||||
*/
|
||||
protected void startOrRestart(final GdbLaunch launch, boolean restart, final RequestMonitor requestMonitor) {
|
||||
if (fAttach) {
|
||||
if (fMIBackend.getIsAttachSession()) {
|
||||
// When attaching to a running process, we do not need to set a breakpoint or
|
||||
// start the program; it is left up to the user.
|
||||
requestMonitor.done();
|
||||
|
@ -308,7 +291,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
final IContainerDMContext containerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
||||
|
||||
final MICommand<MIInfo> execCommand;
|
||||
if (fSessionType == SessionType.REMOTE) {
|
||||
if (fMIBackend.getSessionType() == SessionType.REMOTE) {
|
||||
// When doing remote debugging, we use -exec-continue instead of -exec-run
|
||||
execCommand = new MIExecContinue(containerDmc);
|
||||
} else {
|
||||
|
@ -379,8 +362,6 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
return fInferiorProcess;
|
||||
}
|
||||
|
||||
public IPath getExecutablePath() { return fMIBackend.getProgramPath(); }
|
||||
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||
// Handle our "GDB Exited" event and stop processing commands.
|
||||
|
|
|
@ -45,8 +45,6 @@ class GDBInferiorProcess extends MIInferiorProcess {
|
|||
getSession().getExecutor().submit(new DsfRunnable() {
|
||||
public void run() {
|
||||
if (isDisposed() || !getSession().isActive()) return;
|
||||
IGDBControl gdb = (IGDBControl)getCommandControlService();
|
||||
if (gdb == null) return;
|
||||
|
||||
// An inferior will be destroy():interrupt and kill if
|
||||
// - For attach session:
|
||||
|
@ -55,7 +53,7 @@ class GDBInferiorProcess extends MIInferiorProcess {
|
|||
// if the inferior is still running.
|
||||
// - For PostMortem(Core): send event
|
||||
// else noop
|
||||
if (gdb.getIsAttachSession() == false) {
|
||||
if (fBackend.getIsAttachSession() == false) {
|
||||
// Try to interrupt the inferior, first.
|
||||
if (getState() == State.RUNNING) {
|
||||
fBackend.interrupt();
|
||||
|
|
|
@ -10,20 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.dd.gdb.internal.provisional.service.command;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.SessionType;
|
||||
import org.eclipse.dd.mi.service.command.AbstractCLIProcess;
|
||||
import org.eclipse.dd.mi.service.command.MIInferiorProcess;
|
||||
|
||||
public interface IGDBControl extends ICommandControlService {
|
||||
|
||||
SessionType getSessionType();
|
||||
|
||||
boolean getIsAttachSession();
|
||||
|
||||
void terminate(final RequestMonitor rm);
|
||||
void initInferiorInputOutput(final RequestMonitor requestMonitor);
|
||||
|
||||
|
@ -39,6 +33,4 @@ public interface IGDBControl extends ICommandControlService {
|
|||
AbstractCLIProcess getCLIProcess();
|
||||
|
||||
MIInferiorProcess getInferiorProcess();
|
||||
|
||||
IPath getExecutablePath();
|
||||
}
|
Loading…
Add table
Reference in a new issue