Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
// support for acme; acid must be run with /acme/acid/$cputype/Acid
2
 
3
 
4
defn w(*code)
5
{
6
	local dir;
7
 
8
	printto("/tmp/acme.acid", eval code);
9
	rc("cat /tmp/acme.acid | wnew -d "+"Acid/-stk'("+itoa(pid)+")'");
10
}
11
 
12
defn procstk(pid, name)
13
{
14
	local dir;
15
 
16
	printto("/tmp/acme.acid", stk());
17
	rc("cat /tmp/acme.acid | wnew -d "+"Acid/-'"+name+"("+itoa(pid)+")'");
18
}
19
 
20
defn taskstk(tid, name)
21
{
22
	local dir;
23
 
24
	printto("/tmp/acme.acid", threadstk(tid));
25
	rc("cat /tmp/acme.acid | wnew -d "+"Acid/-"+name+"'("+itoa(pid)+")'");
26
}
27
 
28
defn _stk(pc, sp, link, dolocals)
29
{
30
	local stk;
31
 
32
	print("At pc:", pc, ":", fmt(pc, 'a'), " ");
33
	pfl(pc);
34
 
35
	stk = strace(pc, sp, link);
36
 
37
	while stk do {
38
		frame = head stk;
39
		print(fmt(frame[0], 'a'), "(");
40
		params(frame[2], frame[0]);
41
		print(") ");
42
		print("\n\tcalled from ", fmt(frame[1], 'a'), " ");
43
		pfl(frame[1]);
44
		stk = tail stk;
45
		if dolocals then
46
			locals(frame[3], frame[0]);
47
	}
48
}
49
 
50
//defn _stk(pc, sp, dolocals)
51
//{
52
//	w(__stk(pc, sp, dolocals));
53
//}
54
 
55
 
56
defn params(param, name)
57
{
58
	while param do {
59
		sym = head param;
60
		print("*", fmt(name, 'a'), ":", sym[0], "=", sym[1]);
61
		param = tail param;
62
		if param then
63
			print (",");
64
	}	
65
}
66
 
67
defn locals(l, name)
68
{
69
	local sym;
70
 
71
	while l do {
72
		sym = head l;
73
		print("\t*", fmt(name, 'a'), ":", sym[0], "=", sym[1], "\n");
74
		l = tail l;
75
	}	
76
}
77
 
78
defn bptab()					// print a table of breakpoints
79
{
80
	local lst, addr;
81
 
82
	lst = bplist;
83
	while lst do {
84
		addr = head lst;
85
		print("\tbpdel(", fmt(addr, 'a'), ")\n");
86
		lst = tail lst;
87
	}
88
}
89
 
90
defn procs()			// print status of processes
91
{
92
	local c, lst, cpid;
93
 
94
	cpid = pid;
95
	lst = proclist;
96
	while lst do {
97
		np = head lst;
98
		setproc(np);
99
		if np == cpid then
100
			print(">");
101
		print("\t", "setproc(", np, ")\t", status(np), " at ", fmt(*PC, 'a'), "\n");
102
		lst = tail lst;
103
	}
104
	pid = cpid;
105
	if pid != 0 then
106
		setproc(pid);
107
}
108
 
109
defn allstacks()			// print stacks of processes and threads
110
{
111
	complex Proc P;
112
	local T, Tq;
113
	local c, lst, cpid;
114
 
115
	cpid = pid;
116
	P = (Proc)pq.$head;
117
	while P != 0 do{
118
		Tq = (Tqueue)P.threads;
119
		T = (Thread)Tq.$head;
120
		setproc(P.pid);
121
		while T != 0 do{
122
			if(T.cmdname == 0) then taskstk(T, "unknown");
123
			else taskstk(T, *(T.cmdname\s));
124
			T = T.nextt;
125
		}
126
		P = P.next;
127
	}
128
	pid = cpid;
129
	if pid != 0 then
130
		setproc(pid);
131
}
132
 
133
print("/sys/lib/acid/acme");