SCM Repository
[smlnj] Diff of /sml/trunk/src/smlnj-lib/TraceDebugProf/back-trace.sml
Diff of /sml/trunk/src/smlnj-lib/TraceDebugProf/back-trace.sml
Parent Directory
|
Revision Log
|
Patch
18 |
* Author: Matthias Blume (blume@tti-c.org) |
* Author: Matthias Blume (blume@tti-c.org) |
19 |
*) |
*) |
20 |
structure BackTrace : sig |
structure BackTrace : sig |
|
exception BTraceTriggered of unit -> string list |
|
21 |
val trigger : unit -> 'a |
val trigger : unit -> 'a |
22 |
val monitor : (unit -> 'a) -> 'a |
val monitor : (unit -> 'a) -> 'a |
23 |
val install : unit -> unit |
val install : unit -> unit |
186 |
|
|
187 |
fun monitor work = |
fun monitor work = |
188 |
let val restore = save () |
let val restore = save () |
189 |
fun hdl (e, []) = raise e |
fun last (x, []) = x |
190 |
|
| last (_, x :: xs) = last (x, xs) |
191 |
|
fun emsg e = |
192 |
|
case SMLofNJ.exnHistory e of |
193 |
|
[] => General.exnMessage e |
194 |
|
| (h :: t) => |
195 |
|
concat [last (h, t), ": ", General.exnMessage e] |
196 |
|
fun hdl (e, []) = |
197 |
|
(Control.Print.say (emsg e ^ "\n\n"); |
198 |
|
raise e) |
199 |
| hdl (e, hist) = |
| hdl (e, hist) = |
200 |
(Control.Print.say |
(Control.Print.say |
201 |
(concat ("\n*** BACK-TRACE ***\n" :: hist)); |
(concat ("\n*** BACK-TRACE ***\n" :: hist)); |
202 |
Control.Print.say "\n"; |
Control.Print.say |
203 |
|
(concat ["\n", emsg e, "\n\n"]); |
204 |
raise e) |
raise e) |
205 |
in |
in |
206 |
work () |
work () |
|
Legend:
Removed from v.1656 |
|
changed lines |
|
Added in v.1669 |
|
|