summaryrefslogtreecommitdiff
path: root/lib/acid/rdebug
blob: be8c45f97a9d95e432ba7a693b24ca38c0ed3109 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Acid remote debug (using devdbg.c)

defn step()
{
	local ur;
	local addrs;
	local id;
	local l;
	local b;
	local bl;
	local sl;

	complex Proc proc;
	ur = proc.dbgreg;
	if ur == 0 then
		error("step: process not in breakpoint trap");
	complex Ureg ur;

	 //
	 // stop all kprocs that could potentially hit this breakpoint
	 // make a list of all the breakpoints at this address
	 //
	bl = {};
	sl = {};
	l = bpl;
	while l do {
		b = head l;
		if b[2] == ur.pc then {
			if status(b[1]) != "Stopped" then {
				stop(b[1]);
				sl = append sl, b[1];
			}
			bl = append bl, b;
		}
		l = tail l;
	}

	 //
	 // delete all the breakpoints at this address
	 //
	if bl then {
		l = bl;
		while l do {
			b = head l;
			_bpconddel(b[0]);
			l = tail l;
		}
	}

	 //
	 // single step to the following address
	 //
	addrs = follow(ur.pc);
	id = bpset(addrs[0]);
	startstop(pid);
	bpdel(id);

	 //
	 // restore all the breakpoints at this address
	 //
	if bl then {
		l = bl;
		while l do {
			b = head l;
			_bpcondset(b[0], b[1], b[2], b[3]);
			l = tail l;
		}
	}

	 //
	 // restart all kprocs that could potentially hit this breakpoint
	 //
	if sl then {
		l = sl;
		while l do {
			start(head l);
			l = tail l;
		}
	}
}

defn pstop(pid)
{
	local l;
	local pc;
	local ur;

	if nopstop then
		return {};

	complex Proc proc;
	ur = proc.dbgreg;
	complex Ureg ur;
	pc = ur.pc;

	if _breakid != -1 then {
		print("break ", _breakid\d, ": pid ");
		_breakid = -1;
	}
	print(pid,": ", status(pid), "\t");

	print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");

	if notes then {
		if notes[0] != "sys: breakpoint" then {
			print("Notes pending:\n");
			l = notes;
			while l do {
				print("\t", head l, "\n");
				l = tail l;
			}
		}
	}
}

print("$ROOT/lib/acid/rdebug");