mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
[277752] Add multi-process support to ThreadFilter. Also, support the case of multiple launches.
This commit is contained in:
parent
7d74b57d78
commit
3cdfd7abfa
1 changed files with 40 additions and 47 deletions
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
@ -21,9 +22,9 @@ import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
|
@ -35,7 +36,7 @@ import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||||
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -57,7 +58,6 @@ import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
|
||||||
|
|
||||||
public class GdbThreadFilterEditor {
|
public class GdbThreadFilterEditor {
|
||||||
|
|
||||||
|
@ -147,13 +147,11 @@ public class GdbThreadFilterEditor {
|
||||||
if (parent instanceof ILaunchManager) {
|
if (parent instanceof ILaunchManager) {
|
||||||
List<Object> children = new ArrayList<Object>();
|
List<Object> children = new ArrayList<Object>();
|
||||||
ILaunch[] launches = ((ILaunchManager) parent).getLaunches();
|
ILaunch[] launches = ((ILaunchManager) parent).getLaunches();
|
||||||
IContainerDMContext target;
|
IContainerDMContext[] targetArray;
|
||||||
for (int i = 0; i < launches.length; i++) {
|
for (int i = 0; i < launches.length; i++) {
|
||||||
if (launches[i] instanceof GdbLaunch) {
|
if (launches[i] instanceof GdbLaunch) {
|
||||||
target = syncGetContainer((GdbLaunch) launches[i]);
|
targetArray = syncGetContainers((GdbLaunch) launches[i]);
|
||||||
if (target != null) {
|
children.addAll(Arrays.asList(targetArray));
|
||||||
children.add(target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return children.toArray();
|
return children.toArray();
|
||||||
|
@ -283,13 +281,11 @@ public class GdbThreadFilterEditor {
|
||||||
}
|
}
|
||||||
List<Object> targets = new ArrayList<Object>();
|
List<Object> targets = new ArrayList<Object>();
|
||||||
ILaunch[] launches = ((ILaunchManager) input).getLaunches();
|
ILaunch[] launches = ((ILaunchManager) input).getLaunches();
|
||||||
IContainerDMContext target;
|
IContainerDMContext[] targetArray;
|
||||||
for (int i = 0; i < launches.length; i++) {
|
for (int i = 0; i < launches.length; i++) {
|
||||||
if (launches[i] instanceof GdbLaunch) {
|
if (launches[i] instanceof GdbLaunch) {
|
||||||
target = syncGetContainer((GdbLaunch) launches[i]);
|
targetArray = syncGetContainers((GdbLaunch) launches[i]);
|
||||||
if (target != null) {
|
targets.addAll(Arrays.asList(targetArray));
|
||||||
targets.add(target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return targets.toArray(new IContainerDMContext[targets.size()]);
|
return targets.toArray(new IContainerDMContext[targets.size()]);
|
||||||
|
@ -366,39 +362,42 @@ public class GdbThreadFilterEditor {
|
||||||
return list.toArray(new IExecutionDMContext[list.size()]);
|
return list.toArray(new IExecutionDMContext[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IContainerDMContext syncGetContainer(final GdbLaunch launch) {
|
private IContainerDMContext[] syncGetContainers(final GdbLaunch launch) {
|
||||||
final DsfSession session = launch.getSession();
|
final DsfSession session = launch.getSession();
|
||||||
|
|
||||||
class ContainerQuery extends Query<IContainerDMContext> {
|
class ContainerQuery extends Query<IContainerDMContext[]> {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(DataRequestMonitor<IContainerDMContext> rm) {
|
protected void execute(final DataRequestMonitor<IContainerDMContext[]> rm) {
|
||||||
if (!session.isActive()) {
|
if (!session.isActive()) {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Launch's session not active.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Launch's session not active.")); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceTracker tracker1 = new ServiceTracker(GdbUIPlugin.getBundleContext(), ICommandControlService.class
|
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
.getName(), null);
|
ICommandControlService commandControl = tracker.getService(ICommandControlService.class);
|
||||||
tracker1.open();
|
IMIProcesses procService = tracker.getService(IMIProcesses.class);
|
||||||
|
|
||||||
ICommandControlService commandControl = (ICommandControlService) tracker1.getService();
|
|
||||||
ServiceTracker tracker2 = new ServiceTracker(GdbUIPlugin.getBundleContext(), IMIProcesses.class
|
|
||||||
.getName(), null);
|
|
||||||
tracker2.open();
|
|
||||||
IMIProcesses procService = (IMIProcesses) tracker2.getService();
|
|
||||||
|
|
||||||
if (commandControl != null && procService != null) {
|
if (commandControl != null && procService != null) {
|
||||||
IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
procService.getProcessesBeingDebugged(
|
||||||
IContainerDMContext containerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
commandControl.getContext(),
|
||||||
|
new DataRequestMonitor<IDMContext[]>(session.getExecutor(), rm) {
|
||||||
rm.setData(containerDmc);
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
if (getData() instanceof IContainerDMContext[]) {
|
||||||
|
IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData();
|
||||||
|
rm.setData(containerDmcs);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control or Process service not accessible.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wront type of container contexts.")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
tracker1.close();
|
}
|
||||||
tracker2.close();
|
});
|
||||||
|
} else {
|
||||||
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control or Process service not accessible.")); //$NON-NLS-1$
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
tracker.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,17 +427,15 @@ public class GdbThreadFilterEditor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceTracker tracker = new ServiceTracker(GdbUIPlugin.getBundleContext(), IRunControl.class
|
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
.getName(), null);
|
IRunControl runControl = tracker.getService(IRunControl.class);
|
||||||
tracker.open();
|
|
||||||
IRunControl runControl = (IRunControl) tracker.getService();
|
|
||||||
if (runControl != null) {
|
if (runControl != null) {
|
||||||
runControl.getExecutionContexts(container, rm);
|
runControl.getExecutionContexts(container, rm);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control not accessible.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control not accessible.")); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
tracker.close();
|
tracker.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,17 +465,15 @@ public class GdbThreadFilterEditor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceTracker tracker = new ServiceTracker(GdbUIPlugin.getBundleContext(), IGDBBackend.class
|
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
.getName(), null);
|
IGDBBackend backend = tracker.getService(IGDBBackend.class);
|
||||||
tracker.open();
|
|
||||||
IGDBBackend backend = (IGDBBackend) tracker.getService();
|
|
||||||
if (backend != null) {
|
if (backend != null) {
|
||||||
rm.setData(backend.getProgramPath().toOSString());
|
rm.setData(backend.getProgramPath().toOSString());
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Backend not accessible.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Backend not accessible.")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
tracker.close();
|
tracker.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,10 +503,8 @@ public class GdbThreadFilterEditor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceTracker tracker = new ServiceTracker(GdbUIPlugin.getBundleContext(), IProcesses.class
|
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||||
.getName(), null);
|
IProcesses procService = tracker.getService(IProcesses.class);
|
||||||
tracker.open();
|
|
||||||
IProcesses procService = (IProcesses) tracker.getService();
|
|
||||||
if (procService != null) {
|
if (procService != null) {
|
||||||
IThreadDMContext threadDmc = DMContexts.getAncestorOfType(thread, IThreadDMContext.class);
|
IThreadDMContext threadDmc = DMContexts.getAncestorOfType(thread, IThreadDMContext.class);
|
||||||
procService.getExecutionData(threadDmc, new DataRequestMonitor<IThreadDMData>(
|
procService.getExecutionData(threadDmc, new DataRequestMonitor<IThreadDMData>(
|
||||||
|
@ -532,7 +525,7 @@ public class GdbThreadFilterEditor {
|
||||||
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "IProcesses service not accessible.")); //$NON-NLS-1$
|
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "IProcesses service not accessible.")); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
tracker.close();
|
tracker.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue