2002-07-13 Casper S. Hornstrup <chorns@users.sourceforge.net>

* rules.mak (RSYM): Define.
	* include/ddk/zwtypes.h (DebugDbgLoadSymbols): Add to enum
	_DEBUG_CONTROL_CODE.
	* include/ntdll/ldr.h (LDR_SYMBOL_INFO, LdrpLoadUserModuleSymbols): Add.
	(LdrLoadModuleSymbols): Remove.
	* include/ntos/kdbgsyms.h (ST_FILENAME, ST_FUNCTION,
	ST_LINENUMBER): Add.
	(SYMBOL). Make Name an ANSI_STRING.
	(IMAGE_SYMBOL_INFO, AreSymbolsParsed): Add.
	* lib/ntdll/ldr/startup.c (LdrInitializeThunk): Call
	LdrpLoadUserModuleSymbols() not LdrLoadModuleSymbols().
	* lib/ntdll/ldr/utils.c (LdrLoadModuleSymbols): Rename to
	LdrpLoadUserModuleSymbols.
	(LdrpLoadUserModuleSymbols): Use DebugDbgLoadSymbols debug control code.
	(LdrLoadDll): assert if out of memory.
	(LdrLoadDll): Call
	LdrpLoadUserModuleSymbols(), not LdrLoadModuleSymbols().
	* lib/ntdll/string/ctype.c (_pctype): #undef.
	* ntoskrnl/dbg/dbgctrl.c (NtSystemDebugControl): Call
	LdrLoadUserModuleSymbols on DebugDbgLoadSymbols.
	* ntoskrnl/include/internal/ldr.h (LdrGetAddressInformation): Add.
	* ntoskrnl/include/internal/module.h (MODULE_TEXT_SECTION): Make SymbolInfo
	an IMAGE_SYMBOL_INFO.
	* ntoskrnl/ke/i386/exp.c (LdrGetAddressInformation): Add prototype.
	(print_address): Change #ifdef KDBG to #ifdef DBG.
	(KiDoubleFaultHandler, KiDumpTrapFrame, KeDumpStackFrames): Dump
	one stack frame per line.
	* ntoskrnl/ke/i386/multiboot.S: Create pagetables for more kernel
	address space so larger modules can be passed from the boot loader.
	* ntoskrnl/ke/i386/usertrap.c (LdrGetAddressInformation): Add prototype.
	(print_user_address): Print symbols using LdrGetAddressInformation().
	* ntoskrnl/ldr/loader.c (SYMBOLFILE_HEADER, IMAGE_SYMBOL_INFO_CACHE,
	STAB_ENTRY, N_FUN, N_SLINE, N_SO, SymbolListHead): Add.
	(TAG_SYM_BUF): Remove.
	(LdrInitDebug): Remove unneeded code.
	(LdrInit1): Prepare for loading symbols.
	(LdrpReadLine, HexL, LdrpParseLine, LdrpLoadModuleSymbolsFromBuffer,
	LdrpLoadUserModuleSymbolsFromBuffer): Remove.
	(LdrpParseImageSymbols, LdrpGetFileName, LdrpGetFunctionName,
	LdrpGetLineNumber, LdrGetAddressInformation, LdrpLookupUserSymbolInfo): Add.
	(LdrpLoadModuleSymbols, LdrInitializeBootStartDriver): Change to use new
	symbol structures.
	(LdrLoadUserModuleSymbols): Cache symbol buffers.
	(LdrUnloadModuleSymbols): Implement.
	(LdrLoadModule, LdrUnloadModule): Change #ifdef KDBG to #ifdef DBG.
	(LdrPEProcessModule): Split a line into two lines.
	(LdrPEProcessModule): Setup for loading symbols.
	* ntoskrnl/ldr/sysdll.c (LdrpMapSystemDll): Open with FILE_SHARE_READ.
	* ntoskrnl/ps/process.c (PiFreeSymbols): Call LdrUnloadModuleSymbols() to
	free symbols.
	(PiDeleteProcess): Change #ifdef KDBG to #ifdef DBG.
	* ntoskrnl/rtl/ctype.c (_pctype): #undef.
	* ntoskrnl/rtl/string.c (strncpy): Terminate destination string.
	* tools/Makefile (rsym): Add target.
	* tools/helper.mk: Include config and use -g if DBG = 1.

svn path=/trunk/; revision=3212
This commit is contained in:
Casper Hornstrup 2002-07-13 12:44:09 +00:00
parent 3e56065829
commit 84b74a9cd9
23 changed files with 1068 additions and 539 deletions

View file

