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

Bug 303808: Handle resizing of full GDB console

Note that the TextCanvas used by the terminal widget that powers the
full console has a default minimum of 4 lines and 80 columns.  We could
change those if we feel that is not adequate, or if we don't want to
have such minimum values at all.  This patch leaves the minimum values
as they are by default.

Conflicts:
	dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java

Change-Id: Iad6339da1726db1102c123c97589f46ae681ffc7
This commit is contained in:
Marc Khouzam 2016-09-08 21:23:41 -04:00
parent 10381a74e4
commit 28f290e9d0
4 changed files with 48 additions and 14 deletions

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
@ -49,6 +50,8 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
private final DsfSession fSession; private final DsfSession fSession;
private final ILaunch fLaunch; private final ILaunch fLaunch;
private PTY fGdbPty;
private Composite fMainComposite; private Composite fMainComposite;
private final IDebuggerConsoleView fView; private final IDebuggerConsoleView fView;
private final IDebuggerConsole fConsole; private final IDebuggerConsole fConsole;
@ -194,6 +197,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
if (backend != null) { if (backend != null) {
if (backend.getProcess() != null) { if (backend.getProcess() != null) {
fGdbPty = backend.getProcessPty();
attachTerminal(backend.getProcess()); attachTerminal(backend.getProcess());
} }
} }
@ -204,7 +208,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
} }
protected void attachTerminal(Process process) { protected void attachTerminal(Process process) {
fTerminalControl.setConnector(new GdbTerminalConnector(process)); fTerminalControl.setConnector(new GdbTerminalConnector(process, fGdbPty));
if (fTerminalControl instanceof ITerminalControl) { if (fTerminalControl instanceof ITerminalControl) {
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false); ((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true); ((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);

View file

@ -11,6 +11,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
@ -26,15 +27,18 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
*/ */
public class GdbTerminalConnector extends PlatformObject implements ITerminalConnector { public class GdbTerminalConnector extends PlatformObject implements ITerminalConnector {
private int fTerminalWidth, fTerminalHeight;
private ITerminalControl fControl; private ITerminalControl fControl;
private final Process fProcess; private final Process fProcess;
private final PTY fPty;
public GdbTerminalConnector(Process process) { public GdbTerminalConnector(Process process, PTY pty) {
if (process == null) { if (process == null) {
throw new IllegalArgumentException("Invalid Process"); //$NON-NLS-1$ throw new IllegalArgumentException("Invalid Process"); //$NON-NLS-1$
} }
fProcess = process; fProcess = process;
fPty = pty;
} }
@Override @Override
@ -71,6 +75,13 @@ public class GdbTerminalConnector extends PlatformObject implements ITerminalCon
@Override @Override
public void setTerminalSize(int newWidth, int newHeight) { public void setTerminalSize(int newWidth, int newHeight) {
if (newWidth != fTerminalWidth || newHeight != fTerminalHeight) {
fTerminalWidth = newWidth;
fTerminalHeight = newHeight;
if (fPty != null) {
fPty.setTerminalSize(newWidth, newHeight);
}
}
} }
@Override @Override

View file

@ -40,8 +40,11 @@ import org.eclipse.osgi.util.NLS;
*/ */
public class GDBBackend_7_12 extends GDBBackend { public class GDBBackend_7_12 extends GDBBackend {
/** The PTY that is used to enable the full GDB console */ /** The PTY that is used to create the MI channel */
private PTY fPty; private PTY fMIPty;
/** The PTY that is used to create the GDB process in CLI mode */
private PTY fCLIPty;
/** Indicate that we failed to create a PTY. */ /** Indicate that we failed to create a PTY. */
private boolean fPtyFailure; private boolean fPtyFailure;
@ -68,8 +71,8 @@ public class GDBBackend_7_12 extends GDBBackend {
} }
try { try {
fPty = new PTY(); fMIPty = new PTY();
fPty.validateSlaveName(); fMIPty.validateSlaveName();
// With the PTY the stderr is redirected to the PTY's output stream. // With the PTY the stderr is redirected to the PTY's output stream.
// Therefore, return a dummy stream for the error stream. // Therefore, return a dummy stream for the error stream.
@ -80,7 +83,7 @@ public class GDBBackend_7_12 extends GDBBackend {
} }
}; };
} catch (IOException e) { } catch (IOException e) {
fPty = null; fMIPty = null;
fPtyFailure = true; fPtyFailure = true;
GdbPlugin.log(new Status( GdbPlugin.log(new Status(
IStatus.INFO, GdbPlugin.PLUGIN_ID, IStatus.INFO, GdbPlugin.PLUGIN_ID,
@ -90,23 +93,23 @@ public class GDBBackend_7_12 extends GDBBackend {
@Override @Override
public OutputStream getMIOutputStream() { public OutputStream getMIOutputStream() {
if (fPty == null) { if (fMIPty == null) {
return super.getMIOutputStream(); return super.getMIOutputStream();
} }
return fPty.getOutputStream(); return fMIPty.getOutputStream();
}; };
@Override @Override
public InputStream getMIInputStream() { public InputStream getMIInputStream() {
if (fPty == null) { if (fMIPty == null) {
return super.getMIInputStream(); return super.getMIInputStream();
} }
return fPty.getInputStream(); return fMIPty.getInputStream();
}; };
@Override @Override
public InputStream getMIErrorStream() { public InputStream getMIErrorStream() {
if (fPty == null) { if (fMIPty == null) {
return super.getMIErrorStream(); return super.getMIErrorStream();
} }
return fDummyErrorStream; return fDummyErrorStream;
@ -154,7 +157,7 @@ public class GDBBackend_7_12 extends GDBBackend {
"--interpreter", "console", //$NON-NLS-1$ //$NON-NLS-2$ "--interpreter", "console", //$NON-NLS-1$ //$NON-NLS-2$
// Now trigger the new console towards our PTY. // Now trigger the new console towards our PTY.
"-ex", "new-ui mi " + fPty.getSlaveName(), //$NON-NLS-1$ //$NON-NLS-2$ "-ex", "new-ui mi " + fMIPty.getSlaveName(), //$NON-NLS-1$ //$NON-NLS-2$
// Now print the version so the user gets that familiar output // Now print the version so the user gets that familiar output
"-ex", "show version" //$NON-NLS-1$ //$NON-NLS-2$ "-ex", "show version" //$NON-NLS-1$ //$NON-NLS-2$
@ -180,12 +183,13 @@ public class GDBBackend_7_12 extends GDBBackend {
Process proc = null; Process proc = null;
String[] commandLine = getDebuggerCommandLine(); String[] commandLine = getDebuggerCommandLine();
try { try {
fCLIPty = new PTY(Mode.TERMINAL);
IPath path = getGDBWorkingDirectory(); IPath path = getGDBWorkingDirectory();
proc = ProcessFactory.getFactory().exec( proc = ProcessFactory.getFactory().exec(
commandLine, commandLine,
getGDBLaunch().getLaunchEnvironment(), getGDBLaunch().getLaunchEnvironment(),
new File(path != null ? path.toOSString() : ""), //$NON-NLS-1$ new File(path != null ? path.toOSString() : ""), //$NON-NLS-1$
new PTY(Mode.TERMINAL)); fCLIPty);
} catch (IOException e) { } catch (IOException e) {
String message = "Error while launching command: " + StringUtil.join(commandLine, " "); //$NON-NLS-1$ //$NON-NLS-2$ String message = "Error while launching command: " + StringUtil.join(commandLine, " "); //$NON-NLS-1$ //$NON-NLS-2$
throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, message, e)); throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, message, e));
@ -193,4 +197,9 @@ public class GDBBackend_7_12 extends GDBBackend {
return proc; return proc;
} }
@Override
public PTY getProcessPty() {
return fCLIPty;
}
} }

View file

@ -16,6 +16,7 @@ import java.util.Properties;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.mi.service.IMIBackend; import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -173,4 +174,13 @@ public interface IGDBBackend extends IMIBackend {
default Process getProcess() { default Process getProcess() {
throw new RuntimeException(); throw new RuntimeException();
} }
/**
* Returns the PTY used when starting the GDB process.
* Can be null if no PTY was used.
* @since 5.1
*/
default PTY getProcessPty() {
return null;
}
} }