|
Lines 11-16
Link Here
|
| 11 |
package org.eclipse.cdt.dsf.gdb.internal.ui.actions; |
11 |
package org.eclipse.cdt.dsf.gdb.internal.ui.actions; |
| 12 |
|
12 |
|
| 13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
|
|
14 |
import java.util.HashMap; |
| 14 |
import java.util.List; |
15 |
import java.util.List; |
| 15 |
import java.util.concurrent.ExecutionException; |
16 |
import java.util.concurrent.ExecutionException; |
| 16 |
import java.util.concurrent.RejectedExecutionException; |
17 |
import java.util.concurrent.RejectedExecutionException; |
|
Lines 19-24
Link Here
|
| 19 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
20 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
| 20 |
import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
21 |
import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
| 21 |
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
22 |
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
|
|
23 |
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; |
| 22 |
import org.eclipse.cdt.dsf.concurrent.Query; |
24 |
import org.eclipse.cdt.dsf.concurrent.Query; |
| 23 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
25 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
| 24 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
26 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
|
Lines 29-34
Link Here
|
| 29 |
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; |
31 |
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; |
| 30 |
import org.eclipse.cdt.dsf.gdb.actions.IConnect; |
32 |
import org.eclipse.cdt.dsf.gdb.actions.IConnect; |
| 31 |
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; |
33 |
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; |
|
|
34 |
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo; |
| 32 |
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo; |
35 |
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo; |
| 33 |
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages; |
36 |
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages; |
| 34 |
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; |
37 |
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; |
|
Lines 85-98
Link Here
|
| 85 |
} |
88 |
} |
| 86 |
|
89 |
|
| 87 |
// Need a job because prompter.handleStatus will block |
90 |
// Need a job because prompter.handleStatus will block |
| 88 |
class PromptForPidJob extends Job { |
91 |
protected class PromptForPidJob extends Job { |
| 89 |
|
92 |
|
| 90 |
// The list of processes used in the case of an ATTACH session |
93 |
// The list of processes used in the case of an ATTACH session |
| 91 |
IProcessExtendedInfo[] fProcessList = null; |
94 |
IProcessExtendedInfo[] fProcessList = null; |
| 92 |
DataRequestMonitor<Integer> fRequestMonitor; |
95 |
DataRequestMonitor<Object> fRequestMonitor; |
|
|
96 |
boolean fNewProcessSupported; |
| 93 |
|
97 |
|
| 94 |
public PromptForPidJob(String name, IProcessExtendedInfo[] procs, DataRequestMonitor<Integer> rm) { |
98 |
public PromptForPidJob(String name, boolean newProcessSupported, IProcessExtendedInfo[] procs, DataRequestMonitor<Object> rm) { |
| 95 |
super(name); |
99 |
super(name); |
|
|
100 |
fNewProcessSupported = newProcessSupported; |
| 96 |
fProcessList = procs; |
101 |
fProcessList = procs; |
| 97 |
fRequestMonitor = rm; |
102 |
fRequestMonitor = rm; |
| 98 |
} |
103 |
} |
|
Lines 115-124
Link Here
|
| 115 |
} |
120 |
} |
| 116 |
|
121 |
|
| 117 |
try { |
122 |
try { |
| 118 |
Object result = prompter.handleStatus(processPromptStatus, fProcessList); |
123 |
PrompterInfo info = new PrompterInfo(fNewProcessSupported, fProcessList); |
| 119 |
if (result instanceof Integer) { |
124 |
Object result = prompter.handleStatus(processPromptStatus, info); |
| 120 |
fRequestMonitor.setData((Integer)result); |
125 |
if (result instanceof Integer || result instanceof String) { |
| 121 |
} else { |
126 |
fRequestMonitor.setData(result); |
|
|
127 |
} else { |
| 122 |
fRequestMonitor.setStatus(NO_PID_STATUS); |
128 |
fRequestMonitor.setStatus(NO_PID_STATUS); |
| 123 |
} |
129 |
} |
| 124 |
} catch (CoreException e) { |
130 |
} catch (CoreException e) { |
|
Lines 151-157
Link Here
|
| 151 |
ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); |
157 |
ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); |
| 152 |
|
158 |
|
| 153 |
if (procService != null && commandControl != null) { |
159 |
if (procService != null && commandControl != null) { |
| 154 |
final ICommandControlDMContext controlCtx = commandControl.getContext(); |
160 |
final ICommandControlDMContext controlCtx = commandControl.getContext(); |
|
|
161 |
procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, null) { |
| 162 |
@Override |
| 163 |
protected void handleCompleted() { |
| 164 |
final boolean newProcessSupported = isSuccess() && getData(); |
| 165 |
|
| 155 |
procService.getRunningProcesses( |
166 |
procService.getRunningProcesses( |
| 156 |
controlCtx, |
167 |
controlCtx, |
| 157 |
new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) { |
168 |
new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) { |
|
Lines 165-180
Link Here
|
| 165 |
@Override |
176 |
@Override |
| 166 |
protected void handleSuccess() { |
177 |
protected void handleSuccess() { |
| 167 |
new PromptForPidJob( |
178 |
new PromptForPidJob( |
| 168 |
"Prompt for Process", procInfoList.toArray(new IProcessExtendedInfo[0]), //$NON-NLS-1$ |
179 |
"Prompt for Process", newProcessSupported, procInfoList.toArray(new IProcessExtendedInfo[0]), //$NON-NLS-1$ |
| 169 |
new DataRequestMonitor<Integer>(fExecutor, rm) { |
180 |
new DataRequestMonitor<Object>(fExecutor, rm) { |
| 170 |
@Override |
181 |
@Override |
| 171 |
protected void handleSuccess() { |
182 |
protected void handleSuccess() { |
| 172 |
// New cycle, look for service again |
183 |
// New cycle, look for service again |
| 173 |
final IMIProcesses procService = fTracker.getService(IMIProcesses.class); |
184 |
final IMIProcesses procService = fTracker.getService(IMIProcesses.class); |
| 174 |
if (procService != null) { |
185 |
if (procService != null) { |
| 175 |
IProcessDMContext procDmc = procService.createProcessContext(controlCtx, |
186 |
Object data = getData(); |
| 176 |
Integer.toString(getData())); |
187 |
if (data instanceof String) { |
| 177 |
procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm)); |
188 |
// User wants to start a new process |
|
|
189 |
String binaryPath = (String)data; |
| 190 |
procService.debugNewProcess( |
| 191 |
controlCtx, binaryPath, |
| 192 |
// khouzam, maybe we should at least pass stopOnMain? |
| 193 |
new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm)); |
| 194 |
} else if (data instanceof Integer) { |
| 195 |
IProcessDMContext procDmc = procService.createProcessContext(controlCtx, |
| 196 |
Integer.toString((Integer)getData())); |
| 197 |
procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm)); |
| 198 |
} else { |
| 199 |
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$ |
| 200 |
rm.done(); |
| 201 |
} |
| 178 |
} |
202 |
} |
| 179 |
} |
203 |
} |
| 180 |
}).schedule(); |
204 |
}).schedule(); |
|
Lines 246-251
Link Here
|
| 246 |
} |
270 |
} |
| 247 |
} |
271 |
} |
| 248 |
}); |
272 |
}); |
|
|
273 |
} |
| 274 |
}); |
| 249 |
} else { |
275 |
} else { |
| 250 |
rm.done(); |
276 |
rm.done(); |
| 251 |
} |
277 |
} |