mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 379043 - Safer to explicitly set 'target-async off' (CDI)
This commit is contained in:
parent
f1dcf178a3
commit
9fe63ea09d
2 changed files with 50 additions and 1 deletions
|
@ -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;
|
||||
|
@ -37,6 +38,8 @@ 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".
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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".
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue