From 46cc4c535c415023e8b7ca657656af7d4be6ce42 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 11 Feb 2012 19:48:53 +0100 Subject: [PATCH] Config: Split CONFIG_UCW_DEBUG off CONFIG_DEBUG CONFIG_DEBUG controls the build system, CONFIG_UCW_DEBUG gets embedded in the library. Turning CONFIG_DEBUG in programs using LibUCW can influence ASSERTs and other debugging constructs in the headers, but not presence of debugging code in the library. --- ucw/bigalloc.c | 6 +++--- ucw/conf-input.c | 2 +- ucw/getopt.h | 2 +- ucw/mainloop.c | 2 +- ucw/mainloop.h | 12 ++++++------ ucw/perl/UCW/Configure/LibUCW.pm | 5 +++++ 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ucw/bigalloc.c b/ucw/bigalloc.c index 3133170e..852d8e42 100644 --- a/ucw/bigalloc.c +++ b/ucw/bigalloc.c @@ -65,11 +65,11 @@ big_alloc(u64 len) u64 l = big_round(len); if (l > SIZE_MAX - 2*CPU_PAGE_SIZE) die("big_alloc: Size %llu is too large for the current architecture", (long long) len); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG l += 2*CPU_PAGE_SIZE; #endif byte *p = page_alloc(l); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG *(u64*)p = len; mprotect(p, CPU_PAGE_SIZE, PROT_NONE); mprotect(p+l-CPU_PAGE_SIZE, CPU_PAGE_SIZE, PROT_NONE); @@ -91,7 +91,7 @@ big_free(void *start, u64 len) { byte *p = start; u64 l = big_round(len); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG p -= CPU_PAGE_SIZE; mprotect(p, CPU_PAGE_SIZE, PROT_READ); ASSERT(*(u64*)p == len); diff --git a/ucw/conf-input.c b/ucw/conf-input.c index ad8bfc8e..568aba2e 100644 --- a/ucw/conf-input.c +++ b/ucw/conf-input.c @@ -487,7 +487,7 @@ cf_getopt(int argc, char * const argv[], const char *short_opts, const struct op if (cf_load(optarg)) die("Cannot load config file %s", optarg); } -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG else { /* --dumpconfig */ load_default(); final_commit(); diff --git a/ucw/getopt.h b/ucw/getopt.h index a192c0f7..43866fc4 100644 --- a/ucw/getopt.h +++ b/ucw/getopt.h @@ -167,7 +167,7 @@ void cf_journal_rollback_transaction(uns new_pool, struct cf_journal_item *oldj) "-C, --config filename\t" CF_USAGE_TAB "Override the default configuration file\n\ -S, --set sec.item=val\t" CF_USAGE_TAB "Manual setting of a configuration item\n" CF_USAGE_DEBUG -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG #define CF_LONG_OPTS_DEBUG { "dumpconfig", 0, 0, 0x64436667 } , #define CF_USAGE_DEBUG " --dumpconfig\t" CF_USAGE_TAB "Dump program configuration\n" #else diff --git a/ucw/mainloop.c b/ucw/mainloop.c index 3c9dc623..e81e26eb 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -598,7 +598,7 @@ signal_del(struct main_signal *ms) signal_del_ctx(main_current(), ms); } -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG void file_debug(struct main_file *fi) diff --git a/ucw/mainloop.h b/ucw/mainloop.h index 336439be..60a97f21 100644 --- a/ucw/mainloop.h +++ b/ucw/mainloop.h @@ -112,7 +112,7 @@ static inline void main_shut_down(void) /** * Show the current state of a given context (use @main_debug() for the current context). - * Available only if LibUCW has been compiled with `CONFIG_DEBUG`. + * Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void main_debug_context(struct main_context *m); @@ -197,7 +197,7 @@ static inline int timer_is_active(struct main_timer *tm) **/ void main_get_time(void); -/** Show current state of a timer. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/ +/** Show current state of a timer. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void timer_debug(struct main_timer *tm); /*** @@ -266,7 +266,7 @@ static inline int hook_is_active(struct main_hook *ho) return clist_is_linked(&ho->n); } -/** Show current state of a hook. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/ +/** Show current state of a hook. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void hook_debug(struct main_hook *ho); @@ -353,7 +353,7 @@ static inline int file_is_active(struct main_file *fi) return clist_is_linked(&fi->n); } -/** Show current state of a file. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/ +/** Show current state of a file. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void file_debug(struct main_file *fi); /*** @@ -638,7 +638,7 @@ static inline int process_is_active(struct main_process *mp) return clist_is_linked(&mp->n); } -/** Show current state of a process. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/ +/** Show current state of a process. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void process_debug(struct main_process *pr); /*** @@ -687,7 +687,7 @@ static inline int signal_is_active(struct main_signal *ms) return clist_is_linked(&ms->n); } -/** Show current state of a signal catcher. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/ +/** Show current state of a signal catcher. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/ void signal_debug(struct main_signal *sg); #endif diff --git a/ucw/perl/UCW/Configure/LibUCW.pm b/ucw/perl/UCW/Configure/LibUCW.pm index a35ca87b..853f02c3 100644 --- a/ucw/perl/UCW/Configure/LibUCW.pm +++ b/ucw/perl/UCW/Configure/LibUCW.pm @@ -9,6 +9,11 @@ use UCW::Configure; use strict; use warnings; +# Turn on debugging support if CONFIG_DEBUG +if (Get("CONFIG_DEBUG")) { + Set("CONFIG_UCW_DEBUG"); +} + # Determine page size Test("CPU_PAGE_SIZE", "Determining page size", sub { my $p; -- 2.39.2