### 5.6 The WAM debugger

In some cases it is interesting to have access to the WAM data structures. This sub-debugger allows the user to inspect/modify the contents of any stack or register of the WAM. The WAM debugger is invoked using the built-in predicate wam_debug/0 (section 5.3.1) or the W debugger command (section 5.5). The following table presents the specific commands of the WAM debugger:

Command | Description
write A [N] | write N terms starting at the address A using write/1 (section 8.14.6)
data A [N] | display N words starting at the address A
modify A [N] | display and modify N words starting at the address A
where A | display the real address corresponding to A
what RA | display what corresponds to the real address RA
deref A | display the dereferenced word starting at the address A
envir [SA] | display the contents of the environment located at SA (or the current one)
backtrack [SA] | display the contents of the choice-point located at SA (or the current one)
backtrack all | display all choice-points
quit | quit the WAM debugger
help | display a summary of available commands

In the above table the following conventions apply:

- elements between [ and ] are optional.
- N is an optional integer (defaults to 1).
- A is a WAM address, its syntax is: BANK_NAME [ [ N ] ], i.e. a bank name possibly followed by an index (defaults to 0). BANK_NAME is either:
  - reg: WAM general register (stack pointers, continuation, ...).
  - x: WAM X register (temporary variables, i.e. arguments).
  - y: WAM Y register (permanent variables).
  - ab: WAM X register saved in the current choice-point.
  - STACK_NAME: WAM stack (STACK_NAME in local, global, trail, cstr).
- SA is a WAM stack address, i.e. STACK_NAME [ [ N ] ] (special case of WAM addresses).
- RA is a real address, its syntax is the syntax of C integers (in particular the notation 0x… is recognized).

It is possible to only use the first letters of a commands and bank names when there is no ambiguity. Also the square brackets [ ] enclosing the index of a bank name can be omitted. For instance the following command (showing the contents of 25 consecutive words of the global stack from the index 3): data global[3] 25 can be abbreviated as: d g 3 25.

Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright