Tech Support > Computers & Technology > Programming > configuration parameters
configuration parameters
Posted by jp on November 2nd, 2004


How would you set debug flags when running an executable ?

I have several executables made of many library routines.
I would like each library to have several bit flags to define
what debugging to output.
- routine enter exit
- time of entry / exit
- general
- structure output

When debugging a program, it would be nice to only turn on certain
debug flags to get only the debug information asked for.

There is a possibility of using the configuration routines to do
this, but how do you set the debugging for the configuration before
it starts ?

Command line parameters would be too massive if there were 10 or
20 modules.

This also needs to be somewhat generic. Each executable has a
different set of modules.

Any suggestions ???

Posted by Peter Jansson on November 2nd, 2004


You could perhaps code a special purpose "debug library" that would
contain the routines you would like to have (outputting the time of entry
et.c.) which would be called only if the correct "bit mask" was in the
"configuration file".

Regards,
Peter Jansson
http://www.jansson.net/

Posted by Willem on November 2nd, 2004


jp wrote:
) How would you set debug flags when running an executable ?
)
) I have several executables made of many library routines.
) I would like each library to have several bit flags to define
) what debugging to output.
) - routine enter exit
) - time of entry / exit
) - general
) - structure output
)
) When debugging a program, it would be nice to only turn on certain
) debug flags to get only the debug information asked for.
)
) There is a possibility of using the configuration routines to do
) this, but how do you set the debugging for the configuration before
) it starts ?
)
) Command line parameters would be too massive if there were 10 or
) 20 modules.
)
) This also needs to be somewhat generic. Each executable has a
) different set of modules.
)
) Any suggestions ???

Well, on my box, you can turn on malloc() debugging with environment
variables, so I guess you can do it that way for your other things as well.
(debian linux, but it works on freebsd 4 as well, with different args.)

Just have each library look for a certain variable that sets the debug
bitflags you want. Look in the source code for libc on one of the OSes
that support this on how to do it. (Something with getenv(), I guess.)


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


Similar Posts