ReactOS 0.4.15-dev-7918-g2a2556c
kdb_print.c File Reference
#include <ntoskrnl.h>
#include "kdb.h"
Include dependency graph for kdb_print.c:

Go to the source code of this file.

Macros

#define pKdSendPacket   KdSendPacket
 
#define pKdReceivePacket   KdReceivePacket
 

Functions

static VOID KdbPrintStringWorker (_In_ const CSTRING *Output, _In_ ULONG ApiNumber, _Inout_ PDBGKD_DEBUG_IO DebugIo, _Inout_ PSTRING Header, _Inout_ PSTRING Data)
 
VOID KdbPrintString (_In_ const CSTRING *Output)
 
static BOOLEAN KdbPromptStringWorker (_In_ const CSTRING *PromptString, _Inout_ PSTRING ResponseString)
 
USHORT KdbPromptString (_In_ const CSTRING *PromptString, _Inout_ PSTRING ResponseString)
 
VOID KdbPutsN (_In_ PCCH String, _In_ USHORT Length)
 
VOID KdbPuts (_In_ PCSTR String)
 
VOID __cdecl KdbPrintf (_In_ PCSTR Format,...)
 
SIZE_T KdbPrompt (_In_ PCSTR Prompt, _Out_ PCHAR Buffer, _In_ SIZE_T Size)
 

Variables

static KD_CONTEXT KdbgKdContext
 

Macro Definition Documentation

◆ pKdReceivePacket

#define pKdReceivePacket   KdReceivePacket

Definition at line 22 of file kdb_print.c.

◆ pKdSendPacket

#define pKdSendPacket   KdSendPacket

Definition at line 19 of file kdb_print.c.

Function Documentation

◆ KdbPrintf()

VOID __cdecl KdbPrintf ( _In_ PCSTR  Format,
  ... 
)

Definition at line 160 of file kdb_print.c.

163{
164 va_list ap;
166 CHAR Buffer[1024];
167
168 /* Format the string */
171 sizeof(Buffer),
172 Format,
173 ap);
174 Length = min(Length, MAXUSHORT - sizeof(ANSI_NULL));
175 va_end(ap);
176
177 /* Send it to the debugger directly */
179}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: bufpool.h:45
VOID KdbPutsN(_In_ PCCH String, _In_ USHORT Length)
Definition: kdb_print.c:140
#define min(a, b)
Definition: monoChain.cc:55
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned short USHORT
Definition: pedump.c:61
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define MAXUSHORT
Definition: typedefs.h:83
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define _vsnprintf
Definition: xmlstorage.h:202
char CHAR
Definition: xmlstorage.h:175

Referenced by KdbEnterDebuggerException(), KdbpDeleteBreakPoint(), KdbpDisableBreakPoint(), KdbpEnableBreakPoint(), KdbpInsertBreakPoint(), KdbpPagerInternal(), KdbpPrintAddressInCode(), KdbpShouldStepOverInstruction(), KdbSymPrintAddress(), KdReceivePacket(), and KdSendPacket().

◆ KdbPrintString()

VOID KdbPrintString ( _In_ const CSTRING Output)

Definition at line 64 of file kdb_print.c.

66{
67 DBGKD_DEBUG_IO DebugIo;
69
71 &DebugIo, &Header, &Data);
72}
Definition: Header.h:9
std::wstring STRING
Definition: fontsub.cpp:33
static VOID KdbPrintStringWorker(_In_ const CSTRING *Output, _In_ ULONG ApiNumber, _Inout_ PDBGKD_DEBUG_IO DebugIo, _Inout_ PSTRING Header, _Inout_ PSTRING Data)
Definition: kdb_print.c:25
@ Output
Definition: arc.h:85
#define DbgKdPrintStringApi
Definition: windbgkd.h:122

Referenced by KdbPutsN().

◆ KdbPrintStringWorker()

static VOID KdbPrintStringWorker ( _In_ const CSTRING Output,
_In_ ULONG  ApiNumber,
_Inout_ PDBGKD_DEBUG_IO  DebugIo,
_Inout_ PSTRING  Header,
_Inout_ PSTRING  Data 
)
static

Definition at line 25 of file kdb_print.c.

31{
33 C_ASSERT(PACKET_MAX_SIZE >= sizeof(*DebugIo));
34
35 ASSERT((ApiNumber == DbgKdPrintStringApi) ||
36 (ApiNumber == DbgKdGetStringApi));
37
38 /* Make sure we don't exceed the KD Packet size */
39 Length = min(Output->Length, PACKET_MAX_SIZE - sizeof(*DebugIo));
40
41 /* Build the packet header */
42 DebugIo->ApiNumber = ApiNumber;
43 DebugIo->ProcessorLevel = 0; // (USHORT)KeProcessorLevel;
44 DebugIo->Processor = KeGetCurrentPrcb()->Number;
45
46 if (ApiNumber == DbgKdPrintStringApi)
47 DebugIo->u.PrintString.LengthOfString = Length;
48 else // if (ApiNumber == DbgKdGetStringApi)
49 DebugIo->u.GetString.LengthOfPromptString = Length;
50
51 Header->Length = sizeof(*DebugIo);
52 Header->Buffer = (PCHAR)DebugIo;
53
54 /* Build the data */
55 Data->Length = Length;
56 Data->Buffer = (PCHAR)Output->Buffer;
57
58 /* Send the packet */
59 /* IO packet: call KdTerm */
61}
#define C_ASSERT(e)
Definition: intsafe.h:73
static KD_CONTEXT KdbgKdContext
Definition: kdb_print.c:16
#define pKdSendPacket
Definition: kdb_print.c:19
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1146
#define PACKET_MAX_SIZE
Definition: windbgkd.h:18
#define DbgKdGetStringApi
Definition: windbgkd.h:123
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44

