Author: fireball
Date: Wed Oct 31 17:41:27 2007
New Revision: 30014
URL:
http://svn.reactos.org/svn/reactos?rev=30014&view=rev
Log:
- Dispatch all symbol loads to a single function, which determines type of passed name,
and calls worker function.
- Print source file:line in stack traces if possible, when KDBG is enabled
- if KDBG is not defined, behaviour of the mainstream code is completely untouched.
Modified:
trunk/reactos/ntoskrnl/include/internal/kd.h
trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
trunk/reactos/ntoskrnl/ke/bug.c
trunk/reactos/ntoskrnl/mm/sysldr.c
Modified: trunk/reactos/ntoskrnl/include/internal/kd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/kd.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/kd.h Wed Oct 31 17:41:27 2007
@@ -84,7 +84,12 @@
KdbSymUnloadDriverSymbols(IN PLDR_DATA_TABLE_ENTRY ModuleObject);
VOID
-KdbSymProcessBootSymbols(IN PANSI_STRING FileName);
+KdbSymProcessBootSymbols(IN PANSI_STRING AnsiFileName,
+ IN BOOLEAN FullName,
+ IN BOOLEAN LoadFromFile);
+
+VOID
+KdbSymProcessSymbols(IN PANSI_STRING FileName);
BOOLEAN
KdbSymPrintAddress(IN PVOID Address);
@@ -114,7 +119,7 @@
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME, MODULE)
# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
-# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessBootSymbols(FILENAME)
+# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessSymbols(FILENAME)
#else
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) do { } while (0)
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c Wed Oct 31 17:41:27 2007
@@ -442,7 +442,7 @@
FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(Status))
{
- DPRINT("Could not open image file: %wZ\n", &FileName);
+ DPRINT("Could not open image file: %wZ\n", FileName);
return;
}
@@ -577,6 +577,54 @@
ModuleObject->PatchInformation = NULL;
}
+VOID
+KdbSymProcessSymbols(IN PANSI_STRING AnsiFileName)
+{
+ ANSI_STRING SystemPrefix, RealPathPrefix, ProperName;
+ CHAR Buffer[MAX_PATH], RealPathBuffer[MAX_PATH];
+
+ /* Init our strings for compare operations */
+ RtlInitAnsiString(&SystemPrefix, "\\SystemRoot");
+
+ /* Convert system root to ansi */
+ sprintf(RealPathBuffer, "%S",
(PWCHAR)&SharedUserData->NtSystemRoot[2]);
+ RtlInitAnsiString(&RealPathPrefix, RealPathBuffer);
+ RealPathPrefix.MaximumLength = MAX_PATH;
+
+ /* There are 3 cases:
+ 1) \SystemRoot\System32\ -> no change
+ 2) \ReactOS\System32 -> \SystemRoot\System32
+ 3) module.dll -> \??\C:\ReactOS\system32\module.dll
+ */
+ if (RtlPrefixString(&SystemPrefix, AnsiFileName, FALSE))
+ {
+ /* Case: \SystemRoot\System32\ , just directly load it */
+ KdbSymProcessBootSymbols(AnsiFileName, TRUE, FALSE);
+ }
+ else if (RtlPrefixString(&RealPathPrefix, AnsiFileName, FALSE))
+ {
+ /* It's prefixed with a real path, instead of a \SystemRoot.
+ So build a new, proper name. */
+ RtlZeroMemory(Buffer, MAX_PATH);
+ strcpy(Buffer, "\\SystemRoot");
+ strncat(Buffer,
+ AnsiFileName->Buffer + RealPathPrefix.Length,
+ AnsiFileName->Length - RealPathPrefix.Length);
+
+ /* Convert it to ANSI_STRING */
+ RtlInitAnsiString(&ProperName, Buffer);
+
+ /* Process symbols */
+ KdbSymProcessBootSymbols(&ProperName, TRUE, TRUE);
+ }
+ else
+ {
+ /* Just a bare filename, nothing else. Why? Who knows... */
+ KdbSymProcessBootSymbols(AnsiFileName, FALSE, TRUE);
+ }
+}
+
+
/*! \brief Called when a symbol file is loaded by the loader?
*
* Tries to find a driver (.sys) or executable (.exe) with the same base name
@@ -587,7 +635,9 @@
* \param FileName Filename for which the symbols are loaded.
*/
VOID
-KdbSymProcessBootSymbols(IN PANSI_STRING AnsiFileName)
+KdbSymProcessBootSymbols(IN PANSI_STRING AnsiFileName,
+ IN BOOLEAN FullName,
+ IN BOOLEAN LoadFromFile)
{
BOOLEAN Found = FALSE;
PLIST_ENTRY ListHead, NextEntry;
@@ -624,10 +674,21 @@
LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
- if (RtlEqualUnicodeString(&ModuleName, &LdrEntry->FullDllName, TRUE))
+ if (FullName)
{
- Found = TRUE;
- break;
+ if (RtlEqualUnicodeString(&ModuleName, &LdrEntry->FullDllName,
TRUE))
+ {
+ Found = TRUE;
+ break;
+ }
+ }
+ else
+ {
+ if (RtlEqualUnicodeString(&ModuleName, &LdrEntry->BaseDllName,
TRUE))
+ {
+ Found = TRUE;
+ break;
+ }
}
/* Go to the next one */
@@ -651,17 +712,26 @@
KdbpSymRemoveCachedFile(LdrEntry->PatchInformation);
}
- /* Load new symbol information */
- if (! RosSymCreateFromMem(LdrEntry->DllBase,
- LdrEntry->SizeOfImage,
- (PROSSYM_INFO*)&LdrEntry->PatchInformation))
- {
- /* Error loading symbol info, exit */
- return;
- }
-
- /* Add file to cache */
- KdbpSymAddCachedFile(&ModuleName, LdrEntry->PatchInformation);
+ if (LoadFromFile)
+ {
+ /* Load symbol info from file */
+ KdbpSymLoadModuleSymbols(&LdrEntry->FullDllName,
+ (PROSSYM_INFO*)&LdrEntry->PatchInformation);
+ }
+ else
+ {
+ /* Load new symbol information */
+ if (! RosSymCreateFromMem(LdrEntry->DllBase,
+ LdrEntry->SizeOfImage,
+ (PROSSYM_INFO*)&LdrEntry->PatchInformation))
+ {
+ /* Error loading symbol info, exit */
+ return;
+ }
+
+ /* Add file to cache */
+ KdbpSymAddCachedFile(&ModuleName, LdrEntry->PatchInformation);
+ }
DPRINT("Installed symbols: %wZ@%08x-%08x %p\n",
&ModuleName,
@@ -767,9 +837,9 @@
/* FIXME: Load as 1st and 2nd entries of InLoadOrderList instead
of hardcoding them here! */
RtlInitAnsiString(&FileName,
"\\SystemRoot\\System32\\NTOSKRNL.EXE");
- KdbSymProcessBootSymbols(&FileName);
+ KdbSymProcessBootSymbols(&FileName, TRUE, FALSE);
RtlInitAnsiString(&FileName, "\\SystemRoot\\System32\\HAL.DLL");
- KdbSymProcessBootSymbols(&FileName);
+ KdbSymProcessBootSymbols(&FileName, TRUE, FALSE);
}
}
Modified: trunk/reactos/ntoskrnl/ke/bug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=3001…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/bug.c (original)
+++ trunk/reactos/ntoskrnl/ke/bug.c Wed Oct 31 17:41:27 2007
@@ -290,8 +290,14 @@
if (KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry))
{
/* Print out the module name */
- Addr -= (ULONG_PTR)LdrEntry->DllBase;
- DbgPrint("<%wZ: %x>", &LdrEntry->FullDllName, Addr);
+#ifdef KDBG
+ if (!KdbSymPrintAddress((PVOID)Addr))
+#endif
+ {
+ /* Fall back to usual printing */
+ Addr -= (ULONG_PTR)LdrEntry->DllBase;
+ DbgPrint("<%wZ: %x>", &LdrEntry->FullDllName,
Addr);
+ }
}
else if (Addr)
{
Modified: trunk/reactos/ntoskrnl/mm/sysldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/sysldr.c (original)
+++ trunk/reactos/ntoskrnl/mm/sysldr.c Wed Oct 31 17:41:27 2007
@@ -1860,7 +1860,12 @@
}
/* Check if there's symbols */
+#ifdef KDBG
+ /* If KDBG is defined, then we always have symbols */
+ if (TRUE)
+#else
if (MiCacheImageSymbols(LdrEntry->DllBase))
+#endif
{
/* Check if the system root is present */
if ((PrefixName.Length > (11 * sizeof(WCHAR))) &&