@ -1,3 +1,61 @@
2002-07-13 Casper S. Hornstrup <chorns@users.sourceforge.net>
* rules.mak (RSYM): Define.
* include/ddk/zwtypes.h (DebugDbgLoadSymbols): Add to enum
_DEBUG_CONTROL_CODE.
* include/ntdll/ldr.h (LDR_SYMBOL_INFO, LdrpLoadUserModuleSymbols): Add.
(LdrLoadModuleSymbols): Remove.
* include/ntos/kdbgsyms.h (ST_FILENAME, ST_FUNCTION,
ST_LINENUMBER): Add.
(SYMBOL). Make Name an ANSI_STRING.
(IMAGE_SYMBOL_INFO, AreSymbolsParsed): Add.
* lib/ntdll/ldr/startup.c (LdrInitializeThunk): Call
LdrpLoadUserModuleSymbols() not LdrLoadModuleSymbols().
* lib/ntdll/ldr/utils.c (LdrLoadModuleSymbols): Rename to
LdrpLoadUserModuleSymbols.
(LdrpLoadUserModuleSymbols): Use DebugDbgLoadSymbols debug control code.
(LdrLoadDll): assert if out of memory.
(LdrLoadDll): Call
LdrpLoadUserModuleSymbols(), not LdrLoadModuleSymbols().
* lib/ntdll/string/ctype.c (_pctype): #undef.
* ntoskrnl/dbg/dbgctrl.c (NtSystemDebugControl): Call
LdrLoadUserModuleSymbols on DebugDbgLoadSymbols.
* ntoskrnl/include/internal/ldr.h (LdrGetAddressInformation): Add.
* ntoskrnl/include/internal/module.h (MODULE_TEXT_SECTION): Make SymbolInfo
an IMAGE_SYMBOL_INFO.
* ntoskrnl/ke/i386/exp.c (LdrGetAddressInformation): Add prototype.
(print_address): Change #ifdef KDBG to #ifdef DBG.
(KiDoubleFaultHandler, KiDumpTrapFrame, KeDumpStackFrames): Dump
one stack frame per line.
* ntoskrnl/ke/i386/multiboot.S: Create pagetables for more kernel
address space so larger modules can be passed from the boot loader.
* ntoskrnl/ke/i386/usertrap.c (LdrGetAddressInformation): Add prototype.
(print_user_address): Print symbols using LdrGetAddressInformation().
* ntoskrnl/ldr/loader.c (SYMBOLFILE_HEADER, IMAGE_SYMBOL_INFO_CACHE,
STAB_ENTRY, N_FUN, N_SLINE, N_SO, SymbolListHead): Add.
(TAG_SYM_BUF): Remove.
(LdrInitDebug): Remove unneeded code.
(LdrInit1): Prepare for loading symbols.
(LdrpReadLine, HexL, LdrpParseLine, LdrpLoadModuleSymbolsFromBuffer,
LdrpLoadUserModuleSymbolsFromBuffer): Remove.
(LdrpParseImageSymbols, LdrpGetFileName, LdrpGetFunctionName,
LdrpGetLineNumber, LdrGetAddressInformation, LdrpLookupUserSymbolInfo): Add.
(LdrpLoadModuleSymbols, LdrInitializeBootStartDriver): Change to use new
symbol structures.
(LdrLoadUserModuleSymbols): Cache symbol buffers.
(LdrUnloadModuleSymbols): Implement.
(LdrLoadModule, LdrUnloadModule): Change #ifdef KDBG to #ifdef DBG.
(LdrPEProcessModule): Split a line into two lines.
(LdrPEProcessModule): Setup for loading symbols.
* ntoskrnl/ldr/sysdll.c (LdrpMapSystemDll): Open with FILE_SHARE_READ.
* ntoskrnl/ps/process.c (PiFreeSymbols): Call LdrUnloadModuleSymbols() to
free symbols.
(PiDeleteProcess): Change #ifdef KDBG to #ifdef DBG.
* ntoskrnl/rtl/ctype.c (_pctype): #undef.
* ntoskrnl/rtl/string.c (strncpy): Terminate destination string.
* tools/Makefile (rsym): Add target.
* tools/helper.mk: Include config and use -g if DBG = 1.
2002-07-13 Casper S. Hornstrup <chorns@users.sourceforge.net>
* Makefile (install_before): Install system.hiv to correct location.

View file

@ -8,7 +8,8 @@ typedef enum _DEBUG_CONTROL_CODE
DebugSetSpecialCalls,
DebugClearSpecialCalls,
DebugQuerySpecialCalls,
DebugDbgBreakPoint
DebugDbgBreakPoint,
DebugDbgLoadSymbols
} DEBUG_CONTROL_CODE;
typedef enum _KPROFILE_SOURCE

View file

