SourceForge Logo

Go to the SourceForge project home page


/../index.php

/../news.php

/../release_history.php

index.php


/../screenshots.php

/../download.php

/../contact.php



Debug Tools

Go to documentation index

Table of contents

A. Debug MACROS

We wrote two macros DPRINT and FPRINT (in file "LibUtils/dprint.h") which print some debug messages in a formatted way on standard error, only if files are compiled with the "VERBOSE" preprocessor variable defined.

The DPRINT macro simply prints the given message with its arguments on standard error. The FPRINT macro creates an object which prints a message in its constructor and in its destructor. So, it can be used to trace the beginning and the end of some code fragments or the entering and leaving of methods.

The two macros take as arguments the name of the source class and the priority level of the message (low level = high priority), which is chosen to reflect the architecture of the application. The message is then printed with following format:

"[Pn] <CLASS_NAME> MESSAGE"

B. The debug frame

The debug frame is used to print the standard error of HeavyMole. It uses data displayed by the DPRINT and FPRINT macros to let specify classes we are interested in to be shown.

The debug frame is split in two parts: the text zone where messages filtered from standard error are displayed, and a control area where you can select verbose level and classes to be shown. Verbose level is used to hide messages with lowest priority. It ranges from 0 (shows only error messages) to 5 (shows everything).

The first line in the control area lets you choose the mode to be used: 'show all', 'nothing' or 'specify'. By using the specify mode you can choose the verbose level and specify which sources have to be shown. The different sources are separated in two lists: hidden sources where classes met since the launch of the application are pushed, and shown sources which are the classes selected to be shown. You can pass selected sources from a list to the other by clicking on arrow buttons or by double-clicking an element of a list. Two special sources can be selected: all and unknown sources (unknown sources are for messages which are not displayed by using the DPRINT and FPRINT macros).

Before being displayed in the window, the messages are written to a file ("./debug.log") which can be used to access all messages, including old messages which are not in memory anymore and messages that have not passed the filter. It is common to use the 'grep' command to extract lines you are interested in. Note that the "debug.log" file stream is buffered and that messages are therefore not immediately written to the file (you may need to close the DebugFrame to let all messages be written).

C. How to use the DebugFrame class

C.1. Compilation

The application must have been compiled with the "make debug" command. It sets the "-D DEBUG" option that will switch the comments on, and compile the debugframe executable (this one can also be compiled with "make debugframe"). You can then launch the test program with debugframe <executable filename and parameters>.

So, DON'T FORGET to always compile with "make debug" else debug options won't be set (eg if you modified a file and type "make" instead of "make debug", messages from the modified file won't be displayed).

If you want to modify comments: the macros DPRINT and FPRINT have been put in most methods, but you may need to add yourself the macros where you need it...
In .cc files, you will find the lines:

#ifdef DEBUG
#define VERBOSE
#endif

The compilation option "-D DEBUG" just defines the macro variable DEBUG and the file will so be compiled by using the printing macros. We used this second variable to be able to simply disable some classes by putting the "#define VERBOSE" line in comments (the classes _SortableList and UDPNode have so been disabled cause they are called really too often).

C.2. MS Windows users

The DebugFrame and HeavyMole in debug mode can be compiled using the "makealldebug.bat" file in the heavymole root directory (don't forget to launch "win32.bat" at first).

C.3. Running

The DebugFrame can be launched with debugframe heavymole. Another program using the DPRINT and FPRINT macros can be substituted for heavymole.

WARNING: We recommend you not to let the DebugFrame run too long because the debug.log file will grow too big.

http://heavymole.sourceforge.net - This page was last updated on april 26th 2003