blob: 11a5f31ccf1d9c5f41b3806dc3b38bacaf7a7ece (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import gdb
import weenix
import weenix.list
import weenix.proc
class ProcCommand(weenix.Command):
"""proc [<pids...>]
Prints information about the listed pids. If no
pids are listed the full process tree is printed."""
def __init__(self):
weenix.Command.__init__(self, "proc", gdb.COMMAND_DATA)
def invoke(self, args, tty):
print("invoking...")
if (len(args.strip()) == 0):
print(weenix.proc.str_proc_tree())
else:
for pid in args.split():
if (pid == "curproc"):
print(weenix.proc.curproc())
else:
print(weenix.proc.lookup(pid))
def complete(self, line, word):
print("completing...")
l = map(lambda x: str(x.pid()), weenix.proc.iter())
l.append("curproc")
l = filter(lambda x: x.startswith(word), l)
for used in line.split():
l = filter(lambda x: x != used, l)
l.sort()
return l
ProcCommand()
|