X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdebug.c;h=18c7ebbc0ca1702b3a416569804c8ddf401f42ea;hb=641a3c5a09b61973431c5772333f65eeb76e76c0;hp=b32036e5a277dbe92ab0e3955bf883f8fac957e2;hpb=47e16a4f3eef67b009c3a0389d6e03b95e6dca57;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/debug.c b/KernelLand/Kernel/debug.c index b32036e5..18c7ebbc 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, ...) @@ -431,16 +431,16 @@ void Debug_HexDump(const char *Header, const void *Data, size_t Length) Uint pos = 0; LogF("%014lli ", now()); Debug_Puts(1, Header); - LogF(" (Hexdump of %p)\r\n", Data); + LogF(" (Hexdump of %p+%i)\r\n", Data, Length); #define CH(n) ((' '<=cdat[(n)]&&cdat[(n)]<0x7F) ? cdat[(n)] : '.') while(Length >= 16) { LogF("%014lli Log: %04x:" - " %02x %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x %02x" - " %c%c%c%c%c%c%c%c %c%c%c%c%c%c%c%c\r\n", + " %02x %02x %02x %02x %02x %02x %02x %02x " + " %02x %02x %02x %02x %02x %02x %02x %02x " + " %c%c%c%c%c%c%c%c %c%c%c%c%c%c%c%c\r\n", now(), pos, cdat[ 0], cdat[ 1], cdat[ 2], cdat[ 3], cdat[ 4], cdat[ 5], cdat[ 6], cdat[ 7],