12 |
Tag: <post-commit CVS tag> |
Tag: <post-commit CVS tag> |
13 |
Description: |
Description: |
14 |
---------------------------------------------------------------------- |
---------------------------------------------------------------------- |
15 |
|
Name: Allen Leung |
16 |
|
Date: 2000/06/15 00:38:00 |
17 |
|
Tag: leunga-20000704-sparc-x86 |
18 |
|
|
19 |
|
1. x86 peephole improvement sp += k; sp -= k => nop [from John] |
20 |
|
2. fix to x86 RET bug [found by Dan Grossman] |
21 |
|
3. sparc assembly bug fix for ticc instructions [found by Fermin] |
22 |
|
|
23 |
|
Affects c-- and moby only |
24 |
|
|
25 |
|
---------------------------------------------------------------------- |
26 |
|
Name: Matthias Blume |
27 |
|
Date: 2000/07/04 15:26:00 |
28 |
|
Tag: blume-20000704-trigger |
29 |
|
Description: |
30 |
|
|
31 |
|
1. Improvements to CM manual. |
32 |
|
2. SMLofNJ.Internals.BTrace.trigger reinstated as an alternative way |
33 |
|
of getting a back-trace. The function, when called, raises an |
34 |
|
internal exception which explicitly carries the full back-trace history, |
35 |
|
so it is unaffected by any intervening handle-raise pairs ("trivial" |
36 |
|
or not). The interactive loop will print that history once it arrives |
37 |
|
at top level. |
38 |
|
Short of having all exceptions implicitly carry the full history, the |
39 |
|
recommended way of using this facility is: |
40 |
|
- compile your program with instrumentation "on" |
41 |
|
- run it, when it raises an exception, look at the history |
42 |
|
- if the history is "cut off" because of some handler, go and modify |
43 |
|
your program so that it explicitly calls BTrace.trigger |
44 |
|
- recompile (still instrumented), and rerun; look at the full history |
45 |
|
|
46 |
|
---------------------------------------------------------------------- |
47 |
|
Name: Matthias Blume |
48 |
|
Date: 2000/07/03 15:36:00 JST |
49 |
|
Tag: blume-20000702-manual |
50 |
|
Description: |
51 |
|
|
52 |
|
Small corrections and updates to CM manual. |
53 |
|
|
54 |
|
---------------------------------------------------------------------- |
55 |
|
Name: Matthias Blume |
56 |
|
Date: 2000/06/29 16:04:00 JST |
57 |
|
Tag: blume-20000629-yacctool |
58 |
|
Description: |
59 |
|
|
60 |
|
Changes: |
61 |
|
|
62 |
|
1. Class "mlyacc" now takes separate arguments to pass options to |
63 |
|
generated .sml- and .sig-files independently. |
64 |
|
2. Corresponding CM manual updates. |
65 |
|
3. BTrace module now also reports call sites. (However, for loop clusters |
66 |
|
it only shows from where the cluster was entered.) There are associated |
67 |
|
modifications to core.sml, internals.{sig,sml}, btrace.sml, and btimp.sml. |
68 |
|
|
69 |
|
---------------------------------------------------------------------- |
70 |
|
Name: Matthias Blume |
71 |
|
Date: 2000/06/27 16:51:00 JST |
72 |
|
Tag: blume-20000627-noweb |
73 |
|
Description: |
74 |
|
|
75 |
|
Changes: |
76 |
|
|
77 |
|
1. Implemented "subdir" and "witness" options for noweb tool. |
78 |
|
This caused some slight internal changes in CM's tool implementation. |
79 |
|
2. Fixed bug in "tool plugin" mechanism. This is essentially cleaning |
80 |
|
some remaining issues from earlier path anchor changes. |
81 |
|
3. Updated CM manual accordingly. |
82 |
|
|
83 |
|
4. Changed implementation of back-tracing so that I now consider it |
84 |
|
ready for prime-time. |
85 |
|
|
86 |
|
In particular, you don't have to explicitly trigger the back-trace |
87 |
|
anymore. Instead, if you are running BTrace-instrumented code and |
88 |
|
there is an uncaught exception (regardless of whether or not it was |
89 |
|
raised in instrumented code), the top-level evalloop will print |
90 |
|
the back-trace. |
91 |
|
|
92 |
|
Features: |
93 |
|
|
94 |
|
- Instrumented and uninstrumented code work together seemlessly. |
95 |
|
(Of course, uninstrumented code is never mentioned in actual |
96 |
|
back-traces.) |
97 |
|
|
98 |
|
- Asymptotic time- and space-complexity of instrumented code is |
99 |
|
equal to that of uninstrumented code. (This means that |
100 |
|
tail-recursion is preserved by the instrumentation phase.) |
101 |
|
|
102 |
|
- Modules whose code has been instrumented in different sessions |
103 |
|
work together without problem. |
104 |
|
|
105 |
|
- There is no penalty whatsoever on uninstrumented code. |
106 |
|
|
107 |
|
- There is no penalty on "raise" expressions, even in |
108 |
|
instrumented code. |
109 |
|
|
110 |
|
A potential bug (or perhaps it is a feature, too): |
111 |
|
|
112 |
|
A back-trace reaches no further than the outermost instrumented |
113 |
|
non-trivial "raise". Here, a "trivial" raise is one that is the |
114 |
|
sole RHS of a "handle" rule. Thus, back-traces reach trough |
115 |
|
|
116 |
|
<exp> handle e => raise e |
117 |
|
|
118 |
|
and even |
119 |
|
|
120 |
|
<exp> handle Foo => raise Bar |
121 |
|
|
122 |
|
and, of course, through |
123 |
|
|
124 |
|
<exp> handle Foo => ... |
125 |
|
|
126 |
|
if the exception was not Foo. |
127 |
|
|
128 |
|
Back-traces always reach right through any un-instrumented code |
129 |
|
including any of its "handle" expressions, trivial or not. |
130 |
|
|
131 |
|
To try this out, do the following: |
132 |
|
|
133 |
|
- Erase all existing binfiles for your program. |
134 |
|
(You may keep binfiles for those modules where you think you |
135 |
|
definitely don't need back-tracing.) |
136 |
|
- Turn on back-trace instrumentation: |
137 |
|
SMLofNJ.Internals.BTrace.mode (SOME true); |
138 |
|
- Recompile your program. (I.e., run "CM.make" or "use".) |
139 |
|
- You may now turn instrumentation off again (if you want): |
140 |
|
SMLofNJ.Internals.BTrace.mode (SOME false); |
141 |
|
- Run your program as usual. If it raises an exception that |
142 |
|
reaches the interactive toplevel, then a back-trace will |
143 |
|
automatically be printed. After that, the toplevel loop |
144 |
|
will print the exception history as usual. |
145 |
|
|
146 |
|
---------------------------------------------------------------------- |
147 |
|
Name: Matthias Blume |
148 |
|
Date: 2000/06/26 09:56:46 JST |
149 |
|
Tag: blume-20000626-setup |
150 |
|
Description: |
151 |
|
|
152 |
|
CM: - setup-parameter to "sml" added; this can be used to run arbitrary |
153 |
|
ML code before and after compiling a file (e.g., to set compiler |
154 |
|
flags) |
155 |
|
|
156 |
|
Compiler: - improved btrace API (in core.sml, internals.{sig,sml}) |
157 |
|
- associated changes to btrace.sml (BTrace instrumentation pass) |
158 |
|
- cleaner implementation of btimp.sml (BTrace tracing and report |
159 |
|
module) |
160 |
|
|
161 |
|
CM manual: * new path encoding documented |
162 |
|
* description of setup-parameter to "sml" added |
163 |
|
|
164 |
|
The biggest user-visible change to back-tracing is that it is no |
165 |
|
longer necessary to compile all traced modules within the same |
166 |
|
session. (This was a real limitation.) |
167 |
|
|
168 |
|
---------------------------------------------------------------------- |
169 |
|
Name: Matthias Blume |
170 |
|
Date: 2000/06/24 12:40:00 JST |
171 |
|
Tag: blume-20000624-startup |
172 |
|
Description: |
173 |
|
|
174 |
|
Fixes startup slowdown problem. (I was calling SrcPath.sync a _tad_ |
175 |
|
bit too often -- to put it mildly. :) |
176 |
|
|
177 |
|
---------------------------------------------------------------------- |
178 |
|
Name: Matthias Blume |
179 |
|
Date: 2000/06/23 18:20:00 JST |
180 |
|
Tag: blume-20000623-btrace |
181 |
|
Description: |
182 |
|
|
183 |
|
This updates adds a backtrace facility to aid programmers in debugging |
184 |
|
their programs. This involves the following changes: |
185 |
|
|
186 |
|
1. Module system/smlnj/init/core.sml (structure _Core) now has hooks for |
187 |
|
keeping track of the current call stack. When programs are compiled |
188 |
|
in a special mode, the compiler will insert calls to these hooks |
189 |
|
into the user program. |
190 |
|
"Hook" means that it is possible for different implementations of |
191 |
|
back-tracing to register themselves (at different times). |
192 |
|
|
193 |
|
2. compiler/MiscUtil/profile/btrace.sml implements the annotation phase |
194 |
|
as an Absyn.dec->Absyn.dec rewrite. Normally this phase is turned off. |
195 |
|
It can be turned on using this call: |
196 |
|
SMLofNJ.Internals.BTrace.mode (SOME true); |
197 |
|
Turning it off again: |
198 |
|
SMLofNJ.Internals.BTrace.mode (SOME false); |
199 |
|
Querying the current status: |
200 |
|
SMLofNJ.Internals.BTrace.mode NONE; |
201 |
|
Annotated programs are about twice as big as normal ones, and they |
202 |
|
run a factor of 2 to 4 slower with a dummy back-trace plugin (one |
203 |
|
where all hooks do nothing). The slowdown with a plugin that is |
204 |
|
actually useful (such as the one supplied by default) is even greater, |
205 |
|
but in the case of the default plugin it is still only an constant |
206 |
|
factor (amortized). |
207 |
|
|
208 |
|
3. system/Basis/Implementation/NJ/internals.{sig,sml} have been augmented |
209 |
|
with a sub-structure BTrace for controlling back-tracing. In particular, |
210 |
|
the above-mentioned function "mode" controls whether the annotation |
211 |
|
phase is invoked by the compiler. Another important function is |
212 |
|
"trigger": when called it aborts the current execution and causes |
213 |
|
the top-level loop to print a full back-trace. |
214 |
|
|
215 |
|
4. compiler/MiscUtil/profile/btimp.sml is the current default plugin |
216 |
|
for back-tracing. It keeps track of the dynamic call stack and in |
217 |
|
addition to that it keeps a partial history at each "level" of that |
218 |
|
stack. For example, if a tail-calls b, b tail-calls c, and c tail-calls |
219 |
|
d and b (at separate times, dynamically), then the report will show: |
220 |
|
|
221 |
|
GOTO d |
222 |
|
/c |
223 |
|
GOTO \b |
224 |
|
CALL a |
225 |
|
|
226 |
|
This shows that there was an initial non-tail call of a, then a |
227 |
|
tail-call to b or c, looping behavior in a cluster of functions that |
228 |
|
consist of b and c, and then a goto from that cluster (i.e., either from |
229 |
|
b or from c) to d. |
230 |
|
|
231 |
|
Note that (depending on the user program) the amount of information |
232 |
|
that the back-trace module has to keep track of at each level is bounded |
233 |
|
by a constant. Thus, the whole implementation has the same asymptotical |
234 |
|
complexity as the original program (both in space and in time). |
235 |
|
|
236 |
|
5. compiler/TopLevel/interact/evalloop.sml has been modified to |
237 |
|
handle the special exception SMLofNJ.Internals.BTrace.BTrace |
238 |
|
which is raised by the "trigger" function mentioned above. |
239 |
|
|
240 |
|
Notes on usage: |
241 |
|
|
242 |
|
- Annotated code works well together with unannotated code: |
243 |
|
Unannotated calls simply do not show up at all in the backtrace. |
244 |
|
|
245 |
|
- It is not a good idea to let modules that were annotated during |
246 |
|
different sessions run at the same time. This is because the compiler |
247 |
|
chooses small integers to identify individual functions, and there |
248 |
|
will be clashes if different modules were compiled in separate sessions. |
249 |
|
(Nothing will crash, and you will even be told about the clashes, but |
250 |
|
back-trace information will in general not be useful.) |
251 |
|
|
252 |
|
- Back-tracing can be confused by callcc and capture. |
253 |
|
|
254 |
|
- The only way of getting a back-trace right now is to explicitly |
255 |
|
invoke the "trigger" function from your user program. Eventually, we |
256 |
|
should make every exception carry back-trace information (if |
257 |
|
available). But since this creates more overhead at "raise"-time |
258 |
|
(similar to the current exnHistory overhead), I have not yet |
259 |
|
implemented this. (The implementation will be rather easy.) With |
260 |
|
exceptions carrying back-trace information, this facility will be even |
261 |
|
more useful because users don't need to modify their programs... |
262 |
|
|
263 |
|
- While it is possible to compile the compiler with back-trace |
264 |
|
annotations turned on (I did it to get some confidence in |
265 |
|
correctness), you must make absolutely sure that core.sml and |
266 |
|
btimp.sml are compiled WITHOUT annotation! (core.sml cannot actually |
267 |
|
be compiled with annotation because there is no core access yet, but |
268 |
|
if you compile btimp.sml with annotation, then the system will go into |
269 |
|
an infinite recursion and crash.) |
270 |
|
Since CM currently does not know about BTrace, the only way to turn |
271 |
|
annotations on and off for different modules of the compiler is to |
272 |
|
interrupt CMB.make, change the settings, and re-invoke it. Of course, |
273 |
|
this is awkward and clumsy. |
274 |
|
|
275 |
|
Sample sessions: |
276 |
|
|
277 |
|
Standard ML of New Jersey v110.28.1 [FLINT v1.5], June 5, 2000 |
278 |
|
- SMLofNJ.Internals.BTrace.mode (SOME true); |
279 |
|
[autoloading] |
280 |
|
[autoloading done] |
281 |
|
val it = false : bool |
282 |
|
- structure X = struct |
283 |
|
- fun main n = let |
284 |
|
- fun a (x, 0) = d x |
285 |
|
- | a (x, n) = b (x, n - 1) |
286 |
|
- and b (x, n) = c (x, n) |
287 |
|
- and c (x, n) = a (x, n) |
288 |
|
- and d x = e (x, 3) |
289 |
|
- and e (x, 0) = f x |
290 |
|
- | e (x, n) = e (x, n - 1) |
291 |
|
- and f 0 = SMLofNJ.Internals.BTrace.trigger () |
292 |
|
- | f n = n * g (n - 1) |
293 |
|
- and g n = a (n, 3) |
294 |
|
- in |
295 |
|
- f n |
296 |
|
- end |
297 |
|
- end; |
298 |
|
structure X : sig val main : int -> int end |
299 |
|
- X.main 3; |
300 |
|
*** BACK-TRACE *** |
301 |
|
GOTO stdIn:4.2-13.20: X.main[2].f |
302 |
|
GOTO-( stdIn:4.2-13.20: X.main[2].e |
303 |
|
GOTO stdIn:4.2-13.20: X.main[2].d |
304 |
|
/ stdIn:4.2-13.20: X.main[2].a |
305 |
|
| stdIn:4.2-13.20: X.main[2].b |
306 |
|
GOTO-\ stdIn:4.2-13.20: X.main[2].c |
307 |
|
CALL stdIn:4.2-13.20: X.main[2].g |
308 |
|
GOTO stdIn:4.2-13.20: X.main[2].f |
309 |
|
GOTO-( stdIn:4.2-13.20: X.main[2].e |
310 |
|
GOTO stdIn:4.2-13.20: X.main[2].d |
311 |
|
/ stdIn:4.2-13.20: X.main[2].a |
312 |
|
| stdIn:4.2-13.20: X.main[2].b |
313 |
|
GOTO-\ stdIn:4.2-13.20: X.main[2].c |
314 |
|
CALL stdIn:4.2-13.20: X.main[2].g |
315 |
|
GOTO stdIn:4.2-13.20: X.main[2].f |
316 |
|
GOTO-( stdIn:4.2-13.20: X.main[2].e |
317 |
|
GOTO stdIn:4.2-13.20: X.main[2].d |
318 |
|
/ stdIn:4.2-13.20: X.main[2].a |
319 |
|
| stdIn:4.2-13.20: X.main[2].b |
320 |
|
GOTO-\ stdIn:4.2-13.20: X.main[2].c |
321 |
|
CALL stdIn:4.2-13.20: X.main[2].g |
322 |
|
GOTO stdIn:4.2-13.20: X.main[2].f |
323 |
|
CALL stdIn:2.15-17.4: X.main[2] |
324 |
|
- |
325 |
|
|
326 |
|
(Note that because of a FLINt bug the above code currently does not |
327 |
|
compile without BTrace turned on.) |
328 |
|
|
329 |
|
Here is another example, using my modified Tiger compiler: |
330 |
|
|
331 |
|
Standard ML of New Jersey v110.28.1 [FLINT v1.5], June 5, 2000 |
332 |
|
- SMLofNJ.Internals.BTrace.mode (SOME true); |
333 |
|
[autoloading] |
334 |
|
[autoloading done] |
335 |
|
val it = false : bool |
336 |
|
- CM.make "sources.cm"; |
337 |
|
[autoloading] |
338 |
|
... |
339 |
|
[autoloading done] |
340 |
|
[scanning sources.cm] |
341 |
|
[parsing (sources.cm):parse.sml] |
342 |
|
[creating directory CM/SKEL ...] |
343 |
|
[parsing (sources.cm):tiger.lex.sml] |
344 |
|
... |
345 |
|
[wrote CM/sparc-unix/semant.sml] |
346 |
|
[compiling (sources.cm):main.sml] |
347 |
|
[wrote CM/sparc-unix/main.sml] |
348 |
|
[New bindings added.] |
349 |
|
val it = true : bool |
350 |
|
- Main.compile ("../testcases/merge.tig", "foo.out"); |
351 |
|
*** BACK-TRACE *** |
352 |
|
CALL lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trvar |
353 |
|
CALL lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp |
354 |
|
CALL lib/semant.sml:289.3-295.22: SemantFun[2].transExp.trexp.check[2] |
355 |
|
GOTO lib/semant.sml:289.3-295.22: SemantFun[2].transExp.trexp.check[2] |
356 |
|
CALL lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp |
357 |
|
CALL lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp |
358 |
|
CALL lib/semant.sml:488.3-505.6: SemantFun[2].transDec.trdec[2].transBody[2] |
359 |
|
/ lib/semant.sml:411.65-543.8: SemantFun[2].transDec |
360 |
|
CALL-\ lib/semant.sml:413.2-540.9: SemantFun[2].transDec.trdec[2] |
361 |
|
CALL lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp |
362 |
|
CALL lib/semant.sml:8.52-558.4: SemantFun[2].transProg[2] |
363 |
|
CALL main.sml:1.18-118.4: Main.compile[2] |
364 |
|
- |
365 |
|
|
366 |
|
---------------------------------------------------------------------- |
367 |
Name: Matthias Blumen |
Name: Matthias Blumen |
368 |
Date: 2000/06/21 18:00:00 JST |
Date: 2000/06/21 18:00:00 JST |
369 |
Tag: blume-20000621-manual |
Tag: blume-20000621-manual |