Author: hbelusca Date: Thu Oct 6 19:01:33 2016 New Revision: 72922
URL: http://svn.reactos.org/svn/reactos?rev=72922&view=rev Log: [KD] - When enabling or disabling the kernel debugger and setting the KdDebuggerEnabled flag, also update the corresponding user-mode flag in SharedUserData->KdDebuggerEnabled. - Turn KdpGetMemorySizeInMBs into a INIT_FUNCTION. - Print kernel command line & ARC paths even in debug log file mode.
[KD64] WinKD: Also print our nice ReactOS debug header (version, # of processors & memory MB, kernel command line and ARC paths).
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c trunk/reactos/ntoskrnl/kd/kdio.c trunk/reactos/ntoskrnl/kd/kdmain.c trunk/reactos/ntoskrnl/kd64/kdapi.c trunk/reactos/ntoskrnl/kd64/kdinit.c
Modified: trunk/reactos/ntoskrnl/kd/kdinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdinit.c?rev=72... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdinit.c [iso-8859-1] Thu Oct 6 19:01:33 2016 @@ -118,8 +118,9 @@ KdpDebugMode.Gdb = TRUE;
/* Enable Debugging */ + KdDebuggerNotPresent = FALSE; KdDebuggerEnabled = TRUE; - KdDebuggerNotPresent = FALSE; + SharedUserData->KdDebuggerEnabled = TRUE; WrapperInitRoutine = KdpGdbStubInit; }
@@ -131,8 +132,9 @@ KdpDebugMode.Pice = TRUE;
/* Enable Debugging */ + KdDebuggerNotPresent = FALSE; KdDebuggerEnabled = TRUE; - KdDebuggerNotPresent = FALSE; + SharedUserData->KdDebuggerEnabled = TRUE; }
return p2; @@ -192,14 +194,17 @@ else if (strstr(CommandLine, "DEBUG")) { /* Enable the kernel debugger */ + KdDebuggerNotPresent = FALSE; KdDebuggerEnabled = TRUE; - KdDebuggerNotPresent = FALSE; #ifdef KDBG /* Get the KDBG Settings */ KdbpGetCommandLineSettings(LoaderBlock->LoadOptions); #endif }
+ /* Let user-mode know our state */ + SharedUserData->KdDebuggerEnabled = KdDebuggerEnabled; + /* Get the port and baud rate */ Port = strstr(CommandLine, "DEBUGPORT"); BaudRate = strstr(CommandLine, "BAUDRATE");
Modified: trunk/reactos/ntoskrnl/kd/kdio.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdio.c?rev=7292... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] Thu Oct 6 19:01:33 2016 @@ -11,6 +11,7 @@
#include <ntoskrnl.h> #include <reactos/buildno.h> +#define NDEBUG #include <debug.h>
/* GLOBALS *******************************************************************/ @@ -53,9 +54,11 @@ * * Strongly inspired by: * mm\ARM3\mminit.c : MiScanMemoryDescriptors(...) + * + * See also: kd64\kdinit.c */ -SIZE_T -NTAPI +static SIZE_T +INIT_FUNCTION KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { PLIST_ENTRY ListEntry; @@ -240,10 +243,15 @@ KeInitializeSpinLock(&KdpDebugLogSpinLock);
/* Display separator + ReactOS version at start of the debug log */ - DPRINT1("---------------------------------------------------------------\n"); + DPRINT1("-----------------------------------------------------\n"); DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n"); MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors, MemSizeMBs); + DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions); + DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName, + KeLoaderBlock->NtHalPathName, + KeLoaderBlock->ArcHalDeviceName, + KeLoaderBlock->NtBootPathName); } else if (BootPhase == 2) {
Modified: trunk/reactos/ntoskrnl/kd/kdmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdmain.c?rev=72... ============================================================================== --- trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] Thu Oct 6 19:01:33 2016 @@ -295,6 +295,7 @@
/* Disable the Debugger */ KdDebuggerEnabled = FALSE; + SharedUserData->KdDebuggerEnabled = FALSE;
/* Lower the IRQL */ KeLowerIrql(OldIrql); @@ -319,6 +320,7 @@
/* Enable the Debugger */ KdDebuggerEnabled = TRUE; + SharedUserData->KdDebuggerEnabled = TRUE;
/* Lower the IRQL */ KeLowerIrql(OldIrql);
Modified: trunk/reactos/ntoskrnl/kd64/kdapi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdapi.c?rev=7... ============================================================================== --- trunk/reactos/ntoskrnl/kd64/kdapi.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd64/kdapi.c [iso-8859-1] Thu Oct 6 19:01:33 2016 @@ -2013,7 +2013,7 @@ if (KdPreviouslyEnabled) { /* Reinitialize the Debugger */ - KdInitSystem(0, NULL) ; + KdInitSystem(0, NULL); KdpRestoreAllBreakpoints(); } }
Modified: trunk/reactos/ntoskrnl/kd64/kdinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdinit.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/kd64/kdinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd64/kdinit.c [iso-8859-1] Thu Oct 6 19:01:33 2016 @@ -10,8 +10,60 @@ /* INCLUDES ******************************************************************/
#include <ntoskrnl.h> +#include <reactos/buildno.h> #define NDEBUG #include <debug.h> + +/* UTILITY FUNCTIONS *********************************************************/ + +/* + * Get the total size of the memory before + * Mm is initialized, by counting the number + * of physical pages. Useful for debug logging. + * + * Strongly inspired by: + * mm\ARM3\mminit.c : MiScanMemoryDescriptors(...) + * + * See also: kd\kdio.c + */ +static SIZE_T +INIT_FUNCTION +KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PLIST_ENTRY ListEntry; + PMEMORY_ALLOCATION_DESCRIPTOR Descriptor; + SIZE_T NumberOfPhysicalPages = 0; + + /* Loop the memory descriptors */ + for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink; + ListEntry != &LoaderBlock->MemoryDescriptorListHead; + ListEntry = ListEntry->Flink) + { + /* Get the descriptor */ + Descriptor = CONTAINING_RECORD(ListEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Check if this is invisible memory */ + if ((Descriptor->MemoryType == LoaderFirmwarePermanent) || + (Descriptor->MemoryType == LoaderSpecialMemory) || + (Descriptor->MemoryType == LoaderHALCachedMemory) || + (Descriptor->MemoryType == LoaderBBTMemory)) + { + /* Skip this descriptor */ + continue; + } + + /* Check if this is bad memory */ + if (Descriptor->MemoryType != LoaderBad) + { + /* Count this in the total of pages */ + NumberOfPhysicalPages += Descriptor->PageCount; + } + } + + return NumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; +}
/* FUNCTIONS *****************************************************************/
@@ -80,6 +132,7 @@ PLIST_ENTRY NextEntry; ULONG i, j, Length; SIZE_T DebugOptionLength; + SIZE_T MemSizeMBs; CHAR NameBuffer[256]; PWCHAR Name;
@@ -321,6 +374,20 @@ /* Let user-mode know that it's enabled as well */ SharedUserData->KdDebuggerEnabled = TRUE;
+ /* Display separator + ReactOS version at start of the debug log */ + DPRINT1("-----------------------------------------------------\n"); + DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n"); + MemSizeMBs = KdpGetMemorySizeInMBs(KeLoaderBlock); + DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors, MemSizeMBs); + if (KeLoaderBlock) + { + DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions); + DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName, + KeLoaderBlock->NtHalPathName, + KeLoaderBlock->ArcHalDeviceName, + KeLoaderBlock->NtBootPathName); + } + /* Check if the debugger should be disabled initially */ if (DisableKdAfterInit) {