03cac67bfe063ee68929838c46fd47b9a0b8702e
[reactos.git] / reactos / drivers / base / kdgdb / kdgdb.h
1 /*
2 * COPYRIGHT: GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/base/kddll/kddll.h
5 * PURPOSE: Base definitions for the kernel debugger.
6 */
7
8 #ifndef _KDGDB_H_
9 #define _KDGDB_H_
10
11 #define NOEXTAPI
12 #include <ntifs.h>
13 #include <halfuncs.h>
14 #include <stdio.h>
15 #include <arc/arc.h>
16 #include <windbgkd.h>
17 #include <kddll.h>
18
19 #define KDDEBUG /* uncomment to enable debugging this dll */
20
21 #ifndef KDDEBUG
22 #define KDDBGPRINT(...)
23 #else
24 extern ULONG KdpDbgPrint(const char* Format, ...);
25 #define KDDBGPRINT KdpDbgPrint
26 #endif
27
28 /* Callbacks to simulate a KdReceive <-> KdSend loop without GDB being aware of it */
29 typedef VOID (*KDP_SEND_HANDLER)(
30 _In_ ULONG PacketType,
31 _In_ PSTRING MessageHeader,
32 _In_ PSTRING MessageData
33 );
34 typedef KDSTATUS (*KDP_MANIPULATESTATE_HANDLER)(
35 _Out_ DBGKD_MANIPULATE_STATE64* State,
36 _Out_ PSTRING MessageData,
37 _Out_ PULONG MessageLength,
38 _Inout_ PKD_CONTEXT KdContext
39 );
40
41 /* gdb_input.c */
42 extern HANDLE gdb_dbg_thread;
43 KDSTATUS gdb_interpret_input(_Out_ DBGKD_MANIPULATE_STATE64* State, _Out_ PSTRING MessageData, _Out_ PULONG MessageLength, _Inout_ PKD_CONTEXT KdContext);
44
45 /* gdb_receive.c */
46 extern CHAR gdb_input[];
47 KDSTATUS NTAPI gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext);
48 char hex_value(char ch);
49
50 /* gdb_send.c */
51 void send_gdb_packet(_In_ CHAR* Buffer);
52 void send_gdb_memory(_In_ VOID* Buffer, size_t Length);
53 void gdb_send_debug_io(_In_ PSTRING String);
54 void gdb_send_exception(void);
55
56 /* kdcom.c */
57 KDSTATUS NTAPI KdpPollBreakIn(VOID);
58 VOID NTAPI KdpSendByte(_In_ UCHAR Byte);
59 KDSTATUS NTAPI KdpReceiveByte(_Out_ PUCHAR OutByte);
60
61 /* kdpacket.c */
62 extern DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange;
63 extern DBGKD_GET_VERSION64 KdVersion;
64 extern KDDEBUGGER_DATA64* KdDebuggerDataBlock;
65 extern KDP_SEND_HANDLER KdpSendPacketHandler;
66 extern KDP_MANIPULATESTATE_HANDLER KdpManipulateStateHandler;
67
68
69 /* arch_sup.c */
70 void gdb_send_registers(void);
71
72 /* Architecture specific defines. See ntoskrnl/include/internal/arch/ke.h */
73 #ifdef _M_IX86
74 # define KdpGetContextPc(Context) \
75 ((Context)->Eip)
76 # define KdpSetContextPc(Context, ProgramCounter) \
77 ((Context)->Eip = (ProgramCounter))
78 # define KD_BREAKPOINT_SIZE sizeof(UCHAR)
79 #else
80 # error "Please define relevant macros for your architecture"
81 #endif
82
83 #endif /* _KDGDB_H_ */