1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +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; package org.eclipse.cdt.debug.mi.core.command;
import java.io.File; import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.core.IAddress; 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) { public String getWorkingDirectory(File cwd) {
return "--cd=" + cwd.getAbsolutePath(); //$NON-NLS-1$ 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 class MIGDBSetNewConsole extends MIGDBSet {
public MIGDBSetNewConsole(String miVersion) { 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; 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.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. * 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) { public MIEnvironmentDirectory createMIEnvironmentDirectory(boolean reset, String[] pathdirs) {
return new CygwinMIEnvironmentDirectory( getMIVersion(), reset, 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.CLIInfoSharedLibrary;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD; 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.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.MIGDBSetSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath; import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory; import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
@ -36,107 +37,72 @@ public class StandardWinCommandFactory extends StandardCommandFactory {
super( miVersion ); super( miVersion );
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIEnvironmentCD(java.lang.String)
*/
public MIEnvironmentCD createMIEnvironmentCD( String pathdir ) { public MIEnvironmentCD createMIEnvironmentCD( String pathdir ) {
return new WinMIEnvironmentCD( getMIVersion(), pathdir ); return new WinMIEnvironmentCD( getMIVersion(), pathdir );
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createCLIInfoSharedLibrary()
*/
public CLIInfoSharedLibrary createCLIInfoSharedLibrary() { public CLIInfoSharedLibrary createCLIInfoSharedLibrary() {
return new WinCLIInfoSharedLibrary(); return new WinCLIInfoSharedLibrary();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBSetAutoSolib(boolean)
*/
public MIGDBSetAutoSolib createMIGDBSetAutoSolib( boolean set ) { public MIGDBSetAutoSolib createMIGDBSetAutoSolib( boolean set ) {
// Suppress "set auto-solib" - returns error on Windows // Suppress "set auto-solib" - returns error on Windows
return new MIGDBSetAutoSolib( getMIVersion(), true ) { return new MIGDBSetAutoSolib( getMIVersion(), true ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() { public String getOperation() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() { public String[] getOptions() {
return new String[0]; return new String[0];
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() { public String[] getParameters() {
return new String[0]; return new String[0];
} }
}; };
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBShowSolibSearchPath()
*/
public MIGDBShowSolibSearchPath createMIGDBShowSolibSearchPath() { public MIGDBShowSolibSearchPath createMIGDBShowSolibSearchPath() {
// Suppress "show solib-search-path" - returns error on Windows // Suppress "show solib-search-path" - returns error on Windows
return new MIGDBShowSolibSearchPath( getMIVersion() ) { return new MIGDBShowSolibSearchPath( getMIVersion() ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() { public String getOperation() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() { public String[] getOptions() {
return new String[0]; return new String[0];
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() { public String[] getParameters() {
return new String[0]; return new String[0];
} }
}; };
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIGDBSetSolibSearchPath(java.lang.String[])
*/
public MIGDBSetSolibSearchPath createMIGDBSetSolibSearchPath( String[] params ) { public MIGDBSetSolibSearchPath createMIGDBSetSolibSearchPath( String[] params ) {
// Suppress "set solib-search-path" - returns error on Windows // Suppress "set solib-search-path" - returns error on Windows
return new MIGDBSetSolibSearchPath( getMIVersion(), params ) { return new MIGDBSetSolibSearchPath( getMIVersion(), params ) {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOperation()
*/
public String getOperation() { public String getOperation() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getOptions()
*/
public String[] getOptions() { public String[] getOptions() {
return new String[0]; return new String[0];
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.command.MICommand#getParameters()
*/
public String[] getParameters() { public String[] getParameters() {
return new String[0]; 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; MIProcess pgdb = null;
boolean failed = false; boolean failed = false;
try { try {
pgdb = new MIProcessAdapter(args, launchTimeout, monitor); pgdb = factory.createMIProcess(args, launchTimeout, monitor);
if (MIPlugin.getDefault().isDebugging()) { if (MIPlugin.getDefault().isDebugging()) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();

View file

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