From: Arun Thomas Date: Fri, 16 Sep 2011 12:57:49 +0000 (+0200) Subject: MKSYSDEBUG: conditionally compile more debug code X-Git-Tag: v3.2.0~305 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.log?a=commitdiff_plain;h=92fa3189abf21933b08ea4a206cbd3f3af23e0f2;p=minix.git MKSYSDEBUG: conditionally compile more debug code --- diff --git a/kernel/arch/i386/exception.c b/kernel/arch/i386/exception.c index d5224932b..b5e99caaf 100644 --- a/kernel/arch/i386/exception.c +++ b/kernel/arch/i386/exception.c @@ -136,6 +136,7 @@ PRIVATE void inkernel_disaster(struct proc *saved_proc, struct exception_frame * frame, struct ex_s *ep, int is_nested) { +#if USE_SYSDEBUG if(ep) { if (ep->msg == NULL || machine.processor < ep->minprocessor) printf("\nIntel-reserved exception %d\n", frame->vector); @@ -177,6 +178,7 @@ PRIVATE void inkernel_disaster(struct proc *saved_proc, /* in an early stage of boot process we don't have processes yet */ panic("exception in kernel while booting, no saved_proc yet"); +#endif /* USE_SYSDEBUG */ } /*===========================================================================* @@ -261,6 +263,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame) panic("return from inkernel_disaster"); } +#if USE_SYSDEBUG /*===========================================================================* * proc_stacktrace_execute * *===========================================================================*/ @@ -303,13 +306,16 @@ PRIVATE void proc_stacktrace_execute(struct proc *whichproc, reg_t v_bp, reg_t p } printf("\n"); } +#endif /* USE_SYSDEBUG */ /*===========================================================================* * proc_stacktrace * *===========================================================================*/ PUBLIC void proc_stacktrace(struct proc *whichproc) { +#if USE_SYSDEBUG proc_stacktrace_execute(whichproc, whichproc->p_reg.fp, whichproc->p_reg.pc); +#endif /* USE_SYSDEBUG */ } PUBLIC void enable_fpu_exception(void) diff --git a/kernel/arch/i386/pre_init.c b/kernel/arch/i386/pre_init.c index f84ce23e9..2f89ce0a6 100644 --- a/kernel/arch/i386/pre_init.c +++ b/kernel/arch/i386/pre_init.c @@ -19,7 +19,9 @@ #include "libexec.h" #include +#if USE_SYSDEBUG #define MULTIBOOT_VERBOSE 1 +#endif /* FIXME: Share this define with kernel linker script */ #define MULTIBOOT_KERNEL_ADDR 0x00200000UL @@ -142,6 +144,7 @@ PRIVATE void mb_scroll_up(int lines) PRIVATE void mb_print(char *str) { +#if MULTIBOOT_VERBOSE while (*str) { if (*str == '\n') { str++; @@ -157,6 +160,7 @@ PRIVATE void mb_print(char *str) while (print_line >= MULTIBOOT_CONSOLE_LINES) mb_scroll_up(1); } +#endif /* MULTIBOOT_VERBOSE */ } PRIVATE void mb_print_hex(u32_t value) diff --git a/kernel/arch/i386/protect.c b/kernel/arch/i386/protect.c index f28175ca4..4189278dc 100644 --- a/kernel/arch/i386/protect.c +++ b/kernel/arch/i386/protect.c @@ -366,6 +366,7 @@ for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; ++rp) { PUBLIC void printseg(char *banner, const int iscs, struct proc *pr, const u32_t selector) { +#if USE_SYSDEBUG u32_t base, limit, index, dpl; struct segdesc_s *desc; @@ -446,6 +447,7 @@ PUBLIC void printseg(char *banner, const int iscs, struct proc *pr, printf("DPL %d\n", dpl); return; +#endif /* USE_SYSDEBUG */ } /*===========================================================================* diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index a67c57a91..bbb0bc325 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -136,6 +136,10 @@ CPPFLAGS+= -DUSE_COVERAGE CPPFLAGS+= -DUSE_LIVEUPDATE .endif +.if ${USE_SYSDEBUG} != "no" +CPPFLAGS+= -DUSE_SYSDEBUG +.endif + CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR} .if (${CC} == "gcc") || (${CC} == "clang") diff --git a/lib/libsys/stacktrace.c b/lib/libsys/stacktrace.c index 6ddb4442e..6d382f7e0 100644 --- a/lib/libsys/stacktrace.c +++ b/lib/libsys/stacktrace.c @@ -34,6 +34,7 @@ typedef unsigned int reg_t; void util_nstrcat(char *str, unsigned long number) { +#if USE_SYSDEBUG int n = 10, lead = 1; char nbuf[12], *p; p = nbuf; @@ -51,16 +52,21 @@ void util_nstrcat(char *str, unsigned long number) *p++ = ' '; *p++ = '\0'; strcat(str, nbuf); +#endif /* USE_SYSDEBUG */ } void util_stacktrace(void) { +#if USE_SYSDEBUG FUNC_STACKTRACE(printf("0x%lx ", (unsigned long) pc)); printf("\n"); +#endif /* USE_SYSDEBUG */ } void util_stacktrace_strcat(char *str) { +#if USE_SYSDEBUG FUNC_STACKTRACE(util_nstrcat(str, pc)); +#endif /* USE_SYSDEBUG */ }