@ -19,11 +19,20 @@ typedef struct _LDR_MODULE
HANDLE SectionHandle;
ULONG CheckSum;
ULONG TimeDateStamp;
#ifdef KDBG
SYMBOL_TABLE Symbols;
#endif /* KDBG */
#ifdef DBG
IMAGE_SYMBOL_INFO SymbolInfo;
#endif /* DBG */
} LDR_MODULE, *PLDR_MODULE;
typedef struct _LDR_SYMBOL_INFO {
PLDR_MODULE ModuleObject;
ULONG_PTR ImageBase;
PVOID SymbolsBuffer;
ULONG SymbolsBufferLength;
PVOID SymbolStringsBuffer;
ULONG SymbolStringsBufferLength;
} LDR_SYMBOL_INFO, *PLDR_SYMBOL_INFO;
#define RVA(m, b) ((ULONG)b + m)
@ -48,7 +57,12 @@ typedef struct _MODULE_INFORMATION
MODULE_ENTRY ModuleEntry[1];
} MODULE_INFORMATION, *PMODULE_INFORMATION;
#ifdef DBG
VOID
LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule);
#endif
PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle);
NTSTATUS LdrMapSections(HANDLE ProcessHandle,
@ -58,9 +72,6 @@ NTSTATUS LdrMapSections(HANDLE ProcessHandle,
NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle,
PHANDLE NTDllSectionHandle);
VOID LdrLoadModuleSymbols(PLDR_MODULE ModuleObject);
NTSTATUS STDCALL
LdrDisableThreadCalloutsForDll(IN PVOID BaseAddress);

View file

@ -4,12 +4,18 @@
#include <ddk/ntddk.h>
#define ST_FILENAME 0x00
#define ST_FUNCTION 0x01
#define ST_LINENUMBER 0x02
typedef struct _SYMBOL
{
struct _SYMBOL *Next;
/* Address relative to module base address */
ULONG RelativeAddress;
UNICODE_STRING Name;
ULONG SymbolType;
ANSI_STRING Name;
ULONG LineNumber;
} SYMBOL, *PSYMBOL;
typedef struct _SYMBOL_TABLE
@ -18,5 +24,23 @@ typedef struct _SYMBOL_TABLE
PSYMBOL Symbols;
} SYMBOL_TABLE, *PSYMBOL_TABLE;
typedef struct _IMAGE_SYMBOL_INFO
{
SYMBOL_TABLE FileNameSymbols;
SYMBOL_TABLE FunctionSymbols;
SYMBOL_TABLE LineNumberSymbols;
ULONG_PTR ImageBase;
ULONG_PTR ImageSize;
PVOID FileBuffer;
PVOID SymbolsBase;
ULONG SymbolsLength;
PVOID SymbolStringsBase;
ULONG SymbolStringsLength;
} IMAGE_SYMBOL_INFO, *PIMAGE_SYMBOL_INFO;
#define AreSymbolsParsed(si)((si)->FileNameSymbols.Symbols \
|| (si)->FunctionSymbols.Symbols \
|| (si)->LineNumberSymbols.Symbols)
#endif

View file

@ -1,4 +1,4 @@
/* $Id: startup.c,v 1.37 2002/04/26 13:08:18 ekohl Exp $
/* $Id: startup.c,v 1.38 2002/07/13 12:44:06 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -183,10 +183,11 @@ LdrInitializeThunk (ULONG Unknown1,
InsertTailList(&Peb->Ldr->InInitializationOrderModuleList,
&NtModule->InInitializationOrderModuleList);
#ifdef KDBG
LdrLoadModuleSymbols(NtModule);
#endif /* KDBG */
#ifdef DBG
LdrpLoadUserModuleSymbols(NtModule);
#endif /* DBG */
/* add entry for executable (becomes first list entry) */
ExeModule = (PLDR_MODULE)RtlAllocateHeap (Peb->ProcessHeap,
@ -229,9 +230,11 @@ LdrInitializeThunk (ULONG Unknown1,
InsertHeadList(&Peb->Ldr->InLoadOrderModuleList,
&ExeModule->InLoadOrderModuleList);
#ifdef KDBG
LdrLoadModuleSymbols(ExeModule);
#endif /* KDBG */
#ifdef DBG
LdrpLoadUserModuleSymbols(ExeModule);
#endif /* DBG */
EntryPoint = LdrPEStartup((PVOID)ImageBase, NULL);
ExeModule->EntryPoint = (ULONG)EntryPoint;

View file

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.50 2002/04/26 13:08:18 ekohl Exp $
/* $Id: utils.c,v 1.51 2002/07/13 12:44:06 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -48,20 +48,21 @@ static PVOID LdrGetExportByName(PVOID BaseAddress, PUCHAR SymbolName, USHORT Hin
/* FUNCTIONS *****************************************************************/
#ifdef KDBG
#ifdef DBG
VOID LdrLoadModuleSymbols(PLDR_MODULE ModuleObject)
VOID
LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule)
{
NtSystemDebugControl(
0xffffffff,
(PVOID)ModuleObject,
DebugDbgLoadSymbols,
(PVOID)LdrModule,
0,
NULL,
0,
NULL);
}
#endif /* KDBG */
#endif /* DBG */
/***************************************************************************
@ -364,6 +365,7 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL,
Module = RtlAllocateHeap(RtlGetProcessHeap(),
0,
sizeof (LDR_MODULE));
assert(Module);
Module->BaseAddress = (PVOID)ImageBase;
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
if (Module->EntryPoint != 0)
@ -400,9 +402,11 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL,
&Module->InInitializationOrderModuleList);
/* FIXME: release loader lock */
#ifdef KDBG
LdrLoadModuleSymbols(Module);
#endif /* KDBG */
#ifdef DBG
LdrpLoadUserModuleSymbols(Module);
#endif /* DBG */
/* initialize dll */
if ((NTHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) ==

View file

@ -1,4 +1,4 @@
/* $Id: ctype.c,v 1.7 2000/01/10 20:30:15 ekohl Exp $
/* $Id: ctype.c,v 1.8 2002/07/13 12:44:06 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <ctype.h>
#undef _pctype
#define upalpha ('A' - 'a')

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.72 2002/07/04 19:56:35 dwelch Exp $
# $Id: Makefile,v 1.73 2002/07/13 12:44:07 chorns Exp $
#
# ReactOS Operating System
#
@ -617,7 +617,7 @@ $(TARGETNAME).dbg: $(TARGETNAME).dbg.o $(TARGETNAME).a $(TARGETNAME).dbg.lnk
- $(RM) temp.exp
$(TARGETNAME).sym: $(TARGETNAME).nostrip.exe
$(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym
$(RSYM) $(TARGETNAME).nostrip.exe $(TARGETNAME).sym
$(TARGETNAME).o: $(OBJECTS)
$(LD) \

View file

@ -50,10 +50,12 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode,
case DebugQuerySpecialCalls:
case DebugDbgBreakPoint:
break;
#ifdef DBG
case DebugDbgLoadSymbols:
LdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
#endif /* DBG */
break;
default:
#ifdef KDBG
LdrLoadUserModuleSymbols((PLDR_MODULE)InputBuffer);
#endif /* KDBG */
break;
}
return STATUS_SUCCESS;

View file

@ -112,13 +112,22 @@ LdrUnloadModule(PMODULE_OBJECT ModuleObject);
PMODULE_OBJECT
LdrGetModuleObject(PUNICODE_STRING ModuleName);
NTSTATUS
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
IN ULONG_PTR RelativeAddress,
OUT PULONG LineNumber,
OUT PCH FileName OPTIONAL,
OUT PCH FunctionName OPTIONAL);
#ifdef KDBG
VOID
LdrpLoadModuleSymbols(PMODULE_OBJECT ModuleObject);
#ifdef DBG
VOID
LdrLoadUserModuleSymbols(PLDR_MODULE ModuleObject);
#endif /* KDBG */
LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule);
VOID
LdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo);
#endif /* DBG */
#endif /* __INCLUDE_INTERNAL_LDR_H */

