Commit a71f11c6 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Simplified use of --dbg_file option

parent de42837a
......@@ -233,11 +233,21 @@ static int main_cmdline(int argc, char *argv[])
break;
case 'f': /* Full debug for the function with this name. */
#ifdef DEBUG
fd_debug_one_function = optarg;
#else /* DEBUG */
TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature");
return EINVAL;
#endif /* DEBUG */
break;
case 'F': /* Full debug for the file with this name. */
fd_debug_one_file = optarg;
#ifdef DEBUG
fd_debug_one_file = basename(optarg);
#else /* DEBUG */
TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature");
return EINVAL;
#endif /* DEBUG */
break;
case 'q': /* Decrease verbosity then remove debug messages. */
......
......@@ -70,6 +70,10 @@
#include <stdlib.h>
#include <unistd.h>
#ifdef DEBUG
#include <libgen.h> /* for basename if --dbg_file is specified */
#endif /* DEBUG */
/*============================================================*/
/* DEBUG */
/*============================================================*/
......@@ -166,10 +170,18 @@ extern int fd_g_debug_lvl;
#define __PRETTY_FUNCTION__ __func__
#endif /* __PRETTY_FUNCTION__ */
/* A version of __FILE__ without the full path */
static char * file_bname = NULL;
#define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__)))
/* Boolean for tracing at a certain level */
#ifdef DEBUG
#define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \
|| (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \
|| (fd_debug_one_file && !strcmp(fd_debug_one_file, __FILE__) ) )
|| (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) )
#else /* DEBUG */
#define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl)
#endif /* DEBUG */
/* The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) */
#define TRACE_DEBUG(level,format,args... ) { \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment