1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Allow to more easily extend GDBControl service.

Change-Id: Iec5ef773222390237d4665fb9bd3daa5b3cae947
This commit is contained in:
Marc Khouzam 2016-05-13 13:27:38 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 1bdfc29020
commit 93fa9c00a6
4 changed files with 103 additions and 57 deletions

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
Bundle-Version: 5.0.0.qualifier Bundle-Version: 5.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>5.0.0-SNAPSHOT</version> <version>5.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.dsf.gdb</artifactId> <artifactId>org.eclipse.cdt.dsf.gdb</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -505,53 +505,73 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
@Override @Override
protected void initialize(final RequestMonitor requestMonitor) { protected void initialize(final RequestMonitor requestMonitor) {
InputStream errorStream = null; doCommandMonitoringStep(requestMonitor);
if (fMIBackend instanceof IMIBackend2) {
errorStream = ((IMIBackend2)fMIBackend).getMIErrorStream();
}
startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream(), errorStream);
requestMonitor.done();
} }
@Override @Override
protected void shutdown(RequestMonitor requestMonitor) { protected void shutdown(RequestMonitor requestMonitor) {
stopCommandProcessing(); undoCommandMonitoringStep(requestMonitor);
requestMonitor.done();
} }
} }
/** @since 5.1 */
protected void doCommandMonitoringStep(final RequestMonitor requestMonitor) {
InputStream errorStream = null;
if (fMIBackend instanceof IMIBackend2) {
errorStream = ((IMIBackend2)fMIBackend).getMIErrorStream();
}
startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream(), errorStream);
requestMonitor.done();
}
/** @since 5.1 */
protected void undoCommandMonitoringStep(RequestMonitor requestMonitor) {
stopCommandProcessing();
requestMonitor.done();
}
protected class CommandProcessorsStep extends InitializationShutdownStep { protected class CommandProcessorsStep extends InitializationShutdownStep {
CommandProcessorsStep(Direction direction) { super(direction); } CommandProcessorsStep(Direction direction) { super(direction); }
@Override @Override
public void initialize(final RequestMonitor requestMonitor) { public void initialize(final RequestMonitor requestMonitor) {
try { doCommandProcessorsStep(requestMonitor);
fCLIProcess = new GDBBackendCLIProcess(GDBControl.this, fMIBackend);
}
catch(IOException e) {
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "Failed to create CLI Process", e)); //$NON-NLS-1$
requestMonitor.done();
return;
}
fCLICommandProcessor = createCLIEventProcessor(GDBControl.this, getContext());
fMIEventProcessor = createMIRunControlEventProcessor(GDBControl.this, getContext());
fControlEventProcessor = createControlEventProcessor();
requestMonitor.done();
} }
@Override @Override
protected void shutdown(RequestMonitor requestMonitor) { protected void shutdown(RequestMonitor requestMonitor) {
fControlEventProcessor.dispose(); undoCommandProcessorsStep(requestMonitor);
fCLICommandProcessor.dispose();
fMIEventProcessor.dispose();
fCLIProcess.dispose();
requestMonitor.done();
} }
} }
/** @since 5.1 */
protected void doCommandProcessorsStep(final RequestMonitor requestMonitor) {
try {
fCLIProcess = new GDBBackendCLIProcess(GDBControl.this, fMIBackend);
}
catch(IOException e) {
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "Failed to create CLI Process", e)); //$NON-NLS-1$
requestMonitor.done();
return;
}
fCLICommandProcessor = createCLIEventProcessor(GDBControl.this, getContext());
fMIEventProcessor = createMIRunControlEventProcessor(GDBControl.this, getContext());
fControlEventProcessor = createControlEventProcessor();
requestMonitor.done();
}
/** @since 5.1 */
protected void undoCommandProcessorsStep(RequestMonitor requestMonitor) {
fControlEventProcessor.dispose();
fCLICommandProcessor.dispose();
fMIEventProcessor.dispose();
fCLIProcess.dispose();
requestMonitor.done();
}
/** /**
* @since 4.1 * @since 4.1
*/ */
@ -562,47 +582,67 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
@Override @Override
public void initialize( final RequestMonitor requestMonitor ) { public void initialize( final RequestMonitor requestMonitor ) {
fCommandTimeoutManager = createCommandTimeoutManager( GDBControl.this ); doCommandTimeoutStep(requestMonitor);
if (fCommandTimeoutManager != null) {
fCommandTimeoutManager.addCommandTimeoutListener(fTimeoutListener);
}
requestMonitor.done();
} }
@Override @Override
protected void shutdown( RequestMonitor requestMonitor ) { protected void shutdown( RequestMonitor requestMonitor ) {
if ( fCommandTimeoutManager != null ) { undoCommandTimeoutStep(requestMonitor);
fCommandTimeoutManager.removeCommandTimeoutListener(fTimeoutListener);
fCommandTimeoutManager.dispose();
}
requestMonitor.done();
} }
} }
/** @since 5.1 */
protected void doCommandTimeoutStep(final RequestMonitor requestMonitor) {
fCommandTimeoutManager = createCommandTimeoutManager( GDBControl.this );
if (fCommandTimeoutManager != null) {
fCommandTimeoutManager.addCommandTimeoutListener(fTimeoutListener);
}
requestMonitor.done();
}
/** @since 5.1 */
protected void undoCommandTimeoutStep(RequestMonitor requestMonitor) {
if ( fCommandTimeoutManager != null ) {
fCommandTimeoutManager.removeCommandTimeoutListener(fTimeoutListener);
fCommandTimeoutManager.dispose();
}
requestMonitor.done();
}
protected class RegisterStep extends InitializationShutdownStep { protected class RegisterStep extends InitializationShutdownStep {
RegisterStep(Direction direction) { super(direction); } RegisterStep(Direction direction) { super(direction); }
@Override @Override
public void initialize(final RequestMonitor requestMonitor) { public void initialize(final RequestMonitor requestMonitor) {
getSession().addServiceEventListener(GDBControl.this, null); doRegisterStep(requestMonitor);
register(
new String[]{ ICommandControl.class.getName(),
ICommandControlService.class.getName(),
IMICommandControl.class.getName(),
AbstractMIControl.class.getName(),
IGDBControl.class.getName() },
new Hashtable<String,String>());
getSession().dispatchEvent(new GDBControlInitializedDMEvent(getContext()), getProperties());
requestMonitor.done();
} }
@Override @Override
protected void shutdown(RequestMonitor requestMonitor) { protected void shutdown(RequestMonitor requestMonitor) {
unregister(); undoRegisterStep(requestMonitor);
getSession().removeServiceEventListener(GDBControl.this);
requestMonitor.done();
} }
} }
/** @since 5.1 */
protected void doRegisterStep(final RequestMonitor requestMonitor) {
getSession().addServiceEventListener(GDBControl.this, null);
register(
new String[]{ ICommandControl.class.getName(),
ICommandControlService.class.getName(),
IMICommandControl.class.getName(),
AbstractMIControl.class.getName(),
IGDBControl.class.getName() },
new Hashtable<String,String>());
getSession().dispatchEvent(new GDBControlInitializedDMEvent(getContext()), getProperties());
requestMonitor.done();
}
/** @since 5.1 */
protected void undoRegisterStep(RequestMonitor requestMonitor) {
unregister();
getSession().removeServiceEventListener(GDBControl.this);
requestMonitor.done();
}
/** @since 4.0 */ /** @since 4.0 */
@Override @Override
public List<String> getFeatures() { public List<String> getFeatures() {

View file

@ -91,7 +91,8 @@ public class GDBControl_7_0 extends GDBControl {
return new MIRunControlEventProcessor_7_0(connection, controlDmc); return new MIRunControlEventProcessor_7_0(connection, controlDmc);
} }
private void listFeatures(final RequestMonitor requestMonitor) { /** @since 5.1 */
protected void doListFeatures(final RequestMonitor requestMonitor) {
queueCommand( queueCommand(
getCommandFactory().createMIListFeatures(getContext()), getCommandFactory().createMIListFeatures(getContext()),
new DataRequestMonitor<MIListFeaturesInfo>(getExecutor(), requestMonitor) { new DataRequestMonitor<MIListFeaturesInfo>(getExecutor(), requestMonitor) {
@ -103,6 +104,11 @@ public class GDBControl_7_0 extends GDBControl {
}); });
} }
/** @since 5.1 */
protected void undoListFeatures(RequestMonitor requestMonitor) {
requestMonitor.done();
}
@Override @Override
protected Sequence getCompleteInitializationSequence(Map<String, Object> attributes, RequestMonitorWithProgress rm) { protected Sequence getCompleteInitializationSequence(Map<String, Object> attributes, RequestMonitorWithProgress rm) {
return new FinalLaunchSequence_7_0(getSession(), attributes, rm); return new FinalLaunchSequence_7_0(getSession(), attributes, rm);
@ -130,12 +136,12 @@ public class GDBControl_7_0 extends GDBControl {
@Override @Override
protected void initialize(final RequestMonitor requestMonitor) { protected void initialize(final RequestMonitor requestMonitor) {
listFeatures(requestMonitor); doListFeatures(requestMonitor);
} }
@Override @Override
protected void shutdown(RequestMonitor requestMonitor) { protected void shutdown(RequestMonitor requestMonitor) {
requestMonitor.done(); undoListFeatures(requestMonitor);
} }
} }