Symbol loading working in kdb.

svn path=/trunk/; revision=3249
This commit is contained in:
David Welch 2002-07-18 00:25:31 +00:00
parent 90bd33d955
commit 2e467c56a3
13 changed files with 171 additions and 164 deletions

View file

@ -8,12 +8,12 @@ ARCH := i386
# #
# Whether to compile in the kernel debugger # Whether to compile in the kernel debugger
# #
KDBG := 0 KDBG := 1
# #
# Whether to compile for debugging # Whether to compile for debugging
# #
DBG := 0 DBG := 1
# #
# Whether to compile a multiprocessor or single processor version # Whether to compile a multiprocessor or single processor version

View file

@ -1,3 +1,6 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_LDR_H
#define __NTOSKRNL_INCLUDE_INTERNAL_LDR_H
#include <ntos/kdbgsyms.h> #include <ntos/kdbgsyms.h>
#include <roscfg.h> #include <roscfg.h>
@ -19,9 +22,9 @@ typedef struct _LDR_MODULE
HANDLE SectionHandle; HANDLE SectionHandle;
ULONG CheckSum; ULONG CheckSum;
ULONG TimeDateStamp; ULONG TimeDateStamp;
#ifdef DBG #ifdef KDBG
IMAGE_SYMBOL_INFO SymbolInfo; IMAGE_SYMBOL_INFO SymbolInfo;
#endif /* DBG */ #endif /* KDBG */
} LDR_MODULE, *PLDR_MODULE; } LDR_MODULE, *PLDR_MODULE;
typedef struct _LDR_SYMBOL_INFO { typedef struct _LDR_SYMBOL_INFO {
@ -57,7 +60,7 @@ typedef struct _MODULE_INFORMATION
MODULE_ENTRY ModuleEntry[1]; MODULE_ENTRY ModuleEntry[1];
} MODULE_INFORMATION, *PMODULE_INFORMATION; } MODULE_INFORMATION, *PMODULE_INFORMATION;
#ifdef DBG #ifdef KDBG
VOID VOID
LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule); LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule);
@ -118,4 +121,6 @@ LdrShutdownThread(VOID);
NTSTATUS STDCALL NTSTATUS STDCALL
LdrUnloadDll(IN PVOID BaseAddress); LdrUnloadDll(IN PVOID BaseAddress);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_LDR_H */
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.73 2002/07/13 12:44:07 chorns Exp $ # $Id: Makefile,v 1.74 2002/07/18 00:25:30 dwelch Exp $
# #
# ReactOS Operating System # ReactOS Operating System
# #
@ -27,7 +27,7 @@ endif
ifeq ($(KDBG), 1) ifeq ($(KDBG), 1)
OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/rdebug.o \ OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/rdebug.o \
dbg/i386/kdb_help.o dbg/i386/kdb_help.o dbg/kdb_stabs.o
else else
OBJECTS_KDBG := OBJECTS_KDBG :=
endif endif

View file