View file

@ -13,11 +13,9 @@ typedef struct _MODULE_TEXT_SECTION
ULONG Length;
LIST_ENTRY ListEntry;
PWCH Name;
#ifdef KDBG
SYMBOL_TABLE Symbols;
#endif /* KDBG */
PVOID SymbolsBase;
ULONG SymbolsLength;
#ifdef DBG
IMAGE_SYMBOL_INFO SymbolInfo;
#endif /* DBG */
} MODULE_TEXT_SECTION, *PMODULE_TEXT_SECTION;
typedef struct _MODULE_OBJECT

View file

@ -45,6 +45,17 @@
/* GLOBALS *****************************************************************/
#ifdef DBG
NTSTATUS
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
IN ULONG_PTR RelativeAddress,
OUT PULONG LineNumber,
OUT PCH FileName OPTIONAL,
OUT PCH FunctionName OPTIONAL);
#endif /* DBG */
#define _STR(x) #x
#define STR(x) _STR(x)
@ -124,16 +135,17 @@ extern unsigned int _text_start__, _text_end__;
STATIC BOOLEAN
print_address(PVOID address)
{
#ifdef KDBG
ULONG Offset;
PSYMBOL Symbol, NextSymbol;
BOOLEAN Printed = FALSE;
ULONG NextAddress;
#endif /* KDBG */
PLIST_ENTRY current_entry;
MODULE_TEXT_SECTION* current;
extern LIST_ENTRY ModuleTextListHead;
ULONG_PTR RelativeAddress;
#ifdef DBG
NTSTATUS Status;
ULONG LineNumber;
CHAR FileName[256];
CHAR FunctionName[256];
#endif
current_entry = ModuleTextListHead.Flink;
while (current_entry != &ModuleTextListHead &&
@ -141,46 +153,31 @@ print_address(PVOID address)
{
current =
CONTAINING_RECORD(current_entry, MODULE_TEXT_SECTION, ListEntry);
if (address >= (PVOID)current->Base &&
address < (PVOID)(current->Base + current->Length))
{
#ifdef KDBG
Offset = (ULONG)((ULONG)address - current->Base);
Symbol = current->Symbols.Symbols;
while (Symbol != NULL)
{
NextSymbol = Symbol->Next;
if (NextSymbol != NULL)
NextAddress = NextSymbol->RelativeAddress;
else
NextAddress = current->Length;
if ((Offset >= Symbol->RelativeAddress) &&
(Offset < NextAddress))
{
DbgPrint("<%ws: %x (%wZ)>", current->Name, Offset,
&Symbol->Name);
Printed = TRUE;
break;
}
Symbol = NextSymbol;
}
if (!Printed)
DbgPrint("<%ws: %x>", current->Name, Offset);
#else /* KDBG */
DbgPrint("<%ws: %x>", current->Name,
address - current->Base);
#endif /* KDBG */
RelativeAddress = (ULONG_PTR) address - current->Base;
#ifdef DBG
Status = LdrGetAddressInformation(&current->SymbolInfo,
RelativeAddress,
&LineNumber,
FileName,
FunctionName);
if (NT_SUCCESS(Status))
{
DbgPrint("<%ws: %x (%s:%d (%s))>",
current->Name, RelativeAddress, FileName, LineNumber, FunctionName);
}
else
{
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
}
#else /* !DBG */
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
#endif /* !DBG */
return(TRUE);
}
current_entry = current_entry->Flink;
}
return(FALSE);
@ -338,6 +335,7 @@ KiDoubleFaultHandler(VOID)
{
print_address((PVOID)Frame[1]);
Frame = (PULONG)Frame[0];
DbgPrint("\n");
}
#else
DbgPrint("Frames: ");
@ -504,9 +502,6 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG ExceptionNr, ULONG cr2)
print_address((PVOID)Frame[1]);
Frame = (PULONG)Frame[0];
i++;
}
if ((i % 8) != 0)
{
DbgPrint("\n");
}
}
@ -592,9 +587,6 @@ KeDumpStackFrames(PULONG Frame)
print_address((PVOID)Frame[1]);
Frame = (PULONG)Frame[0];
i++;
}
if ((i % 8) != 0)
{
DbgPrint("\n");
}
}

