|
|
1.1 root 1:
2:
3:
4:
5:
6:
7:
8: APPENDIX C
9:
10:
11: Short Subjects.
12:
13:
14:
15:
16:
17: The Garbage Collector
18:
19: The garbage collector is invoked automatically whenever
20: a collectable data type runs out. All data types are col-
21: lectable except strings and atoms are not. After a garbage
22: collection finishes, the collector will call the function
23: _g_c_a_f_t_e_r which should be a lambda of one argument. The argu-
24: ment passed to _g_c_a_f_t_e_r is the name of the data type which
25: ran out and caused the garbage collection. It is _g_c_a_f_t_e_r's
26: responsibility to allocate more pages of free space. The
27: default _g_c_a_f_t_e_r makes its decision based on the percentage
28: of space still in use after the garbage collection. If
29: there is a large percentage of space still in use, _g_c_a_f_t_e_r
30: allocates a larger amount of free space than if only a small
31: percentage of space is still in use. The default _g_c_a_f_t_e_r
32: will also print a summary of the space in use if the vari-
33: able $_g_c_p_r_i_n_t is non nil. The summary always includes the
34: state of the list and fixnum space and will include another
35: type if it caused the garbage collection. The type which
36: caused the garbage collection is preceded by an asterisk.
37:
38:
39:
40:
41: Debugging
42:
43: There are two simple functions to help you debug your
44: programs: _b_a_k_t_r_a_c_e and _s_h_o_w_s_t_a_c_k. When an error occurs (or
45: when you type the interrupt character), you will be left at
46: a break level with the state of the computation frozen in
47: the stack. At this point, calling the function _s_h_o_w_s_t_a_c_k
48: will cause the contents of the lisp evaluation stack to be
49: printed in reverse chronological order (most recent first).
50: When the programs you are running are interpreted or traced,
51: the output of _s_h_o_w_s_t_a_c_k can be very verbose. The function
52: _b_a_k_t_r_a_c_e prints a summary of what _s_h_o_w_s_t_a_c_k prints. That
53: is, if showstack would print a list, _b_a_k_t_r_a_c_e would only
54: print the first element of the list. If you are running
55: compiled code with the (_s_t_a_t_u_s _t_r_a_n_s_l_i_n_k) non nil, then fast
56: links are being made. In this case, there is not enough
57: information on the stack for _s_h_o_w_s_t_a_c_k and _b_a_k_t_r_a_c_e. Thus,
58: if you are debugging compiled code you should probably do
59: (_s_s_t_a_t_u_s _t_r_a_n_s_l_i_n_k _n_i_l).
60: 9
61:
62: 9 C-1
63:
64:
65:
66:
67:
68:
69:
70: C-2
71:
72:
73: If the contents of the stack don't tell you enough
74: about your problem, the next thing you may want to try is to
75: run your program with certain functions traced. You can
76: direct the trace package to stop program execution when it
77: enters a function, allowing you to examine the contents of
78: variables or call other functions. The trace package is
79: documented in Chapter 11.
80:
81: It is also possible to single step the evaluator and to
82: look at stack frames within lisp. The programs which per-
83: form these actions are described in Chapters 14 and 15.
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:
117:
118:
119:
120:
121:
122:
123:
124:
125: 9
126:
127: 9 Printed: July 21, 1983
128:
129:
130:
131:
132:
133:
134:
135: C-3
136:
137:
138: The Interpreter's Top Level
139:
140: The default top level interpreter for Franz, named
141: _f_r_a_n_z-_t_o_p-_l_e_v_e_l is defined in /usr/lib/lisp/toplevel.l It is
142: given control when the lisp system starts up because the
143: variable top-level is bound to the symbol _f_r_a_n_z-_t_o_p-_l_e_v_e_l.
144: The first action _f_r_a_n_z-_t_o_p-_l_e_v_e_l takes is to print out the
145: name of the current version of the lisp system. Then it
146: loads the file .lisprc from the HOME directory of the person
147: invoking the lisp system if that file exists. The .lisprc
148: file allows you to set up your own defaults, read in files,
149: set up autoloading or anything else you might want to do to
150: personalize the lisp system. Next, the top level goes into
151: a prompt-read-eval-print loop. Each time around the loop,
152: before printing the prompt it checks if the variable user-
153: top-level is bound. If so, then the value of user-top-level
154: will be _f_u_n_c_a_l_led. This provides a convenient way for a
155: user to introduce his own top level (Liszt, the lisp com-
156: piler, is an example of a program which uses this). If the
157: user types a ^D (which is the end of file character), and
158: the standard input is not from a keyboard, the lisp system
159: will exit. If the standard input is a keyboard and if the
160: value of (_s_t_a_t_u_s _i_g_n_o_r_e_e_o_f) is nil, the lisp system will
161: also exit. Otherwise the end of file will be ignored. When
162: a _r_e_s_e_t is done the current value of _e_r_r_l_i_s_t is saved away
163: and control is thrown back up to the top level where _e_v_a_l is
164: mapped over the saved value of _e_r_r_l_i_s_t.
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190: 9
191:
192: 9 Printed: July 21, 1983
193:
194:
195:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.