Referenced by KdbPrintString(), and KdbPromptStringWorker().

◆ KdbPrompt()

SIZE_T KdbPrompt ( _In_ PCSTR  Prompt,
_Out_ PCHAR  Buffer,
_In_ SIZE_T  Size 
)

Definition at line 182 of file kdb_print.c.

186{
187 CSTRING PromptString;
188 STRING ResponseBuffer;
189
190 PromptString.Buffer = Prompt;
191 PromptString.Length = PromptString.MaximumLength =
192 (USHORT)strnlen(Prompt, MAXUSHORT - sizeof(ANSI_NULL));
193
194 ResponseBuffer.Buffer = Buffer;
195 ResponseBuffer.Length = 0;
196 ResponseBuffer.MaximumLength = (USHORT)min(Size, MAXUSHORT);
197
198 return KdbPromptString(&PromptString, &ResponseBuffer);
199}
USHORT KdbPromptString(_In_ const CSTRING *PromptString, _Inout_ PSTRING ResponseString)
Definition: kdb_print.c:125
USHORT MaximumLength
Definition: umtypes.h:158
CONST CHAR * Buffer
Definition: umtypes.h:159
USHORT Length
Definition: umtypes.h:157
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by KdbpCliMainLoop().

◆ KdbPromptString()

USHORT KdbPromptString ( _In_ const CSTRING PromptString,
_Inout_ PSTRING  ResponseString 
)

Definition at line 125 of file kdb_print.c.

128{
129 /* Enter prompt loop: send the prompt and receive the response */
130 ResponseString->Length = 0;
131 while (KdbPromptStringWorker(PromptString, ResponseString))
132 {
133 /* Loop while we need to resend */
134 }
135 return ResponseString->Length;
136}
static BOOLEAN KdbPromptStringWorker(_In_ const CSTRING *PromptString, _Inout_ PSTRING ResponseString)
Definition: kdb_print.c:75

Referenced by KdbPrompt().

◆ KdbPromptStringWorker()

static BOOLEAN KdbPromptStringWorker ( _In_ const CSTRING PromptString,
_Inout_ PSTRING  ResponseString 
)
static

Definition at line 75 of file kdb_print.c.

78{
79 DBGKD_DEBUG_IO DebugIo;
83
84 /* Print the prompt */
85 // DebugIo.u.GetString.LengthOfPromptString = Length;
86 DebugIo.u.GetString.LengthOfStringRead = ResponseString->MaximumLength;
88 &DebugIo, &Header, &Data);
89
90 /* Set the maximum lengths for the receive */
91 Header.MaximumLength = sizeof(DebugIo);
92 Data.MaximumLength = ResponseString->MaximumLength;
93 /* Build the data */
94 Data.Buffer = ResponseString->Buffer;
95
96 /* Enter receive loop */
97 do
98 {
99 /* Get our reply */
100 /* IO packet: call KdTerm */
102 &Header,
103 &Data,
104 &Length,
106
107 /* Return TRUE if we need to resend */
109 return TRUE;
110
111 /* Loop until we succeed */
112 } while (Status != KdPacketReceived);
113
114 /* Don't copy back a larger response than there is room for */
115 Length = min(Length, ResponseString->MaximumLength);
116
117 /* We've got the string back; return the length */
118 ResponseString->Length = (USHORT)Length;
119
120 /* Success; we don't need to resend */
121 return FALSE;
122}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
#define pKdReceivePacket
Definition: kdb_print.c:22
#define KdPacketReceived
Definition: kddll.h:5
#define KdPacketNeedsResend
Definition: kddll.h:7
ULONG KDSTATUS
Definition: kddll.h:4
DBGKD_GET_STRING GetString
Definition: windbgkd.h:427
union _DBGKD_DEBUG_IO::@3546 u
ULONG LengthOfStringRead
Definition: windbgkd.h:413
uint32_t ULONG
Definition: typedefs.h:59

Referenced by KdbPromptString().

◆ KdbPuts()

VOID KdbPuts ( _In_ PCSTR  String)

Definition at line 152 of file kdb_print.c.

154{
155 KdbPutsN(String, (USHORT)strnlen(String, MAXUSHORT - sizeof(ANSI_NULL)));
156}
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by KdbEnterDebuggerException(), KdbpDisableBreakPoint(), KdbpInsertBreakPoint(), KdbpPagerInternal(), and KdbpPrintDisasm().

◆ KdbPutsN()

VOID KdbPutsN ( _In_ PCCH  String,
_In_ USHORT  Length 
)

Definition at line 140 of file kdb_print.c.

143{
145
146 Output.Buffer = String;
147 Output.Length = Output.MaximumLength = Length;
149}
VOID KdbPrintString(_In_ const CSTRING *Output)
Definition: kdb_print.c:64

Referenced by KdbPrintf(), and KdbPuts().

Variable Documentation

◆ KdbgKdContext

KD_CONTEXT KdbgKdContext
static

Definition at line 16 of file kdb_print.c.

Referenced by KdbPrintStringWorker(), and KdbPromptStringWorker().