From: John Hodge Date: Sun, 8 Jun 2014 09:57:23 +0000 (+0800) Subject: Kernel/Debug - Fix normal log lines to be printed in one go X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=31bf9d6faae9630f2de1244fc4317fc91db8bc07;p=tpg%2Facess2.git Kernel/Debug - Fix normal log lines to be printed in one go - Propagate full-draw-success status from Debug_Fmt to allow detection of a truncated line (and allow line capping) --- diff --git a/KernelLand/Kernel/arch/x86/time.c b/KernelLand/Kernel/arch/x86/time.c index 54e59a5d..b367c50a 100644 --- a/KernelLand/Kernel/arch/x86/time.c +++ b/KernelLand/Kernel/arch/x86/time.c @@ -103,6 +103,7 @@ void Time_Interrupt(int IRQ, void *Ptr) if( giTime_TSCAtLastTick ) { giTime_TSCPerTick = curTSC - giTime_TSCAtLastTick; + //Debug("TSC Frequency is %llu-%llu = %llu Hz", curTSC, giTime_TSCAtLastTick, giTime_TSCPerTick*2); } giTime_TSCAtLastTick = curTSC; diff --git a/KernelLand/Kernel/debug.c b/KernelLand/Kernel/debug.c index b32036e5..ec39a16b 100644 --- a/KernelLand/Kernel/debug.c +++ b/KernelLand/Kernel/debug.c @@ -21,7 +21,7 @@ static void Debug_Putchar(char ch); static void Debug_Puts(int bUseKTerm, const char *Str); void Debug_DbgOnlyFmt(const char *format, va_list args); void Debug_FmtS(int bUseKTerm, const char *format, ...); -void Debug_Fmt(int bUseKTerm, const char *format, va_list args); +bool Debug_Fmt(int bUseKTerm, const char *format, va_list args); void Debug_SetKTerminal(const char *File); // === GLOBALS === @@ -91,17 +91,18 @@ void Debug_DbgOnlyFmt(const char *format, va_list args) Debug_Fmt(0, format, args); } -void Debug_Fmt(int bUseKTerm, const char *format, va_list args) +bool Debug_Fmt(int bUseKTerm, const char *format, va_list args) { char buf[DEBUG_MAX_LINE_LEN]; buf[DEBUG_MAX_LINE_LEN-1] = 0; - int len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args); + size_t len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args); Debug_Puts(bUseKTerm, buf); if( len > DEBUG_MAX_LINE_LEN-1 ) { // do something Debug_Puts(bUseKTerm, "[...]"); + return false; } - return ; + return true; } void Debug_FmtS(int bUseKTerm, const char *format, ...) @@ -131,25 +132,24 @@ void Debug_KernelPanic(void) /** * \fn void LogF(const char *Msg, ...) * \brief Raw debug log (no new line, no prefix) + * \return True if all of the provided text was printed */ -void LogF(const char *Fmt, ...) +bool LogF(const char *Fmt, ...) { - va_list args; - #if LOCK_DEBUG_OUTPUT - if(CPU_HAS_LOCK(&glDebug_Lock)) return ; + if(CPU_HAS_LOCK(&glDebug_Lock)) return true; SHORTLOCK(&glDebug_Lock); #endif + va_list args; va_start(args, Fmt); - - Debug_Fmt(1, Fmt, args); - + bool rv = Debug_Fmt(1, Fmt, args); va_end(args); #if LOCK_DEBUG_OUTPUT SHORTREL(&glDebug_Lock); #endif + return rv; } /** * \fn void Debug(const char *Msg, ...) diff --git a/KernelLand/Kernel/include/logdebug.h b/KernelLand/Kernel/include/logdebug.h index b6b7997e..39bdba38 100644 --- a/KernelLand/Kernel/include/logdebug.h +++ b/KernelLand/Kernel/include/logdebug.h @@ -38,7 +38,7 @@ extern void Log_Debug(const char *Ident, const char *Message, ...); extern void Debug_KernelPanic(void); //!< Initiate a kernel panic extern void Panic(const char *Msg, ...) NORETURN; //!< Print a panic message (initiates a kernel panic) extern void Warning(const char *Msg, ...); //!< Print a warning message -extern void LogF(const char *Fmt, ...); //!< Print a log message without a trailing newline +extern bool LogF(const char *Fmt, ...); //!< Print a log message without a trailing newline extern void LogFV(const char *Fmt, va_list Args); //!< va_list non-newline log message extern void Log(const char *Fmt, ...); //!< Print a log message extern void Debug(const char *Fmt, ...); //!< Print a debug message (doesn't go to KTerm) diff --git a/KernelLand/Kernel/logging.c b/KernelLand/Kernel/logging.c index 46d4c049..3ccfef2b 100644 --- a/KernelLand/Kernel/logging.c +++ b/KernelLand/Kernel/logging.c @@ -158,18 +158,18 @@ void Log_Int_PrintMessage(tLogEntry *Entry) if( CPU_HAS_LOCK(&glLogOutput) ) return ; // TODO: Error? SHORTLOCK( &glLogOutput ); - LogF("%s%014lli", + bool completed = LogF( + "%s%014lli%s [%-8s] %i - %.*s\x1B[0m\r\n", csaLevelColours[Entry->Level], - Entry->Time - ); - LogF("%s [%-8s] %i - %.*s", + Entry->Time, csaLevelCodes[Entry->Level], Entry->Ident, Threads_GetTID(), Entry->Length, Entry->Data ); - LogF("\x1B[0m\r\n"); // Separate in case Entry->Data is too long + if( !completed ) + LogF("\x1B[0m\r\n"); // Separate in case Entry->Data is too long SHORTREL( &glLogOutput ); }