Commit 441843f8 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Added simple command-line switch to turn on full debug for specific function or file

parent 2eeaded4
......@@ -191,6 +191,8 @@ static int main_cmdline(int argc, char *argv[])
{ "debug", no_argument, NULL, 'd' },
{ "quiet", no_argument, NULL, 'q' },
{ "dbglocale", optional_argument, NULL, 'l' },
{ "dbg_func", required_argument, NULL, 'f' },
{ "dbg_file", required_argument, NULL, 'F' },
{ NULL, 0, NULL, 0 }
};
......@@ -230,6 +232,14 @@ static int main_cmdline(int argc, char *argv[])
fd_g_debug_lvl++;
break;
case 'f': /* Full debug for the function with this name. */
fd_debug_one_function = optarg;
break;
case 'F': /* Full debug for the file with this name. */
fd_debug_one_file = optarg;
break;
case 'q': /* Decrease verbosity then remove debug messages. */
fd_g_debug_lvl--;
break;
......
......@@ -97,6 +97,8 @@
*/
void fd_log_debug ( char * format, ... );
extern pthread_mutex_t fd_log_lock;
extern char * fd_debug_one_function;
extern char * fd_debug_one_file;
/*
* FUNCTION: fd_log_threadname
......@@ -165,7 +167,9 @@ extern int fd_g_debug_lvl;
#endif /* __PRETTY_FUNCTION__ */
/* Boolean for tracing at a certain level */
#define TRACE_BOOL(_level_) ( (_level_) <= local_debug_level + fd_g_debug_lvl )
#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__) ) )
/* 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... ) { \
......
......@@ -41,6 +41,11 @@ pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_key_t fd_log_thname;
int fd_g_debug_lvl = 0;
/* These may be used to pass specific debug requests via the command-line parameters */
char * fd_debug_one_function = NULL;
char * fd_debug_one_file = NULL;
/* Log a debug message */
void fd_log_debug ( char * format, ... )
{
......
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