Author: dgorbachev Date: Mon Jun 22 15:32:58 2009 New Revision: 41534
URL: http://svn.reactos.org/svn/reactos?rev=41534&view=rev Log: - If KDBG is not compiled in, try to use GDB instead. - Check WrapperTable.KdpPrintRoutine. - Allow to use GDB (/DEBUGPORT=GDB) and have debug output (/DEBUGPORT=COM1) at the same time.
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c trunk/reactos/ntoskrnl/kd/kdio.c trunk/reactos/ntoskrnl/kd/kdmain.c
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdinit.c?rev=41... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdinit.c [iso-8859-1] Mon Jun 22 15:32:58 2009 @@ -44,13 +44,52 @@
PCHAR NTAPI -KdpGetWrapperDebugMode(PCHAR Currentp2, - PLOADER_PARAMETER_BLOCK LoaderBlock) +KdpGetDebugMode(PCHAR Currentp2) { PCHAR p2 = Currentp2; + ULONG Value; + + /* Check for Screen Debugging */ + if (!_strnicmp(p2, "SCREEN", 6)) + { + /* Enable It */ + p2 += 6; + KdpDebugMode.Screen = TRUE; + } + /* Check for Serial Debugging */ + else if (!_strnicmp(p2, "COM", 3)) + { + /* Gheck for a valid Serial Port */ + p2 += 3; + Value = (ULONG)atol(p2); + if (Value > 0 && Value < 5) + { + /* Valid port found, enable Serial Debugging */ + KdpDebugMode.Serial = TRUE; + + /* Set the port to use */ + SerialPortInfo.ComPort = Value; + KdpPort = Value; + } + } + /* Check for Debug Log Debugging */ + else if (!_strnicmp(p2, "FILE", 4)) + { + /* Enable It */ + p2 += 4; + KdpDebugMode.File = TRUE; + } + + /* Check for BOCHS Debugging */ + else if (!_strnicmp(p2, "BOCHS", 5)) + { + /* Enable It */ + p2 += 5; + KdpDebugMode.Bochs = TRUE; + }
/* Check for GDB Debugging */ - if (!_strnicmp(p2, "GDB", 3)) + else if (!_strnicmp(p2, "GDB", 3)) { /* Enable it */ p2 += 3; @@ -72,61 +111,6 @@ /* Enable Debugging */ KdDebuggerEnabled = TRUE; KdDebuggerNotPresent = FALSE; - } - -#ifdef KDBG - /* Get the KDBG Settings and enable it */ - KdDebuggerEnabled = TRUE; - KdDebuggerNotPresent = FALSE; - KdbpGetCommandLineSettings(LoaderBlock->LoadOptions); -#endif - return p2; -} - -PCHAR -NTAPI -KdpGetDebugMode(PCHAR Currentp2) -{ - PCHAR p2 = Currentp2; - ULONG Value; - - /* Check for Screen Debugging */ - if (!_strnicmp(p2, "SCREEN", 6)) - { - /* Enable It */ - p2 += 6; - KdpDebugMode.Screen = TRUE; - } - /* Check for Serial Debugging */ - else if (!_strnicmp(p2, "COM", 3)) - { - /* Gheck for a valid Serial Port */ - p2 += 3; - Value = (ULONG)atol(p2); - if (Value > 0 && Value < 5) - { - /* Valid port found, enable Serial Debugging */ - KdpDebugMode.Serial = TRUE; - - /* Set the port to use */ - SerialPortInfo.ComPort = Value; - KdpPort = Value; - } - } - /* Check for Debug Log Debugging */ - else if (!_strnicmp(p2, "FILE", 4)) - { - /* Enable It */ - p2 += 4; - KdpDebugMode.File = TRUE; - } - - /* Check for BOCHS Debugging */ - else if (!_strnicmp(p2, "BOCHS", 5)) - { - /* Enable It */ - p2 += 5; - KdpDebugMode.Bochs = TRUE; }
return p2; @@ -179,7 +163,7 @@ /* Upcase it */ _strupr(CommandLine);
- /* Check for settings that we support */ + /* XXX Check for settings that we support */ if (strstr(CommandLine, "BREAK")) KdpEarlyBreak = TRUE; if (strstr(CommandLine, "NODEBUG")) KdDebuggerEnabled = FALSE; if (strstr(CommandLine, "CRASHDEBUG")) KdDebuggerEnabled = FALSE; @@ -190,16 +174,23 @@ KdpDebugMode.Serial = TRUE; }
+#ifdef KDBG + /* Get the KDBG Settings and enable it */ + KdDebuggerEnabled = TRUE; + KdDebuggerNotPresent = FALSE; + KdbpGetCommandLineSettings(LoaderBlock->LoadOptions); +#endif + /* Get the port and baud rate */ Port = strstr(CommandLine, "DEBUGPORT"); BaudRate = strstr(CommandLine, "BAUDRATE"); Irq = strstr(CommandLine, "IRQ");
- /* Check if we got the /DEBUGPORT parameter */ - if (Port) + /* Check if we got the /DEBUGPORT parameter(s) */ + while (Port) { /* Move past the actual string, to reach the port*/ - Port += strlen("DEBUGPORT"); + Port += sizeof("DEBUGPORT") - 1;
/* Now get past any spaces and skip the equal sign */ while (*Port == ' ') Port++; @@ -207,15 +198,14 @@
/* Get the debug mode and wrapper */ Port = KdpGetDebugMode(Port); - Port = KdpGetWrapperDebugMode(Port, LoaderBlock); - KdDebuggerEnabled = TRUE; + Port = strstr(Port, "DEBUGPORT"); }
/* Check if we got a baud rate */ if (BaudRate) { /* Move past the actual string, to reach the rate */ - BaudRate += strlen("BAUDRATE"); + BaudRate += sizeof("BAUDRATE") - 1;
/* Now get past any spaces */ while (*BaudRate == ' ') BaudRate++; @@ -233,7 +223,7 @@ if (Irq) { /* Move past the actual string, to reach the rate */ - Irq += strlen("IRQ"); + Irq += sizeof("IRQ") - 1;
/* Now get past any spaces */ while (*Irq == ' ') Irq++; @@ -257,7 +247,7 @@ if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0); return TRUE; } - else + else /* BootPhase > 0 */ { #ifdef _M_IX86 KdpEnableSafeMem(); @@ -271,4 +261,4 @@ return TRUE; }
- /* EOF */ +/* EOF */
Modified: trunk/reactos/ntoskrnl/kd/kdio.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdio.c?rev=4153... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] Mon Jun 22 15:32:58 2009 @@ -293,11 +293,11 @@ }
/* Call the Wrapper Routine */ - if (WrapperInitRoutine) WrapperTable.KdpPrintRoutine(String, Length); + if (WrapperTable.KdpPrintRoutine) + WrapperTable.KdpPrintRoutine(String, Length);
/* Return the Length */ return Length; }
/* EOF */ -
Modified: trunk/reactos/ntoskrnl/kd/kdmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdmain.c?rev=41... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] Mon Jun 22 15:32:58 2009 @@ -163,12 +163,22 @@ EipOld = Context->Eip; #endif
+#ifdef KDBG /* Call KDBG if available */ Return = KdbEnterDebuggerException(ExceptionRecord, PreviousMode, Context, TrapFrame, !SecondChance); +#else /* not KDBG */ + if (WrapperInitRoutine) + { + /* Call GDB */ + Return = WrapperTable.KdpExceptionRoutine(ExceptionRecord, + Context, + TrapFrame); + } +#endif /* not KDBG */
/* Bump EIP over int 3 if debugger did not already change it */ if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT)