1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Change the arguement of createCSession() by asking a java.io.File

we force the caller to do the check for existance of the executable
or the working directory
This commit is contained in:
Alain Magloire 2003-01-20 21:01:25 +00:00
parent 458d1e28cb
commit 9c6cdeb984
2 changed files with 52 additions and 15 deletions

View file

@ -4,6 +4,7 @@
*/
package org.eclipse.cdt.debug.mi.core;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -38,9 +39,9 @@ public class GDBDebugger implements ICDebugger {
public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException {
try {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
String cwd = exe.getProject().getLocation().toOSString();
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
CSession session = (CSession)MIPlugin.getDefault().createCSession(cwd, gdbinit, gdb, exe.getLocation().toOSString());
CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {
@ -55,9 +56,9 @@ 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");
String cwd = exe.getProject().getLocation().toOSString();
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
CSession session = (CSession)MIPlugin.getDefault().createCSession(cwd, gdbinit, gdb, exe.getLocation().toOSString(), pid, null);
CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), pid, null, cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {
@ -73,9 +74,9 @@ public class GDBDebugger implements ICDebugger {
public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
try {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
String cwd = exe.getProject().getLocation().toOSString();
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
CSession session = (CSession)MIPlugin.getDefault().createCSession(cwd, gdbinit, gdb, exe.getLocation().toOSString(), corefile.toOSString());
CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), corefile.toFile(), cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {

View file

@ -4,6 +4,7 @@
*/
package org.eclipse.cdt.debug.mi.core;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
@ -34,6 +35,9 @@ public class MIPlugin extends Plugin {
//The shared instance.
private static MIPlugin plugin;
// GDB init command file
private static final String GDBINIT = ".gdbinit";
/**
* The constructor
* @see org.eclipse.core.runtime.Plugin#Plugin(IPluginDescriptor)
@ -84,13 +88,13 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws MIException
*/
public ICDISession createCSession(String cwd, String gdbinit, String gdb, String program) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit) throws IOException, MIException {
PTY pty = null;
try {
pty = new PTY();
} catch (IOException e) {
}
return createCSession(cwd, gdbinit, gdb, program, pty);
return createCSession(gdb, program, cwd, gdbinit, pty);
}
/**
@ -99,16 +103,28 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String cwd, String gdbinit, String gdb, String program, PTY pty) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit, PTY pty) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = "gdb";
}
if (gdbinit == null || gdbinit.length() == 0) {
gdbinit = GDBINIT;
}
String[] args;
if (pty != null) {
args = new String[] {gdb, "--cd="+cwd, "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program};
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1"};
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program.getAbsolutePath()};
}
} else {
args = new String[] {gdb, "--cd="+cwd, "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program};
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1"};
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program.getAbsolutePath()};
}
}
Process pgdb = ProcessFactory.getFactory().exec(args);
@ -138,11 +154,21 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String cwd, String gdbinit, String gdb, String program, String core) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File core, File cwd, String gdbinit) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = "gdb";
}
String[] args = new String[] {gdb, "--cd="+cwd, "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program, core};
if (gdbinit == null || gdbinit.length() == 0) {
gdbinit = GDBINIT;
}
String[] args;
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath()};
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getAbsolutePath()};
}
Process pgdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(pgdb, null, MISession.CORE);
return new CSession(session);
@ -155,11 +181,21 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String cwd, String gdbinit, String gdb, String program, int pid, String[] targetParams) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = "gdb";
}
String[] args = new String[] {gdb, "--cd="+cwd, "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program};
if (gdbinit == null || gdbinit.length() == 0) {
gdbinit = GDBINIT;
}
String[] args;
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1"};
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getAbsolutePath()};
}
Process pgdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(pgdb, null, MISession.ATTACH);
MIInfo info = null;