ReactOS 0.4.15-dev-7712-gbbbcd8e
kdbg.c File Reference
#include <ntoskrnl.h>
#include "kdb.h"
Include dependency graph for kdbg.c:

Go to the source code of this file.

Macros

#define pKdD0Transition   KdD0Transition
 
#define pKdD3Transition   KdD3Transition
 
#define pKdSave   KdSave
 
#define pKdRestore   KdRestore
 
#define pKdSendPacket   KdSendPacket
 
#define pKdReceivePacket   KdReceivePacket
 

Functions

NTSTATUS NTAPI KdD0Transition (VOID)
 
NTSTATUS NTAPI KdD3Transition (VOID)
 
NTSTATUS NTAPI KdSave (_In_ BOOLEAN SleepTransition)
 
NTSTATUS NTAPI KdRestore (_In_ BOOLEAN SleepTransition)
 
VOID NTAPI KdSendPacket (_In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_opt_ PSTRING MessageData, _Inout_ PKD_CONTEXT Context)
 
KDSTATUS NTAPI KdReceivePacket (_In_ ULONG PacketType, _Out_ PSTRING MessageHeader, _Out_ PSTRING MessageData, _Out_ PULONG DataLength, _Inout_ PKD_CONTEXT Context)
 

Variables

static ULONG KdbgNextApiNumber = DbgKdContinueApi
 
static CONTEXT KdbgContext
 
static EXCEPTION_RECORD64 KdbgExceptionRecord
 
static BOOLEAN KdbgFirstChanceException
 
static NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
 

Macro Definition Documentation

◆ pKdD0Transition

#define pKdD0Transition   KdD0Transition

◆ pKdD3Transition

#define pKdD3Transition   KdD3Transition

◆ pKdReceivePacket

#define pKdReceivePacket   KdReceivePacket

◆ pKdRestore

#define pKdRestore   KdRestore

◆ pKdSave

#define pKdSave   KdSave

◆ pKdSendPacket

#define pKdSendPacket   KdSendPacket

Function Documentation

◆ KdD0Transition()

NTSTATUS NTAPI KdD0Transition ( VOID  )

Definition at line 27 of file kdbg.c.

30{
31 /* Call KdTerm */
32 return pKdD0Transition();
33}
#define pKdD0Transition

◆ KdD3Transition()

NTSTATUS NTAPI KdD3Transition ( VOID  )

Definition at line 37 of file kdbg.c.

40{
41 /* Call KdTerm */
42 return pKdD3Transition();
43}
#define pKdD3Transition

◆ KdReceivePacket()

KDSTATUS NTAPI KdReceivePacket ( _In_ ULONG  PacketType,
_Out_ PSTRING  MessageHeader,
_Out_ PSTRING  MessageData,
_Out_ PULONG  DataLength,
_Inout_ PKD_CONTEXT  Context 
)

Definition at line 149 of file kdbg.c.

157{
158 if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
159 {
160 // FIXME TODO: Implement break-in for the debugger
161 // and return KdPacketReceived when handled properly.
162 return KdPacketTimedOut;
163 }
164
165 if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
166 {
167 /* Call KdTerm */
168 return pKdReceivePacket(PacketType,
169 MessageHeader,
170 MessageData,
172 Context);
173 }
174
175 /* Debugger-only packets */
176 if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
177 {
178 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
179 RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
181 {
182 ManipulateState->ApiNumber = DbgKdGetContextApi;
183 MessageData->Length = 0;
184 MessageData->Buffer = (PCHAR)&KdbgContext;
185 return KdPacketReceived;
186 }
188 {
189 ManipulateState->ApiNumber = DbgKdSetContextApi;
190 MessageData->Length = sizeof(KdbgContext);
191 MessageData->Buffer = (PCHAR)&KdbgContext;
192 return KdPacketReceived;
193 }
195 {
196 KdbPrintf("%s:%d is UNIMPLEMENTED\n", __FUNCTION__, __LINE__);
197 }
198 ManipulateState->ApiNumber = DbgKdContinueApi;
199 ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
200
201 /* Prepare for next time */
204
205 return KdPacketReceived;
206 }
207
208 KdbPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
209 return KdPacketTimedOut;
210}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define __FUNCTION__
Definition: types.h:116
VOID __cdecl KdbPrintf(_In_ PCSTR Format,...)
Definition: kdb_print.c:160
#define PCHAR
Definition: match.c:90
static ULONG KdbgNextApiNumber
Definition: kdbg.c:17
#define pKdReceivePacket
static NTSTATUS KdbgContinueStatus
Definition: kdbg.c:21
static CONTEXT KdbgContext
Definition: kdbg.c:18
#define KdPacketReceived
Definition: kddll.h:5
#define KdPacketTimedOut
Definition: kddll.h:6
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS ContinueStatus
Definition: windbgkd.h:579
union _DBGKD_MANIPULATE_STATE64::@3553 u
DBGKD_CONTINUE Continue
Definition: windbgkd.h:799
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DbgKdGetContextApi
Definition: windbgkd.h:76
#define DbgKdSetContextApi
Definition: windbgkd.h:77
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
#define DbgKdContinueApi
Definition: windbgkd.h:80
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44

