mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-17 22:15:23 +02:00
Bug 241985
Made ServiceFactory accept a variable number of arguments to allow for different constructor signatures for services.
This commit is contained in:
parent
475a55a1e4
commit
d6faf244f9
5 changed files with 31 additions and 28 deletions
|
@ -16,7 +16,7 @@ import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
public abstract class AbstractDsfDebugServicesFactory implements IDsfDebugServicesFactory {
|
public abstract class AbstractDsfDebugServicesFactory implements IDsfDebugServicesFactory {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <V> V createService(DsfSession session, Class<V> clazz) {
|
public <V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments) {
|
||||||
if (IBreakpoints.class.isAssignableFrom(clazz)) {
|
if (IBreakpoints.class.isAssignableFrom(clazz)) {
|
||||||
return (V)createBreakpointService(session);
|
return (V)createBreakpointService(session);
|
||||||
} else if (ICommandControl.class.isAssignableFrom(clazz)) {
|
} else if (ICommandControl.class.isAssignableFrom(clazz)) {
|
||||||
|
|
|
@ -17,5 +17,5 @@ import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
* to easily have different service implementation for different backends.
|
* to easily have different service implementation for different backends.
|
||||||
*/
|
*/
|
||||||
public interface IDsfDebugServicesFactory {
|
public interface IDsfDebugServicesFactory {
|
||||||
public <V> V createService(DsfSession session, Class<V> clazz);
|
<V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,38 +40,37 @@ public class ServicesLaunchSequence extends Sequence {
|
||||||
//
|
//
|
||||||
// Create the connection.
|
// Create the connection.
|
||||||
//
|
//
|
||||||
fCommandControl = fLaunch.getServiceFactory().createService(fSession, GDBControl.class);
|
fCommandControl = fLaunch.getServiceFactory().createService(GDBControl.class, fSession, fLaunch.getLaunchConfiguration());
|
||||||
fCommandControl.initData(fLaunch.getLaunchConfiguration());
|
|
||||||
fCommandControl.initialize(requestMonitor);
|
fCommandControl.initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IRunControl.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IRunControl.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IProcesses.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IProcesses.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IMemory.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IMemory.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IModules.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IModules.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IStack.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IStack.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IExpressions.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IExpressions.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fSourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(fSession, ISourceLookup.class);
|
fSourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(ISourceLookup.class, fSession);
|
||||||
fSourceLookup.initialize(requestMonitor);
|
fSourceLookup.initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
|
@ -82,21 +81,21 @@ public class ServicesLaunchSequence extends Sequence {
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
// Create the low-level breakpoint service
|
// Create the low-level breakpoint service
|
||||||
fLaunch.getServiceFactory().createService(fSession, IBreakpoints.class).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
fLaunch.getServiceFactory().createService(IBreakpoints.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
// Create high-level breakpoint service and install breakpoints
|
// Create high-level breakpoint service and install breakpoints
|
||||||
// for the GDB debug context.
|
// for the GDB debug context.
|
||||||
fLaunch.getServiceFactory().createService(fSession, MIBreakpointsManager.class).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
fLaunch.getServiceFactory().createService(MIBreakpointsManager.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IRegisters.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IRegisters.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fLaunch.getServiceFactory().createService(fSession, IDisassembly.class).initialize(requestMonitor);
|
fLaunch.getServiceFactory().createService(IDisassembly.class, fSession).initialize(requestMonitor);
|
||||||
}},
|
}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.dd.mi.service.MIMemory;
|
||||||
import org.eclipse.dd.mi.service.MIModules;
|
import org.eclipse.dd.mi.service.MIModules;
|
||||||
import org.eclipse.dd.mi.service.MIRegisters;
|
import org.eclipse.dd.mi.service.MIRegisters;
|
||||||
import org.eclipse.dd.mi.service.MIStack;
|
import org.eclipse.dd.mi.service.MIStack;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
||||||
|
|
||||||
|
@ -47,12 +48,19 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <V> V createService(DsfSession session, Class<V> clazz) {
|
public <V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments) {
|
||||||
if (MIBreakpointsManager.class.isAssignableFrom(clazz)) {
|
if (MIBreakpointsManager.class.isAssignableFrom(clazz)) {
|
||||||
return (V)createBreakpointManagerService(session);
|
return (V)createBreakpointManagerService(session);
|
||||||
|
} else if (ICommandControl.class.isAssignableFrom(clazz)) {
|
||||||
|
for (Object arg : optionalArguments) {
|
||||||
|
if (arg instanceof ILaunchConfiguration) {
|
||||||
|
return (V)createCommandControl(session, (ILaunchConfiguration)arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.createService(session, clazz);
|
|
||||||
|
return super.createService(clazz, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MIBreakpointsManager createBreakpointManagerService(DsfSession session) {
|
protected MIBreakpointsManager createBreakpointManagerService(DsfSession session) {
|
||||||
|
@ -64,9 +72,8 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
||||||
return new MIBreakpoints(session);
|
return new MIBreakpoints(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) {
|
||||||
protected ICommandControl createCommandControl(DsfSession session) {
|
return new GDBControl(session, config);
|
||||||
return new GDBControl(session);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -115,12 +115,8 @@ public class GDBControl extends AbstractMIControl {
|
||||||
|
|
||||||
private PTY fPty;
|
private PTY fPty;
|
||||||
|
|
||||||
public GDBControl(DsfSession session) {
|
public GDBControl(DsfSession session, ILaunchConfiguration config) {
|
||||||
super(session);
|
super(session);
|
||||||
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initData(ILaunchConfiguration config) {
|
|
||||||
fSessionType = LaunchUtils.getSessionType(config);
|
fSessionType = LaunchUtils.getSessionType(config);
|
||||||
fAttach = LaunchUtils.getIsAttach(config);
|
fAttach = LaunchUtils.getIsAttach(config);
|
||||||
fGdbPath = LaunchUtils.getGDBPath(config);
|
fGdbPath = LaunchUtils.getGDBPath(config);
|
||||||
|
@ -129,6 +125,7 @@ public class GDBControl extends AbstractMIControl {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fExecPath = new Path(""); //$NON-NLS-1$
|
fExecPath = new Path(""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
Loading…
Add table
Reference in a new issue