Mathematica 9 is now available

Wolfram Library Archive

All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

An Easy To Use Debugger: Dbg & M-Debug

David Bailey
Organization: David Bailey Consultancy
Old MathSource #

Revision date


2001 version: Dbg is designed to make it easier to debug Mathematica code. A full description is available in the notebook debugger_doc.nb. Dbg uses the frontend to help to navigate the often large amounts of information generated by a debug session. It also trims away much essentially useless information, such as the 'evaluation' of simple atomic objects that evaluate to themselves. A palette is provided with an abort button to stop infinite processes and obtain traceback information. There is also a button to tag portions of code with colour so that they can be easily found in the debug output. The palette also acts as a step counter to help keep track of how far a program has proceeded. Using the palette it is possible to step a program and to set breakpoints specified by pattern or by adding colour to the program.

2004 Version: Update by Author (12 Dec 2004) I have renamed the new version M-Debug because it works in a more intuitive way than Dbg, and is not therefore a compatible upgrade of the previous system.

Unlike Dbg, M-Debug is driven entirely using a palette, and contains a range of new features - such as the ability to watch variables, and perform user-defined actions while the program under test is suspended. M-Debug will also perform a set of extra syntax checks on Mathematica source as functions are defined. Thus, for example, defining a function in terms of a Module with the wrong number of arguments (or with the first argument a non-list) will produce an immediate error, rather that faulting at run-time. M-Debug is highly configurable, and records its settings for future use.

M-Debug is a full package with its own extension to the Mathematica help system.

To install M-Debug, download to the Mathematica directory, and unzip it with a tool that preserves the directory structure. Then start Mathematica and rebuild the help index.

*Mathematica Technology > Programming > Testing

Debug, Trace, Breakpoint
Related items

*Dbg: An Easy-to-Use Debugger   [in Conference Proceedings]
Downloads Download Wolfram CDF Player

debugger.m (30.8 KB) - Mathematica package
debugger_doc.nb (240.3 KB) - Mathematica notebook
Download (48.1 KB) - ZIP archive [for Mathematica 5.0]