Next: , Previous: Programming Tools, Up: Programming Tools


5.24.1 Examining data and code

The following words inspect the stack non-destructively:

.s              tools       “dot-s”

Display the number of items on the data stack, followed by a list of the items (but not more than specified by maxdepth-.s; TOS is the right-most item.

f.s              gforth       “f-dot-s”

Display the number of items on the floating-point stack, followed by a list of the items (but not more than specified by maxdepth-.s; TOS is the right-most item.

maxdepth-.s       – addr         gforth       “maxdepth-dot-s”

A variable containing 9 by default. .s and f.s display at most that many stack items.

There is a word .r but it does not display the return stack! It is used for formatted numeric output (see Simple numeric output).

depth       – +n         core       “depth”

+n is the number of values that were on the data stack before +n itself was placed on the stack.

fdepth       – +n         float       “f-depth”

+n is the current number of (floating-point) values on the floating-point stack.

clearstack       ... –         gforth       “clear-stack”

remove and discard all/any items from the data stack.

clearstacks       ... –         gforth       “clear-stacks”

empty data and FP stack

The following words inspect memory.

?       a-addr –         tools       “question”

Display the contents of address a-addr in the current number base.

dump       addr u –         tools       “dump”

Display u lines of memory starting at address addr. Each line displays the contents of 16 bytes. When Gforth is running under an operating system you may get Invalid memory address errors if you attempt to access arbitrary locations.

And finally, see allows to inspect code:

see       "<spaces>name" –         tools       “see”

Locate name using the current search order. Display the definition of name. Since this is achieved by decompiling the definition, the formatting is mechanised and some source information (comments, interpreted sequences within definitions etc.) is lost.

xt-see       xt –         gforth       “xt-see”

Decompile the definition represented by xt.

simple-see       "name" –         gforth       “simple-see”

a simple decompiler that's closer to dump than see.

simple-see-range       addr1 addr2 –         gforth       “simple-see-range”

see-code       "name" –         gforth       “see-code”

like simple-see, but also shows the dynamic native code for the inlined primitives (except for the last).

see-code-range       addr1 addr2 –         gforth       “see-code-range”