[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Change the signature of createCSession()
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.71
diff -u -r1.71 ChangeLog
--- ChangeLog 18 Jan 2003 02:29:59 -0000 1.71
+++ ChangeLog 20 Jan 2003 20:59:15 -0000
@@ -1,3 +1,22 @@
+2003-01-20 Alain Magloire
+
+ The problem was that no check was done for the existence of
+ the program/executable nor the working directory etc ...
+ By asking the arguements to be File, the check is done by
+ the caller.
+
+ * src/.../mi/core/MIPlugin.java (createCSession): Change the
+ the arguments.
+ * src/.../mi/core/GDBDebugger.java (createCSession): Change the
+
+2003-01-20 Alain Magloire
+
+ * src/.../mi/core/command/MIWhatis.java: New file.
+ * src/.../mi/core/command/MIPType.java: New file.
+ * src/.../mi/core/command/MISharedLibary.java: New file.
+ * src/.../mi/core/output/MIWhatisInfo.java: New file.
+ * src/.../mi/core/output/MIPTypeInfo.java: New file.
+
2003-01-18 Alain Magloire
* src/.../mi/core/cdi/event/DestroyedEvent.java (DestroyedEvent):
Index: src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java,v
retrieving revision 1.10
diff -u -r1.10 GDBDebugger.java
--- src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java 17 Jan 2003 15:12:05 -0000 1.10
+++ src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java 20 Jan 2003 20:59:16 -0000
@@ -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 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 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 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) {
Index: src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java,v
retrieving revision 1.35
diff -u -r1.35 MIPlugin.java
--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 17 Jan 2003 18:33:44 -0000 1.35
+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 20 Jan 2003 20:59:16 -0000
@@ -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 @@
//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 @@
* @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 @@
* @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 @@
* @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 @@
* @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;
Index: src/org/eclipse/cdt/debug/mi/core/command/MIPType.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/MIPType.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/MIPType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/MIPType.java 20 Jan 2003 20:59:16 -0000
@@ -0,0 +1,40 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+import org.eclipse.cdt.debug.mi.core.output.MIPTypeInfo;
+
+/**
+ *
+ * ptype type
+ *
+ */
+public class MIPType extends CLICommand
+{
+ public MIPType(String var) {
+ super("ptype " + var);
+ }
+
+ public MIPTypeInfo getMIPtypeInfo() throws MIException {
+ return (MIPTypeInfo)getMIInfo();
+ }
+
+ public MIInfo getMIInfo() throws MIException {
+ MIInfo info = null;
+ MIOutput out = getMIOutput();
+ if (out != null) {
+ info = new MIPTypeInfo(out);
+ if (info.isError()) {
+ throw new MIException(info.getErrorMsg());
+ }
+ }
+ return info;
+ }
+}
Index: src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java 20 Jan 2003 20:59:16 -0000
@@ -0,0 +1,25 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+
+/**
+ *
+ * sharedlibrary regex
+ *
+ */
+public class MISharedLibrary extends CLICommand
+{
+ public MISharedLibrary(String lib) {
+ super("sharedlibrary " + lib);
+ }
+
+}
Index: src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java 20 Jan 2003 20:59:16 -0000
@@ -0,0 +1,40 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
+
+/**
+ *
+ * whatis type
+ *
+ */
+public class MIWhatis extends CLICommand
+{
+ public MIWhatis(String var) {
+ super("whatis " + var);
+ }
+
+ public MIWhatisInfo getMIWhatisInfo() throws MIException {
+ return (MIWhatisInfo)getMIInfo();
+ }
+
+ public MIInfo getMIInfo() throws MIException {
+ MIInfo info = null;
+ MIOutput out = getMIOutput();
+ if (out != null) {
+ info = new MIWhatisInfo(out);
+ if (info.isError()) {
+ throw new MIException(info.getErrorMsg());
+ }
+ }
+ return info;
+ }
+}
Index: src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java
diff -N src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java 20 Jan 2003 20:59:16 -0000
@@ -0,0 +1,48 @@
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.output;
+
+/**
+ * GDB/MI whatis parsing.
+ */
+public class MIPTypeInfo extends MIInfo {
+
+ String type;
+
+ public MIPTypeInfo(MIOutput out) {
+ super(out);
+ parse();
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ void parse() {
+ StringBuffer buffer = new StringBuffer();
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIOOBRecord[] oobs = out.getMIOOBRecords();
+ for (int i = 0; i < oobs.length; i++) {
+ if (oobs[i] instanceof MIConsoleStreamOutput) {
+ MIStreamRecord cons = (MIStreamRecord) oobs[i];
+ String str = cons.getString();
+ // We are interested in the shared info
+ if (str != null) {
+ str = str.trim();
+ if (str.startsWith ("type")) {
+ int equal = str.indexOf('=');
+ if (equal > 0) {
+ str = str.substring(equal + 1);
+ }
+ }
+ buffer.append(str);
+ }
+ }
+ }
+ }
+ type = buffer.toString().trim();
+ }
+}
Index: src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java
diff -N src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java 20 Jan 2003 20:59:16 -0000
@@ -0,0 +1,48 @@
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.output;
+
+/**
+ * GDB/MI whatis parsing.
+ */
+public class MIWhatisInfo extends MIInfo {
+
+ String type;
+
+ public MIWhatisInfo(MIOutput out) {
+ super(out);
+ parse();
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ void parse() {
+ StringBuffer buffer = new StringBuffer();
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIOOBRecord[] oobs = out.getMIOOBRecords();
+ for (int i = 0; i < oobs.length; i++) {
+ if (oobs[i] instanceof MIConsoleStreamOutput) {
+ MIStreamRecord cons = (MIStreamRecord) oobs[i];
+ String str = cons.getString();
+ // We are interested in the shared info
+ if (str != null) {
+ str = str.trim();
+ if (str.startsWith ("type")) {
+ int equal = str.indexOf('=');
+ if (equal > 0) {
+ str = str.substring(equal + 1);
+ }
+ }
+ buffer.append(str);
+ }
+ }
+ }
+ }
+ type = buffer.toString().trim();
+ }
+}