mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 241423
Added a connect action to the debug view.
This commit is contained in:
parent
52be905ca0
commit
f1f4d7cb2a
13 changed files with 399 additions and 108 deletions
|
@ -30,6 +30,7 @@ Require-Bundle: org.eclipse.ui,
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package:
|
Export-Package:
|
||||||
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel,
|
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel,
|
||||||
|
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.actions,
|
||||||
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.expression,
|
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.expression,
|
||||||
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch,
|
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch,
|
||||||
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.modules,
|
org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.modules,
|
||||||
|
|
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/connect.gif
Executable file
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/obj16/connect.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 189 B |
15
plugins/org.eclipse.dd.gdb.ui/plugin.properties
Normal file
15
plugins/org.eclipse.dd.gdb.ui/plugin.properties
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
###############################################################################
|
||||||
|
# Copyright (c) 2008 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
|
||||||
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
#
|
||||||
|
# Contributors:
|
||||||
|
# Ericsson - initial API and implementation
|
||||||
|
###############################################################################
|
||||||
|
pluginName=Debug Services Framework GDB UI Plug-in
|
||||||
|
providerName=Eclipse.org
|
||||||
|
|
||||||
|
action.connect.label = Connect...
|
||||||
|
action.connect.tooltip = Connect to a process
|
|
@ -58,5 +58,37 @@
|
||||||
id="org.eclipse.dd.gdb.ui.GdbServerDebuggerPage">
|
id="org.eclipse.dd.gdb.ui.GdbServerDebuggerPage">
|
||||||
</debuggerPage>
|
</debuggerPage>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.popupMenus">
|
||||||
|
<viewerContribution
|
||||||
|
id="org.eclipse.dd.gdb.ui.debugview.context"
|
||||||
|
targetID="org.eclipse.debug.ui.DebugView">
|
||||||
|
<action
|
||||||
|
class="org.eclipse.dd.gdb.internal.ui.actions.ConnectActionDelegate"
|
||||||
|
enablesFor="9999"
|
||||||
|
icon="icons/full/obj16/connect.gif"
|
||||||
|
id="org.eclipse.dd.gdb.ui.connect"
|
||||||
|
label="%action.connect.label"
|
||||||
|
menubarPath="threadGroup"
|
||||||
|
tooltip="%action.connect.tooltip">
|
||||||
|
</action>
|
||||||
|
</viewerContribution>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.viewActions">
|
||||||
|
<viewContribution
|
||||||
|
id="org.eclipse.dd.gdb.ui.debugview.toolbar"
|
||||||
|
targetID="org.eclipse.debug.ui.DebugView">
|
||||||
|
<action
|
||||||
|
class="org.eclipse.dd.gdb.internal.ui.actions.ConnectActionDelegate"
|
||||||
|
enablesFor="9999"
|
||||||
|
icon="icons/full/obj16/connect.gif"
|
||||||
|
id="org.eclipse.dd.gdb.ui.connect"
|
||||||
|
label="%action.connect.label"
|
||||||
|
toolbarPath="threadGroup"
|
||||||
|
tooltip="%action.connect.tooltip">
|
||||||
|
</action>
|
||||||
|
</viewContribution>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -30,9 +30,11 @@ import org.eclipse.dd.dsf.debug.ui.actions.DsfSuspendCommand;
|
||||||
import org.eclipse.dd.dsf.debug.ui.contexts.DsfSuspendTrigger;
|
import org.eclipse.dd.dsf.debug.ui.contexts.DsfSuspendTrigger;
|
||||||
import org.eclipse.dd.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter;
|
import org.eclipse.dd.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunchDelegate;
|
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunchDelegate;
|
||||||
import org.eclipse.dd.gdb.internal.ui.actions.DsfTerminateCommand;
|
import org.eclipse.dd.gdb.internal.ui.actions.DsfTerminateCommand;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.actions.GdbConnectCommand;
|
||||||
import org.eclipse.dd.gdb.internal.ui.actions.GdbRestartCommand;
|
import org.eclipse.dd.gdb.internal.ui.actions.GdbRestartCommand;
|
||||||
import org.eclipse.dd.gdb.internal.ui.viewmodel.GdbViewModelAdapter;
|
import org.eclipse.dd.gdb.internal.ui.viewmodel.GdbViewModelAdapter;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
@ -76,6 +78,7 @@ public class GdbAdapterFactory
|
||||||
final DsfResumeCommand fResumeCommand;
|
final DsfResumeCommand fResumeCommand;
|
||||||
final GdbRestartCommand fRestartCommand;
|
final GdbRestartCommand fRestartCommand;
|
||||||
final DsfTerminateCommand fTerminateCommand;
|
final DsfTerminateCommand fTerminateCommand;
|
||||||
|
final GdbConnectCommand fConnectCommand;
|
||||||
final IDebugModelProvider fDebugModelProvider;
|
final IDebugModelProvider fDebugModelProvider;
|
||||||
final DsfSuspendTrigger fSuspendTrigger;
|
final DsfSuspendTrigger fSuspendTrigger;
|
||||||
final DsfSteppingModeTarget fSteppingModeTarget;
|
final DsfSteppingModeTarget fSteppingModeTarget;
|
||||||
|
@ -107,6 +110,7 @@ public class GdbAdapterFactory
|
||||||
fResumeCommand = new DsfResumeCommand(session);
|
fResumeCommand = new DsfResumeCommand(session);
|
||||||
fRestartCommand = new GdbRestartCommand(session, fLaunch);
|
fRestartCommand = new GdbRestartCommand(session, fLaunch);
|
||||||
fTerminateCommand = new DsfTerminateCommand(session);
|
fTerminateCommand = new DsfTerminateCommand(session);
|
||||||
|
fConnectCommand = new GdbConnectCommand(session);
|
||||||
fSuspendTrigger = new DsfSuspendTrigger(session, fLaunch);
|
fSuspendTrigger = new DsfSuspendTrigger(session, fLaunch);
|
||||||
fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
|
fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
|
||||||
|
|
||||||
|
@ -118,6 +122,7 @@ public class GdbAdapterFactory
|
||||||
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
||||||
session.registerModelAdapter(IRestart.class, fRestartCommand);
|
session.registerModelAdapter(IRestart.class, fRestartCommand);
|
||||||
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
||||||
|
session.registerModelAdapter(IConnect.class, fConnectCommand);
|
||||||
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
|
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
|
||||||
|
|
||||||
fDebugModelProvider = new IDebugModelProvider() {
|
fDebugModelProvider = new IDebugModelProvider() {
|
||||||
|
@ -155,6 +160,7 @@ public class GdbAdapterFactory
|
||||||
session.unregisterModelAdapter(IResumeHandler.class);
|
session.unregisterModelAdapter(IResumeHandler.class);
|
||||||
session.unregisterModelAdapter(IRestart.class);
|
session.unregisterModelAdapter(IRestart.class);
|
||||||
session.unregisterModelAdapter(ITerminateHandler.class);
|
session.unregisterModelAdapter(ITerminateHandler.class);
|
||||||
|
session.unregisterModelAdapter(IConnect.class);
|
||||||
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
|
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
|
||||||
|
|
||||||
fStepIntoCommand.dispose();
|
fStepIntoCommand.dispose();
|
||||||
|
@ -164,6 +170,7 @@ public class GdbAdapterFactory
|
||||||
fResumeCommand.dispose();
|
fResumeCommand.dispose();
|
||||||
fRestartCommand.dispose();
|
fRestartCommand.dispose();
|
||||||
fTerminateCommand.dispose();
|
fTerminateCommand.dispose();
|
||||||
|
fConnectCommand.dispose();
|
||||||
fSuspendTrigger.dispose();
|
fSuspendTrigger.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.actions.AbstractVMProviderActionDelegate;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||||
|
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IViewPart;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action to trigger a prompt for a process to attach to
|
||||||
|
*/
|
||||||
|
public class ConnectActionDelegate extends AbstractVMProviderActionDelegate {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void run(IAction action) {
|
||||||
|
if (action.isEnabled()) {
|
||||||
|
// disable the action so it cannot be run again until an event or
|
||||||
|
// selection change updates the enablement
|
||||||
|
action.setEnabled(false);
|
||||||
|
|
||||||
|
final IConnect connectCommand = getConnectCommand();
|
||||||
|
if (connectCommand != null) {
|
||||||
|
connectCommand.connect(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(IViewPart view) {
|
||||||
|
super.init(view);
|
||||||
|
updateEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debugContextChanged(DebugContextEvent event) {
|
||||||
|
super.debugContextChanged(event);
|
||||||
|
updateEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
super.selectionChanged(action, selection);
|
||||||
|
updateEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEnablement() {
|
||||||
|
boolean enabled = false;
|
||||||
|
final IConnect connectCommand = getConnectCommand();
|
||||||
|
if (connectCommand != null) {
|
||||||
|
enabled = connectCommand.canConnect();
|
||||||
|
}
|
||||||
|
getAction().setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IConnect getConnectCommand() {
|
||||||
|
IConnect command = null;
|
||||||
|
Object element = getViewerInput();
|
||||||
|
if (element instanceof IDMVMContext) {
|
||||||
|
IDMVMContext dmc = (IDMVMContext)element;
|
||||||
|
command = (IConnect)dmc.getAdapter(IConnect.class);
|
||||||
|
} else if (element instanceof GdbLaunch) {
|
||||||
|
GdbLaunch launch = (GdbLaunch)element;
|
||||||
|
command = (IConnect)launch.getSession().getModelAdapter(IConnect.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.IProcessInfo;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.CountingRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Query;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IProcesses;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.dd.mi.service.MIProcesses;
|
||||||
|
import org.eclipse.dd.mi.service.ProcessInfo;
|
||||||
|
import org.eclipse.dd.mi.service.command.AbstractMIControl;
|
||||||
|
import org.eclipse.dd.mi.service.command.MIControlDMContext;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
|
|
||||||
|
public class GdbConnectCommand implements IConnect {
|
||||||
|
|
||||||
|
private final DsfExecutor fExecutor;
|
||||||
|
private final DsfServicesTracker fTracker;
|
||||||
|
|
||||||
|
public GdbConnectCommand(DsfSession session) {
|
||||||
|
fExecutor = session.getExecutor();
|
||||||
|
fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
fTracker.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canConnect() {
|
||||||
|
Query<Boolean> canConnectQuery = new Query<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void execute(DataRequestMonitor<Boolean> rm) {
|
||||||
|
IProcesses procService = fTracker.getService(IProcesses.class);
|
||||||
|
AbstractMIControl miControl = fTracker.getService(AbstractMIControl.class);
|
||||||
|
|
||||||
|
if (procService != null && miControl != null) {
|
||||||
|
procService.isDebuggerAttachSupported(miControl.getControlDMContext(), rm);
|
||||||
|
} else {
|
||||||
|
rm.setData(false);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fExecutor.execute(canConnectQuery);
|
||||||
|
try {
|
||||||
|
return canConnectQuery.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need a job because prompter.handleStatus will block
|
||||||
|
class PromptForPidJob extends Job {
|
||||||
|
|
||||||
|
// The list of processes used in the case of an ATTACH session
|
||||||
|
IProcessInfo[] fProcessList = null;
|
||||||
|
DataRequestMonitor<Integer> fRequestMonitor;
|
||||||
|
|
||||||
|
public PromptForPidJob(String name, IProcessInfo[] procs, DataRequestMonitor<Integer> rm) {
|
||||||
|
super(name);
|
||||||
|
fProcessList = procs;
|
||||||
|
fRequestMonitor = rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200/*STATUS_HANDLER_PROMPT*/, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
final IStatus processPromptStatus = new Status(IStatus.INFO, "org.eclipse.dd.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
|
final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
|
||||||
|
|
||||||
|
final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, -1,
|
||||||
|
LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$
|
||||||
|
null);
|
||||||
|
|
||||||
|
if (prompter == null) {
|
||||||
|
fRequestMonitor.setStatus(NO_PID_STATUS);
|
||||||
|
fRequestMonitor.done();
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object result = prompter.handleStatus(processPromptStatus, fProcessList);
|
||||||
|
if (result instanceof Integer) {
|
||||||
|
fRequestMonitor.setData((Integer)result);
|
||||||
|
} else {
|
||||||
|
fRequestMonitor.setStatus(NO_PID_STATUS);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
fRequestMonitor.setStatus(NO_PID_STATUS);
|
||||||
|
}
|
||||||
|
fRequestMonitor.done();
|
||||||
|
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void connect(RequestMonitor requestMonitor)
|
||||||
|
{
|
||||||
|
// Create a fake rm to avoid null pointer exceptions
|
||||||
|
final RequestMonitor rm;
|
||||||
|
if (requestMonitor == null) {
|
||||||
|
rm = new RequestMonitor(fExecutor, null);
|
||||||
|
} else {
|
||||||
|
rm = requestMonitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't wait for the operation to finish because this
|
||||||
|
// method can be called from the UI thread, and it will
|
||||||
|
// block it, which is bad, because we need to use the UI
|
||||||
|
// thread to prompt the user for the process to choose.
|
||||||
|
// This is why we simply use a DsfRunnable.
|
||||||
|
fExecutor.execute(new DsfRunnable() {
|
||||||
|
public void run() {
|
||||||
|
final IProcesses procService = fTracker.getService(IProcesses.class);
|
||||||
|
AbstractMIControl miControl = fTracker.getService(AbstractMIControl.class);
|
||||||
|
final MIControlDMContext controlCtx = miControl.getControlDMContext();
|
||||||
|
|
||||||
|
if (procService != null && miControl != null) {
|
||||||
|
procService.getRunningProcesses(
|
||||||
|
controlCtx,
|
||||||
|
new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
|
||||||
|
final List<IProcessInfo> procInfoList = new ArrayList<IProcessInfo>();
|
||||||
|
|
||||||
|
// For each process, obtain its name
|
||||||
|
// Once all the names are obtained, prompt the user for the pid to use
|
||||||
|
final CountingRequestMonitor countingRm =
|
||||||
|
new CountingRequestMonitor(fExecutor, rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
new PromptForPidJob(
|
||||||
|
"Prompt for Process", procInfoList.toArray(new IProcessInfo[0]), //$NON-NLS-1$
|
||||||
|
new DataRequestMonitor<Integer>(fExecutor, rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
// New cycle, look for service again
|
||||||
|
final MIProcesses procService = fTracker.getService(MIProcesses.class);
|
||||||
|
if (procService != null) {
|
||||||
|
IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
|
||||||
|
Integer.toString(getData()));
|
||||||
|
procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).schedule();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// New cycle, look for service again
|
||||||
|
final IProcesses procService = fTracker.getService(IProcesses.class);
|
||||||
|
|
||||||
|
if (procService != null) {
|
||||||
|
countingRm.setDoneCount(getData().length);
|
||||||
|
|
||||||
|
for (IProcessDMContext processCtx : getData()) {
|
||||||
|
procService.getExecutionData(
|
||||||
|
processCtx,
|
||||||
|
new DataRequestMonitor<IThreadDMData> (fExecutor, countingRm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
int pid = 0;
|
||||||
|
try {
|
||||||
|
pid = Integer.parseInt(getData().getId());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
procInfoList.add(new ProcessInfo(pid, getData().getName()));
|
||||||
|
countingRm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
countingRm.setDoneCount(1);
|
||||||
|
countingRm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Export-Package: org.eclipse.dd.gdb.internal.provisional,
|
Export-Package: org.eclipse.dd.gdb.internal.provisional,
|
||||||
|
org.eclipse.dd.gdb.internal.provisional.actions,
|
||||||
org.eclipse.dd.gdb.internal.provisional.breakpoints,
|
org.eclipse.dd.gdb.internal.provisional.breakpoints,
|
||||||
org.eclipse.dd.gdb.internal.provisional.launching,
|
org.eclipse.dd.gdb.internal.provisional.launching,
|
||||||
org.eclipse.dd.gdb.internal.provisional.service,
|
org.eclipse.dd.gdb.internal.provisional.service,
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.provisional.actions;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
|
||||||
|
public interface IConnect {
|
||||||
|
/**
|
||||||
|
* Returns whether this element can currently attempt to
|
||||||
|
* connect to a new process.
|
||||||
|
*/
|
||||||
|
public boolean canConnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes this element to attempt to connect to a new process.
|
||||||
|
*/
|
||||||
|
public void connect(RequestMonitor rm);
|
||||||
|
}
|
|
@ -15,7 +15,6 @@ import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IProcessInfo;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
||||||
|
@ -25,29 +24,24 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.core.variables.VariablesPlugin;
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
import org.eclipse.dd.dsf.concurrent.CountingRequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.dd.dsf.concurrent.Sequence;
|
import org.eclipse.dd.dsf.concurrent.Sequence;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
|
|
||||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
|
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.actions.IConnect;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.GDBProcesses;
|
import org.eclipse.dd.gdb.internal.provisional.service.GDBProcesses;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.dd.mi.service.CSourceLookup;
|
import org.eclipse.dd.mi.service.CSourceLookup;
|
||||||
import org.eclipse.dd.mi.service.MIBreakpointsManager;
|
import org.eclipse.dd.mi.service.MIBreakpointsManager;
|
||||||
import org.eclipse.dd.mi.service.ProcessInfo;
|
|
||||||
import org.eclipse.dd.mi.service.command.commands.CLISource;
|
import org.eclipse.dd.mi.service.command.commands.CLISource;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MIEnvironmentCD;
|
import org.eclipse.dd.mi.service.command.commands.MIEnvironmentCD;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MIFileExecAndSymbols;
|
import org.eclipse.dd.mi.service.command.commands.MIFileExecAndSymbols;
|
||||||
|
@ -59,8 +53,6 @@ import org.eclipse.dd.mi.service.command.commands.MIGDBSetSysroot;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MITargetSelect;
|
import org.eclipse.dd.mi.service.command.commands.MITargetSelect;
|
||||||
import org.eclipse.dd.mi.service.command.commands.RawCommand;
|
import org.eclipse.dd.mi.service.command.commands.RawCommand;
|
||||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.IStatusHandler;
|
|
||||||
|
|
||||||
public class FinalLaunchSequence extends Sequence {
|
public class FinalLaunchSequence extends Sequence {
|
||||||
|
|
||||||
|
@ -406,54 +398,6 @@ public class FinalLaunchSequence extends Sequence {
|
||||||
* If attach session, perform the attach.
|
* If attach session, perform the attach.
|
||||||
*/
|
*/
|
||||||
new Step() {
|
new Step() {
|
||||||
|
|
||||||
// Need a job because prompter.handleStatus will block
|
|
||||||
class PromptForPidJob extends Job {
|
|
||||||
|
|
||||||
// The list of processes used in the case of an ATTACH session
|
|
||||||
IProcessInfo[] fProcessList = null;
|
|
||||||
DataRequestMonitor<IProcessDMContext> fRequestMonitor;
|
|
||||||
|
|
||||||
public PromptForPidJob(String name, IProcessInfo[] procs, DataRequestMonitor<IProcessDMContext> rm) {
|
|
||||||
super(name);
|
|
||||||
fProcessList = procs;
|
|
||||||
fRequestMonitor = rm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200/*STATUS_HANDLER_PROMPT*/, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
final IStatus processPromptStatus = new Status(IStatus.INFO, "org.eclipse.dd.gdb.ui", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
|
|
||||||
final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
|
|
||||||
|
|
||||||
final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1,
|
|
||||||
LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$
|
|
||||||
null);
|
|
||||||
|
|
||||||
if (prompter == null) {
|
|
||||||
fRequestMonitor.setStatus(NO_PID_STATUS);
|
|
||||||
fRequestMonitor.done();
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Object result = prompter.handleStatus(processPromptStatus, fProcessList);
|
|
||||||
if (result instanceof Integer) {
|
|
||||||
fRequestMonitor.setData(fProcService.createProcessContext(fCommandControl.getGDBDMContext(),
|
|
||||||
Integer.toString((Integer)result)));
|
|
||||||
} else {
|
|
||||||
fRequestMonitor.setStatus(NO_PID_STATUS);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
fRequestMonitor.setStatus(NO_PID_STATUS);
|
|
||||||
}
|
|
||||||
fRequestMonitor.done();
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
if (fAttach) {
|
if (fAttach) {
|
||||||
|
@ -471,53 +415,12 @@ public class FinalLaunchSequence extends Sequence {
|
||||||
fProcService.createProcessContext(fCommandControl.getGDBDMContext(), Integer.toString(pid)),
|
fProcService.createProcessContext(fCommandControl.getGDBDMContext(), Integer.toString(pid)),
|
||||||
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
|
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
|
||||||
} else {
|
} else {
|
||||||
fProcService.getRunningProcesses(
|
IConnect connectCommand = (IConnect)fLaunch.getSession().getModelAdapter(IConnect.class);
|
||||||
fCommandControl.getGDBDMContext(),
|
if (connectCommand != null) {
|
||||||
new DataRequestMonitor<IProcessDMContext[]>(getExecutor(), requestMonitor) {
|
connectCommand.connect(requestMonitor);
|
||||||
@Override
|
} else {
|
||||||
protected void handleSuccess() {
|
requestMonitor.done();
|
||||||
|
|
||||||
final List<IProcessInfo> procInfoList = new ArrayList<IProcessInfo>();
|
|
||||||
|
|
||||||
// For each process, obtain its name
|
|
||||||
// Once all the names are obtained, prompt the user the pid to use
|
|
||||||
final CountingRequestMonitor countingRm =
|
|
||||||
new CountingRequestMonitor(getExecutor(), requestMonitor) {
|
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
new PromptForPidJob(
|
|
||||||
"Prompt for Process", procInfoList.toArray(new IProcessInfo[0]), //$NON-NLS-1$
|
|
||||||
new DataRequestMonitor<IProcessDMContext>(getExecutor(), requestMonitor) {
|
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
fProcService.attachDebuggerToProcess(
|
|
||||||
getData(),
|
|
||||||
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
|
|
||||||
}
|
}
|
||||||
}).schedule();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
countingRm.setDoneCount(getData().length);
|
|
||||||
|
|
||||||
for (IProcessDMContext processCtx : getData()) {
|
|
||||||
fProcService.getExecutionData(
|
|
||||||
processCtx,
|
|
||||||
new DataRequestMonitor<IThreadDMData> (getExecutor(), countingRm) {
|
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
int pid = 0;
|
|
||||||
try {
|
|
||||||
pid = Integer.parseInt(getData().getId());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
procInfoList.add(new ProcessInfo(pid, getData().getName()));
|
|
||||||
countingRm.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
|
|
|
@ -117,6 +117,12 @@ public class GDBProcesses extends MIProcesses {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||||
|
rm.setData(!fGdb.isConnected());
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getProcessesBeingDebugged(IDMContext dmc, DataRequestMonitor<IDMContext[]> rm) {
|
public void getProcessesBeingDebugged(IDMContext dmc, DataRequestMonitor<IDMContext[]> rm) {
|
||||||
MIInferiorProcess inferiorProcess = fGdb.getInferiorProcess();
|
MIInferiorProcess inferiorProcess = fGdb.getInferiorProcess();
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class GDBControl extends AbstractMIControl {
|
||||||
|
|
||||||
public boolean fAttach;
|
public boolean fAttach;
|
||||||
|
|
||||||
private boolean fConnected = false;
|
private boolean fConnected = true;
|
||||||
|
|
||||||
private MonitorJob fMonitorJob;
|
private MonitorJob fMonitorJob;
|
||||||
private IPath fGdbPath;
|
private IPath fGdbPath;
|
||||||
|
|
|
@ -356,7 +356,7 @@ public class MIProcesses extends AbstractDsfService implements IProcesses {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm) {
|
||||||
rm.setData(true);
|
rm.setData(false);
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue