From 40592de32da78bdd814657ab1f368b1688d6f082 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Tue, 16 Aug 2011 17:18:55 +0200 Subject: [PATCH] Optionally disable kernel debug code --- kernel/Makefile | 10 +++++++++- kernel/arch/i386/Makefile.inc | 2 -- kernel/arch/i386/arch_system.c | 4 ++++ kernel/clock.c | 3 +++ kernel/debug.h | 8 ++++++++ kernel/start.c | 2 ++ kernel/utility.c | 2 ++ share/mk/bsd.own.mk | 6 ++++-- share/mk/sys.mk | 2 +- 9 files changed, 33 insertions(+), 6 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 1b760c86e..b411e3774 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -6,7 +6,7 @@ PROG= kernel # first-stage, arch-dependent startup code SRCS= mpx.S SRCS+= start.c table.c main.c proc.c \ - system.c clock.c utility.c debug.c interrupt.c \ + system.c clock.c utility.c interrupt.c \ cpulocals.c .ifdef CONFIG_SMP @@ -63,6 +63,14 @@ SRCS+= do_mcontext.c CPPFLAGS+= -DUSE_MCONTEXT .endif +.if ${USE_DEBUGREG} != "no" +SRCS+= breakpoints.c debugreg.S +.endif + +# Extra debugging routines +.if ${USE_DEBUG} != "no" +SRCS+= debug.c +.endif # These come last, so the profiling buffer is at the end of the data segment SRCS+= profile.c do_sprofile.c diff --git a/kernel/arch/i386/Makefile.inc b/kernel/arch/i386/Makefile.inc index 4d9f7db13..08fb9fced 100644 --- a/kernel/arch/i386/Makefile.inc +++ b/kernel/arch/i386/Makefile.inc @@ -4,9 +4,7 @@ .PATH: ${.CURDIR}/arch/${ARCH} SRCS+= arch_do_vmctl.c \ - breakpoints.c \ arch_clock.c \ - debugreg.S \ do_int86.c \ do_iopenable.c \ do_readbios.c \ diff --git a/kernel/arch/i386/arch_system.c b/kernel/arch/i386/arch_system.c index bb48c2afd..a94c3a4a0 100644 --- a/kernel/arch/i386/arch_system.c +++ b/kernel/arch/i386/arch_system.c @@ -395,6 +395,7 @@ PUBLIC void arch_init(void) #endif } +#if DEBUG_SERIAL PUBLIC void ser_putc(char c) { int i; @@ -414,6 +415,7 @@ PUBLIC void ser_putc(char c) #endif } + /*===========================================================================* * do_ser_debug * *===========================================================================*/ @@ -597,6 +599,8 @@ PRIVATE void ser_dump_proc_cpu(void) } #endif +#endif /* DEBUG_SERIAL */ + #if SPROFILE PUBLIC int arch_init_profile_clock(const u32_t freq) diff --git a/kernel/clock.c b/kernel/clock.c index cb41aed29..074dba884 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -140,8 +140,11 @@ PUBLIC int timer_int_handler(void) TMR_NEVER : clock_timers->tmr_exp_time; } +#if DEBUG_SERIAL if (do_serial_debug) do_ser_debug(); +#endif + } return(1); /* reenable interrupts */ diff --git a/kernel/debug.h b/kernel/debug.h index ce808f31a..58921db7c 100644 --- a/kernel/debug.h +++ b/kernel/debug.h @@ -13,6 +13,9 @@ #include "config.h" #endif +/* Debug info via serial (see ser_debug()) */ +#define DEBUG_SERIAL 1 + /* Enable prints such as * . send/receive failed due to deadlock or dead source or dead destination * . trap not allowed @@ -47,6 +50,11 @@ /* DEBUG_IPCSTATS collects information on who sends messages to whom. */ #define DEBUG_IPCSTATS 0 +#if USE_SMALL +#undef DEBUG_SERIAL +#undef DEBUG_ENABLE_IPC_WARNINGS +#endif + #if DEBUG_DUMPIPC || DEBUG_IPCSTATS /* either of these needs the hook */ #define DEBUG_IPC_HOOK 1 #endif diff --git a/kernel/start.c b/kernel/start.c index 55f8a28bf..ba25c665e 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -84,6 +84,7 @@ PUBLIC void cstart( if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */ system_hz = DEFAULT_HZ; +#if DEBUG_SERIAL /* Intitialize serial debugging */ value = env_get(SERVARNAME); if(value && atoi(value) == 0) { @@ -92,6 +93,7 @@ PUBLIC void cstart( value = env_get(SERBAUDVARNAME); if (value) serial_debug_baud = atoi(value); } +#endif #ifdef USE_APIC value = env_get("no_apic"); diff --git a/kernel/utility.c b/kernel/utility.c index 7d6521846..15a043c58 100644 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -50,11 +50,13 @@ int c; /* character to append */ * to the output driver if an END_OF_KMESS is encountered. */ if (c != END_OF_KMESS) { +#if DEBUG_SERIAL if (do_serial_debug) { if(c == '\n') ser_putc('\r'); ser_putc(c); } +#endif kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */ if (kmess.km_size < sizeof(kmess.km_buf)) kmess.km_size += 1; diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 3c97108e9..7cb676d0b 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -757,7 +757,7 @@ _MKVARS.yes= \ MKYP #MINIX-specific vars _MKVARS.yes+= \ - MKWATCHDOG MKACPI MKAPIC MKMCONTEXT + MKWATCHDOG MKACPI MKAPIC MKMCONTEXT MKDEBUGREG MKDEBUG .for var in ${_MKVARS.yes} ${var}?= yes .endfor @@ -822,6 +822,8 @@ MKACPI:= no MKAPIC:= no MKMCONTEXT:= no MKCOVERAGE:= no +MKDEBUGREG:= no +MKDEBUG:= no .endif # @@ -883,7 +885,7 @@ ${var}?= no # variable is set to "no". # .for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP \ -USE_WATCHDOG USE_ACPI USE_APIC USE_MCONTEXT +USE_WATCHDOG USE_ACPI USE_APIC USE_MCONTEXT USE_DEBUGREG USE_DEBUG .if (${${var:S/USE_/MK/}} == "no") ${var}:= no .else diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 01cea435c..28a396fc8 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -247,5 +247,5 @@ NBSD_LIBC= yes .if ${COMPILER_TYPE} == "gnu" && defined(MKSMALL) && ${MKSMALL} == "yes" DBG= -Os -CFLAGS+= -DNDEBUG=1 +CFLAGS+= -DNDEBUG=1 -DUSE_SMALL=1 .endif -- 2.44.0