src/Pure/Tools/debugger.ML
changeset 78650 47d0c333d155
parent 78648 852ec09aef13
child 78716 97dfba4405e3
equal deleted inserted replaced
78649:d46006355819 78650:47d0c333d155
    85 
    85 
    86 fun get_debugging () = the_default [] (Thread_Data.get debugging_var);
    86 fun get_debugging () = the_default [] (Thread_Data.get debugging_var);
    87 val is_debugging = not o null o get_debugging;
    87 val is_debugging = not o null o get_debugging;
    88 
    88 
    89 fun with_debugging e =
    89 fun with_debugging e =
    90   Thread_Data.setmp debugging_var (SOME (PolyML.DebuggerInterface.debugState (Thread.self ()))) e ();
    90   Thread_Data.setmp debugging_var
       
    91     (SOME (PolyML.DebuggerInterface.debugState (Thread.Thread.self ()))) e ();
    91 
    92 
    92 fun the_debug_state thread_name index =
    93 fun the_debug_state thread_name index =
    93   (case get_debugging () of
    94   (case get_debugging () of
    94     [] => error ("Missing debugger information for thread " ^ quote thread_name)
    95     [] => error ("Missing debugger information for thread " ^ quote thread_name)
    95   | states =>
    96   | states =>
   108 fun get_stepping () = the_default (Stepping (false, ~1)) (Thread_Data.get stepping_var);
   109 fun get_stepping () = the_default (Stepping (false, ~1)) (Thread_Data.get stepping_var);
   109 fun put_stepping stepping = Thread_Data.put stepping_var (SOME (Stepping stepping));
   110 fun put_stepping stepping = Thread_Data.put stepping_var (SOME (Stepping stepping));
   110 
   111 
   111 fun is_stepping () =
   112 fun is_stepping () =
   112   let
   113   let
   113     val stack = PolyML.DebuggerInterface.debugState (Thread.self ());
   114     val stack = PolyML.DebuggerInterface.debugState (Thread.Thread.self ());
   114     val Stepping (stepping, depth) = get_stepping ();
   115     val Stepping (stepping, depth) = get_stepping ();
   115   in stepping andalso (depth < 0 orelse length stack <= depth) end;
   116   in stepping andalso (depth < 0 orelse length stack <= depth) end;
   116 
   117 
   117 fun continue () = put_stepping (false, ~1);
   118 fun continue () = put_stepping (false, ~1);
   118 fun step () = put_stepping (true, ~1);
   119 fun step () = put_stepping (true, ~1);