@ -28,6 +28,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <roscfg.h> #include <roscfg.h>
#include <internal/ldr.h> #include <internal/ldr.h>
#include <internal/kd.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -52,8 +53,8 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode,
break; break;
#ifdef KDBG #ifdef KDBG
case DebugDbgLoadSymbols: case DebugDbgLoadSymbols:
LdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer); KdbLdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
#endif /* DBG */ #endif /* KDBG */
break; break;
default: default:
break; break;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: kdb.c,v 1.6 2002/05/05 14:57:43 chorns Exp $ /* $Id: kdb.c,v 1.7 2002/07/18 00:25:30 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/dbg/kdb.c * FILE: ntoskrnl/dbg/kdb.c
@ -33,6 +33,7 @@
#include <internal/ps.h> #include <internal/ps.h>
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <internal/kd.h>
#include "kdb.h" #include "kdb.h"
#define NDEBUG #define NDEBUG
@ -259,7 +260,11 @@ DbgPrintBackTrace(PULONG Frame, ULONG StackBase, ULONG StackLimit)
while (Frame != NULL && (ULONG)Frame >= StackLimit && while (Frame != NULL && (ULONG)Frame >= StackLimit &&
(ULONG)Frame < StackBase) (ULONG)Frame < StackBase)
{ {
#if 0
DbgPrint("%.8x ", Frame[1]); DbgPrint("%.8x ", Frame[1]);
#else
KdbPrintAddress((PVOID)Frame[1]);
#endif
Frame = (PULONG)Frame[0]; Frame = (PULONG)Frame[0];
i++; i++;
} }

View file

@ -39,14 +39,13 @@
#include <internal/trap.h> #include <internal/trap.h>
#include <ntdll/ldr.h> #include <ntdll/ldr.h>
#include <internal/safe.h> #include <internal/safe.h>
#include <internal/kd.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
#ifdef DBG
typedef struct _SYMBOLFILE_HEADER { typedef struct _SYMBOLFILE_HEADER {
unsigned long StabsOffset; unsigned long StabsOffset;
unsigned long StabsLength; unsigned long StabsLength;
@ -91,11 +90,8 @@ typedef struct _STAB_ENTRY {
*/ */
#define N_SO 0x64 #define N_SO 0x64
LIST_ENTRY SymbolListHead; static LIST_ENTRY SymbolListHead;
static KSPIN_LOCK SymbolListLock;
#endif /* DBG */
#ifdef DBG
NTSTATUS NTSTATUS
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo, LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
@ -104,24 +100,23 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
OUT PCH FileName OPTIONAL, OUT PCH FileName OPTIONAL,
OUT PCH FunctionName OPTIONAL); OUT PCH FunctionName OPTIONAL);
#endif /* DBG */ VOID
KdbLdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo);
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
STATIC BOOLEAN BOOLEAN
print_user_address(PVOID address) KdbPrintUserAddress(PVOID address)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
PLDR_MODULE current; PLDR_MODULE current;
PEPROCESS CurrentProcess; PEPROCESS CurrentProcess;
PPEB Peb = NULL; PPEB Peb = NULL;
ULONG_PTR RelativeAddress; ULONG_PTR RelativeAddress;
#ifdef DBG
NTSTATUS Status; NTSTATUS Status;
ULONG LineNumber; ULONG LineNumber;
CHAR FileName[256]; CHAR FileName[256];
CHAR FunctionName[256]; CHAR FunctionName[256];
#endif
CurrentProcess = PsGetCurrentProcess(); CurrentProcess = PsGetCurrentProcess();
if (NULL != CurrentProcess) if (NULL != CurrentProcess)
@ -147,7 +142,6 @@ print_user_address(PVOID address)
address < (PVOID)(current->BaseAddress + current->SizeOfImage)) address < (PVOID)(current->BaseAddress + current->SizeOfImage))
{ {
RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress; RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
#ifdef DBG
Status = LdrGetAddressInformation(&current->SymbolInfo, Status = LdrGetAddressInformation(&current->SymbolInfo,
RelativeAddress, RelativeAddress,
&LineNumber, &LineNumber,
@ -162,10 +156,6 @@ print_user_address(PVOID address)
{ {
DbgPrint("<%wZ: %x>", &current->BaseDllName, RelativeAddress); DbgPrint("<%wZ: %x>", &current->BaseDllName, RelativeAddress);
} }
#else /* !DBG */
DbgPrint("<%wZ: %x>", &current->BaseDllName, RelativeAddress);
#endif /* !DBG */
return(TRUE); return(TRUE);
} }
@ -174,19 +164,17 @@ print_user_address(PVOID address)
return(FALSE); return(FALSE);
} }
STATIC BOOLEAN BOOLEAN
print_address(PVOID address) KdbPrintAddress(PVOID address)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
MODULE_TEXT_SECTION* current; MODULE_TEXT_SECTION* current;
extern LIST_ENTRY ModuleTextListHead; extern LIST_ENTRY ModuleTextListHead;
ULONG_PTR RelativeAddress; ULONG_PTR RelativeAddress;
#ifdef DBG
NTSTATUS Status; NTSTATUS Status;
ULONG LineNumber; ULONG LineNumber;
CHAR FileName[256]; CHAR FileName[256];
CHAR FunctionName[256]; CHAR FunctionName[256];
#endif
current_entry = ModuleTextListHead.Flink; current_entry = ModuleTextListHead.Flink;
@ -200,7 +188,6 @@ print_address(PVOID address)
address < (PVOID)(current->Base + current->Length)) address < (PVOID)(current->Base + current->Length))
{ {
RelativeAddress = (ULONG_PTR) address - current->Base; RelativeAddress = (ULONG_PTR) address - current->Base;
#ifdef kDBG
Status = LdrGetAddressInformation(&current->SymbolInfo, Status = LdrGetAddressInformation(&current->SymbolInfo,
RelativeAddress, RelativeAddress,
&LineNumber, &LineNumber,
@ -215,9 +202,6 @@ print_address(PVOID address)
{ {
DbgPrint("<%ws: %x>", current->Name, RelativeAddress); DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
} }
#else /* !DBG */
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
#endif /* !DBG */
return(TRUE); return(TRUE);
} }
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
@ -225,10 +209,8 @@ print_address(PVOID address)
return(FALSE); return(FALSE);
} }
#ifdef DBG
VOID VOID
PiFreeSymbols(PPEB Peb) KdbFreeSymbolsProcess(PPEB Peb)
{ {
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
PLDR_MODULE Current; PLDR_MODULE Current;
@ -245,34 +227,32 @@ PiFreeSymbols(PPEB Peb)
InLoadOrderModuleList); InLoadOrderModuleList);
SymbolInfo = &Current->SymbolInfo; SymbolInfo = &Current->SymbolInfo;
LdrUnloadModuleSymbols(SymbolInfo); KdbLdrUnloadModuleSymbols(SymbolInfo);
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
} }
} }
VOID VOID
KdbLdrInit(VOID) KdbLdrInit(MODULE_TEXT_SECTION* NtoskrnlTextSection,
MODULE_TEXT_SECTION* LdrHalTextSection)
{ {
#ifdef DBG RtlZeroMemory(&NtoskrnlTextSection->SymbolInfo,
RtlZeroMemory(&NtoskrnlTextSection.SymbolInfo, sizeof(NtoskrnlTextSection.SymbolInfo)); sizeof(NtoskrnlTextSection->SymbolInfo));
NtoskrnlTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase; NtoskrnlTextSection->SymbolInfo.ImageBase =
NtoskrnlTextSection.SymbolInfo.ImageSize = NtoskrnlTextSection.Length; NtoskrnlTextSection->OptionalHeader->ImageBase;
#endif NtoskrnlTextSection->SymbolInfo.ImageSize = NtoskrnlTextSection->Length;
#ifdef DBG RtlZeroMemory(&LdrHalTextSection->SymbolInfo,
RtlZeroMemory(&LdrHalTextSection.SymbolInfo, sizeof(LdrHalTextSection.SymbolInfo)); sizeof(LdrHalTextSection->SymbolInfo));
LdrHalTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase; LdrHalTextSection->SymbolInfo.ImageBase =
LdrHalTextSection.SymbolInfo.ImageSize = LdrHalTextSection.Length; LdrHalTextSection->OptionalHeader->ImageBase;
#endif LdrHalTextSection->SymbolInfo.ImageSize = LdrHalTextSection->Length;
#ifdef DBG
InitializeListHead(&SymbolListHead); InitializeListHead(&SymbolListHead);
#endif KeInitializeSpinLock(&SymbolListLock);
} }
#ifdef DBG
VOID VOID
LdrpParseImageSymbols(PIMAGE_SYMBOL_INFO SymbolInfo) LdrpParseImageSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
/* Note: It is important that the symbol strings buffer not be released after /* Note: It is important that the symbol strings buffer not be released after
@ -577,7 +557,7 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
VOID VOID
LdrpLoadModuleSymbols(PUNICODE_STRING FileName, LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
PIMAGE_SYMBOL_INFO SymbolInfo) PIMAGE_SYMBOL_INFO SymbolInfo)
{ {
FILE_STANDARD_INFORMATION FileStdInfo; FILE_STANDARD_INFORMATION FileStdInfo;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -681,9 +661,8 @@ LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength; SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
} }
VOID VOID
LdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo) KdbLdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
{ {
PSYMBOL NextSymbol; PSYMBOL NextSymbol;
PSYMBOL Symbol; PSYMBOL Symbol;
@ -752,7 +731,7 @@ LdrpLookupUserSymbolInfo(PLDR_MODULE LdrModule)
DPRINT("Searching symbols for %S\n", LdrModule->FullDllName.Buffer); DPRINT("Searching symbols for %S\n", LdrModule->FullDllName.Buffer);
KeAcquireSpinLock(&ModuleListLock,&Irql); KeAcquireSpinLock(&SymbolListLock, &Irql);
CurrentEntry = SymbolListHead.Flink; CurrentEntry = SymbolListHead.Flink;
while (CurrentEntry != (&SymbolListHead)) while (CurrentEntry != (&SymbolListHead))
@ -761,21 +740,20 @@ LdrpLookupUserSymbolInfo(PLDR_MODULE LdrModule)
if (RtlEqualUnicodeString(&Current->FullName, &LdrModule->FullDllName, TRUE)) if (RtlEqualUnicodeString(&Current->FullName, &LdrModule->FullDllName, TRUE))
{ {
KeReleaseSpinLock(&ModuleListLock, Irql); KeReleaseSpinLock(&SymbolListLock, Irql);
return Current; return Current;
} }
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
} }
KeReleaseSpinLock(&ModuleListLock, Irql); KeReleaseSpinLock(&SymbolListLock, Irql);
return(NULL); return(NULL);
} }
VOID VOID
LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule) KdbLdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
{ {
PIMAGE_SYMBOL_INFO_CACHE CacheEntry; PIMAGE_SYMBOL_INFO_CACHE CacheEntry;
@ -801,6 +779,7 @@ LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
CacheEntry = ExAllocatePool(NonPagedPool, sizeof(IMAGE_SYMBOL_INFO_CACHE)); CacheEntry = ExAllocatePool(NonPagedPool, sizeof(IMAGE_SYMBOL_INFO_CACHE));
assert(CacheEntry); assert(CacheEntry);
RtlZeroMemory(CacheEntry, sizeof(IMAGE_SYMBOL_INFO_CACHE)); RtlZeroMemory(CacheEntry, sizeof(IMAGE_SYMBOL_INFO_CACHE));
RtlCreateUnicodeString(&CacheEntry->FullName, LdrModule->FullDllName.Buffer); RtlCreateUnicodeString(&CacheEntry->FullName, LdrModule->FullDllName.Buffer);
assert(CacheEntry->FullName.Buffer); assert(CacheEntry->FullName.Buffer);
LdrpLoadModuleSymbols(&LdrModule->FullDllName, &LdrModule->SymbolInfo); LdrpLoadModuleSymbols(&LdrModule->FullDllName, &LdrModule->SymbolInfo);
@ -808,92 +787,99 @@ LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
} }
} }
#endif /* DBG */
VOID VOID
KdbLoadDriver(VOID) KdbLoadDriver(PUNICODE_STRING Filename, PMODULE_OBJECT Module)
{ {
#ifdef DBG
/* Load symbols for the image if available */ /* Load symbols for the image if available */
LdrpLoadModuleSymbols(Filename, &Module->TextSection->SymbolInfo); LdrpLoadModuleSymbols(Filename, &Module->TextSection->SymbolInfo);
#endif /* DBG */
} }
VOID VOID
KdbUnloadDriver(VOID) KdbUnloadDriver(PMODULE_OBJECT ModuleObject)
{ {
#ifdef DBG
/* Unload symbols for module if available */ /* Unload symbols for module if available */
LdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo); KdbLdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo);
#endif /* DBG */
} }
VOID VOID
KdbInitializeDriver(VOID) KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length)
{ {
#ifdef DBG PMODULE_OBJECT ModuleObject;
PSYMBOLFILE_HEADER SymbolFileHeader; UNICODE_STRING ModuleName;
PIMAGE_SYMBOL_INFO SymbolInfo;
#endif /* DBG */
#ifdef DBG
CHAR TmpBaseName[MAX_PATH]; CHAR TmpBaseName[MAX_PATH];
CHAR TmpFileName[MAX_PATH]; CHAR TmpFileName[MAX_PATH];
PSYMBOLFILE_HEADER SymbolFileHeader;
PIMAGE_SYMBOL_INFO SymbolInfo;
ANSI_STRING AnsiString; ANSI_STRING AnsiString;
#endif /* DBG */
#ifdef DBG DPRINT("Module %s is a symbol file\n", FileName);
if ((FileExt != NULL) && (strcmp(FileExt, ".sym") == 0)) strncpy(TmpBaseName, FileName, Length);
TmpBaseName[Length] = '\0';
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
strcpy(TmpFileName, TmpBaseName);
strcat(TmpFileName, ".sys");
RtlInitAnsiString(&AnsiString, TmpFileName);
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
ModuleObject = LdrGetModuleObject(&ModuleName);
RtlFreeUnicodeString(&ModuleName);
if (ModuleObject == NULL)
{ {
DPRINT("Module %s is a symbol file\n", FileName);
strncpy(TmpBaseName, FileName, Length);
TmpBaseName[Length] = '\0';
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
strcpy(TmpFileName, TmpBaseName); strcpy(TmpFileName, TmpBaseName);
strcat(TmpFileName, ".sys"); strcat(TmpFileName, ".exe");
RtlInitAnsiString(&AnsiString, TmpFileName); RtlInitAnsiString(&AnsiString, TmpFileName);
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE); RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
ModuleObject = LdrGetModuleObject(&ModuleName); ModuleObject = LdrGetModuleObject(&ModuleName);
RtlFreeUnicodeString(&ModuleName); RtlFreeUnicodeString(&ModuleName);
if (ModuleObject == NULL)
{
strcpy(TmpFileName, TmpBaseName);
strcat(TmpFileName, ".exe");
RtlInitAnsiString(&AnsiString, TmpFileName);
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
ModuleObject = LdrGetModuleObject(&ModuleName);
RtlFreeUnicodeString(&ModuleName);
}
if (ModuleObject != NULL)
{
SymbolInfo = (PIMAGE_SYMBOL_INFO) &ModuleObject->TextSection->SymbolInfo;
SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
SymbolInfo->FileBuffer = ModuleLoadBase;
SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
SymbolInfo->SymbolStringsBase = ModuleLoadBase + SymbolFileHeader->StabstrOffset;
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
}
return(STATUS_SUCCESS);
} }
else if (ModuleObject != NULL)
{ {
DPRINT("Module %s is non-symbol file\n", FileName); SymbolInfo = (PIMAGE_SYMBOL_INFO) &ModuleObject->TextSection->SymbolInfo;
} SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
SymbolInfo->FileBuffer = ModuleLoadBase;
#endif /* !DBG */ SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
#ifdef DBG SymbolInfo->SymbolStringsBase = ModuleLoadBase + SymbolFileHeader->StabstrOffset;
RtlZeroMemory(&ModuleTextSection->SymbolInfo, sizeof(ModuleTextSection->SymbolInfo)); SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
ModuleTextSection->SymbolInfo.ImageBase = PEOptionalHeader->ImageBase; }
ModuleTextSection->SymbolInfo.ImageSize = ModuleTextSection->Length;
#endif /* DBG */
} }
#endif /* DBG */ VOID
KdbInitializeDriver(PMODULE_TEXT_SECTION ModuleTextSection)
{
RtlZeroMemory(&ModuleTextSection->SymbolInfo, sizeof(ModuleTextSection->SymbolInfo));
ModuleTextSection->SymbolInfo.ImageBase =
ModuleTextSection->OptionalHeader->ImageBase;
ModuleTextSection->SymbolInfo.ImageSize = ModuleTextSection->Length;
}
VOID
KdbLdrLoadAutoConfigDrivers(VOID)
{
UNICODE_STRING ModuleName;
PMODULE_OBJECT ModuleObject;
/*
* Load symbols for ntoskrnl.exe and hal.dll because \SystemRoot
* is created after their module entries
*/
RtlInitUnicodeString(&ModuleName, KERNEL_MODULE_NAME);
ModuleObject = LdrGetModuleObject(&ModuleName);
if (ModuleObject != NULL)
{
LdrpLoadModuleSymbols(&ModuleName,
&ModuleObject->TextSection->SymbolInfo);
}
RtlInitUnicodeString(&ModuleName, HAL_MODULE_NAME);
ModuleObject = LdrGetModuleObject(&ModuleName);
if (ModuleObject != NULL)
{
LdrpLoadModuleSymbols(&ModuleName,
&ModuleObject->TextSection->SymbolInfo);
}
}

