Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2012-05-09 19:17:19 +0000
committerMikhail Khodjaiants2012-05-09 19:17:19 +0000
commit9fe63ea09d83e740c0f9c96c99043362fe501885 (patch)
tree7a2e792cc1d8a720c579a46d29c5523571f8fea1 /debug
parentf1dcf178a3b981bcb9fbcf3e92c0409c1efadfd0 (diff)
downloadorg.eclipse.cdt-9fe63ea09d83e740c0f9c96c99043362fe501885.tar.gz
org.eclipse.cdt-9fe63ea09d83e740c0f9c96c99043362fe501885.tar.xz
org.eclipse.cdt-9fe63ea09d83e740c0f9c96c99043362fe501885.zip
Bug 379043 - Safer to explicitly set 'target-async off' (CDI)
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java27
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java24
2 files changed, 50 insertions, 1 deletions
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
index c58b5f482e3..cfad08fbd3b 100644
--- 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
@@ -11,7 +11,6 @@
package org.eclipse.cdt.debug.mi.core;
import java.io.File;
-import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -19,11 +18,13 @@ 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;
@@ -36,6 +37,8 @@ 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.
@@ -107,6 +110,7 @@ public class GDBCDIDebugger2 extends AbstractGDBCDIDebugger {
@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();
@@ -261,4 +265,25 @@ public class GDBCDIDebugger2 extends AbstractGDBCDIDebugger {
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/GDBServerCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java
index e61fd0031f8..37365ef3fed 100644
--- 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
@@ -11,7 +11,9 @@
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;
@@ -35,6 +37,7 @@ public class GDBServerCDIDebugger2 extends GDBCDIDebugger2 {
@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();
@@ -134,4 +137,25 @@ public class GDBServerCDIDebugger2 extends GDBCDIDebugger2 {
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".
+ }
+ }
+ }
}

Back to the top