From 58809635add79df4287a33c8cf081700272010ea Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 30 Nov 2006 09:54:31 +0000 Subject: [PATCH] - Raw test app for DbgUi+Dbgk Debugging Subsystem (skeletal, and doesn't test Win32 APIs). svn path=/trunk/; revision=24988 --- reactos/hal/hal/hal.c | 40 +++++++++++++ reactos/ntoskrnl/tests/TestDebug.c | 93 ++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 reactos/ntoskrnl/tests/TestDebug.c diff --git a/reactos/hal/hal/hal.c b/reactos/hal/hal/hal.c index 576097f166c..87e0ebb06bf 100644 --- a/reactos/hal/hal/hal.c +++ b/reactos/hal/hal/hal.c @@ -42,6 +42,38 @@ DriverEntry( return STATUS_SUCCESS; } +/* +* @unimplemented +*/ +VOID +NTAPI +HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + KEBUGCHECK(0); + return; +} + +/* +* @unimplemented +*/ +VOID +NTAPI +HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + KEBUGCHECK(0); + return; +} + +/* +* @unimplemented +*/ +ULONG_PTR +NTAPI +HalSetProfileInterval(IN ULONG_PTR Interval) +{ + KEBUGCHECK(0); + return Interval; +} VOID FASTCALL @@ -1161,6 +1193,14 @@ KeAcquireQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle) return (KIRQL)0; } +KIRQL +FASTCALL +KeAcquireQueuedSpinLockRaiseToSynch(IN PKLOCK_QUEUE_HANDLE LockHandle) +{ + UNIMPLEMENTED; + return (KIRQL)0; +} + VOID FASTCALL KeReleaseQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle, diff --git a/reactos/ntoskrnl/tests/TestDebug.c b/reactos/ntoskrnl/tests/TestDebug.c new file mode 100644 index 00000000000..ad83f9fa8ba --- /dev/null +++ b/reactos/ntoskrnl/tests/TestDebug.c @@ -0,0 +1,93 @@ +#define _X86_ +#include "ntndk.h" + +VOID +Main(VOID) +{ + NTSTATUS Status; + HANDLE hProcess; + OBJECT_ATTRIBUTES ObjectAttributes; + CLIENT_ID ClientId; + DBGUI_WAIT_STATE_CHANGE State; + BOOLEAN Alive = TRUE; + + printf("*** Native (DbgUi) Debugging Test Application\n"); + printf("Press any key to connect to Dbgk..."); + getchar(); + + Status = DbgUiConnectToDbg(); + printf(" Connection Established. Status: %lx\n", Status); + printf("Debug Object Handle: %lx\n", NtCurrentTeb()->DbgSsReserved[1]); + printf("Press any key to debug services.exe..."); + getchar(); + + InitializeObjectAttributes(&ObjectAttributes, NULL, 0, 0, 0); + ClientId.UniqueThread = 0; + ClientId.UniqueProcess = UlongToHandle(168); + Status = NtOpenProcess(&hProcess, + PROCESS_ALL_ACCESS, + &ObjectAttributes, + &ClientId); + Status = DbgUiDebugActiveProcess(hProcess); + printf(" Debugger Attached. Status: %lx\n", Status); + printf("Press any key to get first debug event... "); + getchar(); + + while (Alive) + { + Status = DbgUiWaitStateChange(&State, NULL); + printf(" Event Received. Status: %lx\n", Status); + printf("New State: %lx. Application Client ID: %lx/%lx\n", + State.NewState, + State.AppClientId.UniqueProcess, State.AppClientId.UniqueThread); + + switch (State.NewState) + { + case DbgCreateProcessStateChange: + printf("Process Handle: %lx. Thread Handle: %lx\n", + State.StateInfo.CreateProcessInfo.HandleToProcess, + State.StateInfo.CreateProcessInfo.HandleToThread); + printf("Process image handle: %lx\n", + State.StateInfo.CreateProcessInfo.NewProcess.FileHandle); + printf("Process image base: %lx\n", + State.StateInfo.CreateProcessInfo.NewProcess.BaseOfImage); + break; + + case DbgCreateThreadStateChange: + printf("New thread: %lx\n", State.StateInfo.CreateThread.HandleToThread); + printf("Thread Start Address: %p\n", State.StateInfo.CreateThread.NewThread.StartAddress); + break; + + case DbgLoadDllStateChange: + printf("New DLL: %lx\n", State.StateInfo.LoadDll.FileHandle); + printf("DLL LoadAddress: %p\n", State.StateInfo.LoadDll.BaseOfDll); + break; + + case DbgBreakpointStateChange: + printf("Initial breakpoint hit at: %p!\n", + State.StateInfo.Exception.ExceptionRecord.ExceptionAddress); + break; + + case DbgExitThreadStateChange: + printf("Thread exited: %lx\n", State.StateInfo.ExitThread.ExitStatus); + break; + + case DbgExitProcessStateChange: + printf("Process exited: %lx\n", State.StateInfo.ExitProcess.ExitStatus); + Alive = FALSE; + break; + } + + printf("Press any key to continue debuggee..."); + getchar(); + + ClientId.UniqueProcess = State.AppClientId.UniqueProcess; + ClientId.UniqueThread = State.AppClientId.UniqueThread; + Status = DbgUiContinue(&ClientId, DBG_CONTINUE); + printf(" Debuggee Resumed. Status: %lx\n", Status); + printf("Press any key to get next debug event... "); + getchar(); + }; + printf("*** End of test\n"); + getchar(); +}