[U-Boot-Users] [RFD] Consistent debugging output structure
Robert Schwebel
robert at schwebel.de
Wed Mar 19 19:32:07 CET 2003
Hi,
I would like to discuss the current state of the u-boot debug output
code. Nearly every C file in the source tree implements it's own way of
outputting debug messages during development, and most of them do it by
using Yet Another #ifdef Desert (TM).
Therfore, I would like to propose that we add a generic header file,
something like this:
----------8<----------
#ifndef __UDEBUG_H
#define __UDEBUG_H
#if (DEBUG > 2 )
#define DBG_PRINTF3(fmt,args...) printf(fmt ,##args)
#define DBG_PUTS3(args...) puts(args)
#else
#define DBG_PRINTF3(fmt,args...)
#define DBG_PUTS3(args...)
#endif
#if (DEBUG > 1)
#define DBG_PRINTF2(fmt,args...) printf(fmt ,##args)
#define DBG_PUTS2(args...) puts(args)
#else
#define DBG_PRINTF2(fmt,args...)
#define DBG_PUTS2(args...)
#endif
#ifdef DEBUG
#define DBG_PRINTF(fmt,args...) printf(fmt ,##args)
#define DBG_PUTS(args...) puts(args)
#else
#define DBG_PRINTF(fmt,args...)
#define DBG_PUTS(args...)
#endif
#endif /* __UDEBUG_H */
---------->8----------
which could be included by every file that wants to make debug outputs;
it just had to define the DEBUG level before it #includes udebug.h.
The transition could be done incrementally - it just has to be
documented somewhere that this is the preferred method.
Robert
--
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Braunschweiger Str. 79, 31134 Hildesheim, Germany
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Phone: +49-5121-28619-0 | Fax: +49-5121-28619-4
More information about the U-Boot
mailing list