Hooks are functions evaluated before or after executing a
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:
Adds a function to the list of pre-hooks associated with the give command. command is a string naming the corresponding
mixvmcommand, 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
runcommand:(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).
Adds a function to the list of pre-hooks associated with the give command. The arguments have the same meaning as in
Global pre/post hooks are executed before/after any
mixvmcommand 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.
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
runcommands. If you are curious, you can check the Scheme source code at prefix/share/mdk/mixguile-vm-stat.scm (where prefix stands for your root install directory, usualy
See Hook functions for further examples on using hook functions.