View file

@ -114,6 +114,31 @@ _multiboot_entry:
movl $(V2P(kernel_pagetable+5*4096) + 0x7), 0xC14(%esi)
movl $(V2P(kernel_pagetable+6*4096) + 0x7), 0xC18(%esi)
movl $(V2P(kernel_pagetable+7*4096) + 0x7), 0xC1c(%esi)
movl $(V2P(kernel_pagetable+8*4096) + 0x7), 0xC20(%esi)
movl $(V2P(kernel_pagetable+9*4096) + 0x7), 0xC24(%esi)
movl $(V2P(kernel_pagetable+10*4096) + 0x7), 0xC28(%esi)
movl $(V2P(kernel_pagetable+11*4096) + 0x7), 0xC2c(%esi)
movl $(V2P(kernel_pagetable+12*4096) + 0x7), 0xC30(%esi)
movl $(V2P(kernel_pagetable+13*4096) + 0x7), 0xC34(%esi)
movl $(V2P(kernel_pagetable+14*4096) + 0x7), 0xC38(%esi)
movl $(V2P(kernel_pagetable+15*4096) + 0x7), 0xC3c(%esi)
movl $(V2P(kernel_pagetable+16*4096) + 0x7), 0xC40(%esi)
movl $(V2P(kernel_pagetable+17*4096) + 0x7), 0xC44(%esi)
movl $(V2P(kernel_pagetable+18*4096) + 0x7), 0xC48(%esi)
movl $(V2P(kernel_pagetable+19*4096) + 0x7), 0xC4c(%esi)
movl $(V2P(kernel_pagetable+20*4096) + 0x7), 0xC50(%esi)
movl $(V2P(kernel_pagetable+21*4096) + 0x7), 0xC54(%esi)
movl $(V2P(kernel_pagetable+22*4096) + 0x7), 0xC58(%esi)
movl $(V2P(kernel_pagetable+23*4096) + 0x7), 0xC5c(%esi)
movl $(V2P(kernel_pagetable+24*4096) + 0x7), 0xC60(%esi)
movl $(V2P(kernel_pagetable+25*4096) + 0x7), 0xC64(%esi)
movl $(V2P(kernel_pagetable+26*4096) + 0x7), 0xC68(%esi)
movl $(V2P(kernel_pagetable+27*4096) + 0x7), 0xC6c(%esi)
movl $(V2P(kernel_pagetable+28*4096) + 0x7), 0xC70(%esi)
movl $(V2P(kernel_pagetable+29*4096) + 0x7), 0xC74(%esi)
movl $(V2P(kernel_pagetable+30*4096) + 0x7), 0xC78(%esi)
movl $(V2P(kernel_pagetable+31*4096) + 0x7), 0xC7c(%esi)
movl $(V2P(lowmem_pagetable) + 0x7), 0xD00(%esi)
movl $(V2P(startup_pagedirectory) + 0x7), 0xF00(%esi)
#ifdef MP
@ -144,7 +169,7 @@ _multiboot_entry:
movl %eax, (%esi, %edi)
addl $0x1000, %eax
addl $4, %edi
cmpl $2048, %edi
cmpl $8192, %edi
jl .l4
#ifdef MP
@ -315,7 +340,7 @@ lowmem_pagetable:
.fill 4096, 1, 0
kernel_pagetable:
.fill 8*4096, 1, 0
.fill 32*4096, 1, 0
#ifdef MP
apic_pagetable:

View file

