Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implement attach list process.

	Implement the ProcessList extension point for Solaris, by
	spawning "ps -e -o pid,arg".  This is use when
	attaching to a running process with gdb.
	
	* src/org/eclipse/cdt/internal/core/solaris:
	New Source folder created.
	* src/../internal/core/solaris/ProcessInfo.java
	src/../internal/core/solaris/ProcessList.java:
	New file implements IProcessFactory.



Index: .classpath
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.solaris/.classpath,v
retrieving revision 1.2
diff -u -r1.2 .classpath
--- .classpath	18 Sep 2002 13:48:56 -0000	1.2
+++ .classpath	15 Oct 2002 17:56:27 -0000
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+    <classpathentry kind="src" path="src"/>
     <classpathentry kind="src" path="/org.eclipse.cdt.core"/>
     <classpathentry kind="src" path="/org.eclipse.core.resources"/>
     <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
@@ -9,5 +10,5 @@
     <classpathentry kind="src" path="/org.eclipse.debug.core"/>
     <classpathentry kind="src" path="/org.eclipse.core.boot"/>
     <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
-    <classpathentry kind="output" path=""/>
+    <classpathentry kind="output" path="bin"/>
 </classpath>
Index: .cvsignore
===================================================================
RCS file: .cvsignore
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	15 Oct 2002 17:56:28 -0000
@@ -0,0 +1,2 @@
+bin
+doc
Index: ChangeLog
===================================================================
RCS file: ChangeLog
diff -N ChangeLog
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ChangeLog	15 Oct 2002 17:56:28 -0000
@@ -0,0 +1,11 @@
+2002-10-15 Alain Magloire
+
+	Implement the ProcessList extension point for Solaris, by
+	spawning "ps -e -o pid,arg".  This is use when
+	attaching to a running process with gdb.
+	
+	* src/org/eclipse/cdt/internal/core/solaris:
+	New Source folder created.
+	* src/../internal/core/solaris/ProcessInfo.java
+	src/../internal/core/solaris/ProcessList.java:
+	New file implements IProcessFactory.
\ No newline at end of file
Index: ProcessInfo.java
===================================================================
RCS file: ProcessInfo.java
diff -N ProcessInfo.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProcessInfo.java	15 Oct 2002 17:56:28 -0000
@@ -0,0 +1,45 @@
+package org.eclipse.cdt.internal.core.solaris;
+
+import org.eclipse.cdt.core.IProcessInfo;
+
+/**
+ * @author alain
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class ProcessInfo implements IProcessInfo {
+
+	int pid;
+	String name;
+	
+	public ProcessInfo(String pidString, String name) {
+		try {
+			pid = Integer.parseInt(pidString);
+		} catch (NumberFormatException e) {
+		}
+		this.name = name;
+	}
+	
+	public ProcessInfo(int pid, String name) {
+		this.pid = pid;
+		this.name = name;
+	}
+	
+	/**
+	 * @see org.eclipse.cdt.core.IProcessInfo#getName()
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.core.IProcessInfo#getPid()
+	 */
+	public int getPid() {
+		return pid;
+	}
+
+}
Index: ProcessList.java
===================================================================
RCS file: ProcessList.java
diff -N ProcessList.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ProcessList.java	15 Oct 2002 17:56:28 -0000
@@ -0,0 +1,67 @@
+package org.eclipse.cdt.internal.core.solaris;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.cdt.core.IProcessList;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+/**
+ * Insert the type's description here.
+ * @see IProcessList
+ */
+public class ProcessList implements IProcessList {
+	
+	ProcessInfo[] empty = new ProcessInfo[0];
+	
+	public ProcessList() {
+	}
+	
+	/**
+	 * Insert the method's description here.
+	 * @see IProcessList#getProcessList
+	 */
+	public IProcessInfo [] getProcessList()  {
+		Process ps;
+		BufferedReader psOutput;
+		String[] args = {"/usr/bin/ps", "-e", "-o", "pid,args"};
+
+		try {
+			ps = ProcessFactory.getFactory().exec(args);
+			psOutput = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+		} catch(Exception e) {
+			return new IProcessInfo[0];
+		}
+		
+		//Read the output and parse it into an array list
+		ArrayList procInfo = new ArrayList();
+
+		try {
+			String lastline;
+			while ((lastline = psOutput.readLine()) != null) {
+				//The format of the output should be 
+				//PID space name
+		
+				int index = lastline.indexOf(' ');
+				if (index != -1) {
+					String pidString = lastline.substring(0, index).trim();
+					try {
+						int pid = Integer.parseInt(pidString);
+						String arg = lastline.substring(index + 1);
+						procInfo.add(new ProcessInfo(pid, arg));
+					} catch (NumberFormatException e) {
+					}
+				}
+			}
+		
+		} catch(Exception e) {
+			/* Ignore */
+		}
+		
+		ps.destroy();
+		return (IProcessInfo [])procInfo.toArray(new IProcessInfo[procInfo.size()]);
+	}
+	
+}
Index: fragment.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.solaris/fragment.xml,v
retrieving revision 1.3
diff -u -r1.3 fragment.xml
--- fragment.xml	26 Sep 2002 19:18:10 -0000	1.3
+++ fragment.xml	15 Oct 2002 17:56:28 -0000
@@ -8,7 +8,14 @@
    plugin-version="1.0.0">
 
    <runtime>
+      <library name="cdt_solaris.jar"/>
    </runtime>
-
+   
+   <extension
+         point="org.eclipse.cdt.core.ProcessList">
+      <processList
+            class="org.eclipse.cdt.internal.core.solaris.ProcessList">
+      </processList>
+   </extension>
 
 </fragment>



Back to the top