X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fcommon%2Fdebug.h;h=8265a377f31e1b4005524c279eef74e46a79c7aa;hb=b0e09fe0aada2e5d9dc0299e969b3c93c1092d97;hp=26ceb6e2fa2d9e86599f9d18640dfe59548f8714;hpb=af54b3443c1b7a152638788f50b45272e4888e10;p=libfirm diff --git a/ir/common/debug.h b/ir/common/debug.h index 26ceb6e2f..8265a377f 100644 --- a/ir/common/debug.h +++ b/ir/common/debug.h @@ -1,17 +1,43 @@ -/** - * Debug facility. - * @author Michael Beck, Sebastian Hack - * @date 15.12.2004 +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. */ -#ifndef _FIRM_DEBUG_H -#define _FIRM_DEBUG_H +/** + * @file + * @brief Debug facility. + * @author Michael Beck, Sebastian Hack + * @date 15.12.2004 + * @version $Id$ + */ +#ifndef FIRM_COMMON_DEBUG_H +#define FIRM_COMMON_DEBUG_H #include "firm_config.h" +#ifdef DEBUG_libfirm + +/* WITH DEBUG OUTPUT */ + #ifdef WITH_LIBCORE #define DBG(x) _LC_DBG(x) +#define DB(x) _LC_DB(x) + #include /* use the newer debug implementation in libcore */ @@ -29,6 +55,7 @@ extern firm_dbg_module_t *firm_dbg_register(const char *name); #define LEVEL_3 LC_LEVEL_3 #define LEVEL_4 LC_LEVEL_4 #define LEVEL_5 LC_LEVEL_5 +#define SET_LEVEL_0 LC_SET_LEVEL_0 #define SET_LEVEL_1 LC_SET_LEVEL_1 #define SET_LEVEL_2 LC_SET_LEVEL_2 #define SET_LEVEL_3 LC_SET_LEVEL_3 @@ -36,24 +63,25 @@ extern firm_dbg_module_t *firm_dbg_register(const char *name); #define SET_LEVEL_5 LC_SET_LEVEL_5 #define SET_LEVEL_ALL LC_SET_LEVEL_ALL -#else +#else /* WITH_LIBCORE */ /* use the builtin debug implementation */ #include enum firm_dbg_level_t { - LEVEL_DEFAULT = 0, /**< Prints always. Use with DBG(). */ - LEVEL_1 = 1, - LEVEL_2 = 2, - LEVEL_3 = 4, - LEVEL_4 = 8, - LEVEL_5 = 16, - - SET_LEVEL_1 = 1, /**< use with firm_dbg_set_mask(). */ - SET_LEVEL_2 = 3, - SET_LEVEL_3 = 7, - SET_LEVEL_4 = 15, - SET_LEVEL_5 = 31, + LEVEL_DEFAULT = 0, /**< Prints always. Use with DBG(). */ + LEVEL_1 = 1, + LEVEL_2 = 2, + LEVEL_3 = 4, + LEVEL_4 = 8, + LEVEL_5 = 16, + + SET_LEVEL_0 = 0, /**< use with firm_dbg_set_mask(). */ + SET_LEVEL_1 = 1, + SET_LEVEL_2 = 3, + SET_LEVEL_3 = 7, + SET_LEVEL_4 = 15, + SET_LEVEL_5 = 31, SET_LEVEL_ALL = SET_LEVEL_5 }; @@ -65,6 +93,9 @@ void *_firm_dbg_make_msg(const firm_dbg_module_t *mod, unsigned mask, const char /* Internal function to the debug module. */ void _firm_dbg_print_msg(const char *filename, int line, const char *func, void *data); +/* Internal function to the debug module. */ +void _firm_dbg_print(const firm_dbg_module_t *mod, unsigned mask, const char *fmt, ...); + /** * Register a module to the firm debug facility. * If the module has already been registered, no new module is allocated @@ -97,7 +128,7 @@ unsigned firm_dbg_get_mask(const firm_dbg_module_t *module); void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file); #define _DBG_MAIN(func,args) \ - _firm_dbg_print_msg(__FILE__, __LINE__, func, _firm_dbg_make_msg args) + _firm_dbg_print_msg(__FILE__, __LINE__, func, _firm_dbg_make_msg args) /* If we have C99 use the __func__ variable for calling functions name. */ #if defined(__STD_VERSION__) && __STD_VERSION >= 199901L @@ -106,22 +137,23 @@ void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file); /* Else, check for gcc and use the proprietary __FUNCTION__ macro. */ #ifdef __GNUC__ -#define _DBG(args) _DBG_MAIN(__FUNCTION__, args) +#define _DBG(args) _DBG_MAIN(__FUNCTION__, args) #else /* Else go without the name of the calling function. */ -#define _DBG(args) _DBG_MAIN("", args) -#endif -#endif +#define _DBG(args) _DBG_MAIN("", args) +#endif /* __GNUC__ */ +#endif /* __STD_VERSION__ ... */ + +#define _DB(args) _firm_dbg_print args /** * Debug messages issued with this macro are always printed, even in * retail versions. * @see DBG() */ -#define DBG_RETAIL(args) _DBG(args) - -#ifdef DEBUG_libfirm +#define DBG_RETAIL(args) _DBG(args) +#define DB_RETAIL(args) _DB(args) /** * Issue a debug message. @@ -146,12 +178,32 @@ void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file); * DBG((my_mod, LEVEL_DEFAULT, "entity %e has type %t", ent, type)) * @endcode */ -#define DBG(args) _DBG(args) - -#else -#define DBG(args) -#endif +#define DBG(args) _DBG(args) +#define DB(args) _DB(args) #endif /* WITH_LIBCORE */ -#endif /* _FIRM_DEBUG_H */ +/** create a debug handle in debug mode */ +#define FIRM_DBG_REGISTER(handle, name) handle = firm_dbg_register(name) +#define DEBUG_ONLY(code) code +#define RELEASE_ONLY(code) + +#else /* ndef DEBUG_libfirm */ + +/* DEBUG OUTPUT IS COMPLETELY DISABLED */ + +#define DBG(x) +#define DB(x) + +/** create a debug handle in release mode */ +#define FIRM_DBG_REGISTER(handle, name) +#define DEBUG_ONLY(code) +#define RELEASE_ONLY(code) code + +#define firm_dbg_set_mask(module, mask) +#define firm_dbg_get_mask(module) +#define firm_dbg_set_file(module, file) + +#endif /* DEBUG_libfirm */ + +#endif