Debugging Tools
SWOOP Object-Oriented Programming
Libraries, Functions, Callbacks, and Threads
SwiftForth Programming References
Download Free Evaluation Version
Order SwiftForth™ for Windows, Mac OS X and Linux programming. Examples, source, documentation, more.
consulting services
contract programming
hardware design
intensive Forth classes
contact us today
Mac and the Mac logo are trademarks of Apple Inc., registered in the U.S. and other countries.
SwiftForth includes a disassembler can be used to generate human-readable source code from compiled definitions. This is useful as a cross check, whenever a new definition fails to work as expected, and also shows the results of SwiftForth’s optimizing compiler. By disassembling a definition, you can see exactly what instructions were generated by the compiler.
The single command SEE <name> disassembles the code generated for name.
For example, the definition of TIMER is:
: TIMER ( u -- ) COUNTER SWAP - U. ;
It disassembles as follows:
SEE TIMER 47170F 45B2AF ( COUNTER ) CALL E89B9BFEFF 471714 0 [EBP] EBX SUB 2B5D00 471717 4 # EBP ADD 83C504 47171A 40916F ( U. ) JMP E9507AF9FF
The left column shows the memory location being disassembled. This is followed by the instruction (or data) at that location. Note that the disassembler attempts to match named locations in memory with their addresses. The right column shows the actual bytes in memory.
A simple single-step debugger allows you to step through code compiled from a source file. Here is a simple example:
[DEBUG : 2X ( n1 -- n2 ) DUP + ; : 3X ( n1 -- n2 ) DUP 2X + ; : 4X ( n1 -- n2 ) DUP 2X SWAP 2X + ; : 5X ( n1 -- n2 ) DUP 3X SWAP 2X + ; DEBUG]
Assuming this source has been compiled, you may type 4 DEBUG 5X to enter the single-step debug loop.
At each step, the source line is displayed with the next word to be stepped through highlighted. After this, the current data stack is displayed (in the familiar .S format) along with a prompt for the next step: