mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 239050 I was finally able to get the cache working for the MIProcesses service. And for both non-stop and all-stop mode.
Basically, the cache of this service is used for container-level commands; therefore it should only be made unavailable/available on Container events. In all-stop we issue container events, but not in non-stop. So, everything works. Furthermore, I only clear the cache when threads start and exit.
This commit is contained in:
parent
5f3384b6fe
commit
6497fcf2f7
2 changed files with 72 additions and 44 deletions
|
@ -20,12 +20,13 @@ import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
||||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerResumedDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExitedDMEvent;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExitedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IStartedDMEvent;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IStartedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
|
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
|
||||||
import org.eclipse.dd.dsf.service.AbstractDsfService;
|
import org.eclipse.dd.dsf.service.AbstractDsfService;
|
||||||
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
||||||
|
@ -296,7 +297,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractMIControl fCommandControl;
|
private AbstractMIControl fCommandControl;
|
||||||
private CommandCache fCommandCache;
|
private CommandCache fContainerCommandCache;
|
||||||
|
|
||||||
private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
|
private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
|
||||||
private static final String UNIQUE_GROUP_ID = "0"; //$NON-NLS-1$
|
private static final String UNIQUE_GROUP_ID = "0"; //$NON-NLS-1$
|
||||||
|
@ -337,8 +338,8 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
// new Hashtable<String, String>());
|
// new Hashtable<String, String>());
|
||||||
|
|
||||||
fCommandControl = getServicesTracker().getService(AbstractMIControl.class);
|
fCommandControl = getServicesTracker().getService(AbstractMIControl.class);
|
||||||
fCommandCache = new CommandCache(getSession(), fCommandControl);
|
fContainerCommandCache = new CommandCache(getSession(), fCommandControl);
|
||||||
fCommandCache.setContextAvailable(fCommandControl.getControlDMContext(), true);
|
fContainerCommandCache.setContextAvailable(fCommandControl.getControlDMContext(), true);
|
||||||
getSession().addServiceEventListener(this, null);
|
getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
|
@ -413,7 +414,13 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
final MIThreadDMC threadDmc = (MIThreadDMC)dmc;
|
final MIThreadDMC threadDmc = (MIThreadDMC)dmc;
|
||||||
|
|
||||||
IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, IProcessDMContext.class);
|
IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, IProcessDMContext.class);
|
||||||
fCommandCache.execute(new CLIInfoThreads(procDmc),
|
getDebuggingContext(procDmc,
|
||||||
|
new DataRequestMonitor<IDMContext>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
if (getData() instanceof IMIExecutionGroupDMContext) {
|
||||||
|
IMIExecutionGroupDMContext contDmc = (IMIExecutionGroupDMContext)getData();
|
||||||
|
fContainerCommandCache.execute(new CLIInfoThreads(contDmc),
|
||||||
new DataRequestMonitor<CLIInfoThreadsInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<CLIInfoThreadsInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
|
@ -433,10 +440,23 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void getDebuggingContext(IThreadDMContext dmc, DataRequestMonitor<IDMContext> rm) {
|
public void getDebuggingContext(IThreadDMContext dmc, DataRequestMonitor<IDMContext> rm) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID,
|
if (dmc instanceof MIProcessDMC) {
|
||||||
NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
MIProcessDMC procDmc = (MIProcessDMC)dmc;
|
||||||
|
rm.setData(createExecutionGroupContext(procDmc, procDmc.getProcId()));
|
||||||
|
} else if (dmc instanceof MIThreadDMC) {
|
||||||
|
MIThreadDMC threadDmc = (MIThreadDMC)dmc;
|
||||||
|
IMIProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, IMIProcessDMContext.class);
|
||||||
|
IMIExecutionGroupDMContext groupDmc = createExecutionGroupContext(procDmc, procDmc.getProcId());
|
||||||
|
rm.setData(createExecutionContext(groupDmc, threadDmc, threadDmc.getId()));
|
||||||
|
} else {
|
||||||
|
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid thread context.", null)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +538,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
public void getProcessesBeingDebugged(IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) {
|
public void getProcessesBeingDebugged(IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) {
|
||||||
final IMIExecutionGroupDMContext groupDmc = DMContexts.getAncestorOfType(dmc, IMIExecutionGroupDMContext.class);
|
final IMIExecutionGroupDMContext groupDmc = DMContexts.getAncestorOfType(dmc, IMIExecutionGroupDMContext.class);
|
||||||
if (groupDmc != null) {
|
if (groupDmc != null) {
|
||||||
fCommandCache.execute(
|
fContainerCommandCache.execute(
|
||||||
new MIThreadListIds(groupDmc),
|
new MIThreadListIds(groupDmc),
|
||||||
new DataRequestMonitor<MIThreadListIdsInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<MIThreadListIdsInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -589,23 +609,36 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses {
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IResumedDMEvent e) {
|
public void eventDispatched(IResumedDMEvent e) {
|
||||||
fCommandCache.setContextAvailable(e.getDMContext(), false);
|
if (e instanceof IContainerResumedDMEvent) {
|
||||||
// I need to put this so that in non-stop mode, we can send the CLIInfo
|
// This will happen in all-stop mode
|
||||||
// command while some threads are running.
|
fContainerCommandCache.setContextAvailable(e.getDMContext(), false);
|
||||||
// However, in all-stop, this line breaks a thread exiting, and threads running
|
} else {
|
||||||
// because it allows us to send the thread-list-ids although we don't have a prompt
|
// This will happen in non-stop mode
|
||||||
// We need to find a proper solution for the cache.
|
// Keep target available for Container commands
|
||||||
// fCommandCache.setContextAvailable(fCommandControl.getControlDMContext(), true);
|
|
||||||
if (e.getReason() != StateChangeReason.STEP) {
|
|
||||||
fCommandCache.reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(ISuspendedDMEvent e) {
|
public void eventDispatched(ISuspendedDMEvent e) {
|
||||||
fCommandCache.setContextAvailable(e.getDMContext(), true);
|
if (e instanceof IContainerSuspendedDMEvent) {
|
||||||
fCommandCache.setContextAvailable(fCommandControl.getControlDMContext(), true);
|
// This will happen in all-stop mode
|
||||||
fCommandCache.reset();
|
fContainerCommandCache.setContextAvailable(e.getDMContext(), true);
|
||||||
|
} else {
|
||||||
|
// This will happen in non-stop mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Event handler when a thread starts
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(IStartedDMEvent e) {
|
||||||
|
fContainerCommandCache.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event handler when a thread exits
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(IExitedDMEvent e) {
|
||||||
|
fContainerCommandCache.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.dd.mi.service.command.commands;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
import org.eclipse.dd.mi.service.command.output.CLIInfoThreadsInfo;
|
import org.eclipse.dd.mi.service.command.output.CLIInfoThreadsInfo;
|
||||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||||
|
@ -31,10 +30,6 @@ public class CLIInfoThreads extends CLICommand<CLIInfoThreadsInfo> {
|
||||||
super(ctx, "info threads"); //$NON-NLS-1$
|
super(ctx, "info threads"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLIInfoThreads(IProcessDMContext ctx) {
|
|
||||||
super(ctx, "info threads"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CLIInfoThreadsInfo getResult(MIOutput output) {
|
public CLIInfoThreadsInfo getResult(MIOutput output) {
|
||||||
return (CLIInfoThreadsInfo)getMIInfo(output);
|
return (CLIInfoThreadsInfo)getMIInfo(output);
|
||||||
|
|
Loading…
Add table
Reference in a new issue