|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 TUBITAK-UEKAE-BTE and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* TUBITAK-UEKAE-BTE - GDB_7_1 support |
| 10 |
*******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.cdt.dsf.gdb.service; |
| 13 |
|
| 14 |
import java.util.Hashtable; |
| 15 |
import java.util.Map; |
| 16 |
|
| 17 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
| 18 |
import org.eclipse.cdt.dsf.datamodel.DMContexts; |
| 19 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
| 20 |
import org.eclipse.cdt.dsf.debug.service.IProcesses; |
| 21 |
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; |
| 22 |
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; |
| 23 |
import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext; |
| 24 |
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; |
| 25 |
import org.eclipse.cdt.dsf.mi.service.IMIProcesses; |
| 26 |
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoInferiorsInfo; |
| 27 |
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; |
| 28 |
import org.eclipse.cdt.dsf.mi.service.command.output.MIListThreadGroupsInfo; |
| 29 |
import org.eclipse.cdt.dsf.service.DsfSession; |
| 30 |
import org.eclipse.core.runtime.IStatus; |
| 31 |
import org.eclipse.core.runtime.Status; |
| 32 |
|
| 33 |
public class GDBProcesses_7_1 extends GDBProcesses_7_0 { |
| 34 |
|
| 35 |
public GDBProcesses_7_1(DsfSession session) { |
| 36 |
super(session); |
| 37 |
// TODO Auto-generated constructor stub |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
@Override |
| 42 |
protected void registerProcService() { |
| 43 |
register(new String[] { IProcesses.class.getName(), |
| 44 |
IMIProcesses.class.getName(), |
| 45 |
IGDBProcesses.class.getName(), |
| 46 |
GDBProcesses_7_1.class.getName() }, |
| 47 |
new Hashtable<String, String>()); |
| 48 |
} |
| 49 |
|
| 50 |
public boolean doIsRunNewProcessSupported() { |
| 51 |
return true; |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public void isRunNewProcessSupported(IDMContext dmc, |
| 56 |
DataRequestMonitor<Boolean> rm) { |
| 57 |
rm.setData(true); |
| 58 |
rm.done(); |
| 59 |
} |
| 60 |
|
| 61 |
@Override |
| 62 |
public void runNewProcess(IDMContext dmc, String file, |
| 63 |
Map<String, Object> attributes, |
| 64 |
DataRequestMonitor<IProcessDMContext> rm) { |
| 65 |
final DataRequestMonitor<IProcessDMContext> requestMonitor = rm; |
| 66 |
|
| 67 |
if (dmc instanceof GDBControlDMContext) { |
| 68 |
|
| 69 |
if ( !doIsRunNewProcessSupported() ) { |
| 70 |
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Multi-process debug not supported.", null)); //$NON-NLS-1$ |
| 71 |
requestMonitor.done(); |
| 72 |
return; |
| 73 |
} |
| 74 |
|
| 75 |
final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); |
| 76 |
fCommandControl.queueCommand( |
| 77 |
fCommandFactory.createCLIAddInferior( controlDmc ), |
| 78 |
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) { |
| 79 |
@Override |
| 80 |
protected void handleSuccess() { |
| 81 |
IMIProcesses procService = getServicesTracker().getService(IMIProcesses.class); |
| 82 |
if (procService != null) { |
| 83 |
IProcessDMContext procDmc = procService.createProcessContext(controlDmc, null); |
| 84 |
IMIContainerDMContext containerDmc = createContainerContext(procDmc, null); |
| 85 |
getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties()); |
| 86 |
requestMonitor.setData(procDmc); |
| 87 |
} |
| 88 |
|
| 89 |
requestMonitor.done(); |
| 90 |
} |
| 91 |
}); |
| 92 |
|
| 93 |
} else { |
| 94 |
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$ |
| 95 |
requestMonitor.done(); |
| 96 |
} |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
/* |
| 101 |
* Selects active inferior |
| 102 |
* Every process has an address space . Besides one address space may have multiple processes |
| 103 |
* This is not supported now!!! |
| 104 |
*/ |
| 105 |
public void selectActiveInferior(IDMContext dmc, int inferiorNo , |
| 106 |
DataRequestMonitor<IProcessDMContext> rm) { |
| 107 |
final DataRequestMonitor<IProcessDMContext> requestMonitor = rm; |
| 108 |
|
| 109 |
if (dmc instanceof GDBControlDMContext) { |
| 110 |
|
| 111 |
if ( !doIsRunNewProcessSupported() ) { |
| 112 |
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Multi-process debug not supported.", null)); //$NON-NLS-1$ |
| 113 |
requestMonitor.done(); |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); |
| 118 |
fCommandControl.queueCommand( |
| 119 |
fCommandFactory.createCLISelectInferior( controlDmc , inferiorNo ), |
| 120 |
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) { |
| 121 |
@Override |
| 122 |
protected void handleSuccess() { |
| 123 |
System.out.println("Active inferior changed"); |
| 124 |
requestMonitor.done(); |
| 125 |
} |
| 126 |
}); |
| 127 |
|
| 128 |
} else { |
| 129 |
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$ |
| 130 |
requestMonitor.done(); |
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
@Override |
| 136 |
public void getProcessesBeingDebugged(final IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) { |
| 137 |
final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); |
| 138 |
final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class); |
| 139 |
if (containerDmc != null) { |
| 140 |
fThreadCommandCache.execute( |
| 141 |
fCommandFactory.createMIListThreadGroups(controlDmc, containerDmc.getGroupId()), |
| 142 |
new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), rm) { |
| 143 |
@Override |
| 144 |
protected void handleSuccess() { |
| 145 |
rm.setData(makeExecutionDMCs(containerDmc, getData().getThreadInfo().getThreadList())); |
| 146 |
rm.done(); |
| 147 |
} |
| 148 |
}); |
| 149 |
} else { |
| 150 |
fContainerCommandCache.execute( |
| 151 |
fCommandFactory.createCLIInfoInferiors(controlDmc,null), |
| 152 |
new DataRequestMonitor<CLIInfoInferiorsInfo>(getExecutor(), rm) { |
| 153 |
@Override |
| 154 |
protected void handleSuccess() { |
| 155 |
rm.setData(makeContainerDMCs(controlDmc, getData().getGroupList())); |
| 156 |
rm.done(); |
| 157 |
} |
| 158 |
@Override |
| 159 |
protected void handleFailure() { |
| 160 |
// If the target is not available, generate the list ourselves |
| 161 |
IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fDebuggedProcessesAndNames.size()]; |
| 162 |
int i = 0; |
| 163 |
for (String groupId : fDebuggedProcessesAndNames.keySet()) { |
| 164 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
| 165 |
containerDmcs[i++] = createContainerContext(processDmc, groupId); |
| 166 |
} |
| 167 |
rm.setData(containerDmcs); |
| 168 |
rm.done(); |
| 169 |
} |
| 170 |
}); |
| 171 |
} |
| 172 |
} |
| 173 |
} |