Go to the first, previous, next, last section, table of contents.


Function: ]invokeDebugger { [event] -> }
file: job.t
package: muf
status: alpha

The ]invokeDebugger function is a standard way for a Muq program to enter the debugger.

If @$s.debuggerHook is a compiled function, it will be called with the event block and the value of @$s.debuggerHook itself. We pass the latter because @$s.debuggerHook is set to nil while the hook function is executing.

If @$s.debuggerHook returns, then if @$s.debugger is a compiled function, it is invoked with the event as argument. (The event is first converted from a stackblock to a vector via ]makeVector.) This function should never return. (If it does, ]invokeDebugger will in desperation kill the job.)

Note that @$s.debugger is set at login to the value of me$s.debugger: thus the way to "permanently" change to another debugger is to set me$s.debugger to the desired function.

By default, the standard Muq db binds me$s.debugger to mufDebugger. See section mufDebugger.

For a very simple example, try:

withTag my-tag do{
    [   :function :: { -> ! } 'my-tag goto ;
        :name     'my-restart
        :reportFunction "Continue from 'my-tag"
    | ]withRestartDo{
        [ | ]invokeDebugger

This will invoke the debugger after establishing a restart which lets you continue from where you left off.

The ]invokeDebugger function is currently implemented as:

: ]invokeDebugger { [] -> @ ! }

    ( Invoke debugger_hook, if present: )
    @$s.debuggerHook -> dh
    dh compiledFunction? if
        ( We're supposed to bind rather than )
        ( set, but we'll cheat, since we do  )
        ( not have binding implemented yet:  )
            nil --> @$s.debuggerHook
            |dup[ dh dh
            call{ [] $ -> }
            dh --> @$s.debugger_hook

    ( Since debuggerHook returned, )
    ( invoke standard debugger:     )
    ]makeVector -> event
    @$s.debugger -> debugger
    debugger compiledFunction? if
        event debugger call{ $ -> @ }

    ( If no debugger, kill job: )
    "]invokeDebugger: Invalid @$s.debugger, killing job." ,
    nil endJob
']invokeDebugger export

See section break. See section ]error. See section ]cerror.

Go to the first, previous, next, last section, table of contents.