The PolyML.Debug structure contains functions to assist with debugging. For a tutorial see here.
structure Debug : sig val breakAt : string * int -> unit val breakEx : exn -> unit val breakIn : string -> unit val clearAt : string * int -> unit val clearEx : exn -> unit val clearIn : string -> unit val continue : unit -> unit val continueWithEx : exn -> unit val down : unit -> unit val dump : unit -> unit val locals: unit -> unit
val stack : unit -> unit val step : unit -> unit val stepOut : unit -> unit val stepOver : unit -> unit val trace : bool -> unit val up : unit -> unit val variables : unit -> unit end