DebugTrace—An Alternative Debugger

David Bailey

www.dbaileyconsultancy.co.uk

Abstract

Mathematica has had a built-in debugger since Version 6.0. However, in this paper I will present a free alternative debugger, DebugTrace, based on rather different principles, that is more attuned to the absolute beginner user, and also contains features suitable for very complex debugging tasks. DebugTrace operates on whole notebooks—which accommodates typical beginner coding style—and uses line numbers rather than selections to denote program location. This, in turn means that a debug session can be recorded for future inspection. Steps in the program are also numbered, so that a subsequent debug session can be instructed to skip at once to a position of interest. Other features include:

     •  An awareness of high level concepts, such as functions, rather than a purely kernel-oriented viewpoint.
     •  A mechanism to find the values of active local variables, without knowing their $n suffix. This can also be used to construct conditional breakpoints, where the value of n may vary, as, for example, when a module is repeatedly entered.
     •  The ability to print out the values of pattern arguments to functions.
     •  Some ability to debug dynamic constructs.
     •  Breakpoints can be toggled on or off by merely clicking the relevant line number in a special 'listing' notebook created on the fly.
     •  DebugTrace is written as a normal user package and is not encoded, so it could be extended in many ways.
     •  Full documentation is provided, which uses the new help system.

The talk will conclude with a discussion of how DebugTrace is implemented, and, more generally, about desirable features in a Mathematica debugger.