Previous: , Up: Hook functions   [Contents][Index] Break hooks

We have seen in the previous section how to associate hooks to command execution, but they are not the whole story. You can also associate hook functions to program interruption, that is, specify functions that should be called every time the execution of a MIX program is stopped due to the presence of a breakpoint, either explicit or conditional. Break hooks take as arguments the line number and memory address at which the break occurred. A simple hook that logs the line and address of the breakpoint could be defined as:

(define break-hook
  (lambda (line address)
    (display "Breakpoint encountered at line ")
    (display line)
    (display " and address ")
    (display address)

and installed for explicit and conditional breakpoints using

(mix-add-break-hook break-hook)
(mix-add-cond-break-hook break-hook)

after that, every time the virtual machine encounters a breakpoint, break-code shall be evaluated for you15.