Re: C/C++ tracing techniques

From: Tony Young (ty) (acmyau_blah@yahoo.com.au)
Date: 04/01/03


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



Relevant Pages

  • .Net not able to debug a webform
    ... Error while trying to run project: Unable to start debugging on the web ... Set customError mode values to control the display of user-friendly ... error messages to users instead of error details (including a stack trace): ... <!-- SESSION STATE SETTINGS ...
    (microsoft.public.dotnet.framework)
  • Re: .Net not able to debug a webform
    ... you should set this value to true only when debugging and to ... > that you do not display application detail information to remote clients. ... > Application-level tracing enables trace log output for every page within ... > particular session. ...
    (microsoft.public.dotnet.framework)
  • Re: Simple Form Debugging
    ... When debugging, you can see more info when trace is turned on. ... several attributes in various areas of the web.config file that will display ... extra info, here are the ones I find the most useful: ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Enable Perl Debugging at Run-Time
    ... however it would be neater if there was a command in perl ... It's a filter which removes 'debugging' code based on ... This particular script is one of many CGI's, so I don't have much scope ... code to 'self trace' and dump trace data to STDERR. ...
    (perl.beginners)
  • Re: AMD64 X2 lost ticks on PM timer
    ... to what debugging facilities are available with each preemption level. ... I got the following trace. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)