And these should've been added...
Added: trunk/reactos/ntoskrnl/dbgk/
Added: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
Added: trunk/reactos/ntoskrnl/dbgk/debug.c
Added: trunk/reactos/ntoskrnl/ex/dbgctrl.c
Added: trunk/reactos/ntoskrnl/include/internal/dbgk.h
Added: trunk/reactos/ntoskrnl/include/internal/kdb.h
Added: trunk/reactos/ntoskrnl/rtl/debug.c
_____
Added: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
--- trunk/reactos/ntoskrnl/dbgk/dbgkutil.c 2005-04-23 06:43:39 UTC
(rev 14761)
+++ trunk/reactos/ntoskrnl/dbgk/dbgkutil.c 2005-04-23 06:45:56 UTC
(rev 14762)
@@ -0,0 +1,57 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Kernel
+ * FILE: ntoskrnl/dbgk/dbgkutil.c
+ * PURPOSE: User-Mode Debugging Support, Internal Debug
Functions.
+ *
+ * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+/* FUNCTIONS
*****************************************************************/
+
+VOID
+STDCALL
+DbgkCreateThread(PVOID StartAddress)
+{
+#if 0
+ LPC_DBG_MESSAGE Message;
+ LPC_DBG_MESSAGE Reply;
+ NTSTATUS Status;
+
+ if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL)
+ {
+ return;
+ }
+
+ Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE);
+ Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) -
+ sizeof(LPC_MESSAGE);
+ Message.Type = DBG_EVENT_CREATE_THREAD;
+ Message.Status = STATUS_SUCCESS;
+ Message.Data.CreateThread.Reserved = 0;
+ Message.Data.CreateThread.StartAddress = StartAddress;
+
+ /* FIXME: Freeze all threads in process */
+
+ /* Send the message to the process's debug port and wait for a reply
*/
+ Status =
+
LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort,
+ &Message,
+ &Reply);
+ if (!NT_SUCCESS(Status))
+ {
+ return;
+ }
+
+ /* FIXME: Examine reply */
+ return;
+#endif
+}
+
+/* EOF */
_____
Added: trunk/reactos/ntoskrnl/dbgk/debug.c
--- trunk/reactos/ntoskrnl/dbgk/debug.c 2005-04-23 06:43:39 UTC (rev
14761)
+++ trunk/reactos/ntoskrnl/dbgk/debug.c 2005-04-23 06:45:56 UTC (rev
14762)
@@ -0,0 +1,164 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Kernel
+ * FILE: ntoskrnl/dbgk/debug.c
+ * PURPOSE: User-Mode Debugging Support, Debug Object
Management.
+ *
+ * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+POBJECT_TYPE DbgkDebugObjectType;
+/* FUNCTIONS
*****************************************************************/
+
+NTSTATUS
+STDCALL
+NtCreateDebugObject(OUT PHANDLE DebugHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ IN BOOLEAN KillProcessOnExit)
+{
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ PDBGK_DEBUG_OBJECT DebugObject;
+ HANDLE hDebug;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ PAGED_CODE();
+ DPRINT("NtCreateDebugObject(0x%x, 0x%x, 0x%x)\n", DebugHandle,
DesiredAccess, ObjectAttributes);
+
+ /* Check Output Safety */
+ if(PreviousMode != KernelMode) {
+
+ _SEH_TRY {
+
+ ProbeForWrite(DebugHandle,
+ sizeof(HANDLE),
+ sizeof(ULONG));
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+
+ if(!NT_SUCCESS(Status)) return Status;
+ }
+
+ /* Create the Object */
+ Status = ObCreateObject(PreviousMode,
+ DbgkDebugObjectType,
+ ObjectAttributes,
+ PreviousMode,
+ NULL,
+ sizeof(PDBGK_DEBUG_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&DebugObject);
+
+ /* Check for Success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Initialize the Debug Object's Fast Mutex */
+ ExInitializeFastMutex(&DebugObject->Mutex);
+
+ /* Initialize the State Event List */
+ InitializeListHead(&DebugObject->StateEventListEntry);
+
+ /* Initialize the Debug Object's Wait Event */
+ KeInitializeEvent(&DebugObject->Event, NotificationEvent, 0);
+
+ /* Set the Flags */
+ DebugObject->KillProcessOnExit = KillProcessOnExit;
+
+ /* Insert it */
+ Status = ObInsertObject((PVOID)DebugObject,
+ NULL,
+ DesiredAccess,
+ 0,
+ NULL,
+ &hDebug);
+ ObDereferenceObject(DebugObject);
+
+ /* Check for success and return handle */
+ if(NT_SUCCESS(Status)) {
+
+ _SEH_TRY {
+
+ *DebugHandle = hDebug;
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+ }
+ }
+
+ /* Return Status */
+ return Status;
+}
+
+NTSTATUS
+STDCALL
+NtWaitForDebugEvent(IN HANDLE DebugObject, // Debug object handle must
grant DEBUG_OBJECT_WAIT_STATE_CHANGE access.
+ IN BOOLEAN Alertable,
+ IN PLARGE_INTEGER Timeout OPTIONAL,
+ OUT PDBGUI_WAIT_STATE_CHANGE StateChange)
+{
+
+ UNIMPLEMENTED;
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+STDCALL
+NtDebugContinue(IN HANDLE DebugObject, // Debug object handle must
grant DEBUG_OBJECT_WAIT_STATE_CHANGE access.
+ IN PCLIENT_ID AppClientId,
+ IN NTSTATUS ContinueStatus)
+{
+
+ UNIMPLEMENTED;
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+STDCALL
+NtDebugActiveProcess(IN HANDLE Process, // Process handle must
grant PROCESS_SUSPEND_RESUME access.
+ IN HANDLE DebugObject) // Debug object handle
must grant DEBUG_OBJECT_ADD_REMOVE_PROCESS access.
+{
+
+ UNIMPLEMENTED;
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+STDCALL
+NtRemoveProcessDebug(IN HANDLE Process, // Process handle must
grant PROCESS_SUSPEND_RESUME access.
+ IN HANDLE DebugObject) // Debug object handle
must grant DEBUG_OBJECT_ADD_REMOVE_PROCESS access.
+{
+
+ UNIMPLEMENTED;
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+STDCALL
+NtSetInformationDebugObject(IN HANDLE DebugObject, // Debug object
handle need not grant any particular access right.
+ IN DEBUGOBJECTINFOCLASS
DebugObjectInformationClass,
+ IN PVOID DebugInformation,
+ IN ULONG DebugInformationLength,
+ OUT PULONG ReturnLength OPTIONAL)
+{
+ UNIMPLEMENTED;
+
+ return STATUS_NOT_IMPLEMENTED;
+}
+/* EOF */
_____
Added: trunk/reactos/ntoskrnl/ex/dbgctrl.c
--- trunk/reactos/ntoskrnl/ex/dbgctrl.c 2005-04-23 06:43:39 UTC (rev
14761)
+++ trunk/reactos/ntoskrnl/ex/dbgctrl.c 2005-04-23 06:45:56 UTC (rev
14762)
@@ -0,0 +1,46 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/ex/dbgctrl.c
+ * PURPOSE: System debug control
+ *
+ * PROGRAMMERS: No programmer listed.
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+/* FUNCTIONS
*****************************************************************/
+
+NTSTATUS
+STDCALL
+NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode,
+ PVOID InputBuffer,
+ ULONG InputBufferLength,
+ PVOID OutputBuffer,
+ ULONG OutputBufferLength,
+ PULONG ReturnLength)
+{
+ switch (ControlCode)
+ {
+ case DebugGetTraceInformation:
+ case DebugSetInternalBreakpoint:
+ case DebugSetSpecialCall:
+ case DebugClearSpecialCalls:
+ case DebugQuerySpecialCalls:
+ case DebugDbgBreakPoint:
+ break;
+
+ case DebugDbgLoadSymbols:
+ KDB_LOADUSERMODULE_HOOK((PLDR_MODULE) InputBuffer);
+ break;
+
+ default:
+ break;
+ }
+
+ return STATUS_SUCCESS;
+}
_____
Added: trunk/reactos/ntoskrnl/include/internal/dbgk.h
--- trunk/reactos/ntoskrnl/include/internal/dbgk.h 2005-04-23
06:43:39 UTC (rev 14761)
+++ trunk/reactos/ntoskrnl/include/internal/dbgk.h 2005-04-23
06:45:56 UTC (rev 14762)
@@ -0,0 +1,143 @@
+/*
+ * ReactOS kernel
+ * Copyright (C) 2000 David Welch <welch(a)cwcom.net>
+ *
+ * This program is free software; you can redistribute it and/or
modify
+ * it under the terms of the GNU General Public License as published
by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __NTOSKRNL_INCLUDE_INTERNAL_DBGK_H
+#define __NTOSKRNL_INCLUDE_INTERNAL_DBGK_H
+
+//
+// DebugObject access rights.
+// Note that DEBUG_OBJECT_ALL_ACCESS includes the specific rights 0x0F,
but there are only two
+// debug object specific access rights that are ever checked by the
kernel. This appears to be a bug.
+//
+#define DEBUG_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE
| 0x0F)
+#define DEBUG_OBJECT_WAIT_STATE_CHANGE 0x0001 /* Required to call
NtWaitForDebugEvent & NtContinueDebugEvent */
+#define DEBUG_OBJECT_ADD_REMOVE_PROCESS 0x0002 /* Required to call
NtDebugActiveProcess & NtRemoveProcessDebug */
+
+typedef enum _DEBUGOBJECTINFOCLASS {
+ DebugObjectUnusedInformation,
+ DebugObjectKillProcessOnExitInformation
+} DEBUGOBJECTINFOCLASS, * PDEBUGOBJECTINFOCLASS;
+
+typedef struct _DEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION {
+ ULONG KillProcessOnExit; // Interpreted as a
BOOLEAN, TRUE -> process is terminated on NtRemoveProcessDebug.
+} DEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION, *
+PDEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION;
+
+//
+// Debug Object
+//
+typedef struct _DBGK_DEBUG_OBJECT {
+ KEVENT Event;
+ FAST_MUTEX Mutex;
+ LIST_ENTRY StateEventListEntry;
+ union {
+ ULONG Flags;
+ struct {
+ UCHAR DebuggerInactive :1;
+ UCHAR KillProcessOnExit :1;
+ };
+ };
+} DBGK_DEBUG_OBJECT, *PDBGK_DEBUG_OBJECT;
+
+//
+// DbgUi types for LPC debug port messages (KM -> UM).
+//
+// These also apply to Nt*Debug APIs with NT 5.01, 5.02, and later.
+//
+typedef enum _DBG_STATE {
+ DbgIdle,
+ DbgReplyPending,
+ DbgCreateThreadStateChange,
+ DbgCreateProcessStateChange,
+ DbgExitThreadStateChange,
+ DbgExitProcessStateChange,
+ DbgExceptionStateChange,
+ DbgBreakpointStateChange,
+ DbgSingleStepStateChange,
+ DbgLoadDllStateChange,
+ DbgUnloadDllStateChange
+} DBG_STATE, *PDBG_STATE;
+
+typedef struct _DBGKM_EXCEPTION {
+ EXCEPTION_RECORD ExceptionRecord;
+ ULONG FirstChance;
+} DBGKM_EXCEPTION, *PDBGKM_EXCEPTION;
+
+typedef struct _DBGKM_CREATE_THREAD {
+ ULONG SubSystemKey;
+ PVOID StartAddress;
+} DBGKM_CREATE_THREAD, *PDBGKM_CREATE_THREAD;
+
+typedef struct _DBGKM_CREATE_PROCESS {
+ ULONG SubSystemKey;
+ HANDLE FileHandle;
+ PVOID BaseOfImage;
+ ULONG DebugInfoFileOffset;
+ ULONG DebugInfoSize;
+ DBGKM_CREATE_THREAD InitialThread;
+} DBGKM_CREATE_PROCESS, *PDBGKM_CREATE_PROCESS;
+
+typedef struct _DBGKM_EXIT_THREAD {
+ NTSTATUS ExitStatus;
+} DBGKM_EXIT_THREAD, *PDBGKM_EXIT_THREAD;
+
+typedef struct _DBGKM_EXIT_PROCESS {
+ NTSTATUS ExitStatus;
+} DBGKM_EXIT_PROCESS, *PDBGKM_EXIT_PROCESS;
+
+typedef struct _DBGKM_LOAD_DLL {
+ HANDLE FileHandle;
+ PVOID BaseOfDll;
+ ULONG DebugInfoFileOffset;
+ ULONG DebugInfoSize;
+} DBGKM_LOAD_DLL, *PDBGKM_LOAD_DLL;
+
+typedef struct _DBGKM_UNLOAD_DLL {
+ PVOID BaseAddress;
+} DBGKM_UNLOAD_DLL, *PDBGKM_UNLOAD_DLL;
+
+typedef struct _DBGUI_WAIT_STATE_CHANGE {
+ DBG_STATE NewState;
+ CLIENT_ID AppClientId;
+ union {
+ struct {
+ HANDLE HandleToThread;
+ DBGKM_CREATE_THREAD NewThread;
+ } CreateThread;
+ struct {
+ HANDLE HandleToProcess;
+ HANDLE HandleToThread;
+ DBGKM_CREATE_PROCESS NewProcess;
+ } CreateProcessInfo;
+ DBGKM_EXIT_THREAD ExitThread;
+ DBGKM_EXIT_PROCESS ExitProcess;
+ DBGKM_EXCEPTION Exception;
+ DBGKM_LOAD_DLL LoadDll;
+ DBGKM_UNLOAD_DLL UnloadDll;
+ } StateInfo;
+} DBGUI_WAIT_STATE_CHANGE, * PDBGUI_WAIT_STATE_CHANGE;
+
+
+VOID
+STDCALL
+DbgkCreateThread(PVOID StartAddress);
+
+#endif
+
+/* EOF */
_____
Added: trunk/reactos/ntoskrnl/include/internal/kdb.h
--- trunk/reactos/ntoskrnl/include/internal/kdb.h 2005-04-23
06:43:39 UTC (rev 14761)
+++ trunk/reactos/ntoskrnl/include/internal/kdb.h 2005-04-23
06:45:56 UTC (rev 14762)
@@ -0,0 +1,284 @@
+#ifndef NTOSKRNL_KDB_H
+#define NTOSKRNL_KDB_H
+
+/* INCLUDES
******************************************************************/
+
+#define NTOS_MODE_KERNEL
+#include <ntos.h>
+
+#include <internal/ke.h>
+
+/* DEFINES
*******************************************************************/
+
+#define TAG_KDBG (('K' << 24) | ('D' << 16) |
('B' << 8) | 'G')
+
+#ifndef RTL_NUMBER_OF
+# define RTL_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+
+/* TYPES
*********************************************************************/
+
+/* from kdb.c */
+typedef struct _KDB_KTRAP_FRAME
+{
+ KTRAP_FRAME Tf;
+ ULONG Cr0;
+ ULONG Cr1; /* reserved/unused */
+ ULONG Cr2;
+ ULONG Cr3;
+ ULONG Cr4;
+} KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME;
+
+typedef enum _KDB_BREAKPOINT_TYPE
+{
+ KdbBreakPointNone = 0,
+ KdbBreakPointSoftware,
+ KdbBreakPointHardware,
+ KdbBreakPointTemporary
+} KDB_BREAKPOINT_TYPE;
+
+typedef enum _KDB_ACCESS_TYPE
+{
+ KdbAccessRead,
+ KdbAccessWrite,
+ KdbAccessReadWrite,
+ KdbAccessExec
+} KDB_ACCESS_TYPE;
+
+typedef struct _KDB_BREAKPOINT
+{
+ KDB_BREAKPOINT_TYPE Type; /* Type of breakpoint */
+ BOOLEAN Enabled; /* Whether the bp is enabled */
+ ULONG_PTR Address; /* Address of the breakpoint */
+ BOOLEAN Global; /* Whether the breakpoint is
global or local to a process */
+ PEPROCESS Process; /* Owning process */
+ PCHAR ConditionExpression;
+ PVOID Condition;
+ union {
+ /* KdbBreakPointSoftware */
+ UCHAR SavedInstruction;
+ /* KdbBreakPointHardware */
+ struct {
+ UCHAR DebugReg : 2;
+ UCHAR Size : 3;
+ KDB_ACCESS_TYPE AccessType;
+ } Hw;
+ } Data;
+} KDB_BREAKPOINT, *PKDB_BREAKPOINT;
+
+typedef enum _KDB_ENTER_CONDITION
+{
+ KdbDoNotEnter,
+ KdbEnterAlways,
+ KdbEnterFromKmode,
+ KdbEnterFromUmode
+} KDB_ENTER_CONDITION;
+
+
+/* from kdb_symbols.c */
+typedef struct _KDB_MODULE_INFO
+{
+ WCHAR Name[256];
+ ULONG_PTR Base;
+ ULONG Size;
+ PROSSYM_INFO RosSymInfo;
+} KDB_MODULE_INFO, *PKDB_MODULE_INFO;
+
+
+/* FUNCTIONS
*****************************************************************/
+
+/* from i386/i386-dis.c */
+
+LONG
+KdbpDisassemble(
+ IN ULONG Address,
+ IN ULONG IntelSyntax);
+
+LONG
+KdbpGetInstLength(
+ IN ULONG Address);
+
+/* from i386/kdb_help.S */
+
+STDCALL VOID
+KdbpStackSwitchAndCall(
+ IN PVOID NewStack,
+ IN VOID (*Function)(VOID));
+
+/* from kdb_cli.c */
+
+extern PCHAR KdbInitFileBuffer;
+
+VOID
+KdbpCliInit();
+
+VOID
+KdbpCliMainLoop(
+ IN BOOLEAN EnteredOnSingleStep);
+
+VOID
+KdbpCliModuleLoaded(
+ IN PUNICODE_STRING Name);
+
+VOID
+KdbpCliInterpretInitFile();
+
+VOID
+KdbpPrint(
+ IN PCHAR Format,
+ IN ... OPTIONAL);
+
+/* from kdb_expr.c */
+
+BOOLEAN
+KdbpRpnEvaluateExpression(
+ IN PCHAR Expression,
+ IN PKDB_KTRAP_FRAME TrapFrame,
+ OUT PULONGLONG Result,
+ OUT PLONG ErrOffset OPTIONAL,
+ OUT PCHAR ErrMsg OPTIONAL);
+
+PVOID
+KdbpRpnParseExpression(
+ IN PCHAR Expression,
+ OUT PLONG ErrOffset OPTIONAL,
+ OUT PCHAR ErrMsg OPTIONAL);
+
+BOOLEAN
+KdbpRpnEvaluateParsedExpression(
+ IN PVOID Expression,
+ IN PKDB_KTRAP_FRAME TrapFrame,
+ OUT PULONGLONG Result,
+ OUT PLONG ErrOffset OPTIONAL,
+ OUT PCHAR ErrMsg OPTIONAL);
+
+/* from kdb_symbols.c */
+
+BOOLEAN
+KdbpSymFindModuleByAddress(IN PVOID Address,
+ OUT PKDB_MODULE_INFO pInfo);
+
+BOOLEAN
+KdbpSymFindModuleByName(IN LPCWSTR Name,
+ OUT PKDB_MODULE_INFO pInfo);
+
+BOOLEAN
+KdbpSymFindModuleByIndex(IN INT Index,
+ OUT PKDB_MODULE_INFO pInfo);
+
+BOOLEAN
+KdbSymPrintAddress(IN PVOID Address);
+
+NTSTATUS
+KdbSymGetAddressInformation(IN PROSSYM_INFO RosSymInfo,
+ IN ULONG_PTR RelativeAddress,
+ OUT PULONG LineNumber OPTIONAL,
+ OUT PCH FileName OPTIONAL,
+ OUT PCH FunctionName OPTIONAL);
+
+/* from kdb.c */
+
+extern PEPROCESS KdbCurrentProcess;
+extern PETHREAD KdbCurrentThread;
+extern LONG KdbLastBreakPointNr;
+extern ULONG KdbNumSingleSteps;
+extern BOOLEAN KdbSingleStepOver;
+extern PKDB_KTRAP_FRAME KdbCurrentTrapFrame;
+
+VOID
+KdbInit();
+
+VOID
+KdbModuleLoaded(
+ IN PUNICODE_STRING Name);
+
+LONG
+KdbpGetNextBreakPointNr(
+ IN ULONG Start OPTIONAL);
+
+BOOLEAN
+KdbpGetBreakPointInfo(
+ IN ULONG BreakPointNr,
+ OUT ULONG_PTR *Address OPTIONAL,
+ OUT KDB_BREAKPOINT_TYPE *Type OPTIONAL,
+ OUT UCHAR *Size OPTIONAL,
+ OUT KDB_ACCESS_TYPE *AccessType OPTIONAL,
+ OUT UCHAR *DebugReg OPTIONAL,
+ OUT BOOLEAN *Enabled OPTIONAL,
+ OUT BOOLEAN *Global OPTIONAL,
+ OUT PEPROCESS *Process OPTIONAL,
+ OUT PCHAR *ConditionExpression OPTIONAL);
+
+NTSTATUS
+KdbpInsertBreakPoint(
+ IN ULONG_PTR Address,
+ IN KDB_BREAKPOINT_TYPE Type,
+ IN UCHAR Size OPTIONAL,
+ IN KDB_ACCESS_TYPE AccessType OPTIONAL,
+ IN PCHAR ConditionExpression OPTIONAL,
+ IN BOOLEAN Global,
+ OUT PULONG BreakPointNumber OPTIONAL);
+
+BOOLEAN
+KdbpDeleteBreakPoint(
+ IN LONG BreakPointNr OPTIONAL,
+ IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL);
+
+BOOLEAN
+KdbpEnableBreakPoint(
+ IN LONG BreakPointNr OPTIONAL,
+ IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL);
+
+BOOLEAN
+KdbpDisableBreakPoint(
+ IN LONG BreakPointNr OPTIONAL,
+ IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL);
+
+BOOLEAN
+KdbpGetEnterCondition(
+ IN LONG ExceptionNr,
+ IN BOOLEAN FirstChance,
+ OUT KDB_ENTER_CONDITION *Condition);
+
+BOOLEAN
+KdbpSetEnterCondition(
+ IN LONG ExceptionNr,
+ IN BOOLEAN FirstChance,
+ IN KDB_ENTER_CONDITION Condition);
+
+BOOLEAN
+KdbpAttachToThread(
+ PVOID ThreadId);
+
+BOOLEAN
+KdbpAttachToProcess(
+ PVOID ProcessId);
+
+/* other functions */
+
+#define KdbpSafeReadMemory(dst, src, size) MmSafeCopyFromUser(dst,
src, size)
+#define KdbpSafeWriteMemory(dst, src, size) MmSafeCopyToUser(dst, src,
size)
+
+#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode,
0)
+CHAR
+KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry);
+
+#define KdbpGetCharSerial() KdbpTryGetCharSerial(0)
+CHAR
+KdbpTryGetCharSerial(UINT Retry);
+
+VOID
+KdbEnter(VOID);
+VOID
+DbgRDebugInit(VOID);
+VOID
+DbgShowFiles(VOID);
+VOID
+DbgEnableFile(PCH Filename);
+VOID
+DbgDisableFile(PCH Filename);
+
+
+#endif /* NTOSKRNL_KDB_H */
+
_____
Added: trunk/reactos/ntoskrnl/rtl/debug.c
--- trunk/reactos/ntoskrnl/rtl/debug.c 2005-04-23 06:43:39 UTC (rev
14761)
+++ trunk/reactos/ntoskrnl/rtl/debug.c 2005-04-23 06:45:56 UTC (rev
14762)
@@ -0,0 +1,190 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/rtl/dbgprint.c
+ * PURPOSE: Debug output
+ *
+ * PROGRAMMERS: Eric Kohl (ekohl(a)abo.rhein-zeitung.de)
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include <ntoskrnl.h>
+#include <internal/debug.h>
+
+/* FUNCTIONS
****************************************************************/
+
+/*
+ * Note: DON'T CHANGE THIS FUNCTION!!!
+ * DON'T CALL HalDisplayString OR SOMETING ELSE!!!
+ * You'll only break the serial/bochs debugging feature!!!
+ */
+
+/*
+ * @implemented
+ */
+ULONG
+DbgPrint(PCH Format, ...)
+{
+ ANSI_STRING DebugString;
+ CHAR Buffer[1024];
+ va_list ap;
+#ifdef SERIALIZE_DBGPRINT
+# define MESSAGETABLE_SIZE 16
+ LONG MyTableIndex;
+ static LONG Lock = 0;
+ static LONG TableWriteIndex = 0, TableReadIndex = 0;
+ static CHAR MessageTable[MESSAGETABLE_SIZE][sizeof(Buffer)] = { {
'\0' } };
+#endif /* SERIALIZE_DBGPRINT */
+
+ /* init ansi string */
+ DebugString.Buffer = Buffer;
+ DebugString.MaximumLength = sizeof(Buffer);
+
+ va_start (ap, Format);
+ DebugString.Length = _vsnprintf (Buffer, sizeof( Buffer ), Format,
ap);
+ va_end (ap);
+
+#ifdef SERIALIZE_DBGPRINT
+ /* check if we are already running */
+ if (InterlockedCompareExchange(&Lock, 1, 0) == 1)
+ {
+ MyTableIndex = InterlockedIncrement(&TableWriteIndex) - 1;
+ InterlockedCompareExchange(&TableWriteIndex, 0,
MESSAGETABLE_SIZE);
+ MyTableIndex %= MESSAGETABLE_SIZE;
+
+ if (MessageTable[MyTableIndex][0] != '\0') /* table is full */
+ {
+ DebugString.Buffer = "CRITICAL ERROR: DbgPrint Table is
FULL!";
+ DebugString.Length = 39;
+ KdpPrintString(&DebugString);
+ for (;;);
+ }
+ else
+ {
+ /*DebugString.Buffer = "ÁÁÁ";
+ DebugString.Length = 3;
+ KdpPrintString(&DebugString);*/
+ memcpy(MessageTable[MyTableIndex], DebugString.Buffer,
DebugString.Length);
+ MessageTable[MyTableIndex][DebugString.Length] = '\0';
+ }
+ }
+ else
+ {
+#endif /* SERIALIZE_DBGPRINT */
+ KdpPrintString (&DebugString);
+#ifdef SERIALIZE_DBGPRINT
+ MyTableIndex = TableReadIndex;
+ while (MessageTable[MyTableIndex][0] != '\0')
+ {
+ /*DebugString.Buffer = "$$$";
+ DebugString.Length = 3;
+ KdpPrintString(&DebugString);*/
+
+ DebugString.Buffer = MessageTable[MyTableIndex];
+ DebugString.Length = strlen(DebugString.Buffer);
+ DebugString.MaximumLength = DebugString.Length + 1;
+
+ KdpPrintString(&DebugString);
+ MessageTable[MyTableIndex][0] = '\0';
+
+ MyTableIndex = InterlockedIncrement(&TableReadIndex);
+ InterlockedCompareExchange(&TableReadIndex, 0,
MESSAGETABLE_SIZE);
+ MyTableIndex %= MESSAGETABLE_SIZE;
+ }
+ InterlockedDecrement(&Lock);
+ }
+# undef MESSAGETABLE_SIZE
+#endif /* SERIALIZE_DBGPRINT */
+
+ return (ULONG)DebugString.Length;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+__cdecl
+DbgPrintEx(IN ULONG ComponentId,
+ IN ULONG Level,
+ IN PCH Format,
+ ...)
+{
+ UNIMPLEMENTED;
+ return 0;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+__cdecl
+DbgPrintReturnControlC(PCH Format,
+ ...)
+{
+ UNIMPLEMENTED;
+ return 0;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+STDCALL
+DbgPrompt(PCH OutputString,
+ PCH InputString,
+ USHORT InputSize)
+{
+ ANSI_STRING Output;
+ ANSI_STRING Input;
+
+ Input.Length = 0;
+ Input.MaximumLength = InputSize;
+ Input.Buffer = InputString;
+
+ Output.Length = strlen (OutputString);
+ Output.MaximumLength = Output.Length + 1;
+ Output.Buffer = OutputString;
+
+ /* FIXME: Not implemented yet!
+ KdpPromptString (&Output, &Input); */
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+STDCALL
+DbgQueryDebugFilterState(IN ULONG ComponentId,
+ IN ULONG Level)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+STDCALL
+DbgSetDebugFilterState(IN ULONG ComponentId,
+ IN ULONG Level,
+ IN BOOLEAN State)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+STDCALL
+DbgLoadImageSymbols(IN PUNICODE_STRING Name,
+ IN ULONG Base,
+ IN ULONG Unknown3)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+/* EOF */