mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 212916
Support for redirecting the inferior's input/output to a terminal.
This commit is contained in:
parent
ac09808486
commit
178f065901
5 changed files with 76 additions and 6 deletions
|
@ -41,6 +41,7 @@ import org.eclipse.dd.mi.service.command.commands.MIFileExecFile;
|
|||
import org.eclipse.dd.mi.service.command.commands.MIFileSymbolFile;
|
||||
import org.eclipse.dd.mi.service.command.commands.MIGDBSetAutoSolib;
|
||||
import org.eclipse.dd.mi.service.command.commands.MIGDBSetSolibSearchPath;
|
||||
import org.eclipse.dd.mi.service.command.commands.MIInferiorTTYSet;
|
||||
import org.eclipse.dd.mi.service.command.commands.MITargetSelect;
|
||||
import org.eclipse.dd.mi.service.command.output.MIBreakInsertInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||
|
@ -60,6 +61,26 @@ public class FinalLaunchSequence extends Sequence {
|
|||
|
||||
requestMonitor.done();
|
||||
}},
|
||||
/*
|
||||
* Specify connection of inferior input/output with a terminal.
|
||||
*/
|
||||
new Step() { @Override
|
||||
public void execute(RequestMonitor requestMonitor) {
|
||||
try {
|
||||
boolean useTerminal = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, true);
|
||||
|
||||
if (useTerminal) {
|
||||
fCommandControl.queueCommand(
|
||||
new MIInferiorTTYSet(fCommandControl.getControlDMContext(), fCommandControl.getPtyName()),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor));
|
||||
} else {
|
||||
requestMonitor.done();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get terminal option", e)); //$NON-NLS-1$
|
||||
requestMonitor.done();
|
||||
}
|
||||
}},
|
||||
/*
|
||||
* Source the gdbinit file specified in the launch
|
||||
*/
|
||||
|
|
|
@ -43,9 +43,11 @@ public class ServicesLaunchSequence extends Sequence {
|
|||
@Override
|
||||
public void execute(RequestMonitor requestMonitor) {
|
||||
String debugMode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
|
||||
boolean useTerminal = true;
|
||||
try {
|
||||
debugMode = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
||||
useTerminal = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, true);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
|
@ -64,7 +66,7 @@ public class ServicesLaunchSequence extends Sequence {
|
|||
//
|
||||
// Create the connection.
|
||||
//
|
||||
fCommandControl = new GDBControl(fSession, getGDBPath(), fExecPath, fSessionType, 30);
|
||||
fCommandControl = new GDBControl(fSession, getGDBPath(), fExecPath, fSessionType, useTerminal, 30);
|
||||
fCommandControl.initialize(requestMonitor);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.cdt.utils.spawner.ProcessFactory;
|
||||
import org.eclipse.cdt.utils.spawner.Spawner;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -97,16 +98,19 @@ public class GDBControl extends AbstractMIControl {
|
|||
private MIRunControlEventProcessor fMIEventProcessor;
|
||||
private CLIEventProcessor fCLICommandProcessor;
|
||||
private AbstractCLIProcess fCLIProcess;
|
||||
private MIInferiorProcess fInferiorProcess;
|
||||
private MIInferiorProcess fInferiorProcess = null;
|
||||
|
||||
public GDBControl(DsfSession session, IPath gdbPath, IPath execPath, SessionType type, int gdbLaunchTimeout) {
|
||||
boolean fUseTerminal;
|
||||
private PTY fPty;
|
||||
|
||||
public GDBControl(DsfSession session, IPath gdbPath, IPath execPath, SessionType type, boolean useTerminal, int gdbLaunchTimeout) {
|
||||
super(session);
|
||||
fSessionType = type;
|
||||
fGdbPath = gdbPath;
|
||||
fExecPath = execPath;
|
||||
fGDBLaunchTimeout = gdbLaunchTimeout;
|
||||
fControlDmc = new GDBControlDMContext(session.getId(), getClass().getName() + ":" + ++fgInstanceCounter); //$NON-NLS-1$
|
||||
|
||||
fUseTerminal = useTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,6 +261,10 @@ public class GDBControl extends AbstractMIControl {
|
|||
|
||||
public void getInferiorProcessId(DataRequestMonitor<Integer> rm) {
|
||||
}
|
||||
|
||||
public String getPtyName() {
|
||||
return fPty.getSlaveName();
|
||||
}
|
||||
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(ExitedEvent e) {
|
||||
|
@ -518,8 +526,19 @@ public class GDBControl extends AbstractMIControl {
|
|||
requestMonitor.done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fUseTerminal) {
|
||||
try {
|
||||
fPty = new PTY();
|
||||
fInferiorProcess = new GDBInferiorProcess(GDBControl.this, fPty);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
fInferiorProcess = new GDBInferiorProcess(GDBControl.this, fProcess.getOutputStream());
|
||||
// If !fUseTerminal or IOException was caught
|
||||
if (fInferiorProcess == null)
|
||||
fInferiorProcess = new GDBInferiorProcess(GDBControl.this, fProcess.getOutputStream());
|
||||
|
||||
fCLICommandProcessor = new CLIEventProcessor(GDBControl.this, fControlDmc, fInferiorProcess);
|
||||
fMIEventProcessor = new MIRunControlEventProcessor(GDBControl.this, fControlDmc);
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ public class MIInferiorProcess extends Process
|
|||
fInputStream.close();
|
||||
} catch (IOException e) {}
|
||||
try {
|
||||
fInputStreamPiped.close();
|
||||
if (fInputStreamPiped != null) fInputStreamPiped.close();
|
||||
} catch (IOException e) {}
|
||||
try {
|
||||
fErrorStream.close();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.mi.service.command.commands;
|
||||
|
||||
import org.eclipse.dd.mi.service.command.MIControlDMContext;
|
||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||
|
||||
|
||||
/**
|
||||
* -inferior-tty-set TTY
|
||||
*
|
||||
* Set terminal for future runs of the program being debugged.
|
||||
*/
|
||||
public class MIInferiorTTYSet extends MICommand<MIInfo>
|
||||
{
|
||||
public MIInferiorTTYSet(MIControlDMContext dmc, String tty) {
|
||||
super(dmc, "-inferior-tty-set", null, new String[] {tty}); //$NON-NLS-1$
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue