Re: C/C++ tracing techniques
From: Tony Young (ty) (acmyau_blah@yahoo.com.au)
Date: 04/01/03
- Next message: Michael Fuhr: "Re: how is lastlog written ?"
- Previous message: Joseph Seigh: "Re: time C function and multi-threadedness"
- Maybe in reply to: Alex Pavloff: "Re: C/C++ tracing techniques"
- Next in thread: Matthias Riese: "Re: C/C++ tracing techniques"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Tony Young (ty)" <acmyau_blah@yahoo.com.au> Date: Tue, 01 Apr 2003 01:44:37 GMT
Frank wrote:
> I was wondering what techniques people have used for a tracing sub
> system inside a C/C++ program beyond a print statement to stdout/stderr.
>
> I want to be able to trace the execution of a program and display
> variable values from time to time, but to be able to turn it off too,
> hopefully not by recompiling.
We have a fairly detailed system based around an ini file (for want of a
better term).
We have calls to a dbug_printf() function in various places in the code.
A dbug_init() function is used at program start to check for the ini
file. If it exists it reads various information such as the output file,
what to display for trace messages (date/time, file, line number, etc),
and what debugging levels should be used.
Each call to dbug_printf() checks to see if debugging is turned on via
the existence of the ini file, and uses the options read by dbug_init()
to display relevant debugging info.
Various macros can be used to optimise things so that calls to
dbug_printf() to very little if debugging is not requested.
eg
#define dbug_printf(a,b,...) if (dbug_on==1) real_dbug_printf(a,b,...)
hth
ty
- Next message: Michael Fuhr: "Re: how is lastlog written ?"
- Previous message: Joseph Seigh: "Re: time C function and multi-threadedness"
- Maybe in reply to: Alex Pavloff: "Re: C/C++ tracing techniques"
- Next in thread: Matthias Riese: "Re: C/C++ tracing techniques"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|