1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Fix up interrupt signalling for cygwin and mingw gdb. As a side affect, mingw no longer pops up it's own console but prints to the console like other platforms do.

This commit is contained in:
Doug Schaefer 2007-05-17 18:51:41 +00:00
parent 22f7f27e18
commit dc88016beb
7 changed files with 100 additions and 91 deletions

View file

@ -12,8 +12,12 @@
package org.eclipse.cdt.debug.mi.core.command;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.mi.core.MIProcess;
import org.eclipse.cdt.debug.mi.core.MIProcessAdapter;
import org.eclipse.core.runtime.IProgressMonitor;
/**
@ -438,4 +442,8 @@ public class CommandFactory {
public String getWorkingDirectory(File cwd) {
return "--cd=" + cwd.getAbsolutePath(); //$NON-NLS-1$
}
public MIProcess createMIProcess(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
return new MIProcessAdapter(args, launchTimeout, monitor);
}
}

View file

@ -3,7 +3,11 @@ package org.eclipse.cdt.debug.mi.core.command;
public class MIGDBSetNewConsole extends MIGDBSet {
public MIGDBSetNewConsole(String miVersion) {
super(miVersion, new String[] {"new-console"}); //$NON-NLS-1$
this(miVersion, "on");
}
public MIGDBSetNewConsole(String miVersion, String param) {
super(miVersion, new String[] {"new-console", param}); //$NON-NLS-1$
}
}

View file

@ -10,7 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.command.factories.win32;
import java.io.IOException;
import org.eclipse.cdt.debug.mi.core.CygwinMIProcessAdapter;
import org.eclipse.cdt.debug.mi.core.MIProcess;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Command factory for the gdb/mi protocol for CygWin environment.
@ -34,4 +40,17 @@ public class CygwinCommandFactory extends StandardWinCommandFactory {
public MIEnvironmentDirectory createMIEnvironmentDirectory(boolean reset, String[] pathdirs) {
return new CygwinMIEnvironmentDirectory( getMIVersion(), reset, pathdirs );
}
public MIGDBSetNewConsole createMIGDBSetNewConsole() {
// With cygwin, the Ctrl-C isn't getting propagated to the
// inferior. Thus we need to have the inferior in it's own
// console so that the fall back of sending it the interrupt
// signal works.
return new MIGDBSetNewConsole(getMIVersion(), "on");
}
public MIProcess createMIProcess(String[] args, int launchTimeout,
IProgressMonitor monitor) throws IOException {
return new CygwinMIProcessAdapter(args, launchTimeout, monitor);
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.mi.core.command.factories.win32;
import org.eclipse.cdt.debug.mi.core.command.CLIInfoSharedLibrary;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetAutoSolib;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
@ -36,107 +37,72 @@ public class StandardWinCommandFactory extends StandardCommandFactory {
super( miVersion );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIEnvironmentCD(java.lang.String)
*/
public MIEnvironmentCD createMIEnvironmentCD( String pathdir ) {
return new WinMIEnvironmentCD( getMIVersion(), pathdir );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createCLIInfoSharedLibrary()
*/
public CLIInfoSharedLibrary createCLIInfoSharedLibrary() {
return new WinCLIInfoSharedLibrary();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBSetAutoSolib(boolean)
*/
public MIGDBSetAutoSolib createMIGDBSetAutoSolib( boolean set ) {
// Suppress "set auto-solib" - returns error on Windows
return new MIGDBSetAutoSolib( getMIVersion(), true ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() {
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() {
return new String[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() {
return new String[0];
}
};
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBShowSolibSearchPath()
*/
public MIGDBShowSolibSearchPath createMIGDBShowSolibSearchPath() {
// Suppress "show solib-search-path" - returns error on Windows
return new MIGDBShowSolibSearchPath( getMIVersion() ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() {
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() {
return new String[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() {
return new String[0];
}
};
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBSetSolibSearchPath(java.lang.String[])
*/
public MIGDBSetSolibSearchPath createMIGDBSetSolibSearchPath( String[] params ) {
// Suppress "set solib-search-path" - returns error on Windows
return new MIGDBSetSolibSearchPath( getMIVersion(), params ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() {
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() {
return new String[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() {
return new String[0];
}
};
}
public MIGDBSetNewConsole createMIGDBSetNewConsole() {
// By default in Windows, turn off new console so that the
// Ctrl-C's get propogated automatically to the inferior.
// Overriden by Cygwin.
return new MIGDBSetNewConsole(getMIVersion(), "off");
}
}

View file

@ -0,0 +1,40 @@
/**********************************************************************
* Copyright (c) 2007 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.debug.mi.core;
import java.io.IOException;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author Doug Schaefer
*/
public class CygwinMIProcessAdapter extends MIProcessAdapter {
/**
* @param args
* @param launchTimeout
* @param monitor
* @throws IOException
*/
public CygwinMIProcessAdapter(String[] args, int launchTimeout,
IProgressMonitor monitor) throws IOException {
super(args, launchTimeout, monitor);
}
public void interrupt(MIInferior inferior) {
// With cygwin gdb, interrupting gdb itself never works.
// You need to interrupt the inferior directly.
interruptInferior(inferior);
}
}

View file

@ -445,7 +445,7 @@ public class MIPlugin extends Plugin {
MIProcess pgdb = null;
boolean failed = false;
try {
pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
pgdb = factory.createMIProcess(args, launchTimeout, monitor);
if (MIPlugin.getDefault().isDebugging()) {
StringBuffer sb = new StringBuffer();

View file

@ -106,20 +106,10 @@ public class MIProcessAdapter implements MIProcess {
return pgdb;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.mi.core.MIProcess#canInterrupt()
*/
public boolean canInterrupt(MIInferior inferior) {
return fGDBProcess instanceof Spawner;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.mi.core.MIProcess#interrupt()
*/
public void interrupt(MIInferior inferior) {
if (fGDBProcess instanceof Spawner) {
Spawner gdbSpawner = (Spawner) fGDBProcess;
@ -136,70 +126,52 @@ public class MIProcessAdapter implements MIProcess {
// If we are still running try to drop the sig to the PID
if (inferior.isRunning() && inferior.getInferiorPID() > 0) {
// lets try something else.
gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
synchronized (inferior) {
for (int i = 0; inferior.isRunning() && i < 5; i++) {
try {
inferior.wait(1000);
} catch (InterruptedException e) {
}
}
}
interruptInferior(inferior);
}
}
}
/*
* (non-Javadoc)
/**
* Send an interrupt to the inferior process.
*
* @see java.lang.Process#exitValue()
* @param inferior
*/
protected void interruptInferior(MIInferior inferior) {
if (fGDBProcess instanceof Spawner) {
Spawner gdbSpawner = (Spawner) fGDBProcess;
gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
synchronized (inferior) {
for (int i = 0; inferior.isRunning() && i < 5; i++) {
try {
inferior.wait(1000);
} catch (InterruptedException e) {
}
}
}
}
}
public int exitValue() {
return fGDBProcess.exitValue();
}
/*
* (non-Javadoc)
*
* @see java.lang.Process#waitFor()
*/
public int waitFor() throws InterruptedException {
return fGDBProcess.waitFor();
}
/*
* (non-Javadoc)
*
* @see java.lang.Process#destroy()
*/
public void destroy() {
fGDBProcess.destroy();
}
/*
* (non-Javadoc)
*
* @see java.lang.Process#getErrorStream()
*/
public InputStream getErrorStream() {
return fGDBProcess.getErrorStream();
}
/*
* (non-Javadoc)
*
* @see java.lang.Process#getInputStream()
*/
public InputStream getInputStream() {
return fGDBProcess.getInputStream();
}
/*
* (non-Javadoc)
*
* @see java.lang.Process#getOutputStream()
*/
public OutputStream getOutputStream() {
return fGDBProcess.getOutputStream();
}