Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/HISTORY
ViewVC logotype

Diff of /sml/trunk/HISTORY

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.671  
changed lines
  Added in v.678

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0