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 670, Sun Jun 18 13:10:57 2000 UTC revision 676, Sat Jun 24 03:37:03 2000 UTC
# Line 13  Line 13 
13  Description:  Description:
14  ----------------------------------------------------------------------  ----------------------------------------------------------------------
15  Name: Matthias Blume  Name: Matthias Blume
16    Date: 2000/06/24 12:40:00 JST
17    Tag: blume-20000624-startup
18    Description:
19    
20    Fixes startup slowdown problem.  (I was calling SrcPath.sync a _tad_
21    bit too often -- to put it mildly. :)
22    
23    ----------------------------------------------------------------------
24    Name: Matthias Blume
25    Date: 2000/06/23 18:20:00 JST
26    Tag: blume-20000623-btrace
27    Description:
28    
29    This updates adds a backtrace facility to aid programmers in debugging
30    their programs.  This involves the following changes:
31    
32    1. Module system/smlnj/init/core.sml (structure _Core) now has hooks for
33       keeping track of the current call stack.  When programs are compiled
34       in a special mode, the compiler will insert calls to these hooks
35       into the user program.
36       "Hook" means that it is possible for different implementations of
37       back-tracing to register themselves (at different times).
38    
39    2. compiler/MiscUtil/profile/btrace.sml implements the annotation phase
40       as an Absyn.dec->Absyn.dec rewrite.  Normally this phase is turned off.
41       It can be turned on using this call:
42         SMLofNJ.Internals.BTrace.mode (SOME true);
43       Turning it off again:
44         SMLofNJ.Internals.BTrace.mode (SOME false);
45       Querying the current status:
46         SMLofNJ.Internals.BTrace.mode NONE;
47       Annotated programs are about twice as big as normal ones, and they
48       run a factor of 2 to 4 slower with a dummy back-trace plugin (one
49       where all hooks do nothing).  The slowdown with a plugin that is
50       actually useful (such as the one supplied by default) is even greater,
51       but in the case of the default plugin it is still only an constant
52       factor (amortized).
53    
54    3. system/Basis/Implementation/NJ/internals.{sig,sml} have been augmented
55       with a sub-structure BTrace for controlling back-tracing.  In particular,
56       the above-mentioned function "mode" controls whether the annotation
57       phase is invoked by the compiler.  Another important function is
58       "trigger": when called it aborts the current execution and causes
59       the top-level loop to print a full back-trace.
60    
61    4. compiler/MiscUtil/profile/btimp.sml is the current default plugin
62       for back-tracing.  It keeps track of the dynamic call stack and in
63       addition to that it keeps a partial history at each "level" of that
64       stack.  For example, if a tail-calls b, b tail-calls c, and c tail-calls
65       d and b (at separate times, dynamically), then the report will show:
66    
67       GOTO   d
68             /c
69       GOTO  \b
70       CALL   a
71    
72       This shows that there was an initial non-tail call of a, then a
73       tail-call to b or c, looping behavior in a cluster of functions that
74       consist of b and c, and then a goto from that cluster (i.e., either from
75       b or from c) to d.
76    
77       Note that (depending on the user program) the amount of information
78       that the back-trace module has to keep track of at each level is bounded
79       by a constant.  Thus, the whole implementation has the same asymptotical
80       complexity as the original program (both in space and in time).
81    
82    5. compiler/TopLevel/interact/evalloop.sml has been modified to
83       handle the special exception SMLofNJ.Internals.BTrace.BTrace
84       which is raised by the "trigger" function mentioned above.
85    
86    Notes on usage:
87    
88    - Annotated code works well together with unannotated code:
89    Unannotated calls simply do not show up at all in the backtrace.
90    
91    - It is not a good idea to let modules that were annotated during
92    different sessions run at the same time.  This is because the compiler
93    chooses small integers to identify individual functions, and there
94    will be clashes if different modules were compiled in separate sessions.
95    (Nothing will crash, and you will even be told about the clashes, but
96    back-trace information will in general not be useful.)
97    
98    - Back-tracing can be confused by callcc and capture.
99    
100    - The only way of getting a back-trace right now is to explicitly
101    invoke the "trigger" function from your user program.  Eventually, we
102    should make every exception carry back-trace information (if
103    available).  But since this creates more overhead at "raise"-time
104    (similar to the current exnHistory overhead), I have not yet
105    implemented this.  (The implementation will be rather easy.)  With
106    exceptions carrying back-trace information, this facility will be even
107    more useful because users don't need to modify their programs...
108    
109    - While it is possible to compile the compiler with back-trace
110    annotations turned on (I did it to get some confidence in
111    correctness), you must make absolutely sure that core.sml and
112    btimp.sml are compiled WITHOUT annotation!  (core.sml cannot actually
113    be compiled with annotation because there is no core access yet, but
114    if you compile btimp.sml with annotation, then the system will go into
115    an infinite recursion and crash.)
116    Since CM currently does not know about BTrace, the only way to turn
117    annotations on and off for different modules of the compiler is to
118    interrupt CMB.make, change the settings, and re-invoke it.  Of course,
119    this is awkward and clumsy.
120    
121    Sample sessions:
122    
123    Standard ML of New Jersey v110.28.1 [FLINT v1.5], June 5, 2000
124    - SMLofNJ.Internals.BTrace.mode (SOME true);
125    [autoloading]
126    [autoloading done]
127    val it = false : bool
128    - structure X = struct
129    -     fun main n = let
130    -         fun a (x, 0) = d x
131    -           | a (x, n) = b (x, n - 1)
132    -         and b (x, n) = c (x, n)
133    -         and c (x, n) = a (x, n)
134    -         and d x = e (x, 3)
135    -         and e (x, 0) = f x
136    -           | e (x, n) = e (x, n - 1)
137    -         and f 0 = SMLofNJ.Internals.BTrace.trigger ()
138    -           | f n = n * g (n - 1)
139    -         and g n = a (n, 3)
140    -     in
141    -         f n
142    -     end
143    - end;
144    structure X : sig val main : int -> int end
145    - X.main 3;
146    *** BACK-TRACE ***
147    GOTO   stdIn:4.2-13.20: X.main[2].f
148    GOTO-( stdIn:4.2-13.20: X.main[2].e
149    GOTO   stdIn:4.2-13.20: X.main[2].d
150         / stdIn:4.2-13.20: X.main[2].a
151         | stdIn:4.2-13.20: X.main[2].b
152    GOTO-\ stdIn:4.2-13.20: X.main[2].c
153    CALL   stdIn:4.2-13.20: X.main[2].g
154    GOTO   stdIn:4.2-13.20: X.main[2].f
155    GOTO-( stdIn:4.2-13.20: X.main[2].e
156    GOTO   stdIn:4.2-13.20: X.main[2].d
157         / stdIn:4.2-13.20: X.main[2].a
158         | stdIn:4.2-13.20: X.main[2].b
159    GOTO-\ stdIn:4.2-13.20: X.main[2].c
160    CALL   stdIn:4.2-13.20: X.main[2].g
161    GOTO   stdIn:4.2-13.20: X.main[2].f
162    GOTO-( stdIn:4.2-13.20: X.main[2].e
163    GOTO   stdIn:4.2-13.20: X.main[2].d
164         / stdIn:4.2-13.20: X.main[2].a
165         | stdIn:4.2-13.20: X.main[2].b
166    GOTO-\ stdIn:4.2-13.20: X.main[2].c
167    CALL   stdIn:4.2-13.20: X.main[2].g
168    GOTO   stdIn:4.2-13.20: X.main[2].f
169    CALL   stdIn:2.15-17.4: X.main[2]
170    -
171    
172    (Note that because of a FLINt bug the above code currently does not
173    compile without BTrace turned on.)
174    
175    Here is another example, using my modified Tiger compiler:
176    
177    Standard ML of New Jersey v110.28.1 [FLINT v1.5], June 5, 2000
178    - SMLofNJ.Internals.BTrace.mode (SOME true);
179    [autoloading]
180    [autoloading done]
181    val it = false : bool
182    - CM.make "sources.cm";
183    [autoloading]
184    ...
185    [autoloading done]
186    [scanning sources.cm]
187    [parsing (sources.cm):parse.sml]
188    [creating directory CM/SKEL ...]
189    [parsing (sources.cm):tiger.lex.sml]
190    ...
191    [wrote CM/sparc-unix/semant.sml]
192    [compiling (sources.cm):main.sml]
193    [wrote CM/sparc-unix/main.sml]
194    [New bindings added.]
195    val it = true : bool
196    - Main.compile ("../testcases/merge.tig", "foo.out");
197    *** BACK-TRACE ***
198    CALL   lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trvar
199    CALL   lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp
200    CALL   lib/semant.sml:289.3-295.22: SemantFun[2].transExp.trexp.check[2]
201    GOTO   lib/semant.sml:289.3-295.22: SemantFun[2].transExp.trexp.check[2]
202    CALL   lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp
203    CALL   lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp
204    CALL   lib/semant.sml:488.3-505.6: SemantFun[2].transDec.trdec[2].transBody[2]
205         / lib/semant.sml:411.65-543.8: SemantFun[2].transDec
206    CALL-\ lib/semant.sml:413.2-540.9: SemantFun[2].transDec.trdec[2]
207    CALL   lib/semant.sml:99.2-396.21: SemantFun[2].transExp.trexp
208    CALL   lib/semant.sml:8.52-558.4: SemantFun[2].transProg[2]
209    CALL   main.sml:1.18-118.4: Main.compile[2]
210    -
211    
212    ----------------------------------------------------------------------
213    Name: Matthias Blumen
214    Date: 2000/06/21 18:00:00 JST
215    Tag: blume-20000621-manual
216    Description:
217    
218    CM manual update: Path environments documented.
219    
220    ----------------------------------------------------------------------
221    Name: Matthias Blume
222    Date: 2000/06/19 13:40:00
223    Tag: blume-20000619-manual
224    Description:
225    
226    CM manual and system/README update.  This only covers the fact that
227    there are no more implicit anchors.  (Path environments and the "bind"
228    option to "cm" have yet to be documented.)
229    
230    ----------------------------------------------------------------------
231    Name: Matthias Blume
232    Date: 2000/06/19 11:05:00 JST
233    Tag: blume-20000619-chdir-bugfix
234    Description:
235    
236    Fixed a bug in new SrcPath module that sometimes led to a bad chDir call.
237    
238    ----------------------------------------------------------------------
239    Name: Matthias Blume
240  Date: 2000/06/18 22:00:10 JST  Date: 2000/06/18 22:00:10 JST
241  Tag: blume-20000618-implicit-anchors-really-gone  Tag: blume-20000618-implicit-anchors-really-gone
242  Description:  Description:

Legend:
Removed from v.670  
changed lines
  Added in v.676

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