File DebuggingX.html    Author McKeeman    Copyright © 2007    index

Debugging X Programs

The lack of intermediate output during execution is acceptable for working programs. It is not practical, however, when the X program misbehaves. While one can always go back to the analysis to find an error, it is often expeditious to "open the bonnet" to do some troubleshooting. Traditional development systems provide output statements as well as debuggers for this purpose.

Dumps and Traces

xcom offers many dumps and traces, including an instruction-by-instruction trace of the machine language version of the users X program. It is usually best to start with flag

  -xcomTrace

to isolate the problem. Then add a more detailed trace as needed. Use the MATLAB command

>> help xcom

for more information.

Unit Tests, Trials, and Times

If one gives the MATLAB command

>> addpath tests trials times

the unit tests can be run from the command line in the mxcom/m directory. It is often the case that getting the unit test and trial to succeed first is easier than trying to get xcom to succeed directly.

X Intermediate Values

One can add assignments anywhere in an X program. If the l.h.s. is unique, its final value will be printed.

Assembly-level Debugging

Running xcom with the -interactive flag

>> xcom -interactive x/pi.x

provides an instruction-by-instruction trace.

Debugging xcom

One can add fprintf statements anywhere in xcom. The output will show up in the command window. And one can use the MATLAB debugger.