◆ KdRestore()

NTSTATUS NTAPI KdRestore ( _In_ BOOLEAN  SleepTransition)

Definition at line 58 of file kdbg.c.

62{
63 /* Call KdTerm */
64 return pKdRestore(SleepTransition);
65}
#define pKdRestore

◆ KdSave()

NTSTATUS NTAPI KdSave ( _In_ BOOLEAN  SleepTransition)

Definition at line 47 of file kdbg.c.

51{
52 /* Call KdTerm */
53 return pKdSave(SleepTransition);
54}
#define pKdSave

◆ KdSendPacket()

VOID NTAPI KdSendPacket ( _In_ ULONG  PacketType,
_In_ PSTRING  MessageHeader,
_In_opt_ PSTRING  MessageData,
_Inout_ PKD_CONTEXT  Context 
)

Definition at line 69 of file kdbg.c.

76{
77 if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
78 {
79 /* Call KdTerm */
80 pKdSendPacket(PacketType, MessageHeader, MessageData, Context);
81 return;
82 }
83
84 /* Debugger-only packets */
85 if (PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
86 {
87 PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
88 if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
89 {
90 /* Load or unload symbols */
91 PLDR_DATA_TABLE_ENTRY LdrEntry;
92 if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, -1, &LdrEntry))
93 {
94 KdbSymProcessSymbols(LdrEntry, !WaitStateChange->u.LoadSymbols.UnloadSymbols);
95 }
96 return;
97 }
98 else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
99 {
103 return;
104 }
105 }
106 else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
107 {
108 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
109 if (ManipulateState->ApiNumber == DbgKdGetContextApi)
110 {
112
113 /* Check if this is an assertion failure */
115 {
116 /* Bump EIP to the instruction following the int 2C */
118 }
119
121 KdbgContext.SegCs & 1,
124#if 0
125 /* Manually dump the stack for the user */
128#endif
131 else
134 return;
135 }
136 else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
137 {
139 return;
140 }
141 }
142
143 KdbPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
144 return;
145}
#define NULL
Definition: types.h:112
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
KD_CONTINUE_TYPE KdbEnterDebuggerException(IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT Context, IN BOOLEAN FirstChance)
KDB Exception filter.
Definition: kdb.c:1262
enum _KD_CONTINUE_TYPE KD_CONTINUE_TYPE
@ kdHandleException
Definition: kdb.h:58
VOID KdbSymProcessSymbols(_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
Load symbols from image mapping. If this fails,.
Definition: kdb_symbols.c:297
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:76
if(dx< 0)
Definition: linetemp.h:194
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
#define KeGetContextPc(Context)
Definition: ke.h:31
static BOOLEAN KdbgFirstChanceException
Definition: kdbg.c:20
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdbg.c:19
#define pKdSendPacket
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
ULONG SegCs
Definition: nt_native.h:1477
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3545 u
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:508
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:509
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:312
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
Definition: btrfs_drv.h:1876
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Variable Documentation

◆ KdbgContext

CONTEXT KdbgContext
static

Definition at line 18 of file kdbg.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgContinueStatus

NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
static

Definition at line 21 of file kdbg.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgExceptionRecord

EXCEPTION_RECORD64 KdbgExceptionRecord
static

Definition at line 19 of file kdbg.c.

Referenced by KdSendPacket().

◆ KdbgFirstChanceException

BOOLEAN KdbgFirstChanceException
static

Definition at line 20 of file kdbg.c.

Referenced by KdSendPacket().

◆ KdbgNextApiNumber

ULONG KdbgNextApiNumber = DbgKdContinueApi
static

Definition at line 17 of file kdbg.c.

Referenced by KdReceivePacket(), and KdSendPacket().