Debugging TL programs
In the Tycoon System a source level debugger for TL programs is still missing. So what help is given a TL programmer to debug his or her programs?
The Tycoon Machine can trace function calls und break the program interpretation on demand.
- Configure your Tycoon Machine for debugging:
cd ${TYCOON_ROOT}
sh configure
Answer yes on the following question:
"Slow down the Tycoon Machine for TL Interpreter debugging support?"
Build a new Tycoon Machine:
make
- Prepare the configuration file tmdebug.txt for the Tycoon Machine.
cd ${TYCOON_ROOT}/src
edit tmdebug.txt
In this file, each line beginning with the keywords trace or break is scanned by the Tycoon Machine at startup.
- Set (local or global) trace counter
- Syntax: trace nnn (where nnn is a decimal number)
-
nnn is a threshold on function calls. The function calls are counted beginning at the startup of the Tycoon Machine. When the counter reaches the threshold, each subsequent function call (maybe only for specific functions; see Tracing of specific functions) is traced. Note that each statement trace nnn sets the threshold for the following traces or breakpoints of specific functions. The last trace statement sets a global trace counter; each function call is traced when this counter is reached.
- Tracing of specific functions
- Syntax: trace "path & filename":iii-jjj kkk (where iii, jjj, and kkk are decimal numbers)
- path & filename is the name of the TL module that should be traced, e.g. "./stdenv/list.tm". iii and jjj are line numbers in this module; all functions that are declared between these lines are traced. kkk gives the unparsing depth of the result value, normally 1. Note that only function calls are traced that happen after a number of function calls that has been declared with a previous Set trace counter statement.
- Tracing of one function
- Syntax: trace "path & filename":iii kkk (where iii and kkk are decimal numbers)
- iii is the first line of the function body, e.g. the line where a begin statement is found in the implementation module.
- Breakpoints
- Syntax: break "path & filename":iii-jjj kkk (where iii, jjj, and kkk are decimal numbers), or:
- Syntax: break "path & filename":iii kkk (where iii and kkk are decimal numbers)
- Like Tracing of specific functions and Tracing of one function, but the function call is suspended by a breakpoint.
- Example for ${TYCOON_ROOT}/src/tmdebug.txt
trace 1 trace all function calls
trace "./bulkenv/bTree.tm":1-1000 1 trace specific module
trace "./bulkenv/bTreeUtil.tm":5-50 2 trace part of module
trace "./bulkenv/bTreeInsert.tm":10 1 trace one specific function
xtrace "./stdenv/iter.tm":1-1000 1 unrecognized line
trace 100 break only after 100 function calls
break "./stdenv/arrayOp.tm":45 set breakpoint on function
trace 100000 trace all function calls after 100000 function calls
You can define the debug option file at the start of the Tycoon machine by the parameter -debug
.
If this is misleading, refer to the actual implementation of debugging support in ${TYCOON_ROOT}/tm2/tmdebug.c.
Gerald Schröder (17-may-1995, 26-feb-1996)