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 index b453346f794..b3a22cfff2c 100644 --- 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 @@ -55,7 +55,7 @@ public class GDBDebugger implements ICDebugger { public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException { try { String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); - CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toOSString(), pid); + CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toOSString(), pid, null); initializeLibraries(config, session); return session; } catch (IOException e) { 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 index 2e888ff7917..59e79ba8db4 100644 --- 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 @@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.CSession; 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.MITargetAttach; +import org.eclipse.cdt.debug.mi.core.command.MITargetSelect; import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.cdt.utils.spawner.ProcessFactory; @@ -135,18 +136,27 @@ public class MIPlugin extends Plugin { * @return ICDISession * @throws IOException */ - public ICDISession createCSession(String gdb, String program, int pid) throws IOException, MIException { + public ICDISession createCSession(String gdb, String program, int pid, String[] targetParams) throws IOException, MIException { if (gdb == null || gdb.length() == 0) { gdb = "gdb"; } String[] args = new String[] {gdb, "--quiet", "-nw", "-i", "mi1", program}; Process pgdb = ProcessFactory.getFactory().exec(args); MISession session = createMISession(pgdb, null, MISession.ATTACH); + MIInfo info = null; try { CommandFactory factory = session.getCommandFactory(); + if (targetParams != null && targetParams.length > 0) { + MITargetSelect target = factory.createMITargetSelect(targetParams); + session.postCommand(target); + info = target.getMIInfo(); + if (info == null) { + throw new IOException("No answer"); + } + } MITargetAttach attach = factory.createMITargetAttach(pid); session.postCommand(attach); - MIInfo info = attach.getMIInfo(); + info = attach.getMIInfo(); if (info == null) { throw new IOException("No answer"); }