View file

@ -1,4 +1,4 @@
/* $Id: kd.h,v 1.11 2002/07/17 22:56:10 dwelch Exp $ /* $Id: kd.h,v 1.12 2002/07/18 00:25:30 dwelch Exp $
* *
* kernel debugger prototypes * kernel debugger prototypes
*/ */
@ -7,6 +7,7 @@
#define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H #define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/ldr.h>
#define KD_DEBUG_DISABLED 0x00 #define KD_DEBUG_DISABLED 0x00
#define KD_DEBUG_GDB 0x01 #define KD_DEBUG_GDB 0x01
@ -71,10 +72,31 @@ VOID KdPrintMda(PCH pch);
#define KDB_DELETEPROCESS_HOOK(PROCESS) #define KDB_DELETEPROCESS_HOOK(PROCESS)
#define KDB_LOADDRIVER_HOOK(MODULE) #define KDB_LOADDRIVER_HOOK(MODULE)
#define KDB_UNLOADDRIVER_HOOK(MODULE) #define KDB_UNLOADDRIVER_HOOK(MODULE)
#define KDB_LOADERINIT_HOOK(NTOS, HAL)
#define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH)
#else #else
#define KDB_DELETEPROCESS_HOOK(PROCESS) XXXX #define KDB_DELETEPROCESS_HOOK(PROCESS) KdbFreeSymbolsProcess(PROCESS)
#define KDB_LOADDRIVER_HOOK(MODULE) XXXX #define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbLoadDriver(FILENAME, MODULE)
#define KDB_UNLOADDRIVER_HOOK(MODULE) XXXX #define KDB_UNLOADDRIVER_HOOK(MODULE) KdbUnloadDriver(MODULE)
#define KDB_LOADERINIT_HOOK(NTOS, HAL) KdbLdrInit(NTOS, HAL)
#define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH) \
KdbProcessSymbolFile(LOADBASE, FILENAME, LENGTH)
#endif /* KDBG */ #endif /* KDBG */
VOID
KdbLdrLoadUserModuleSymbols(PLDR_MODULE LdrModule);
VOID
KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length);
VOID
KdbLdrInit(MODULE_TEXT_SECTION* NtoskrnlTextSection,
MODULE_TEXT_SECTION* LdrHalTextSection);
VOID
KdbUnloadDriver(PMODULE_OBJECT ModuleObject);
VOID
KdbLoadDriver(PUNICODE_STRING Filename, PMODULE_OBJECT Module);
VOID
KdbFreeSymbolsProcess(PPEB Peb);
BOOLEAN
KdbPrintAddress(PVOID address);
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */ #endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */

