src/Pure/Tools/debugger.ML
changeset 60932 13ee73f57c85
parent 60931 f4bc0400bd15
child 60935 441c03582afa
equal deleted inserted replaced
60931:f4bc0400bd15 60932:13ee73f57c85
    62                 val (msg, queue') = Queue.dequeue queue;
    62                 val (msg, queue') = Queue.dequeue queue;
    63                 val input' =
    63                 val input' =
    64                   if Queue.is_empty queue' then Symtab.delete_safe thread_name input
    64                   if Queue.is_empty queue' then Symtab.delete_safe thread_name input
    65                   else Symtab.update (thread_name, queue') input;
    65                   else Symtab.update (thread_name, queue') input;
    66               in SOME (msg, SOME input') end));
    66               in SOME (msg, SOME input') end));
       
    67 
       
    68 
       
    69 (* global break *)
       
    70 
       
    71 local
       
    72   val break = Synchronized.var "Debugger.break" false;
       
    73 in
       
    74 
       
    75 fun is_break () = Synchronized.value break;
       
    76 fun set_break b = Synchronized.change break (K b);
       
    77 
       
    78 end;
    67 
    79 
    68 
    80 
    69 
    81 
    70 (** thread state **)
    82 (** thread state **)
    71 
    83 
   235   Isabelle_Process.protocol_command "Debugger.init"
   247   Isabelle_Process.protocol_command "Debugger.init"
   236     (fn [] =>
   248     (fn [] =>
   237      (init_input ();
   249      (init_input ();
   238       ML_Debugger.on_breakpoint
   250       ML_Debugger.on_breakpoint
   239         (SOME (fn (_, break) =>
   251         (SOME (fn (_, break) =>
   240           if not (is_debugging ()) andalso (! break orelse is_stepping ()) then
   252           if not (is_debugging ()) andalso (! break orelse is_break () orelse is_stepping ())
       
   253           then
   241             (case Simple_Thread.get_name () of
   254             (case Simple_Thread.get_name () of
   242               SOME thread_name => debugger_loop thread_name
   255               SOME thread_name => debugger_loop thread_name
   243             | NONE => ())
   256             | NONE => ())
   244           else ()))));
   257           else ()))));
   245 
   258 
   246 val _ =
   259 val _ =
   247   Isabelle_Process.protocol_command "Debugger.exit"
   260   Isabelle_Process.protocol_command "Debugger.exit"
   248     (fn [] => (ML_Debugger.on_breakpoint NONE; exit_input ()));
   261     (fn [] => (ML_Debugger.on_breakpoint NONE; exit_input ()));
       
   262 
       
   263 val _ =
       
   264   Isabelle_Process.protocol_command "Debugger.break"
       
   265     (fn [b] => set_break (Markup.parse_bool b));
   249 
   266 
   250 val _ =
   267 val _ =
   251   Isabelle_Process.protocol_command "Debugger.breakpoint"
   268   Isabelle_Process.protocol_command "Debugger.breakpoint"
   252     (fn [node_name, id0, breakpoint0, breakpoint_state0] =>
   269     (fn [node_name, id0, breakpoint0, breakpoint_state0] =>
   253       let
   270       let