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

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

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