View file

@ -13,9 +13,10 @@ typedef struct _MODULE_TEXT_SECTION
ULONG Length; ULONG Length;
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
PWCH Name; PWCH Name;
#ifdef DBG PIMAGE_OPTIONAL_HEADER OptionalHeader;
#ifdef KDBG
IMAGE_SYMBOL_INFO SymbolInfo; IMAGE_SYMBOL_INFO SymbolInfo;
#endif /* DBG */ #endif /* KDBG */
} MODULE_TEXT_SECTION, *PMODULE_TEXT_SECTION; } MODULE_TEXT_SECTION, *PMODULE_TEXT_SECTION;
typedef struct _MODULE_OBJECT typedef struct _MODULE_OBJECT

View file

@ -1,4 +1,4 @@
/* $Id: driver.c,v 1.8 2002/06/27 17:49:34 ekohl Exp $ /* $Id: driver.c,v 1.9 2002/07/18 00:25:30 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -484,34 +484,8 @@ LdrLoadAutoConfigDrivers(VOID)
CHAR TextBuffer [256]; CHAR TextBuffer [256];
ULONG x, y, cx, cy; ULONG x, y, cx, cy;
#ifdef KDBG
UNICODE_STRING ModuleName;
PMODULE_OBJECT ModuleObject;
#endif
DPRINT("LdrLoadAutoConfigDrivers() called\n"); DPRINT("LdrLoadAutoConfigDrivers() called\n");
#ifdef KDBG
/*
* Load symbols for ntoskrnl.exe and hal.dll because \SystemRoot
* is created after their module entries
*/
RtlInitUnicodeString(&ModuleName, KERNEL_MODULE_NAME);
ModuleObject = LdrGetModuleObject(&ModuleName);
if (ModuleObject != NULL)
{
LdrpLoadModuleSymbols(ModuleObject);
}
RtlInitUnicodeString(&ModuleName, HAL_MODULE_NAME);
ModuleObject = LdrGetModuleObject(&ModuleName);
if (ModuleObject != NULL)
{
LdrpLoadModuleSymbols(ModuleObject);
}
#endif /* KDBG */
GroupEntry = GroupListHead.Flink; GroupEntry = GroupListHead.Flink;
while (GroupEntry != &GroupListHead) while (GroupEntry != &GroupListHead)
{ {

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: catch.c,v 1.20 2002/05/08 17:05:32 chorns Exp $ /* $Id: catch.c,v 1.21 2002/07/18 00:25:30 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/catch.c * FILE: ntoskrnl/ke/catch.c
@ -200,6 +200,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
CONTEXT TContext; CONTEXT TContext;
DPRINT("KiDispatchException() called\n"); DPRINT("KiDispatchException() called\n");
/* PCR->KeExceptionDispatchCount++; */ /* PCR->KeExceptionDispatchCount++; */
if (Context == NULL) if (Context == NULL)

View file

@ -39,6 +39,7 @@
#include <internal/trap.h> #include <internal/trap.h>
#include <ntdll/ldr.h> #include <ntdll/ldr.h>
#include <internal/safe.h> #include <internal/safe.h>
#include <internal/kd.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -559,7 +560,7 @@ KeDumpStackFrames(PULONG Frame)
print_address((PVOID)Frame[1]); print_address((PVOID)Frame[1]);
Frame = (PULONG)Frame[0]; Frame = (PULONG)Frame[0];
i++; i++;
DbgPrint("\n"); DbgPrint(" ");
} }
} }

