Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java243
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinMIProcessAdapter.java105
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger.java304
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java289
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java174
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java33
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger.java123
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java161
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java138
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java25
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java67
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMILaunchConfigurationConstants.java96
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MICoreUtils.java35
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java642
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPluginResources.properties39
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPreferenceInitializer.java33
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java212
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MITTYAdapter.java55
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MinGWDebugger.java21
19 files changed, 0 insertions, 2795 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java
deleted file mode 100644
index b50f39a6a9f..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2012 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.File;
-import com.ibm.icu.text.DateFormat;
-import com.ibm.icu.text.MessageFormat;
-import java.util.Date;
-import java.util.Map;
-import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.debug.core.ICDIDebugger2;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.ICDISession;
-import org.eclipse.cdt.debug.core.cdi.ICDISessionConfiguration;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IProcess;
-
-/**
- * Base class for the gdb/mi-based <code>ICDIDebugger</code> extension point
- * implementations.
- */
-abstract public class AbstractGDBCDIDebugger implements ICDIDebugger2 {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.ICDIDebugger#createDebuggerSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.core.IBinaryParser.IBinaryObject, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ICDISession createDebuggerSession( ILaunch launch, IBinaryObject exe, IProgressMonitor monitor ) throws CoreException {
- return createSession( launch, exe.getPath().toFile(), monitor );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.ICDIDebugger2#createSession(org.eclipse.debug.core.ILaunch, java.io.File, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ICDISession createSession( ILaunch launch, File executable, IProgressMonitor monitor ) throws CoreException {
- boolean failed = false;
- if ( monitor == null ) {
- monitor = new NullProgressMonitor();
- }
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- boolean verboseMode = verboseMode( launch.getLaunchConfiguration() );
- boolean breakpointsFullPath = getBreakpointsWithFullNameAttribute(launch.getLaunchConfiguration() );
- Session session = createGDBSession( launch, executable, monitor );
- if ( session != null ) {
- try {
- ICDITarget[] targets = session.getTargets();
- for( int i = 0; i < targets.length; i++ ) {
- Process debugger = session.getSessionProcess( targets[i] );
- if ( debugger != null ) {
- IProcess debuggerProcess = createGDBProcess( (Target)targets[i], launch, debugger, renderDebuggerProcessLabel( launch ), null );
- launch.addProcess( debuggerProcess );
- }
- Target target = (Target)targets[i];
- target.enableVerboseMode( verboseMode );
- target.getMISession().setBreakpointsWithFullName(breakpointsFullPath);
- target.getMISession().start();
-
- }
- doStartSession( launch, session, monitor );
- }
- catch( MIException e ) {
- failed = true;
- throw newCoreException( e );
- }
- catch( CoreException e ) {
- failed = true;
- throw e;
- }
- finally {
- try {
- if ( (failed || monitor.isCanceled()) && session != null )
- session.terminate();
- }
- catch( CDIException e1 ) {
- }
- }
- }
- return session;
- }
-
- protected Session createGDBSession( ILaunch launch, File executable, IProgressMonitor monitor ) throws CoreException {
- Session session = null;
- IPath gdbPath = getGDBPath( launch );
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- CommandFactory factory = getCommandFactory( config );
- String[] extraArgs = getExtraArguments( config );
- boolean usePty = usePty( config );
- try {
- session = MIPlugin.getDefault().createSession( getSessionType( config ), gdbPath.toOSString(), factory, executable, extraArgs, usePty, monitor );
- ICDISessionConfiguration sessionConfig = getSessionConfiguration( session );
- if ( sessionConfig != null ) {
- session.setConfiguration( sessionConfig );
- }
- }
- catch( OperationCanceledException e ) {
- }
- catch( Exception e ) {
- // Catch all wrap them up and rethrow
- if ( e instanceof CoreException ) {
- throw (CoreException)e;
- }
- throw newCoreException( e );
- }
- return session;
- }
-
- protected int getSessionType( ILaunchConfiguration config ) throws CoreException {
- String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN.equals( debugMode ) )
- return MISession.PROGRAM;
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH.equals( debugMode ) )
- return MISession.ATTACH;
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( debugMode ) )
- return MISession.CORE;
- throw newCoreException( MIPlugin.getResourceString( "src.AbstractGDBCDIDebugger.0" ) + debugMode, null ); //$NON-NLS-1$
- }
-
- protected String[] getExtraArguments( ILaunchConfiguration config ) throws CoreException {
- return new String[0];
- }
-
- protected boolean usePty( ILaunchConfiguration config ) throws CoreException {
- return config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, true );
- }
-
- abstract protected CommandFactory getCommandFactory( ILaunchConfiguration config ) throws CoreException;
-
- protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
- }
-
- protected String renderDebuggerProcessLabel( ILaunch launch ) {
- String format = "{0} ({1})"; //$NON-NLS-1$
- String timestamp = DateFormat.getInstance().format( new Date( System.currentTimeMillis() ) );
- String label = MIPlugin.getResourceString( "src.AbstractGDBCDIDebugger.2" ); //$NON-NLS-1$
- try {
- IPath path = getGDBPath( launch );
- label = path.toOSString();
- }
- catch( CoreException e ) {
- }
- return MessageFormat.format( format, new String[]{ label, timestamp } );
- }
-
- protected IPath getGDBPath(ILaunch launch) throws CoreException {
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- String command = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME,
- IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
- try {
- command = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(command, false);
- } catch (Exception e) {
- MIPlugin.log(e);
- // take value of command as it
- }
- return new Path(command);
- }
-
- protected ICDISessionConfiguration getSessionConfiguration( ICDISession session ) {
- return null;
- }
-
- /**
- * Throws a core exception with an error status object built from
- * the lower level exception and error code.
- *
- * @param exception lower level exception associated with the error,
- * or <code>null</code> if none
- * @param code error code
- */
- protected CoreException newCoreException( Throwable exception ) {
- String message = MIPlugin.getResourceString( "src.AbstractGDBCDIDebugger.1" ); //$NON-NLS-1$
- return newCoreException( message, exception );
- }
-
- /**
- * Throws a core exception with an error status object built from the given
- * message, lower level exception, and error code.
- *
- * @param message the status message
- * @param exception lower level exception associated with the error,
- * or <code>null</code> if none
- * @param code error code
- */
- protected CoreException newCoreException( String message, Throwable exception ) {
- int code = ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR;
- String ID = MIPlugin.getUniqueIdentifier();
- MultiStatus status = new MultiStatus( ID, code, message, exception );
- status.add( new Status( IStatus.ERROR, ID, code, exception == null ? new String() : exception.getLocalizedMessage(), exception ) );
- return new CoreException( status );
- }
-
- protected IProcess createGDBProcess( Target target, ILaunch launch, Process process, String label, Map attributes ) {
- return new GDBProcess( target, launch, process, label, attributes );
- }
-
- protected boolean verboseMode( ILaunchConfiguration config ) {
- boolean result = IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT;
- try {
- return config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, result );
- }
- catch( CoreException e ) {
- // use default
- }
- return result;
- }
-
- protected boolean getBreakpointsWithFullNameAttribute( ILaunchConfiguration config ) {
- boolean result = IMILaunchConfigurationConstants.DEBUGGER_FULLPATH_BREAKPOINTS_DEFAULT;
- try {
- return config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_FULLPATH_BREAKPOINTS, result );
- }
- catch( CoreException e ) {
- // use default
- }
- return result;
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinMIProcessAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinMIProcessAdapter.java
deleted file mode 100644
index ce05133ff62..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinMIProcessAdapter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007, 2012 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.cdt.utils.spawner.Spawner;
-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);
- }
-
- @Override
- public void interrupt(MIInferior inferior) {
- if (fGDBProcess instanceof Spawner) {
- if (inferior.isRunning()) {
- boolean interruptedInferior = false;
- Spawner gdbSpawner = (Spawner) fGDBProcess;
-
- // Cygwin gdb 6.8 is capricious when it comes to interrupting
- // the target. MinGW and later versions of Cygwin aren't. A
- // simple CTRL-C to gdb seems to do the trick in every case.
- // Once we drop support for gdb 6.8, we should be able to ditch
- // this method and rely on the base implementation
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=304096#c56
- if (inferior.isRemoteInferior()) {
- // Interrupt gdb with a 'kill -SIGINT'. The reason we
- // need to send a simulated Cygwin/POSIX SIGINT to
- // Cygwin gdb is that it has special handling in the case
- // of remote debugging, as explained in the bugzilla
- // comment above. That special handling will forward the
- // interrupt request through gdbserver to the remote
- // inferior, but the interrupt to gdb *must* be a
- // simulated Cygwin/POSIX SIGINT; a CTRL-C won't do.
- gdbSpawner.interrupt();
- }
- else if (inferior.isAttachedInferior()) {
- // Cygwin gdb 6.8 has no support for forwarding an
- // interrupt request to the local process it has
- // attached to. That support has since been added and
- // will be available in 7.x. So, the only way to suspend the
- // attached-to inferior is to interrupt it directly.
- // The following call will take a special path in the
- // JNI code. See
- // Java_org_eclipse_cdt_utils_spawner_Spawner_raise()
- // We don't use the Cygwin 'kill' command since (a) we don't
- // know if the process associated with PID (the inferior) is
- // a cygwin one (kill only works on cygwin programs), and
- // (b) a CTRL-C will work just fine whether it's a cygwin
- // program or not
- interruptInferior(inferior);
- interruptedInferior = true;
- }
- else {
- // The typical case--gdb launches the inferior.
- // Interrupt gdb but with a CTRL-C. gdb (6.8) itself
- // doesn't have a handler for CTRL-C, but all processes
- // in the console
- // process group will receive the CTRL-C, and gdb
- // registers itself to catch any such events that
- // happen in the inferior. Thus it is able to determine
- // and report that the inferior has been interrupted.
- // But it's important we don't interrupt Cygwin gdb with
- // a 'kill' since that will only reach gdb, and gdb
- // won't forward the request on to the inferior. See
- // bugzilla comment referenced above for details.
- gdbSpawner.interruptCTRLC();
- }
-
- waitForInterrupt(inferior);
-
- // If we are still running try to interrupt the inferior (unless we
- // already tried that above)
- if (inferior.isRunning() && inferior.getInferiorPID() > 0 && !interruptedInferior) {
- // lets try something else.
- interruptInferior(inferior);
- }
- }
- }
-
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger.java
deleted file mode 100644
index 2c630d7cb40..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 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
- * Joanne Woo (jwoo@mvista.com) - bug #118900
- *******************************************************************************/
-
-package org.eclipse.cdt.debug.mi.core;
-
-import java.io.File;
-import com.ibm.icu.text.DateFormat;
-import com.ibm.icu.text.MessageFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.debug.core.ICDIDebugger;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.ICDISession;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IProcess;
-
-/**
- * Implementing cdebugger extension point
- */
-public class GDBCDIDebugger implements ICDIDebugger {
-
- ILaunch fLaunch;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.ICDIDebugger#createDebuggerSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ICDISession createDebuggerSession(ILaunch launch, IBinaryObject exe, IProgressMonitor monitor)
- throws CoreException {
- fLaunch = launch;
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- Session dsession = null;
- String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- dsession = createLaunchSession(config, exe, monitor);
- } else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
- dsession = createAttachSession(config, exe, monitor);
- } else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
- dsession = createCoreSession(config, exe, monitor);
- }
- if (dsession != null) {
- ICDITarget[] dtargets = dsession.getTargets();
- for (int i = 0; i < dtargets.length; i++) {
- Process debugger = dsession.getSessionProcess(dtargets[i]);
- if (debugger != null) {
- IProcess debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel(config));
- launch.addProcess(debuggerProcess);
- }
- }
- }
-
- return dsession;
- }
-
- public Session createLaunchSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor) throws CoreException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = getMIVersion(config);
- boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, true);
- File cwd = getProjectPath(config).toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- if (usePty) {
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getPath().toFile(), cwd, gdbinit, monitor);
- } else {
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getPath().toFile(), cwd, gdbinit, null, monitor);
- }
- initializeLibraries(config, session);
- return session;
- } catch (Exception e) {
- // Catch all wrap them up and rethrow
- failed = true;
- if (e instanceof CoreException) {
- throw (CoreException)e;
- }
- throw newCoreException(e);
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- public Session createAttachSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor) throws CoreException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = getMIVersion(config);
- int pid = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1);
- File cwd = getProjectPath(config).toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- File exeFile = exe != null ? exe.getPath().toFile() : null;
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exeFile, pid, null, cwd, gdbinit, monitor);
- initializeLibraries(config, session);
- return session;
- } catch (Exception e) {
- // Catch all wrap them up and rethrow
- failed = true;
- if (e instanceof CoreException) {
- throw (CoreException)e;
- }
- throw newCoreException(e);
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- public Session createCoreSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor) throws CoreException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = getMIVersion(config);
- File cwd = getProjectPath(config).toFile();
- IPath coreFile = new Path(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null));
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getPath().toFile(), coreFile.toFile(), cwd, gdbinit, monitor);
- initializeLibraries(config, session);
- session.getSharedLibraryManager().update();
- return session;
- } catch (Exception e) {
- // Catch all wrap them up and rethrow
- failed = true;
- if (e instanceof CoreException) {
- throw (CoreException)e;
- }
- throw newCoreException(e);
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CoreException {
- try {
- SharedLibraryManager sharedMgr = session.getSharedLibraryManager();
- boolean autolib = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT);
- boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT);
- List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
- ICDITarget[] dtargets = session.getTargets();
- for (int i = 0; i < dtargets.length; ++i) {
- Target target = (Target)dtargets[i];
- try {
- sharedMgr.setAutoLoadSymbols(target, autolib);
- sharedMgr.setStopOnSolibEvents(target, stopOnSolibEvents);
- // The idea is that if the user set autolib, by default
- // we provide with the capability of deferred breakpoints
- // And we set setStopOnSolib events for them(but they should not see those things.
- //
- // If the user explicitly set stopOnSolibEvents well it probably
- // means that they wanted to see those events so do no do deferred breakpoints.
- if (autolib && !stopOnSolibEvents) {
- sharedMgr.setStopOnSolibEvents(target, true);
- sharedMgr.setDeferredBreakpoint(target, true);
- }
- } catch (CDIException e) {
- // Ignore this error
- // it seems to be a real problem on many gdb platform
- }
- if (p.size() > 0) {
- String[] oldPaths = sharedMgr.getSharedLibraryPaths(target);
- String[] paths = new String[oldPaths.length + p.size()];
- System.arraycopy(p.toArray(new String[p.size()]), 0, paths, 0, p.size());
- System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length);
- sharedMgr.setSharedLibraryPaths(target, paths);
- }
- }
- } catch (CDIException e) {
- throw newCoreException(MIPlugin.getResourceString("src.GDBDebugger.Error_initializing_shared_lib_options") + e.getMessage(), e); //$NON-NLS-1$
- }
- }
-
- public static IPath getProjectPath(ILaunchConfiguration configuration) throws CoreException {
- String projectName = getProjectName(configuration);
- if (projectName != null) {
- projectName = projectName.trim();
- if (projectName.length() > 0) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- IPath p = project.getLocation();
- if (p != null) {
- return p;
- }
- }
- }
- return Path.EMPTY;
- }
-
- public static String getProjectName(ILaunchConfiguration configuration) throws CoreException {
- return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
- }
-
- protected ILaunch getLauch() {
- return fLaunch;
- }
-
- protected String renderDebuggerProcessLabel(ILaunchConfiguration config) {
- String format = "{0} ({1})"; //$NON-NLS-1$
- String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
- String label = MIPlugin.getResourceString("src.GDBDebugger.Debugger_process"); //$NON-NLS-1$
- try {
- label = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- }
- catch( CoreException e ) {
- }
- return MessageFormat.format(format, new String[]{label, timestamp});
- }
-
- /**
- * Throws a core exception with an error status object built from the given
- * message, lower level exception, and error code.
- *
- * @param message
- * the status message
- * @param exception
- * lower level exception associated with the error, or
- * <code>null</code> if none
- * @param code
- * error code
- */
- protected CoreException newCoreException(Throwable exception) {
- String message = MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + exception.getMessage();//$NON-NLS-1$
- int code = ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR;
- String ID = MIPlugin.getUniqueIdentifier();
- String exMessage = ((exception==null)||(exception.getLocalizedMessage()==null)) ? new String() : exception.getLocalizedMessage();
- MultiStatus status = new MultiStatus(ID, code, message, exception);
- status.add(new Status(IStatus.ERROR, ID, code, exMessage, exception));
- return new CoreException(status);
- }
-
- protected CoreException newCoreException(String message, Throwable exception) {
- int code = ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR;
- String ID = MIPlugin.getUniqueIdentifier();
- String exMessage = ((exception==null)||(exception.getLocalizedMessage()==null)) ? new String() : exception.getLocalizedMessage();
- MultiStatus status = new MultiStatus(ID, code, message, exception);
- status.add(new Status(IStatus.ERROR, ID, code, exMessage, exception));
- return new CoreException(status);
- }
-
- protected String getMIVersion( ILaunchConfiguration config ) {
- return MIPlugin.getMIVersion( config );
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java
deleted file mode 100644
index 461154a418d..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2012 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.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.CdiResources;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.cdt.debug.mi.core.command.CLITargetAttach;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
-import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole;
-import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-import com.ibm.icu.text.MessageFormat;
-
-/**
- * Implementing the cdebugger extension point for basic launch configurations.
- */
-public class GDBCDIDebugger2 extends AbstractGDBCDIDebugger {
-
- @Override
- protected String[] getExtraArguments( ILaunchConfiguration config ) throws CoreException {
- String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN.equals( debugMode ) )
- return getRunArguments( config );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH.equals( debugMode ) )
- return getAttachArguments( config );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( debugMode ) )
- return getCoreArguments( config );
- return new String[0];
- }
-
- protected String[] getRunArguments( ILaunchConfiguration config ) throws CoreException {
- return new String[]{ getWorkingDirectory( config ), getCommandFile( config ) };
- }
-
- protected String[] getAttachArguments( ILaunchConfiguration config ) throws CoreException {
- return new String[]{ getWorkingDirectory( config ), getCommandFile( config ) };
- }
-
- protected String[] getCoreArguments( ILaunchConfiguration config ) throws CoreException {
- IPath coreFile = new Path( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null ) );
- return new String[]{ getWorkingDirectory( config ), getCommandFile( config ), "-c", coreFile.toFile().getAbsolutePath() }; //$NON-NLS-1$
- }
-
- @Override
- protected CommandFactory getCommandFactory( ILaunchConfiguration config ) throws CoreException {
- String factoryID = MIPlugin.getCommandFactory( config );
- CommandFactory factory = MIPlugin.getDefault().getCommandFactoryManager().getCommandFactory( factoryID );
- String miVersion = getMIVersion( config );
- if ( factory != null ) {
- factory.setMIVersion( miVersion );
- }
- return ( factory != null ) ? factory : new CommandFactory( miVersion );
- }
-
- public static IPath getProjectPath( ILaunchConfiguration configuration ) throws CoreException {
- String projectName = getProjectName( configuration );
- if ( projectName != null ) {
- projectName = projectName.trim();
- if ( projectName.length() > 0 ) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
- IPath p = project.getLocation();
- if ( p != null ) {
- return p;
- }
- }
- }
- return Path.EMPTY;
- }
-
- public static String getProjectName( ILaunchConfiguration configuration ) throws CoreException {
- return configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
- }
-
- protected String getMIVersion( ILaunchConfiguration config ) {
- return MIPlugin.getMIVersion( config );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- setAsyncMode( config, session );
- initializeLibraries( config, session );
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN.equals( debugMode ) )
- startLocalGDBSession( config, session, monitor );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH.equals( debugMode ) )
- startAttachGDBSession( config, session, monitor );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( debugMode ) )
- startCoreGDBSession( config, session, monitor );
- }
-
- protected void startLocalGDBSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
- // TODO: need a better solution for new-console
- MISession miSession = getMISession( session );
- try {
- CommandFactory factory = miSession.getCommandFactory();
- MIGDBSetNewConsole newConsole = factory.createMIGDBSetNewConsole();
- miSession.postCommand( newConsole );
- MIInfo info = newConsole.getMIInfo();
- if ( info == null ) {
- throw new MIException( MIPlugin.getResourceString( "src.common.No_answer" ) ); //$NON-NLS-1$
- }
- }
- catch( MIException e ) {
- // We ignore this exception, for example
- // on GNU/Linux the new-console is an error.
- }
- }
-
- protected void startAttachGDBSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
- MISession miSession = getMISession( session );
- CommandFactory factory = miSession.getCommandFactory();
- int pid = -1;
- try {
- pid = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1 );
- }
- catch( CoreException e ) {
- throw newCoreException( MIPlugin.getResourceString( "src.GDBCDIDebugger2.0" ), e ); //$NON-NLS-1$
- }
- if ( pid <= 0 ) {
- throw newCoreException( MIPlugin.getResourceString( "src.GDBCDIDebugger2.1" ), null ); //$NON-NLS-1$
- }
- try {
- CLITargetAttach attach = factory.createCLITargetAttach( pid );
- miSession.postCommand( attach );
- MIInfo info = attach.getMIInfo();
- if ( info == null ) {
- throw new MIException( MIPlugin.getResourceString( "src.common.No_answer" ) ); //$NON-NLS-1$
- }
- miSession.getMIInferior().setInferiorPID( pid );
- // @@@ for attach we nee to manually set the connected state
- // attach does not send the ^connected ack
- miSession.getMIInferior().setConnected();
- }
- catch( MIException e ) {
- throw newCoreException( MessageFormat.format( MIPlugin.getResourceString( "src.GDBCDIDebugger2.2" ), new Integer[] { new Integer( pid ) } ), e ); //$NON-NLS-1$
- }
- // @@@ We have to set the suspended state manually
- miSession.getMIInferior().setSuspended();
- miSession.getMIInferior().update();
- }
-
- protected void startCoreGDBSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
- getMISession( session ).getMIInferior().setSuspended();
- try {
- session.getSharedLibraryManager().update();
- }
- catch( CDIException e ) {
- throw newCoreException( e );
- }
- }
-
- protected MISession getMISession( Session session ) {
- ICDITarget[] targets = session.getTargets();
- if ( targets.length == 0 || !(targets[0] instanceof Target) )
- return null;
- return ((Target)targets[0]).getMISession();
- }
-
- protected void initializeLibraries( ILaunchConfiguration config, Session session ) throws CoreException {
- try {
- SharedLibraryManager sharedMgr = session.getSharedLibraryManager();
- boolean autolib = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT );
- boolean stopOnSolibEvents = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT );
- List p = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST );
- ICDITarget[] dtargets = session.getTargets();
- for( int i = 0; i < dtargets.length; ++i ) {
- Target target = (Target)dtargets[i];
- try {
- sharedMgr.setAutoLoadSymbols( target, autolib );
- sharedMgr.setStopOnSolibEvents( target, stopOnSolibEvents );
- sharedMgr.setDeferredBreakpoint( target, false );
- // The idea is that if the user set autolib, by default
- // we provide with the capability of deferred breakpoints
- // And we set setStopOnSolib events for them(but they should not see those things.
- //
- // If the user explicitly set stopOnSolibEvents well it probably
- // means that they wanted to see those events so do no do deferred breakpoints.
- if ( autolib && !stopOnSolibEvents ) {
- sharedMgr.setStopOnSolibEvents( target, true );
- sharedMgr.setDeferredBreakpoint( target, true );
- }
- }
- catch( CDIException e ) {
- // Ignore this error
- // it seems to be a real problem on many gdb platform
- }
- if ( p.size() > 0 ) {
- String[] oldPaths = sharedMgr.getSharedLibraryPaths( target );
- String[] paths = new String[oldPaths.length + p.size()];
- System.arraycopy( p.toArray( new String[p.size()] ), 0, paths, 0, p.size() );
- System.arraycopy( oldPaths, 0, paths, p.size(), oldPaths.length );
- sharedMgr.setSharedLibraryPaths( target, paths );
- }
- // use file names instead of full paths
- File[] autoSolibs = MICoreUtils.getAutoSolibs( config );
- ArrayList libs = new ArrayList( autoSolibs.length );
- for ( int j = 0; j < autoSolibs.length; ++j )
- libs.add( new File( autoSolibs[j].getName() ) );
- sharedMgr.autoLoadSymbols( (File[])libs.toArray( new File[libs.size()] ) );
- if ( !autolib && !stopOnSolibEvents )
- sharedMgr.setDeferredBreakpoint( target, libs.size() > 0 );
- }
- }
- catch( CDIException e ) {
- throw newCoreException( MIPlugin.getResourceString( "src.GDBDebugger.Error_initializing_shared_lib_options" ) + e.getMessage(), e ); //$NON-NLS-1$
- }
- }
-
- protected String getWorkingDirectory( ILaunchConfiguration config ) throws CoreException {
- IPath path = null;
- String location = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
-
- if (location != null) {
- String expandedLocation = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(location);
- if (expandedLocation.length() > 0) {
- path = new Path(expandedLocation);
- }
- }
-
- if(path == null){
- path = getProjectPath( config );
- }
-
- CommandFactory factory = getCommandFactory( config );
- return factory.getWorkingDirectory(path.toFile());
- }
-
- protected String getCommandFile( ILaunchConfiguration config ) throws CoreException {
- String gdbinit = config.getAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT );
- return (gdbinit != null && gdbinit.length() > 0) ? "--command=" + gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private void setAsyncMode( ILaunchConfiguration config, Session session ) throws CoreException {
- ICDITarget[] dtargets = session.getTargets();
- for( int i = 0; i < dtargets.length; ++i ) {
- MISession miSession = ((Target)dtargets[i]).getMISession();
- try {
- MIGDBSet setAsyncMode = miSession.getCommandFactory().createMIGDBSet(
- new String[] {
- "target-async", //$NON-NLS-1$
- "0" //$NON-NLS-1$
- } );
- miSession.postCommand( setAsyncMode );
- MIInfo info = setAsyncMode.getMIInfo();
- if (info == null) {
- throw newCoreException(new CDIException(CdiResources.getString( "cdi.Common.No_answer"))); //$NON-NLS-1$
- }
- } catch (MIException e) {
- // Earlier versions of GDB don't support "target-async".
- }
- }
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
deleted file mode 100644
index eb3cc15d84c..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 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.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugger;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.ICDISession;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-public class GDBDebugger implements ICDebugger {
-
- protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException {
- try {
- SharedLibraryManager mgr = session.getSharedLibraryManager();
- boolean autolib = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT);
- boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT);
- List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
- ICDITarget[] dtargets = session.getTargets();
- for (int i = 0; i < dtargets.length; ++i) {
- Target target = (Target)dtargets[i];
- try {
- mgr.setAutoLoadSymbols(target, autolib);
- mgr.setStopOnSolibEvents(target, stopOnSolibEvents);
- // The idea is that if the user set autolib, by default
- // we provide with the capability of deferred breakpoints
- // And we set setStopOnSolib events for them(but they should not see those things.
- //
- // If the user explicitly set stopOnSolibEvents well it probably
- // means that they wanted to see those events so do no do deferred breakpoints.
- if (autolib && !stopOnSolibEvents) {
- mgr.setStopOnSolibEvents(target, true);
- mgr.setDeferredBreakpoint(target, true);
- }
- } catch (CDIException e) {
- // Ignore this error
- // it seems to be a real problem on many gdb platform
- }
- if (p.size() > 0) {
- String[] oldPaths = mgr.getSharedLibraryPaths(target);
- String[] paths = new String[oldPaths.length + p.size()];
- System.arraycopy(p.toArray(new String[p.size()]), 0, paths, 0, p.size());
- System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length);
- mgr.setSharedLibraryPaths(target, paths);
- }
- }
- } catch (CoreException e) {
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_initializing_shared_lib_options") + e.getMessage()); //$NON-NLS-1$
- }
- }
-
- @Override
- public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi"); //$NON-NLS-1$
- File cwd = exe.getProject().getLocation().toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getLocation().toFile(), cwd, gdbinit, null);
- initializeLibraries(config, session);
- return session;
- } catch (IOException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (MIException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (CoreException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- @Override
- public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi"); //$NON-NLS-1$
- File cwd = exe.getProject().getLocation().toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getLocation().toFile(), pid, null, cwd, gdbinit, null);
- initializeLibraries(config, session);
- return session;
- } catch (IOException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (MIException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (CoreException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- @Override
- public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi"); //$NON-NLS-1$
- File cwd = exe.getProject().getLocation().toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getLocation().toFile(), corefile.toFile(), cwd, gdbinit, null);
- initializeLibraries(config, session);
- return session;
- } catch (IOException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (MIException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } catch (CoreException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBDebugger.Error_creating_session") + e.getMessage()); //$NON-NLS-1$
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java
deleted file mode 100644
index c2af3523625..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- * Alena Laskavaia (QNX) - Fix for 186172
- *******************************************************************************/
-package org.eclipse.cdt.debug.mi.core;
-
-import java.util.Map;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.RuntimeProcess;
-
-public class GDBProcess extends RuntimeProcess {
-
- // volatile because the field may be accessed concurrently during construction
- private volatile Target fTarget;
-
- public GDBProcess(Target target, ILaunch launch, Process process, String name, Map attributes) {
- super( launch, process, name, attributes );
- fTarget = target;
- fireChangeEvent();
- }
-
- public Target getTarget() {
- return fTarget;
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger.java
deleted file mode 100644
index 2de2f33adcf..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 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.File;
-import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
-import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
-import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-/**
- * Implementing cdebugger extension point
- */
-public class GDBServerCDIDebugger extends GDBCDIDebugger {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger#createLaunchSession(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public Session createLaunchSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor)
- throws CoreException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = getMIVersion(config);
- File cwd = getProjectPath(config).toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
- String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid"); //$NON-NLS-1$
- remote += ":"; //$NON-NLS-1$
- remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid"); //$NON-NLS-1$
- String[] args = new String[] {"remote", remote}; //$NON-NLS-1$
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getPath().toFile(), 0, args, cwd, gdbinit, monitor);
- } else {
- MIPlugin plugin = MIPlugin.getDefault();
- Preferences prefs = plugin.getPluginPreferences();
- int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
-
- String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); //$NON-NLS-1$
- String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid"); //$NON-NLS-1$
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getPath().toFile(), -1, null, cwd, gdbinit, monitor);
- ICDITarget[] targets = session.getTargets();
- for (int i = 0; i < targets.length; ++i) {
- Target target = (Target)targets[i];
- MISession miSession = target.getMISession();
- CommandFactory factory = miSession.getCommandFactory();
- MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud}); //$NON-NLS-1$
- // Set serial line parameters
- miSession.postCommand(setRemoteBaud, launchTimeout);
- MIInfo info = setRemoteBaud.getMIInfo();
- if (info == null) {
- throw new MIException (MIPlugin.getResourceString("src.GDBServerDebugger.Can_not_set_Baud")); //$NON-NLS-1$
- }
- MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote}); //$NON-NLS-1$
- miSession.postCommand(select, launchTimeout);
- select.getMIInfo();
- if (info == null) {
- throw new MIException (MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$
- }
- }
- }
- initializeLibraries(config, session);
- return session;
- } catch (Exception e) {
- // Catch all wrap them up and rethrow
- failed = true;
- if (e instanceof CoreException) {
- throw (CoreException)e;
- }
- throw newCoreException(e);
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger#createAttachSession(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public Session createAttachSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor)
- throws CoreException {
- String msg = MIPlugin.getResourceString("src.GDBServerDebugger.GDBServer_attaching_unsupported"); //$NON-NLS-1$
- throw newCoreException(msg, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger#createCoreSession(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public Session createCoreSession(ILaunchConfiguration config, IBinaryObject exe, IProgressMonitor monitor)
- throws CoreException {
- String msg = MIPlugin.getResourceString("src.GDBServerDebugger.GDBServer_corefiles_unsupported"); //$NON-NLS-1$
- throw newCoreException(msg, null);
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java
deleted file mode 100644
index c5d5608a602..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2012 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 org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.CdiResources;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
-import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
-import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-/**
- * Implementing the cdebugger extension point for gdbserver.
- */
-public class GDBServerCDIDebugger2 extends GDBCDIDebugger2 {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- setAsyncMode( config, session );
- initializeLibraries( config, session );
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN.equals( debugMode ) )
- startGDBServerSession( config, session, monitor );
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH.equals( debugMode ) ) {
- String msg = MIPlugin.getResourceString( "src.GDBServerDebugger.GDBServer_attaching_unsupported" ); //$NON-NLS-1$
- throw newCoreException( msg, null );
- }
- if ( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( debugMode ) ) {
- String msg = MIPlugin.getResourceString( "src.GDBServerDebugger.GDBServer_corefiles_unsupported" ); //$NON-NLS-1$
- throw newCoreException( msg, null );
- }
- }
-
- protected void startGDBServerSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- ICDITarget[] targets = session.getTargets();
- int launchTimeout = MIPlugin.getLaunchTimeout();
- boolean tcpConnection = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false );
- // Set serial line parameters
- if ( !tcpConnection ) {
- String remoteBaud = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid" ); //$NON-NLS-1$
- for( int i = 0; i < targets.length; ++i ) {
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- Target target = (Target)targets[i];
- MISession miSession = target.getMISession();
- CommandFactory factory = miSession.getCommandFactory();
- MIGDBSet setRemoteBaud = factory.createMIGDBSet( new String[]{ "remotebaud", remoteBaud } ); //$NON-NLS-1$
- // Set serial line parameters
- MIInfo info = null;
- MIException ex = null;
- try {
- // shouldn't we use the command timeout instead?
- miSession.postCommand( setRemoteBaud, launchTimeout );
- info = setRemoteBaud.getMIInfo();
- }
- catch( MIException e ) {
- ex = e;
- }
- if ( info == null ) {
- throw newCoreException( MIPlugin.getResourceString( "src.GDBServerDebugger.Can_not_set_Baud" ), ex ); //$NON-NLS-1$
- }
- }
- }
- for( int i = 0; i < targets.length; ++i ) {
- if ( monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
- Target target = (Target)targets[i];
- MISession miSession = target.getMISession();
- CommandFactory factory = miSession.getCommandFactory();
- String[] targetParams = getTargetParams( config, tcpConnection );
- MITargetSelect select = factory.createMITargetSelect( targetParams );
- MIInfo info = null;
- MIException ex = null;
- try {
- miSession.postCommand( select, launchTimeout );
- info = select.getMIInfo();
- }
- catch( MIException e ) {
- ex = e;
- }
- if ( info == null ) {
- throw newCoreException( MIPlugin.getResourceString( "src.GDBServerCDIDebugger.target_selection_failed" ), ex ); //$NON-NLS-1$
- }
- // @@@ We have to set the suspended state manually
- miSession.getMIInferior().setSuspended();
- miSession.getMIInferior().update();
- miSession.getMIInferior().setIsRemoteInferior(true);
- }
- }
-
- protected String[] getTargetParams( ILaunchConfiguration config, boolean tcpConnection ) throws CoreException {
- String remote = null;
- if ( tcpConnection ) {
- remote = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid" ); //$NON-NLS-1$
- remote += ":"; //$NON-NLS-1$
- remote += config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid" ); //$NON-NLS-1$
- }
- else {
- remote = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid" ); //$NON-NLS-1$
- }
- return new String[]{ "remote", remote }; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger#usePty(org.eclipse.debug.core.ILaunchConfiguration)
- */
- @Override
- protected boolean usePty( ILaunchConfiguration config ) throws CoreException {
- return false;
- }
-
- private void setAsyncMode( ILaunchConfiguration config, Session session ) throws CoreException {
- ICDITarget[] dtargets = session.getTargets();
- for( int i = 0; i < dtargets.length; ++i ) {
- MISession miSession = ((Target)dtargets[i]).getMISession();
- try {
- MIGDBSet setAsyncMode = miSession.getCommandFactory().createMIGDBSet(
- new String[] {
- "target-async", //$NON-NLS-1$
- "0" //$NON-NLS-1$
- } );
- miSession.postCommand( setAsyncMode );
- MIInfo info = setAsyncMode.getMIInfo();
- if (info == null) {
- throw newCoreException(new CDIException(CdiResources.getString( "cdi.Common.No_answer"))); //$NON-NLS-1$
- }
- } catch (MIException e) {
- // Earlier versions of GDB don't support "target-async".
- }
- }
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
deleted file mode 100644
index 3cc9857978a..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation 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:
- * Monta Vista - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.debug.mi.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugger;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-import org.eclipse.cdt.debug.core.cdi.ICDISession;
-import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
-import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
-import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
-import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-public class GDBServerDebugger implements ICDebugger {
-
- void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException {
- try {
- SharedLibraryManager mgr = session.getSharedLibraryManager();
- boolean autolib = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT);
- List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, new ArrayList(1));
- ICDITarget[] dtargets = session.getTargets();
- for (int i = 0; i < dtargets.length; ++i) {
- Target target = (Target)dtargets[i];
- try {
- mgr.setAutoLoadSymbols(target, autolib);
- } catch (CDIException e) {
- // ignore this one, cause problems for many gdb.
- }
- if (p.size() > 0) {
- String[] paths = (String[])p.toArray(new String[0]);
- mgr.setSharedLibraryPaths(target, paths);
- }
- }
- } catch (CoreException e) {
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.Error_initializing") + e.getMessage()); //$NON-NLS-1$
- }
- }
-
- @Override
- public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException {
- Session session = null;
- boolean failed = false;
- try {
- String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
- String miVersion = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi"); //$NON-NLS-1$
- File cwd = exe.getProject().getLocation().toFile();
- String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
- if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
- String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid"); //$NON-NLS-1$
- remote += ":"; //$NON-NLS-1$
- remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid"); //$NON-NLS-1$
- String[] args = new String[] {"remote", remote}; //$NON-NLS-1$
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getLocation().toFile(), 0, args, cwd, gdbinit, null);
- } else {
- MIPlugin plugin = MIPlugin.getDefault();
- Preferences prefs = plugin.getPluginPreferences();
- int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
-
- String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); //$NON-NLS-1$
- String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid"); //$NON-NLS-1$
- session = MIPlugin.getDefault().createCSession(gdb, miVersion, exe.getLocation().toFile(), -1, null, cwd, gdbinit, null);
- ICDITarget[] targets = session.getTargets();
- for (int i = 0; i < targets.length; ++i) {
- Target target = (Target)targets[i];
- MISession miSession = target.getMISession();
- CommandFactory factory = miSession.getCommandFactory();
- MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud}); //$NON-NLS-1$
- // Set serial line parameters
- miSession.postCommand(setRemoteBaud, launchTimeout);
- MIInfo info = setRemoteBaud.getMIInfo();
- if (info == null) {
- throw new MIException (MIPlugin.getResourceString("src.GDBServerDebugger.Can_not_set_Baud")); //$NON-NLS-1$
- }
- MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote}); //$NON-NLS-1$
- miSession.postCommand(select, launchTimeout);
- select.getMIInfo();
- if (info == null) {
- throw new MIException (MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$
- }
- }
- }
- initializeLibraries(config, session);
- return session;
- } catch (IOException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.Error_initializing") + e.getMessage()); //$NON-NLS-1$
- } catch (MIException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.Error_initializing") + e.getMessage()); //$NON-NLS-1$
- } catch (CoreException e) {
- failed = true;
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.Error_initializing") + e.getMessage()); //$NON-NLS-1$
- } finally {
- if (failed) {
- if (session != null) {
- try {
- session.terminate();
- } catch (Exception ex) {
- // ignore the exception here.
- }
- }
- }
- }
- }
-
- @Override
- public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException {
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.GDBServer_attaching_unsupported")); //$NON-NLS-1$
- }
-
- @Override
- public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
- throw new CDIException(MIPlugin.getResourceString("src.GDBServerDebugger.GDBServer_corefiles_unsupported")); //$NON-NLS-1$
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
deleted file mode 100644
index 8aaa289fa4e..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation 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:
- * Monta Vista - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.debug.mi.core;
-
-
-public interface IGDBServerMILaunchConfigurationConstants extends IMILaunchConfigurationConstants {
-
- /**
- * Launch configuration attribute key. The "remote target xxx" value.
- */
- public static final String ATTR_REMOTE_TCP = MIPlugin.getUniqueIdentifier() + ".REMOTE_TCP"; //$NON-NLS-1$
- public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$
- public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$
- public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$
- public static final String ATTR_DEV_SPEED = MIPlugin.getUniqueIdentifier() + ".DEV_SPEED"; //$NON-NLS-1$
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java
deleted file mode 100644
index 88c95ef14d8..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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;
-
-/**
- *
- * Constant definitions for GDB MI plug-in.
- *
- * @since Oct 4, 2002
- */
-public interface IMIConstants
-{
- /**
- * MI plug-in identifier (value <code>"org.eclipse.cdt.debug.mi"</code>).
- */
- public static final String PLUGIN_ID = MIPlugin.getUniqueIdentifier();
-
- /**
- * Preference key for default MI request timeout value.
- */
- public static final String PREF_REQUEST_TIMEOUT = PLUGIN_ID + ".PREF_REQUEST_TIMEOUT"; //$NON-NLS-1$
-
- /**
- * Preference key for default MI launch request timeout value.
- */
- public static final String PREF_REQUEST_LAUNCH_TIMEOUT = PLUGIN_ID + ".PREF_REQUEST_LAUNCH_TIMEOUT"; //$NON-NLS-1$
-
- /**
- * The default MI request timeout when no preference is set.
- */
- public static final int DEF_REQUEST_LAUNCH_TIMEOUT = 30000;
-
- /**
- * The default MI request timeout when no preference is set.
- */
- public static final int DEF_REQUEST_TIMEOUT = 10000;
-
- /**
- * The minimum value the MI request timeout can have.
- */
- public static final int MIN_REQUEST_TIMEOUT = 100;
-
- /**
- * The maximum value the MI request timeout can have.
- */
- public static final int MAX_REQUEST_TIMEOUT = Integer.MAX_VALUE;
-
- /**
- * Boolean preference controlling whether the shared library manager will be
- * refreshed every time when the execution of program stops.
- */
- public static final String PREF_SHARED_LIBRARIES_AUTO_REFRESH = PLUGIN_ID + ".SharedLibraries.auto_refresh"; //$NON-NLS-1$
-
- /**
- * The default value of the for <code>PREF_SHARED_LIBRARIES_AUTO_REFRESH</code> property
- */
- public static final boolean DEF_PREF_SHARED_LIBRARIES_AUTO_REFRESH = true;
-}
-
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMILaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMILaunchConfigurationConstants.java
deleted file mode 100644
index 0a0561a0bde..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMILaunchConfigurationConstants.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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;
-
-public interface IMILaunchConfigurationConstants {
- /**
- * Launch configuration attribute key. The value is the name of
- * the Debuger associated with a C/C++ launch configuration.
- */
- public static final String ATTR_DEBUG_NAME = MIPlugin.getUniqueIdentifier() + ".DEBUG_NAME"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. Boolean value to set the gdb command file
- * Debuger/gdb/MI property.
- */
- public static final String ATTR_GDB_INIT = MIPlugin.getUniqueIdentifier() + ".GDB_INIT"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. Boolean value to set the 'automatically load shared library symbols' flag of the debugger.
- */
- public static final String ATTR_DEBUGGER_AUTO_SOLIB = MIPlugin.getUniqueIdentifier() + ".AUTO_SOLIB"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. Boolean value to set the 'stop on shared library events' flag of the debugger.
- */
- public static final String ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS = MIPlugin.getUniqueIdentifier() + ".STOP_ON_SOLIB_EVENTS"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a List (array of String) of directories for the search path of shared libraries.
- */
- public static final String ATTR_DEBUGGER_SOLIB_PATH = MIPlugin.getUniqueIdentifier() + ".SOLIB_PATH"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a List (array of String) of shared libraries to load symbols automatically.
- */
- public static final String ATTR_DEBUGGER_AUTO_SOLIB_LIST = MIPlugin.getUniqueIdentifier() + ".AUTO_SOLIB_LIST"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
- */
- public static final String DEBUGGER_DEBUG_NAME_DEFAULT = "gdb"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value. The key is ATTR_GDB_INIT.
- */
- public static final String DEBUGGER_GDB_INIT_DEFAULT = ".gdbinit"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value. The key is ATTR_DEBUGGER_AUTO_SOLIB.
- */
- public static final boolean DEBUGGER_AUTO_SOLIB_DEFAULT = true;
-
- /**
- * Launch configuration attribute value. The key is ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS.
- */
- public static final boolean DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT = false;
-
- /**
- * Launch configuration attribute key. The value is a string specifying the identifier of the command factory to use.
- */
- public static final String ATTR_DEBUGGER_COMMAND_FACTORY = MIPlugin.getUniqueIdentifier() + ".commandFactory"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying the protocol to
- * use. For now only "mi", "mi1", "m2", "mi3" are supported.
- */
- public static final String ATTR_DEBUGGER_PROTOCOL = MIPlugin.getUniqueIdentifier() + ".protocol"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying the mode of the gdb console.
- */
- public static final String ATTR_DEBUGGER_VERBOSE_MODE = MIPlugin.getUniqueIdentifier() + ".verboseMode"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value. The key is ATTR_DEBUGGER_VERBOSE_MODE.
- */
- public static final boolean DEBUGGER_VERBOSE_MODE_DEFAULT = false;
- /**
- * Launch configuration attribute key. The value is a boolean specifying is debugger should use full pathname to set breakpoints.
- */
- public static final String ATTR_DEBUGGER_FULLPATH_BREAKPOINTS = MIPlugin.getUniqueIdentifier() + ".breakpointsFullPath"; //$NON-NLS-1$
-
- /**
- * Launch configuration default attribute value. The key is ATTR_DEBUGGER_FULLPATH_BREAKPOINTS.
- * To see why this default is FALSE, see bug 176636
- */
- public static final boolean DEBUGGER_FULLPATH_BREAKPOINTS_DEFAULT = false;
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MICoreUtils.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MICoreUtils.java
deleted file mode 100644
index 14e5d9d252a..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MICoreUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-/**
- * Utility methods.
- */
-public class MICoreUtils {
-
- public static File[] getAutoSolibs( ILaunchConfiguration configuration ) throws CoreException {
- List autoSolibs = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, Collections.EMPTY_LIST );
- List list = new ArrayList( autoSolibs.size() );
- Iterator it = autoSolibs.iterator();
- while( it.hasNext() ) {
- list.add( new File( (String)it.next() ) );
- }
- return (File[])list.toArray( new File[list.size()] );
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
deleted file mode 100644
index 1541c7121b7..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
+++ /dev/null
@@ -1,642 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 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.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import com.ibm.icu.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.debug.core.ICDebugConstants;
-import org.eclipse.cdt.debug.mi.core.cdi.Session;
-import org.eclipse.cdt.debug.mi.core.command.CLITargetAttach;
-import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIStackListFrames;
-import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
-import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryManager;
-import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.cdt.utils.pty.PTY;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.osgi.framework.BundleContext;
-
-/**
- * GDB/MI Plugin.
- */
-public class MIPlugin extends Plugin {
-
- /**
- * The plug-in identifier of the Java core support
- * (value <code>"org.eclipse.jdt.core"</code>).
- */
- public static final String PLUGIN_ID = "org.eclipse.cdt.debug.mi.core" ; //$NON-NLS-1$
-
- /**
- * Simple identifier constant (value <code>"commandFactories"</code>)
- * for the "gdb/mi command factories" extension point.
- *
- * @since 3.1
- */
- public static final String EXTENSION_POINT_COMMAND_FACTORIES = "commandFactories"; //$NON-NLS-1$
-
- //The shared instance.
- private static MIPlugin plugin;
-
- // GDB command
- private static final String GDB = "gdb"; //$NON-NLS-1$
-
- private static final int INTERNAL_ERROR = 42;
-
- /**
- * Has tracing for this plug-in been turned on?
- * @since 7.0
- */
- public static final boolean DEBUG = "true".equals( //$NON-NLS-1$
- Platform.getDebugOption("org.eclipse.cdt.debug.mi.core/debug")); //$NON-NLS-1$
- /**
- * The singleton command factory manager.
- */
- private CommandFactoryManager fCommandFactoryManager;
-
- private static ResourceBundle fgResourceBundle;
- static {
- try {
- fgResourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.debug.mi.core.MIPluginResources"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- fgResourceBundle = null;
- }
- }
- /**
- * The constructor
- * @see org.eclipse.core.runtime.Plugin#Plugin()
- */
- public MIPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * Returns the singleton.
- */
- public static MIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Method createMISession.
- * @param Process
- * @param PTY
- * @param int
- * @param int
- * @throws MIException
- * @return MISession
- *
- * @deprecated
- */
- @Deprecated
- public MISession createMISession(MIProcess process, IMITTY pty, int timeout, int type, int launchTimeout, String miVersion, IProgressMonitor monitor) throws MIException {
- return new MISession(process, pty, type, timeout, launchTimeout, miVersion, monitor);
- }
-
- /**
- * Method createMISession.
- * @param Process
- * @param PTY
- * @param type
- * @throws MIException
- * @return MISession
- *
- * @deprecated
- */
- @Deprecated
- public MISession createMISession(MIProcess process, IMITTY pty, int type, String miVersion, IProgressMonitor monitor) throws MIException {
- MIPlugin miPlugin = getDefault();
- Preferences prefs = miPlugin.getPluginPreferences();
- int timeout = prefs.getInt(IMIConstants.PREF_REQUEST_TIMEOUT);
- int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
- return createMISession(process, pty, timeout, type, launchTimeout, miVersion, monitor);
- }
-
- private MISession createMISession0(int type, MIProcess process, CommandFactory commandFactory, IMITTY pty, int timeout) throws MIException {
- return new MISession(process, pty, type, commandFactory, timeout);
- }
-
- /**
- * Method createCSession; Create an new PTY instance and launch gdb in mi for local debug.
- *
- * @param program
- * @return ICDISession
- * @throws MIException
- *
- * @deprecated use <code>createSession</code>
- */
- @Deprecated
- public Session createCSession(String gdb, String miVersion, File program, File cwd, String gdbinit, IProgressMonitor monitor) throws IOException, MIException {
- IMITTY pty = null;
- boolean failed = false;
-
- try {
- PTY pseudo = new PTY();
- pseudo.validateSlaveName();
- pty = new MITTYAdapter(pseudo);
- } catch (IOException e) {
- // Should we not print/log this ?
- }
-
- try {
- return createCSession(gdb, miVersion, program, cwd, gdbinit, pty, monitor);
- } catch (IOException exc) {
- failed = true;
- throw exc;
- } catch (MIException exc) {
- failed = true;
- throw exc;
- } finally {
- if (failed) {
- // Shutdown the pty console.
- if (pty != null) {
- try {
- OutputStream out = pty.getOutputStream();
- if (out != null) {
- out.close();
- }
- InputStream in = pty.getInputStream();
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- }
- }
- }
- }
- }
-
- /**
- * Method createCSession; lauch gdb in mi mode for local debugging
- * @param program
- * @return ICDISession
- * @throws IOException
- *
- * @deprecated use <code>createSession</code>
- */
- @Deprecated
- public Session createCSession(String gdb, String miVersion, File program, File cwd, String gdbinit, IMITTY pty, IProgressMonitor monitor) throws IOException, MIException {
- if (gdb == null || gdb.length() == 0) {
- gdb = GDB;
- }
-
- String commandFile = (gdbinit != null && gdbinit.length() > 0) ? "--command="+gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- String[] args;
- if (pty != null) {
- if (program == null) {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", miVersion}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- } else {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", miVersion, program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
- } else {
- if (program == null) {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "-q", "-nw", "-i", miVersion}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- } else {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "-q", "-nw", "-i", miVersion, program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- }
-
- int launchTimeout = MIPlugin.getDefault().getPluginPreferences().getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
- MIProcess pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
-
- if (MIPlugin.DEBUG) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; ++i) {
- sb.append(args[i]);
- sb.append(' ');
- }
- MIPlugin.getDefault().debugLog(sb.toString());
- }
-
- MISession session;
- try {
- session = createMISession(pgdb, pty, MISession.PROGRAM, miVersion, monitor);
- } catch (MIException e) {
- pgdb.destroy();
- throw e;
- }
- // Try to detect if we have been attach/connected via "target remote localhost:port"
- // or "attach" and set the state to be suspended.
- try {
- CommandFactory factory = session.getCommandFactory();
- MIStackListFrames frames = factory.createMIStackListFrames();
- session.postCommand(frames);
- MIInfo info = frames.getMIInfo();
- if (info == null) {
- pgdb.destroy();
- throw new MIException(getResourceString("src.common.No_answer")); //$NON-NLS-1$
- }
- //@@@ We have to manually set the suspended state since we have some stackframes
- session.getMIInferior().setSuspended();
- session.getMIInferior().update();
- } catch (MIException e) {
- // If an exception is thrown that means ok
- // we did not attach/connect to any target.
- }
- return new Session(session, false);
- }
-
- /**
- * Method createCSession; Post mortem debug with a core file.
- * @param program
- * @param core
- * @return ICDISession
- * @throws IOException
- *
- * @deprecated use <code>createSession</code>
- */
- @Deprecated
- public Session createCSession(String gdb, String miVersion, File program, File core, File cwd, String gdbinit, IProgressMonitor monitor) throws IOException, MIException {
- if (gdb == null || gdb.length() == 0) {
- gdb = GDB;
- }
-
- String commandFile = (gdbinit != null && gdbinit.length() > 0) ? "--command="+gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- String[] args;
- if (program == null) {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "--quiet", "-nw", "-i", miVersion, "-c", core.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- } else {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "--quiet", "-nw", "-i", miVersion, "-c", core.getAbsolutePath(), program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
- int launchTimeout = MIPlugin.getDefault().getPluginPreferences().getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
- MIProcess pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
-
- if (MIPlugin.DEBUG) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; ++i) {
- sb.append(args[i]);
- sb.append(' ');
- }
- MIPlugin.getDefault().debugLog(sb.toString());
- }
-
- MISession session;
- try {
- session = createMISession(pgdb, null, MISession.CORE, miVersion, monitor);
- //@@@ We have to manually set the suspended state when doing post-mortem
- session.getMIInferior().setSuspended();
- } catch (MIException e) {
- pgdb.destroy();
- throw e;
- }
- return new Session(session);
- }
-
- /**
- * Method createCSession; remote debuging by selectin a target.
- * @param program
- * @param pid
- * @return ICDISession
- * @throws IOException
- *
- * @deprecated use <code>createSession</code>
- */
- @Deprecated
- public Session createCSession(String gdb, String miVersion, File program, int pid, String[] targetParams, File cwd, String gdbinit, IProgressMonitor monitor) throws IOException, MIException {
- if (gdb == null || gdb.length() == 0) {
- gdb = GDB;
- }
-
- String commandFile = (gdbinit != null && gdbinit.length() > 0) ? "--command="+gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- String[] args;
- if (program == null) {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "--quiet", "-nw", "-i", miVersion}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- } else {
- args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), commandFile, "--quiet", "-nw", "-i", miVersion, program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- int launchTimeout = MIPlugin.getDefault().getPluginPreferences().getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
- MIProcess pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
-
- if (MIPlugin.getDefault().isDebugging()) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; ++i) {
- sb.append(args[i]);
- sb.append(' ');
- }
- MIPlugin.getDefault().debugLog(sb.toString());
- }
-
- MISession session;
- try {
- session = createMISession(pgdb, null, MISession.ATTACH, miVersion, monitor);
- } catch (MIException e) {
- pgdb.destroy();
- throw e;
- }
- CommandFactory factory = session.getCommandFactory();
- try {
- if (targetParams != null && targetParams.length > 0) {
- MITargetSelect target = factory.createMITargetSelect(targetParams);
- session.postCommand(target);
- MIInfo info = target.getMIInfo();
- if (info == null) {
- throw new MIException(getResourceString("src.common.No_answer")); //$NON-NLS-1$
- }
- }
- if (pid > 0) {
- CLITargetAttach attach = factory.createCLITargetAttach(pid);
- session.postCommand(attach);
- MIInfo info = attach.getMIInfo();
- if (info == null) {
- throw new MIException(getResourceString("src.common.No_answer")); //$NON-NLS-1$
- }
- session.getMIInferior().setInferiorPID(pid);
- // @@@ for attach we nee to manually set the connected state
- // attach does not send the ^connected ack
- session.getMIInferior().setConnected();
- }
- } catch (MIException e) {
- if(session != null)
- session.terminate();
-
- pgdb.destroy();
- throw e;
- }
- //@@@ We have to manually set the suspended state when we attach
- session.getMIInferior().setSuspended();
- session.getMIInferior().update();
- return new Session(session, true);
- }
-
- /**
- * Starts a process by executing the following command:
- * gdb -q -nw -i <mi_version>(extracted from the command factory)
- * -tty<pty_name> (if <code>usePTY</code> is <code>true</code>)
- * extraArgs program (if <code>program</code> is not <code>null</code>)
- *
- * @param sessionType the type of debugging session:
- * <code>MISession.PROGRAM</code>,
- * <code>MISession.ATTACH</code>
- * or <code>MISession.CORE</code>
- * @param gdb the name of the gdb file
- * @param factory the command set supported by gdb
- * @param program a program to debug or <code>null</code>
- * @param extraArgs arguments to pass to gdb
- * @param usePty whether to use pty or not
- * @param monitor a progress monitor
- * @return an instance of <code>ICDISession</code>
- * @throws IOException
- * @throws MIException
- */
- public Session createSession(int sessionType, String gdb, CommandFactory factory, File program, String[] extraArgs, boolean usePty, IProgressMonitor monitor) throws IOException, MIException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- if (gdb == null || gdb.length() == 0) {
- gdb = GDB;
- }
-
- IMITTY pty = null;
-
- if (usePty) {
- try {
- PTY pseudo = new PTY();
- pseudo.validateSlaveName();
- pty = new MITTYAdapter(pseudo);
- } catch (IOException e) {
- // Should we not print/log this ?
- }
- }
-
- ArrayList argList = new ArrayList(extraArgs.length + 8);
- argList.add(gdb);
- argList.add("-q"); //$NON-NLS-1$
- argList.add("-nw"); //$NON-NLS-1$
- argList.add("-i"); //$NON-NLS-1$
- argList.add(factory.getMIVersion());
- if (pty != null) {
- argList.add("-tty"); //$NON-NLS-1$
- argList.add(pty.getSlaveName());
- }
- argList.addAll(Arrays.asList(extraArgs));
- if (program != null) {
- argList.add(program.getAbsolutePath());
- }
- String[] args = (String[])argList.toArray(new String[argList.size()]);
- int launchTimeout = MIPlugin.getDefault().getPluginPreferences().getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
-
- MISession miSession = null;
- MIProcess pgdb = null;
- boolean failed = false;
- try {
- pgdb = factory.createMIProcess(args, launchTimeout, monitor);
-
- if (MIPlugin.DEBUG) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; ++i) {
- sb.append(args[i]);
- sb.append(' ');
- }
- MIPlugin.getDefault().debugLog(sb.toString());
- }
-
- miSession = createMISession0(sessionType, pgdb, factory, pty, getCommandTimeout());
- } catch (MIException e) {
- failed = true;
- throw e;
- } catch(IOException e ) {
- failed = true;
- throw e;
- } finally {
- if (failed) {
- // Kill gdb
- if ( pgdb != null )
- pgdb.destroy();
- // Shutdown the pty console.
- if (pty != null) {
- try {
- OutputStream out = pty.getOutputStream();
- if (out != null) {
- out.close();
- }
- InputStream in = pty.getInputStream();
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- }
- }
- }
- }
-
- return new Session(miSession);
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- return PLUGIN_ID;
- }
-
- public void debugLog(String message) {
- if (getDefault().isDebugging()) {
- // Time stamp
- message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } ); //$NON-NLS-1$
- // This is to verbose for a log file, better use the console.
- // getDefault().getLog().log(StatusUtil.newStatus(Status.ERROR, message, null));
- // ALERT:FIXME: For example for big buffers say 4k length,
- // the console will simply blows taking down eclipse.
- // This seems only to happen in Eclipse-gtk and Eclipse-motif
- // on GNU/Linux, so we break the lines in smaller chunks.
- while (message.length() > 100) {
- String partial = message.substring(0, 100);
- message = message.substring(100);
- System.out.println(partial + "\\"); //$NON-NLS-1$
- }
- if (message.endsWith("\n")) { //$NON-NLS-1$
- System.out.print(message);
- } else {
- System.out.println(message);
- }
- }
- }
- public static String getResourceString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- } catch (NullPointerException e) {
- return '#' + key + '#';
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- ICDebugConfiguration dc = CDebugCorePlugin.getDefault().getDefaultDefaultDebugConfiguration();
- if (dc == null) {
- CDebugCorePlugin.getDefault().getPluginPreferences().setDefault(ICDebugConstants.PREF_DEFAULT_DEBUGGER_TYPE, "org.eclipse.cdt.debug.mi.core.CDebuggerNew"); //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#shutdown()
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- savePluginPreferences();
- super.stop(context);
- }
-
- public static int getCommandTimeout() {
- Preferences prefs = getDefault().getPluginPreferences();
- return prefs.getInt(IMIConstants.PREF_REQUEST_TIMEOUT);
- }
-
- public static int getLaunchTimeout() {
- Preferences prefs = plugin.getPluginPreferences();
- return prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
- }
-
- public static String getMIVersion( ILaunchConfiguration config ) {
- String miVersion = ""; //$NON-NLS-1$
- try {
- miVersion = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "" ); //$NON-NLS-1$
- }
- catch( CoreException e ) {
- }
- if ( miVersion.length() == 0 ) {
- try {
- miVersion = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi" ); //$NON-NLS-1$
- }
- catch( CoreException e ) {
- miVersion = "mi"; //$NON-NLS-1$
- }
- }
- return miVersion;
- }
-
- public static String getCommandFactory( ILaunchConfiguration config ) {
- String commandFactory = ""; //$NON-NLS-1$
- try {
- commandFactory = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, "" ); //$NON-NLS-1$
- }
- catch( CoreException e ) {
- }
- return commandFactory;
- }
-
- public CommandFactoryManager getCommandFactoryManager() {
- if ( fCommandFactoryManager == null ) {
- fCommandFactoryManager = new CommandFactoryManager();
- }
- return fCommandFactoryManager;
- }
-
- /**
- * Log internal error
- * @param string - error message
- */
- public static void log(String string) {
- log(new Status( IStatus.ERROR, getUniqueIdentifier(), string));
- }
- /**
- * Logs the specified status with this plug-in's log.
- *
- * @param status
- * status to log
- */
- public static void log( IStatus status ) {
- getDefault().getLog().log( status );
- }
-
- /**
- * Logs an internal error with the specified throwable
- *
- * @param e
- * the exception to be logged
- */
- public static void log( Throwable e ) {
- log( new Status( IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal Error", e ) ); //$NON-NLS-1$
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPluginResources.properties b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPluginResources.properties
deleted file mode 100644
index 969a465e6c3..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPluginResources.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2006 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
-###############################################################################
-
-src.common.No_answer=No answer
-src.GDBCDIDebugger2.0=Unable to get pid.
-src.GDBCDIDebugger2.1=Invalid pid.
-src.GDBCDIDebugger2.2=Attach to process {0} failed.
-src.GDBServerDebugger.Error_initializing=Error initializing:
-src.GDBServerDebugger.Can_not_set_Baud=Can not set Baud
-src.GDBServerDebugger.GDBServer_attaching_unsupported=GDBServer does not support attaching
-src.GDBServerDebugger.GDBServer_corefiles_unsupported=GDBServer does not support core files
-src.GDBServerCDIDebugger.target_selection_failed=Target selection failed.
-src.GDBDebugger.Error_initializing_shared_lib_options=Error initializing shared library options:
-src.GDBDebugger.Error_creating_session=Error creating session:
-src.GDBDebugger.Error_launch_timeout=Launch timeout
-src.GDBDebugger.Error_launch_cancel=Launch cancel
-src.GDBDebugger.Debugger_process=Debugger Process
-src.MISession.Process_Terminated=Process Terminated
-src.MISession.Thread_Terminated={R,T}xThread terminated
-src.MISession.Target_not_suspended=Target is not suspended
-src.MISession.Session_terminated=Session terminated
-src.MISession.Inferior_Terminated=Inferior terminated
-src.MISession.Target_not_responding=Target is not responding (timed out)
-src.CygwinGDBDebugger.Error_init_shared_lib_options=Error initializing shared library options:
-src.MIInferior.target_is_suspended=target is suspended
-src.MIInferior.No_session=No MI Session
-src.MIInferior.Failed_to_interrupt=Failed to interrupt
-
-src.AbstractGDBCDIDebugger.0=Invalid session type:
-src.AbstractGDBCDIDebugger.1=Error creating session
-src.AbstractGDBCDIDebugger.2=Debugger Process
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPreferenceInitializer.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPreferenceInitializer.java
deleted file mode 100644
index 99171b0e22f..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPreferenceInitializer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2012 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 org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-
-public class MIPreferenceInitializer extends AbstractPreferenceInitializer {
-
- /**
- * Constructor for MIPreferenceInitializer.
- */
- public MIPreferenceInitializer() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- @Override
- public void initializeDefaultPreferences() {
- MIPlugin.getDefault().getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_TIMEOUT, IMIConstants.DEF_REQUEST_TIMEOUT);
- MIPlugin.getDefault().getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT);
- MIPlugin.getDefault().getPluginPreferences().setDefault(IMIConstants.PREF_SHARED_LIBRARIES_AUTO_REFRESH, IMIConstants.DEF_PREF_SHARED_LIBRARIES_AUTO_REFRESH);
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java
deleted file mode 100644
index 6c13d5a38ec..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 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 java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PushbackInputStream;
-
-import org.eclipse.cdt.utils.spawner.ProcessFactory;
-import org.eclipse.cdt.utils.spawner.Spawner;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- */
-public class MIProcessAdapter implements MIProcess {
-
- Process fGDBProcess;
- InputStream gdbInputStream;
- private static final int ONE_SECOND = 1000;
- private long commandTimeout;
-
- public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
- this(args, 0, monitor);
- }
-
- public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
- fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
- commandTimeout = MIPlugin.getCommandTimeout();
- }
-
- /**
- * Do some basic synchronisation, gdb may take some time to load for
- * whatever reasons and we need to be able to let the user bailout.
- *
- * @param args
- * @return Process
- * @throws IOException
- */
- protected Process getGDBProcess(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
- final Process pgdb = createGDBProcess(args);
- Thread syncStartup = new Thread("GDB Start") { //$NON-NLS-1$
- @Override
- public void run() {
- try {
- PushbackInputStream pb = new PushbackInputStream(pgdb.getInputStream());
- gdbInputStream = pb;
- pb.unread(pb.read()); // actually read something, then return it
- } catch (Exception e) {
- // Do nothing, ignore the errors
- }
- }
- };
- syncStartup.start();
-
- int timepass = 0;
- if (launchTimeout <= 0) {
- // Simulate we are waiting forever.
- launchTimeout = Integer.MAX_VALUE;
- }
-
- // To respect the IProgressMonitor we can not use wait/notify
- // instead we have to loop and check for the monitor to allow to cancel the thread.
- // The monitor is check every 1 second delay;
- for (timepass = 0; timepass < launchTimeout; timepass += ONE_SECOND) {
- if (syncStartup.isAlive() && !monitor.isCanceled()) {
- try {
- Thread.sleep(ONE_SECOND);
- } catch (InterruptedException e) {
- // ignore
- }
- } else {
- break;
- }
- }
- try {
- syncStartup.interrupt();
- syncStartup.join(ONE_SECOND);
- } catch (InterruptedException e) {
- // ignore
- }
- if (monitor.isCanceled()) {
- pgdb.destroy();
- throw new OperationCanceledException();
- } else if (timepass >= launchTimeout) {
- pgdb.destroy();
- String message = MIPlugin.getResourceString("src.GDBDebugger.Error_launch_timeout"); //$NON-NLS-1$
- throw new IOException(message);
- }
- return pgdb;
- }
-
- /**
- * Basic process creation hook. Subclasses may override to create the process some other way,
- * for example by setting the child process's environment.
- *
- * @param args
- * the <tt>gdb</tt> command-line
- * @return the <tt>gdb</tt> process
- * @throws IOException
- * on failure to create the child process
- *
- * @since 7.0
- */
- protected Process createGDBProcess(String[] args) throws IOException {
- return ProcessFactory.getFactory().exec(args);
- }
-
- @Override
- public boolean canInterrupt(MIInferior inferior) {
- return fGDBProcess instanceof Spawner;
- }
-
- @Override
- public void interrupt(MIInferior inferior) {
- if (fGDBProcess instanceof Spawner) {
- if (inferior.isRunning()) {
- Spawner gdbSpawner = (Spawner) fGDBProcess;
- if (inferior.isAttachedInferior() && !inferior.isRemoteInferior()) {
- // not all gdb versions forward the interrupt to an attached
- // local inferior, so interrupt the inferior directly
- interruptInferior(inferior);
- }
- else {
- // standard case (gdb launches process) and remote case (gdbserver)
- gdbSpawner.interrupt();
- }
- waitForInterrupt(inferior);
- }
- }
- }
-
- protected boolean waitForInterrupt(MIInferior inferior) {
- synchronized (inferior) {
- // Allow MI command timeout for the interrupt to propagate.
- long maxSec = commandTimeout / ONE_SECOND + 1;
- for (int i = 0; inferior.isRunning() && i < maxSec; i++) {
- try {
- inferior.wait(ONE_SECOND);
- } catch (InterruptedException e) {
- }
- }
- return inferior.isRunning();
- }
- }
-
- /**
- * 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);
- }
- }
-
- @Override
- public int exitValue() {
- return fGDBProcess.exitValue();
- }
-
- @Override
- public int waitFor() throws InterruptedException {
- return fGDBProcess.waitFor();
- }
-
- @Override
- public void destroy() {
- // We are responsible for closing the streams we have used or else
- // we will leak pipes.
- // Bug 345164
- try {
- getErrorStream().close();
- } catch (IOException e) {}
- try {
- getInputStream().close();
- } catch (IOException e) {}
- try {
- getOutputStream().close();
- } catch (IOException e) {}
-
- fGDBProcess.destroy();
- }
-
- @Override
- public InputStream getErrorStream() {
- return fGDBProcess.getErrorStream();
- }
-
- @Override
- public InputStream getInputStream() {
- return gdbInputStream;
- }
-
- @Override
- public OutputStream getOutputStream() {
- return fGDBProcess.getOutputStream();
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MITTYAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MITTYAdapter.java
deleted file mode 100644
index 6d48143988a..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MITTYAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 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.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.cdt.utils.pty.PTY;
-
-/**
- * Adapt the PTY code to IMITTY
- *
- */
-public class MITTYAdapter implements IMITTY {
-
- PTY fPty;
-
- public MITTYAdapter(PTY pty) {
- fPty = pty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.IMITTY#getSlaveName()
- */
- @Override
- public String getSlaveName() {
- return fPty.getSlaveName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.IMITTY#getOutputStream()
- */
- @Override
- public OutputStream getOutputStream() {
- return fPty.getOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.mi.core.IMITTY#getInputStream()
- */
- @Override
- public InputStream getInputStream() {
- return fPty.getInputStream();
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MinGWDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MinGWDebugger.java
deleted file mode 100644
index ac493ce9f70..00000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MinGWDebugger.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**********************************************************************
- * 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;
-
-
-/**
- * @author Doug Schaefer
- *
- */
-public class MinGWDebugger extends GDBCDIDebugger2 {
-
-}

Back to the top