Tracer Class Reference
A class to help trace program execution. More...
#include <tracer.h>
Collaboration diagram for Tracer:
Public Types | |
enum | Kind_t { EMPTY = 0, INCLUDE, EXCLUDE } |
A list can either be empty or a list to include or exclude. | |
enum | List_t { KLASS = 0, FUNCTION, ALWAYS_EXCLUDE, KLASS_WATCH, FUNCTION_WATCH, LISTSIZE } |
Public Member Functions | |
Tracer (const char *name, const char *klass) | |
A inlined ctor for the tracer class. | |
~Tracer () | |
An inlined dtor to print the leaving message. | |
Static Public Member Functions | |
static void | turnOn (std::ostream *s) |
Turns on the global trace flag and saves away the print stream object. | |
static void | turnOn (std::ostream &s) |
Turns on the global trace flag and saves away the print stream object. | |
static void | turnOnEnv (std::ostream *s) |
Check for the environment variable #TRACER_ON to turn on tracing. | |
static void | turnOnEnv (std::ostream &s) |
Check for the environment variable #TRACER_ON to turn on tracing. | |
static int | traceOn () |
Report the status of the trace flag. | |
static void | turnOff () |
Turn off the global trace flag. | |
static void | applyList (NamesList &nl, List_t listType, Kind_t kind) |
Application interface to specify the INCLUDE/EXCLUDE list. | |
static void | applyList (const char *file, List_t listType, Kind_t kind) |
Private Member Functions | |
void | entering (const char *name, const char *klass) |
Prints entering routine message. | |
void | leaving () |
Print the leaving routine message. | |
Static Private Member Functions | |
static bool | printMe (Kind_t t, NamesList &s, const char *name) |
Checks name against appropriate list. | |
static void | buildList (const char *fn, NamesList *nl) |
Build the list from a file name. | |
static void | cleanup () |
Clean up after tracing. | |
static void | cleanup (NamesList *nl) |
Private Attributes | |
char * | mp_name |
Usually the fully qualified routine name. | |
Static Private Attributes | |
static char * | msp_watch = 0 |
The name of the function we are currently watching. | |
static int | ms_traceOn = 0 |
Global trace flag. | |
static int | ms_watchOn = 0 |
Global watch flag. | |
static int | ms_watchList = 0 |
Global flag which is true iff there is one or more watch lists. | |
static int | ms_indentLvl = 0 |
Static indentation counter. | |
static std::ostream * | msp_stream = 0 |
The stream to send the messages to. It can safely be null. | |
static NamesList * | msp_list [LISTSIZE] |
An array to hold the vectors of names. LISTSIZE is 3. | |
static Kind_t | ms_listK [LISTSIZE] |
The type of each of the lists. | |
static TracerHelper | ms_tracerHelper |
This is here just to force the cleanup of the static member data in the Tracer Class. | |
Friends | |
class | TracerHelper |
Classes | |
class | TracerHelper |
Tracer Clean up class. More... |
Detailed Description
A class to help trace program execution.
- Description
- This class uses the constructor to print out a message that we are entering a function. The destructor prints out the leaving message. This can happen for all functions that call the ctor or just some of them. Application codes call the ctor with the name of the class and function name. When the ``entering'' function checks to see if the function/class are in the proper list. If so it prints. There are 4 tests that must be true in order to print.
- The global ms_traceOn must be on.
- The function must not be in the always exclude list
- The class must pass through the class list OR
- The function must pass through the function list.
If there is no class list nor a function list then the last two conditions are considered to be true. The last two tests are an OR test. That is if either are true the routine name will be printed.
A list can either be an INCLUDE or EXCLUDE list. That is either the list is an include list and only those members in the list are consider true. Or it is an exclude list and the member of the list are not printed and all other are.
In this way one can say that the member functions of some class will printed in an include list and some member functions of other classes will be in an include list of functions.
Member Enumeration Documentation
|
There are 5 list types: class, function and always exclude, klass_watch, function_watch |
Constructor & Destructor Documentation
|
A inlined ctor for the tracer class.
|
|
An inlined dtor to print the leaving message.
|
Member Function Documentation
|
Application interface to specify the INCLUDE/EXCLUDE list.
|
|
Build the list from a file name.
|
|
Clean up after tracing.
|
|
Prints entering routine message.
If there is a watch list (and it is not already on) then check to see if the current routine or class is what we are watching for. Note that the alwaysExc list is obeyed. So if you ask to watch something which is on the exclude list then nothing will happen. Note that we ignore the regular class and function lists if there is a watch list. If the watch is already on, we pass it through the always exclude list and if it passes we print. So the point of the watch is to print the call tree from the watched routine down. Strange behavior will ensue if an always ignored routine is in the middle of the call tree but not routines that the ignored routine calls. That is there will be a gap in the call tree as the ignored routine will not be printed. |
|
Print the leaving routine message.
|
|
Checks name against appropriate list.
|
|
Turns on the global trace flag and saves away the print stream object.
|
|
Turns on the global trace flag and saves away the print stream object.
|
The documentation for this class was generated from the following files:
- tracer.h
- tracer.C