View file

@ -1,4 +1,4 @@
/* $Id: loader.c,v 1.117 2002/07/17 22:56:11 dwelch Exp $ /* $Id: loader.c,v 1.118 2002/07/18 00:25:31 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -145,6 +145,7 @@ LdrInit1(VOID)
NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize + NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize +
SectionList[0].VirtualAddress; SectionList[0].VirtualAddress;
NtoskrnlTextSection.Name = KERNEL_MODULE_NAME; NtoskrnlTextSection.Name = KERNEL_MODULE_NAME;
NtoskrnlTextSection.OptionalHeader = OptionalHeader;
InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry); InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry);
/* Setup hal.dll text section */ /* Setup hal.dll text section */
@ -160,7 +161,11 @@ LdrInit1(VOID)
LdrHalTextSection.Length = SectionList[0].Misc.VirtualSize + LdrHalTextSection.Length = SectionList[0].Misc.VirtualSize +
SectionList[0].VirtualAddress; SectionList[0].VirtualAddress;
LdrHalTextSection.Name = HAL_MODULE_NAME; LdrHalTextSection.Name = HAL_MODULE_NAME;
LdrHalTextSection.OptionalHeader = OptionalHeader;
InsertTailList(&ModuleTextListHead, &LdrHalTextSection.ListEntry); InsertTailList(&ModuleTextListHead, &LdrHalTextSection.ListEntry);
/* Hook for KDB on initialization of the loader. */
KDB_LOADERINIT_HOOK(&NtoskrnlTextSection, &LdrHalTextSection);
} }
@ -407,7 +412,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
*ModuleObject = Module; *ModuleObject = Module;
/* Hook for KDB on loading a driver. */ /* Hook for KDB on loading a driver. */
KDB_LOADDRIVER_HOOK(Module); KDB_LOADDRIVER_HOOK(Filename, Module);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -459,7 +464,6 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
LPWSTR Start; LPWSTR Start;
LPWSTR Ext; LPWSTR Ext;
PCHAR FileExt; PCHAR FileExt;
CHAR TextBuffer [256]; CHAR TextBuffer [256];
ULONG x, y, cx, cy; ULONG x, y, cx, cy;
@ -481,7 +485,12 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
else else
Length = strlen(FileName); Length = strlen(FileName);
if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0)) if ((FileExt != NULL) && (strcmp(FileExt, ".sym") == 0))
{
KDB_SYMBOLFILE_HOOK(ModuleLoadBase, FileName, Length);
return(STATUS_SUCCESS);
}
else if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0))
{ {
CPRINT("Ignoring non-driver file %s\n", FileName); CPRINT("Ignoring non-driver file %s\n", FileName);
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -1142,6 +1151,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
ExAllocatePool(NonPagedPool, ExAllocatePool(NonPagedPool,
(wcslen(NameBuffer) + 1) * sizeof(WCHAR)); (wcslen(NameBuffer) + 1) * sizeof(WCHAR));
wcscpy(ModuleTextSection->Name, NameBuffer); wcscpy(ModuleTextSection->Name, NameBuffer);
ModuleTextSection->OptionalHeader =
CreatedModuleObject->Image.PE.OptionalHeader;
InsertTailList(&ModuleTextListHead, &ModuleTextSection->ListEntry); InsertTailList(&ModuleTextListHead, &ModuleTextSection->ListEntry);
CreatedModuleObject->TextSection = ModuleTextSection; CreatedModuleObject->TextSection = ModuleTextSection;

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.87 2002/07/17 22:56:11 dwelch Exp $ /* $Id: process.c,v 1.88 2002/07/18 00:25:31 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -299,7 +299,7 @@ PiDeleteProcess(PVOID ObjectBody)
KeReleaseSpinLock(&PsProcessListLock, oldIrql); KeReleaseSpinLock(&PsProcessListLock, oldIrql);
/* KDB hook */ /* KDB hook */
KDB_DELETEPROCESS_HOOK(Process); KDB_DELETEPROCESS_HOOK(Process->Peb);
ObDereferenceObject(Process->Token); ObDereferenceObject(Process->Token);