mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 497167: Add support for =thread-group-added event
This will allow us to eventually take action (like prepare the console) as soon as the user adds a new inferior using the gdb console and the command add-inferior. Change-Id: I24ff380b8442de6a88e3caa0fe6832e90e83ac99
This commit is contained in:
parent
25a42fbdce
commit
d72b4df3eb
6 changed files with 97 additions and 4 deletions
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
|||
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.Sequence;
|
||||
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
||||
|
@ -36,6 +37,8 @@ import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
|||
import org.eclipse.cdt.dsf.debug.service.IMultiDetach;
|
||||
import org.eclipse.cdt.dsf.debug.service.IMultiTerminate;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ICreatedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||
|
@ -51,6 +54,7 @@ import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
|
|||
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
|
||||
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadGroupAddedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||
|
@ -131,6 +135,18 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event indicating that a container (gdb inferior) has been created, but is not yet running.
|
||||
* @since 5.1
|
||||
*/
|
||||
protected static class ContainerCreatedDMEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||
implements ICreatedDMEvent
|
||||
{
|
||||
public ContainerCreatedDMEvent(IContainerDMContext context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The first thread-group id used by GDB.
|
||||
* GDB starts up with certain things already setup, and we need
|
||||
|
@ -199,6 +215,12 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
|
|||
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
|
||||
fBackend = getServicesTracker().getService(IGDBBackend.class);
|
||||
|
||||
// We know we missed the very first =thread-group-added event
|
||||
// because GDB sends it as soon as it starts, but we are not
|
||||
// ready to receive it at that time. We send it now instead.
|
||||
IMIContainerDMContext initialContainer = createContainerContextFromGroupId(fCommandControl.getContext(), INITIAL_THREAD_GROUP_ID);
|
||||
getSession().dispatchEvent(new ContainerCreatedDMEvent(initialContainer), getProperties());
|
||||
|
||||
requestMonitor.done();
|
||||
}
|
||||
|
||||
|
@ -667,6 +689,16 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(MIThreadGroupAddedEvent e) {
|
||||
IProcessDMContext procDmc = e.getDMContext();
|
||||
IMIContainerDMContext containerDmc = e.getGroupId() != null ? createContainerContext(procDmc, e.getGroupId()) : null;
|
||||
getSession().dispatchEvent(new ContainerCreatedDMEvent(containerDmc), getProperties());
|
||||
}
|
||||
|
||||
/** @since 4.0 */
|
||||
@DsfServiceEventHandler
|
||||
@Override
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MISteppingRangeEvent;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadCreatedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadExitEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadGroupAddedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadGroupCreatedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadGroupExitedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIWatchpointScopeEvent;
|
||||
|
@ -217,8 +218,31 @@ public class MIRunControlEventProcessor_7_0
|
|||
|
||||
fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties());
|
||||
}
|
||||
} else if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if ("thread-group-added".equals(miEvent)) { //$NON-NLS-1$
|
||||
// With GDB >= 7.2
|
||||
String groupId = null;
|
||||
|
||||
MIResult[] results = exec.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
MIValue val = results[i].getMIValue();
|
||||
if (var.equals("id")) { //$NON-NLS-1$
|
||||
if (val instanceof MIConst) {
|
||||
groupId = ((MIConst) val).getString().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
||||
if (procService != null) {
|
||||
// When a thread-group is first added, there is no process and therefore no pid, so we use UNKNOWN_PROCESS_ID
|
||||
IProcessDMContext processDmc = procService.createProcessContext(fCommandControl.getContext(), MIProcesses.UNKNOWN_PROCESS_ID);
|
||||
MIEvent<?> event = new MIThreadGroupAddedEvent(processDmc, exec.getToken(), groupId);
|
||||
fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties());
|
||||
}
|
||||
} else if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// =thread-group-created was used for GDB 7.0 and 7.1,
|
||||
// but then became =thread-group-started starting with GDB 7.2
|
||||
String groupId = null;
|
||||
String pId = null;
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 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
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.mi.service.command.events;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.Immutable;
|
||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||
|
||||
/**
|
||||
* =thread-group-added,id="i1"
|
||||
*
|
||||
* This can only be detected by gdb/mi with GDB >= 7.2.
|
||||
* @since 5.1
|
||||
*/
|
||||
@Immutable
|
||||
public class MIThreadGroupAddedEvent extends MIEvent<IProcessDMContext> {
|
||||
|
||||
final private String fGroupId;
|
||||
|
||||
public MIThreadGroupAddedEvent(IProcessDMContext ctx, int token, String groupId) {
|
||||
super(ctx, token, null);
|
||||
fGroupId = groupId;
|
||||
}
|
||||
|
||||
public String getGroupId() { return fGroupId; }
|
||||
}
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
||||
Bundle-Version: 2.7.0.qualifier
|
||||
Bundle-Version: 2.8.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.7.0-SNAPSHOT</version>
|
||||
<version>2.8.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -87,7 +87,14 @@ public interface IRunControl extends IDsfService
|
|||
*/
|
||||
IExecutionDMContext[] getTriggeringContexts();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates that a new execution context was created but may not have
|
||||
* started execution yet.
|
||||
* @since 2.8
|
||||
*/
|
||||
public interface ICreatedDMEvent extends IDMEvent<IExecutionDMContext> {}
|
||||
|
||||
/**
|
||||
* Indicates that a new execution context was started.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue