mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 17:25:38 +02:00
implement for solaris ProcessList, this is use to get
a list of pid to attach in the debugger.
This commit is contained in:
parent
d049b3c0ae
commit
0440f4618e
3 changed files with 123 additions and 0 deletions
11
core/org.eclipse.cdt.core.solaris/ChangeLog
Normal file
11
core/org.eclipse.cdt.core.solaris/ChangeLog
Normal file
|
@ -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.
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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()]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue