xref: /inferno-os/module/debug.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1*46439007SCharles.ForsythDebug: module
2*46439007SCharles.Forsyth{
3*46439007SCharles.Forsyth	PATH:	con "/dis/lib/debug.dis";
4*46439007SCharles.Forsyth
5*46439007SCharles.Forsyth	Terror, Tid, Tadt, Tadtpick, Tarray, Tbig, Tbyte, Tchan, Treal,
6*46439007SCharles.Forsyth	Tfn, Targ, Tlocal, Tglobal, Tint, Tlist, Tmodule, Tnil, Tnone,
7*46439007SCharles.Forsyth	Tref, Tstring, Ttuple, Tend, Targs, Tslice, Tpoly: con iota;
8*46439007SCharles.Forsyth
9*46439007SCharles.Forsyth	Pos: adt
10*46439007SCharles.Forsyth	{
11*46439007SCharles.Forsyth		file:		string;
12*46439007SCharles.Forsyth		line:		int;		# line number: origin 1
13*46439007SCharles.Forsyth		pos:		int;		# character within the line: origin 0
14*46439007SCharles.Forsyth	};
15*46439007SCharles.Forsyth	Src: adt
16*46439007SCharles.Forsyth	{
17*46439007SCharles.Forsyth		start:		Pos;		# range within source files
18*46439007SCharles.Forsyth		stop:		Pos;
19*46439007SCharles.Forsyth	};
20*46439007SCharles.Forsyth	Id: adt
21*46439007SCharles.Forsyth	{
22*46439007SCharles.Forsyth		src:		ref Src;
23*46439007SCharles.Forsyth		name:		string;
24*46439007SCharles.Forsyth		offset:		int;		# start of pc, offset in frame, etc
25*46439007SCharles.Forsyth		stoppc:		int;		# limit pc of function
26*46439007SCharles.Forsyth		t:		cyclic ref Type;
27*46439007SCharles.Forsyth	};
28*46439007SCharles.Forsyth	Type: adt
29*46439007SCharles.Forsyth	{
30*46439007SCharles.Forsyth		src:		ref Src;
31*46439007SCharles.Forsyth		kind:		int;
32*46439007SCharles.Forsyth		size:		int;
33*46439007SCharles.Forsyth		name:		string;			# for adts, modules
34*46439007SCharles.Forsyth		Of:		cyclic ref Type;	# for lists, arrays, etc.
35*46439007SCharles.Forsyth		ids:		cyclic array of ref Id;	# for adts, etc. locals for fns
36*46439007SCharles.Forsyth		tags:		cyclic array of ref Type;# for adts with pick tags
37*46439007SCharles.Forsyth
38*46439007SCharles.Forsyth		text:		fn(t: self ref Type, sym: ref Sym): string;
39*46439007SCharles.Forsyth		getkind:	fn(t: self ref Type, sym: ref Sym): int;
40*46439007SCharles.Forsyth	};
41*46439007SCharles.Forsyth	Sym: adt
42*46439007SCharles.Forsyth	{
43*46439007SCharles.Forsyth		path:		string;
44*46439007SCharles.Forsyth		name:		string;		# implements name
45*46439007SCharles.Forsyth		src:		array of ref Src;
46*46439007SCharles.Forsyth		srcstmt:	array of int;
47*46439007SCharles.Forsyth		adts:		array of ref Type;
48*46439007SCharles.Forsyth		fns:		array of ref Id;
49*46439007SCharles.Forsyth		vars:		array of ref Id;
50*46439007SCharles.Forsyth
51*46439007SCharles.Forsyth		srctopc:	fn(s: self ref Sym, src: ref Src): int;
52*46439007SCharles.Forsyth		pctosrc:	fn(s: self ref Sym, pc: int): ref Src;
53*46439007SCharles.Forsyth	};
54*46439007SCharles.Forsyth
55*46439007SCharles.Forsyth	Module: adt
56*46439007SCharles.Forsyth	{
57*46439007SCharles.Forsyth		path:	string;		# from whence loaded
58*46439007SCharles.Forsyth		code:	int;		# address of code start
59*46439007SCharles.Forsyth		data:	int;		# address of data
60*46439007SCharles.Forsyth		comp:	int;		# compiled to native assembler?
61*46439007SCharles.Forsyth		sym:	ref Sym;
62*46439007SCharles.Forsyth
63*46439007SCharles.Forsyth		addsym:	fn(m: self ref Module, sym: ref Sym);
64*46439007SCharles.Forsyth		stdsym:	fn(m: self ref Module);
65*46439007SCharles.Forsyth		dis:	fn(m: self ref Module): string;
66*46439007SCharles.Forsyth		sbl:	fn(m: self ref Module): string;
67*46439007SCharles.Forsyth	};
68*46439007SCharles.Forsyth
69*46439007SCharles.Forsyth	StepExp, StepStmt, StepOver, StepOut: con iota;
70*46439007SCharles.Forsyth	Prog: adt
71*46439007SCharles.Forsyth	{
72*46439007SCharles.Forsyth		id:	int;
73*46439007SCharles.Forsyth		heap:	ref Sys->FD;	# prog heap file
74*46439007SCharles.Forsyth		ctl:	ref Sys->FD;	# prog control file
75*46439007SCharles.Forsyth		dbgctl:	ref Sys->FD;	# debug file
76*46439007SCharles.Forsyth		stk:	ref Sys->FD;	# stack file
77*46439007SCharles.Forsyth
78*46439007SCharles.Forsyth		status:	fn(p: self ref Prog): (int, string, string, string);
79*46439007SCharles.Forsyth		stack:	fn(p: self ref Prog): (array of ref Exp, string);
80*46439007SCharles.Forsyth		step:	fn(p: self ref Prog, how: int): string;
81*46439007SCharles.Forsyth		cont:	fn(p: self ref Prog): string;
82*46439007SCharles.Forsyth		grab:	fn(p: self ref Prog): string;
83*46439007SCharles.Forsyth		start:	fn(p: self ref Prog): string;
84*46439007SCharles.Forsyth		stop:	fn(p: self ref Prog): string;
85*46439007SCharles.Forsyth		unstop:	fn(p: self ref Prog): string;
86*46439007SCharles.Forsyth		kill:	fn(p: self ref Prog): string;
87*46439007SCharles.Forsyth		event:	fn(p: self ref Prog): string;
88*46439007SCharles.Forsyth		setbpt:	fn(p: self ref Prog, dis: string, pc: int): string;
89*46439007SCharles.Forsyth		delbpt:	fn(p: self ref Prog, dis: string, pc: int): string;
90*46439007SCharles.Forsyth	};
91*46439007SCharles.Forsyth
92*46439007SCharles.Forsyth	Exp: adt
93*46439007SCharles.Forsyth	{
94*46439007SCharles.Forsyth		name:	string;
95*46439007SCharles.Forsyth		offset:	int;
96*46439007SCharles.Forsyth		pc:	int;
97*46439007SCharles.Forsyth		m:	ref Module;
98*46439007SCharles.Forsyth		p:	ref Prog;
99*46439007SCharles.Forsyth
100*46439007SCharles.Forsyth		# this is private
101*46439007SCharles.Forsyth		id:	ref Id;
102*46439007SCharles.Forsyth
103*46439007SCharles.Forsyth		expand:	fn(e: self ref Exp): array of ref Exp;
104*46439007SCharles.Forsyth		val:	fn(e: self ref Exp): (string, int);
105*46439007SCharles.Forsyth		typename:	fn(e: self ref Exp): string;
106*46439007SCharles.Forsyth		kind: fn(e: self ref Exp): int;
107*46439007SCharles.Forsyth		src:	fn(e: self ref Exp): ref Src;
108*46439007SCharles.Forsyth		findsym:fn(e: self ref Exp): string;
109*46439007SCharles.Forsyth		srcstr:	fn(e: self ref Exp): string;
110*46439007SCharles.Forsyth	};
111*46439007SCharles.Forsyth
112*46439007SCharles.Forsyth	init:		fn(): int;
113*46439007SCharles.Forsyth	sym:		fn(sbl: string): (ref Sym, string);
114*46439007SCharles.Forsyth	prog:	fn(pid: int): (ref Prog, string);
115*46439007SCharles.Forsyth	startprog:	fn(dis, dir: string, ctxt: ref Draw->Context, argv: list of string): (ref Prog, string);
116*46439007SCharles.Forsyth};
117