Hooks are functions evaluated before or after executing a mixvm
command (or its corresponding Scheme function wrapper), or after an
explicit or conditional breakpoint is found during the execution of a
MIX program. The following functions let you install hooks:
mix-add-pre-hook command hook | Function |
Adds a function to the list of pre-hooks associated with the give
command. command is a string naming the corresponding mixvm
command, and hook is a function which takes a single argument: a
string list of the commands arguments. The following scheme code defines
a simple hook and associates it with the run command:
(define run-hook (lambda (args) (display "argument list: ") (display args) (newline))) (mix-add-pre-hook "run" run-hook) Pre-hooks are executed, in the order they are added, before invoking the corresponding command (or its associated Scheme wrapper function). |
mix-add-post-hook command hook | Function |
Adds a function to the list of pre-hooks associated with the give
command. The arguments have the same meaning as in
mix-add-pre-hook .
|
mix-add-global-pre-hook hook | Function |
mix-add-global-post-hook hook | Function |
Global pre/post hooks are executed before/after any mixvm command
or function wrapper invocation. In this case, hook takes two
arguments: a string with the name of the command being invoked, and a
string list with its arguments.
|
mix-add-break-hook hook | Function |
mix-add-cond-break hook | Function |
Add a hook funtion to be executed when an explicit (resp. conditional)
breakpoint is encountered during program execution. hook is a
function taking two arguments: the source line number where the hook has
occurred, and the current program counter value. The following code
shows a simple definition and installation of a break hook:
(define break-hook (lambda (line address) (display "Breakpoint at line ") (display line) (display " and address ") (display address) (newline))) (mix-add-break-hook break-hook) Break hook functions are entirely implemented in Scheme using regular
post-hooks for the |
See Hook functions for further examples on using hook functions.