From: John Hodge Date: Sat, 20 Aug 2011 10:30:58 +0000 (+0800) Subject: Kernel - Debugging cleanup X-Git-Tag: rel0.11~147 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9dc3cf2a69c5c4563091f37a06eece1723f51d0d;p=tpg%2Facess2.git Kernel - Debugging cleanup --- diff --git a/Kernel/binary.c b/Kernel/binary.c index 58d86d77..76f84ed8 100644 --- a/Kernel/binary.c +++ b/Kernel/binary.c @@ -68,11 +68,12 @@ int Binary_RegisterType(tBinaryType *Type) } /** - * \fn int Proc_Spawn(char *Path) + * \fn int Proc_Spawn(const char *Path) */ -int Proc_Spawn(char *Path) +int Proc_Spawn(const char *Path) { char stackPath[strlen(Path)+1]; + ENTER("sPath", Path); strcpy(stackPath, Path); @@ -86,6 +87,7 @@ int Proc_Spawn(char *Path) Proc_Execve(stackPath, args, &args[1]); for(;;); } + LEAVE('i', 0); return 0; } @@ -123,7 +125,7 @@ int Proc_Execve(const char *File, const char **ArgV, const char **EnvP) // Allocate argenvBuf = malloc(argenvBytes); if(argenvBuf == NULL) { - Log_Error("BIN", "Proc_Execve - What the hell? The kernel is out of heap space"); + Log_Error("Binary", "Proc_Execve - What the hell? The kernel is out of heap space"); LEAVE('i', 0); return 0; } @@ -161,7 +163,7 @@ int Proc_Execve(const char *File, const char **ArgV, const char **EnvP) free(savedFile); if(bases[0] == 0) { - Log_Warning("BIN", "Proc_Execve - Unable to load '%s'", Threads_GetName(-1)); + Log_Warning("Binary", "Proc_Execve - Unable to load '%s'", Threads_GetName(-1)); LEAVE('-'); Threads_Exit(0, -10); for(;;); @@ -199,7 +201,7 @@ Uint Binary_Load(const char *file, Uint *entryPoint) LOG("sTruePath = %p", sTruePath); if(sTruePath == NULL) { - Log_Warning("BIN", "'%s' does not exist.", file); + Log_Warning("Binary", "%p '%s' does not exist.", file, file); LEAVE('x', 0); return 0; } diff --git a/Kernel/debug.c b/Kernel/debug.c index e66b9a9f..0ad74697 100644 --- a/Kernel/debug.c +++ b/Kernel/debug.c @@ -148,6 +148,7 @@ void Debug(const char *Fmt, ...) va_start(args, Fmt); Debug_DbgOnlyFmt(Fmt, args); va_end(args); + Debug_PutCharDebug('\r'); Debug_PutCharDebug('\n'); #if LOCK_DEBUG_OUTPUT SHORTREL(&glDebug_Lock); @@ -168,6 +169,7 @@ void Log(const char *Fmt, ...) va_start(args, Fmt); Debug_Fmt(Fmt, args); va_end(args); + Debug_Putchar('\r'); Debug_Putchar('\n'); #if LOCK_DEBUG_OUTPUT @@ -186,6 +188,7 @@ void Warning(const char *Fmt, ...) va_start(args, Fmt); Debug_Fmt(Fmt, args); va_end(args); + Debug_Putchar('\r'); Debug_Putchar('\n'); #if LOCK_DEBUG_OUTPUT @@ -207,6 +210,7 @@ void Panic(const char *Fmt, ...) va_start(args, Fmt); Debug_Fmt(Fmt, args); va_end(args); + Debug_Putchar('\r'); Debug_Putchar('\n'); Threads_Dump(); @@ -285,7 +289,7 @@ void Debug_Enter(const char *FuncName, const char *ArgTypes, ...) } va_end(args); - Debug_Putchar(')'); Debug_Putchar('\n'); + Debug_Putchar(')'); Debug_Putchar('\r'); Debug_Putchar('\n'); #if LOCK_DEBUG_OUTPUT SHORTREL(&glDebug_Lock); @@ -313,6 +317,7 @@ void Debug_Log(const char *FuncName, const char *Fmt, ...) Debug_Fmt(Fmt, args); va_end(args); + Debug_Putchar('\r'); Debug_Putchar('\n'); #if LOCK_DEBUG_OUTPUT @@ -348,6 +353,7 @@ void Debug_Leave(const char *FuncName, char RetType, ...) // No Return if(RetType == '-') { + Debug_Putchar('\r'); Debug_Putchar('\n'); #if LOCK_DEBUG_OUTPUT SHORTREL(&glDebug_Lock); @@ -367,6 +373,7 @@ void Debug_Leave(const char *FuncName, char RetType, ...) // Extended (64-Bit) case 'X': Debug_Fmt("0x%llx", args); break; } + Debug_Putchar('\r'); Debug_Putchar('\n'); va_end(args); @@ -382,7 +389,7 @@ void Debug_HexDump(const char *Header, const void *Data, Uint Length) Uint pos = 0; LogF("%014lli ", now()); Debug_Puts(1, Header); - LogF(" (Hexdump of %p)\n", Data); + LogF(" (Hexdump of %p)\r\n", Data); #define CH(n) ((' '<=cdat[(n)]&&cdat[(n)]<0x7F) ? cdat[(n)] : '.') @@ -391,7 +398,7 @@ void Debug_HexDump(const char *Header, const void *Data, Uint Length) 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\n", + " %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], @@ -419,6 +426,7 @@ void Debug_HexDump(const char *Header, const void *Data, Uint Length) LogF("%c", CH(i)); } + Debug_Putchar('\r'); Debug_Putchar('\n'); } } diff --git a/Kernel/modules.c b/Kernel/modules.c index 786d409d..c0c02161 100644 --- a/Kernel/modules.c +++ b/Kernel/modules.c @@ -144,7 +144,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) // All Dependencies OK? Initialise StartupPrint(Module->Name); - Log_Log("Module", "Initialising %p '%s' v%i.%i...", + Log_Log("Module", "Starting %p '%s' v%i.%i", Module, Module->Name, Module->Version >> 8, Module->Version & 0xFF ); diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index 936bf277..1294b214 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -317,19 +317,21 @@ void SyscallHandler(tSyscallRegs *Regs) LogF("Log: [%i] ", Threads_GetTID()); LogF((char*)Regs->Arg1, Regs->Arg2, Regs->Arg3, Regs->Arg4, Regs->Arg5, Regs->Arg6); - LogF("\n"); + LogF("\r\n"); break; //#endif // -- Default (Return Error) default: - Warning("SyscallHandler: Unknown System Call %i", Regs->Num); + Log_Warning("Syscalls", "Unknown System Call %i", Regs->Num); if(Regs->Num < NUM_SYSCALLS) - Warning(" Syscall '%s'", cSYSCALL_NAMES[Regs->Num]); + Log_Warning("Syscall", " named '%s'", cSYSCALL_NAMES[Regs->Num]); err = -ENOSYS; ret = -1; break; } + + if(err == 0) err = errno; if(err != 0) { LOG("ID: %i, Return errno = %i", Regs->Num, err);