2009-04-18 16 views
16

Przejrzałem SMLNJ User Guide i nie mogę znaleźć niczego na temat możliwości debugowania. Chciałbym zobaczyć ślad stosu lub przejść przez funkcję. Czy to możliwe. Czy istnieją inne implementacje dla podobnych wariantów SML, które zapewniają tę cechę do?Czy SMLNJ ma jakikolwiek debugger?

Odpowiedz

8

Z sekcji 3.3 SMLNJ faq:

Q: Czy istnieje debugger dla SML/NJ? Co stało się z debugerem Tolmacha dla dla SML/NJ 0.93?

A: Krótka odpowiedź brzmi nie.

Also:

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 

Jest a .NET compiler, chociaż, który twierdzi, że ma pewne wsparcie debugowania ..

10

Obecnie nie debugger krok oparte.

Można uzyskać śledzenia wstecznego stosu, wykonując następujące czynności:

- 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 
- 

Następnie można załadować jakiś kod i zamiast po prostu drukowania wyjątek, dostaniesz symulowaną stosu ślad. Musisz skompilować kod po wykonaniu powyższych kroków, bo inaczej to nie zadziała!

- 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 
- 
2

Poly/ML jest najlepszy nieznany realizacja Standard ML. Miał debugger linii poleceń od samego początku (przynajmniej w latach dziewięćdziesiątych). Niedawno uzyskał pełne wsparcie IDE przez Isabelle/PIDE, np. patrz ML, która zawiera także debugger na poziomie źródłowym.