@ -45,6 +45,17 @@
/* GLOBALS *****************************************************************/
#ifdef DBG
NTSTATUS
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
IN ULONG_PTR RelativeAddress,
OUT PULONG LineNumber,
OUT PCH FileName OPTIONAL,
OUT PCH FunctionName OPTIONAL);
#endif /* DBG */
static char *ExceptionTypeStrings[] =
{
"Divide Error",
@ -72,16 +83,17 @@ static char *ExceptionTypeStrings[] =
STATIC BOOLEAN
print_user_address(PVOID address)
{
#ifdef KDBG
ULONG Offset;
PSYMBOL Symbol, NextSymbol;
BOOLEAN Printed = FALSE;
ULONG NextAddress;
#endif /* KDBG */
PLIST_ENTRY current_entry;
PLDR_MODULE current;
PEPROCESS CurrentProcess;
PPEB Peb = NULL;
ULONG_PTR RelativeAddress;
#ifdef DBG
NTSTATUS Status;
ULONG LineNumber;
CHAR FileName[256];
CHAR FunctionName[256];
#endif
CurrentProcess = PsGetCurrentProcess();
if (NULL != CurrentProcess)
@ -106,37 +118,25 @@ print_user_address(PVOID address)
if (address >= (PVOID)current->BaseAddress &&
address < (PVOID)(current->BaseAddress + current->SizeOfImage))
{
#ifdef KDBG
Offset = (ULONG)(address - current->BaseAddress);
Symbol = current->Symbols.Symbols;
while (Symbol != NULL)
{
NextSymbol = Symbol->Next;
if (NextSymbol != NULL)
NextAddress = NextSymbol->RelativeAddress;
else
NextAddress = current->SizeOfImage;
if ((Offset >= Symbol->RelativeAddress) &&
(Offset < NextAddress))
{
DbgPrint("<%wZ: %x (%wZ)>",
&current->BaseDllName, Offset, &Symbol->Name);
Printed = TRUE;
break;
}
Symbol = NextSymbol;
}
if (!Printed)
DbgPrint("<%wZ: %x>", &current->BaseDllName, Offset);
#else /* KDBG */
DbgPrint("<%wZ: %x>", &current->BaseDllName,
address - current->BaseAddress);
#endif /* KDBG */
RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
#ifdef DBG
Status = LdrGetAddressInformation(&current->SymbolInfo,
RelativeAddress,
&LineNumber,
FileName,
FunctionName);
if (NT_SUCCESS(Status))
{
DbgPrint("<%wZ: %x (%s:%d (%s))>",
&current->BaseDllName, RelativeAddress, FileName, LineNumber, FunctionName);
}
else
{
DbgPrint("<%wZ: %x>", &current->BaseDllName, RelativeAddress);
}
#else /* !DBG */
DbgPrint("<%wZ: %x>", &current->BaseDllName, RelativeAddress);
#endif /* !DBG */
return(TRUE);
}

File diff suppressed because it is too large Load diff

View file

@ -96,7 +96,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
FILE_ALL_ACCESS,
&FileObjectAttributes,
NULL,
0,
FILE_SHARE_READ,
0);
if (!NT_SUCCESS(Status))
{

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.84 2002/07/04 19:56:36 dwelch Exp $
/* $Id: process.c,v 1.85 2002/07/13 12:44:08 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -278,15 +278,14 @@ PsInitProcessManagment(VOID)
&SystemProcessHandle);
}
#ifdef KDBG
#ifdef DBG
VOID
PiFreeSymbols(PPEB Peb)
{
PLIST_ENTRY CurrentEntry;
PLDR_MODULE Current;
PSYMBOL NextSymbol;
PSYMBOL Symbol;
PIMAGE_SYMBOL_INFO SymbolInfo;
assert (Peb);
assert (Peb->Ldr);
@ -297,21 +296,15 @@ PiFreeSymbols(PPEB Peb)
{
Current = CONTAINING_RECORD(CurrentEntry, LDR_MODULE,
InLoadOrderModuleList);
Symbol = Current->Symbols.Symbols;
while (Symbol != NULL)
{
NextSymbol = Symbol->Next;
RtlFreeUnicodeString (&Symbol->Name);
ExFreePool (Symbol);
Symbol = NextSymbol;
}
Current->Symbols.SymbolCount = 0;
Current->Symbols.Symbols = NULL;
SymbolInfo = &Current->SymbolInfo;
LdrUnloadModuleSymbols(SymbolInfo);
CurrentEntry = CurrentEntry->Flink;
}
}
#endif /* KDBG */
#endif /* DBG */
VOID STDCALL
PiDeleteProcess(PVOID ObjectBody)
@ -333,9 +326,9 @@ PiDeleteProcess(PVOID ObjectBody)
RemoveEntryList(&Process->ProcessListEntry);
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
#ifdef KDBG
#ifdef DBG
PiFreeSymbols(Process->Peb);
#endif /* KDBG */
#endif /* DBG */
ObDereferenceObject(Process->Token);

View file

@ -1,4 +1,4 @@
/* $Id: ctype.c,v 1.7 2002/06/16 17:25:58 chorns Exp $
/* $Id: ctype.c,v 1.8 2002/07/13 12:44:08 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <ctype.h>
#undef _pctype
#define upalpha ('A' - 'a')

View file

@ -239,8 +239,12 @@ char *strncpy(char *dst, const char *src, size_t n)
}
}
while (--n != 0);
d[0] = 0;
}
else
{
dst[0] = 0;
}
return dst;
}

View file

@ -76,6 +76,7 @@ CP = $(TOOLS_PATH)/rcopy
RM = $(TOOLS_PATH)/rdel
RMDIR = $(TOOLS_PATH)/rrmdir
RMKDIR = $(TOOLS_PATH)/rmkdir
RSYM = $(TOOLS_PATH)/rsym
MC = $(TOOLS_PATH)/wmc/wmc

View file

@ -6,7 +6,8 @@ TOOLS = \
rcopy$(EXE_POSTFIX) \
rdel$(EXE_POSTFIX) \
rmkdir$(EXE_POSTFIX) \
rrmdir$(EXE_POSTFIX)
rrmdir$(EXE_POSTFIX) \
rsym$(EXE_POSTFIX)
CLEAN_FILES = $(TOOLS)
@ -50,6 +51,15 @@ rrmdir$(EXE_POSTFIX): rrmdir.c
$(HOST_CC) $(CFLAGS) -DDOS_PATHS rrmdir.c -o rrmdir$(EXE_POSTFIX)
endif
ifeq ($(HOST),mingw32-linux)
rsym$(EXE_POSTFIX): rsym.c
$(HOST_CC) $(CFLAGS) -DUNIX_PATHS rsym.c -o rsym$(EXE_POSTFIX)
endif
ifeq ($(HOST),mingw32-windows)
rsym$(EX_POSTFIX): rsym.c
$(HOST_CC) $(CFLAGS) -DDOS_PATHS rsym.c -o rsym$(EXE_POSTFIX)
endif
wmc_directory_target:
make -C wmc wmc$(EXE_POSTFIX)

View file

@ -1,4 +1,4 @@
# $Id: helper.mk,v 1.18 2002/06/30 02:40:24 ei Exp $
# $Id: helper.mk,v 1.19 2002/07/13 12:44:09 chorns Exp $
#
# Helper makefile for ReactOS modules
# Variables this makefile accepts:
@ -42,6 +42,9 @@
# $WINE_MODE = Compile using WINE headers (no,yes) (optional)
# $WINE_RC = Name of .rc file for WINE modules (optional)
include $(PATH_TO_TOP)/config
ifeq ($(TARGET_PATH),)
TARGET_PATH := .
endif
@ -378,7 +381,8 @@ include $(PATH_TO_TOP)/config
TARGET_CFLAGS += $(MK_CFLAGS)
TARGET_CFLAGS += -pipe -march=$(ARCH)
ifeq ($(DBG),1)
#TARGET_CFLAGS += -g
TARGET_CFLAGS += -g
TARGET_LFLAGS += -g
endif
TARGET_CPPFLAGS += $(MK_CPPFLAGS)
@ -456,7 +460,7 @@ endif
-o $(MK_NOSTRIPNAME) \
$(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
- $(RM) temp.exp
- $(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).sym
- $(RSYM) $(MK_NOSTRIPNAME) $(MK_BASENAME).sym
$(MK_FULLNAME): $(MK_NOSTRIPNAME)
$(CP) $(MK_NOSTRIPNAME) $(MK_FULLNAME)
@ -496,7 +500,7 @@ $(MK_NOSTRIPNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS)
-o $(MK_NOSTRIPNAME) \
$(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
- $(RM) temp.exp
$(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).sym
$(RSYM) $(MK_NOSTRIPNAME) $(MK_BASENAME).sym
$(MK_FULLNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS) $(MK_NOSTRIPNAME)
$(LD) -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS)
@ -583,6 +587,7 @@ $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME): $(MK_FULLNAME) $(MK_BASENAME).sy
$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME)
$(CP) $(MK_BASENAME).sym $(INSTALL_DIR)/symbols/$(MK_BASENAME).sym
dist: $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME)
$(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME): $(MK_FULLNAME)

255
reactos/tools/rsym.c Normal file
View file

@ -0,0 +1,255 @@
/*
* Usage: rsym input-file output-file
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NULL ((void*)0)
#define IMAGE_DOS_MAGIC 0x5a4d
#define IMAGE_PE_MAGIC 0x00004550
#define IMAGE_SIZEOF_SHORT_NAME 8
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
typedef void* PVOID;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef signed long LONG;
typedef unsigned long ULONG;
#pragma pack(push,2)
typedef struct _IMAGE_DOS_HEADER {
WORD e_magic;
WORD e_cblp;
WORD e_cp;
WORD e_crlc;
WORD e_cparhdr;
WORD e_minalloc;
WORD e_maxalloc;
WORD e_ss;
WORD e_sp;
WORD e_csum;
WORD e_ip;
WORD e_cs;
WORD e_lfarlc;
WORD e_ovno;
WORD e_res[4];
WORD e_oemid;
WORD e_oeminfo;
WORD e_res2[10];
LONG e_lfanew;
} IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER;
#pragma pack(pop)
#pragma pack(push,4)
typedef struct _IMAGE_DATA_DIRECTORY {
DWORD VirtualAddress;
DWORD Size;
} IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY;
typedef struct _IMAGE_OPTIONAL_HEADER {
WORD Magic;
BYTE MajorLinkerVersion;
BYTE MinorLinkerVersion;
DWORD SizeOfCode;
DWORD SizeOfInitializedData;
DWORD SizeOfUninitializedData;
DWORD AddressOfEntryPoint;
DWORD BaseOfCode;
DWORD BaseOfData;
DWORD ImageBase;
DWORD SectionAlignment;
DWORD FileAlignment;
WORD MajorOperatingSystemVersion;
WORD MinorOperatingSystemVersion;
WORD MajorImageVersion;
WORD MinorImageVersion;
WORD MajorSubsystemVersion;
WORD MinorSubsystemVersion;
DWORD Reserved1;
DWORD SizeOfImage;
DWORD SizeOfHeaders;
DWORD CheckSum;
WORD Subsystem;
WORD DllCharacteristics;
DWORD SizeOfStackReserve;
DWORD SizeOfStackCommit;
DWORD SizeOfHeapReserve;
DWORD SizeOfHeapCommit;
DWORD LoaderFlags;
DWORD NumberOfRvaAndSizes;
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
} IMAGE_OPTIONAL_HEADER,*PIMAGE_OPTIONAL_HEADER;
typedef struct _IMAGE_FILE_HEADER {
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
typedef struct _IMAGE_SECTION_HEADER {
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union {
DWORD PhysicalAddress;
DWORD VirtualSize;
} Misc;
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
} IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER;
#pragma pack(pop)
typedef struct _SYMBOLFILE_HEADER {
unsigned long StabsOffset;
unsigned long StabsLength;
unsigned long StabstrOffset;
unsigned long StabstrLength;
} SYMBOLFILE_HEADER, *PSYMBOLFILE_HEADER;
char* convert_path(char* origpath)
{
char* newpath;
int i;
newpath = strdup(origpath);
i = 0;
while (newpath[i] != 0)
{
#ifdef UNIX_PATHS
if (newpath[i] == '\\')
{
newpath[i] = '/';
}
#else
#ifdef DOS_PATHS
if (newpath[i] == '/')
{
newpath[i] = '\\';
}
#endif
#endif
i++;
}
return(newpath);
}
#define TRANSFER_SIZE (65536)
int main(int argc, char* argv[])
{
SYMBOLFILE_HEADER SymbolFileHeader;
IMAGE_DOS_HEADER PEDosHeader;
IMAGE_FILE_HEADER PEFileHeader;
PIMAGE_SECTION_HEADER PESectionHeaders;
PVOID SymbolsBase;
ULONG SymbolsLength;
PVOID SymbolStringsBase;
ULONG SymbolStringsLength;
ULONG Idx;
char* path1;
char* path2;
FILE* in;
FILE* out;
char* buf;
int n_in;
int n_out;
if (argc != 3)
{
fprintf(stderr, "Too many arguments\n");
exit(1);
}
path1 = convert_path(argv[1]);
path2 = convert_path(argv[2]);
in = fopen(path1, "rb");
if (in == NULL)
{
perror("Cannot open input file");
exit(1);
}
out = fopen(path2, "wb");
if (out == NULL)
{
perror("Cannot open output file");
fclose(in);
exit(1);
}
/* Check if MZ header exists */
n_in = fread(&PEDosHeader, 1, sizeof(PEDosHeader), in);
if (PEDosHeader.e_magic != IMAGE_DOS_MAGIC && PEDosHeader.e_lfanew != 0L)
{
perror("Input file is not a PE image.\n");
}
/* Read PE file header */
/* sizeof(ULONG) = sizeof(MAGIC) */
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG), SEEK_SET);
n_in = fread(&PEFileHeader, 1, sizeof(PEFileHeader), in);
/* Read PE section headers */
PESectionHeaders = malloc(PEFileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER));
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER)
+ sizeof(IMAGE_OPTIONAL_HEADER), SEEK_SET);
n_in = fread(PESectionHeaders, 1, PEFileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER), in);
/* Copy .stab and .stabstr sections if available */
SymbolsBase = NULL;
SymbolsLength = 0;
SymbolStringsBase = NULL;
SymbolStringsLength = 0;
for (Idx = 0; Idx < PEFileHeader.NumberOfSections; Idx++)
{
//printf("section: '%.08s'\n", PESectionHeaders[Idx].Name);
if ((strncmp(PESectionHeaders[Idx].Name, ".stab", 5) == 0)
&& (PESectionHeaders[Idx].Name[5] == 0))
{
//printf(".stab section found. Size %d\n",
// PESectionHeaders[Idx].SizeOfRawData);
SymbolsLength = PESectionHeaders[Idx].SizeOfRawData;
SymbolsBase = malloc(SymbolsLength);
fseek(in, PESectionHeaders[Idx].PointerToRawData, SEEK_SET);
n_in = fread(SymbolsBase, 1, SymbolsLength, in);
}
if (strncmp(PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
{
//printf(".stabstr section found. Size %d\n",
// PESectionHeaders[Idx].SizeOfRawData);
SymbolStringsLength = PESectionHeaders[Idx].SizeOfRawData;
SymbolStringsBase = malloc(SymbolStringsLength);
fseek(in, PESectionHeaders[Idx].PointerToRawData, SEEK_SET);
n_in = fread(SymbolStringsBase, 1, SymbolStringsLength, in);
}
}
SymbolFileHeader.StabsOffset = sizeof(SYMBOLFILE_HEADER);
SymbolFileHeader.StabsLength = SymbolsLength;
SymbolFileHeader.StabstrOffset = SymbolFileHeader.StabsOffset + SymbolsLength;
SymbolFileHeader.StabstrLength = SymbolStringsLength;
n_out = fwrite(&SymbolFileHeader, 1, sizeof(SYMBOLFILE_HEADER), out);
n_out = fwrite(SymbolsBase, 1, SymbolsLength, out);
n_out = fwrite(SymbolStringsBase, 1, SymbolStringsLength, out);
exit(0);
}