我浏览了SMLNJ 用户指南,找不到任何关于调试功能的信息。我很想看到一个堆栈跟踪,或者单步执行一个函数。这可能吗。是否有其他提供此功能的类似 SML 变体的实现?
问问题
6598 次
4 回答
13
目前没有基于步骤的调试器。
您可以通过执行以下操作来获取堆栈回溯:
- CM.make "$smlnj-tdp/back-trace.cm";
[library $smlnj-tdp/back-trace.cm is stable]
[library $smlnj-tdp/plugins.cm is stable]
[library $SMLNJ-LIB/Util/smlnj-lib.cm is stable]
[library $smlnj/compiler/current.cm is stable]
[library $smlnj/compiler/x86.cm is stable]
[library $smlnj/viscomp/core.cm is stable]
[library $smlnj/viscomp/parser.cm is stable]
[library $smlnj/viscomp/basics.cm is stable]
[library $smlnj/viscomp/elaborate.cm is stable]
[library $smlnj/viscomp/elabdata.cm is stable]
[library $smlnj/MLRISC/MLRISC.cm is stable]
[library $SMLNJ-MLRISC/MLRISC.cm is stable]
[library $Lib.cm(=$SMLNJ-MLRISC)/Lib.cm is stable]
[library $Control.cm(=$SMLNJ-MLRISC)/Control.cm is stable]
[library $Graphs.cm(=$SMLNJ-MLRISC)/Graphs.cm is stable]
[library $smlnj/MLRISC/Control.cm is stable]
[library $smlnj/viscomp/debugprof.cm is stable]
[library $smlnj/viscomp/execute.cm is stable]
[library $smlnj/internal/smlnj-version.cm is stable]
[library $smlnj/viscomp/x86.cm is stable]
[New bindings added.]
val it = true : bool
- SMLofNJ.Internals.TDP.mode := true;
[autoloading]
[autoloading done]
val it = () : unit
-
然后,您可以加载一些代码,而不仅仅是打印异常,您将获得一个模拟的堆栈回溯。您必须按照上述步骤重新编译您的代码,否则这将不起作用!
- exception Foo;
exception Foo
- fun otherFun() = raise Foo;
val otherFun = fn : unit -> 'a
- fun raiseAtZero(n) = if (n > 0) then raiseAtZero(n-1) else otherFun();
val raiseAtZero = fn : int -> 'a
- raiseAtZero 10;
stdIn:9.1-9.15 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
*** BACK-TRACE ***
GOTO stdIn:7.5-7.27: otherFun[2]
(from: stdIn:8.60-8.70: raiseAtZero[2])
CALL-( stdIn:8.5-8.70: raiseAtZero[2]
(from: stdIn:9.1-9.15: it)
GOTO stdIn:5.5-5.27: otherFun[2]
(from: stdIn:6.60-6.70: raiseAtZero[2])
CALL-( stdIn:6.5-6.70: raiseAtZero[2]
(from: stdIn:6.71-6.86: it)
uncaught exception Foo
raised at: stdIn:7.24-7.27
-
于 2009-12-12T04:10:22.963 回答
9
PolyML 现在有一个源代码级调试器:http ://www.polyml.org/documentation/Tutorials/Debugging.html
于 2013-08-21T10:12:32.207 回答
7
从SMLNJ 常见问题的第 3.3 节:
问:是否有 SML/NJ 的调试器?Tolmach 的 SML/NJ 0.93 调试器发生了什么变化?
答:简短的回答是否定的。
Debugging SML * For years, no one had an SML debugger * Why? o No one had any bugs? o It is hard to write a debugger for SML o The user community wasn’t large enough * Likely all three are true
不过,有一个 .NET 编译器,它声称有一些调试支持。
于 2009-04-18T22:50:35.103 回答