Author: jgardou
Date: Sun Sep 14 14:27:58 2014
New Revision: 64145
URL:
http://svn.reactos.org/svn/reactos?rev=64145&view=rev
Log:
[KDGDB]
- Improve the 'm' (read memory) gdb request
Modified:
trunk/reactos/drivers/base/kdgdb/gdb_input.c
trunk/reactos/drivers/base/kdgdb/gdb_send.c
trunk/reactos/drivers/base/kdgdb/kdgdb.h
trunk/reactos/drivers/base/kdgdb/kdpacket.c
Modified: trunk/reactos/drivers/base/kdgdb/gdb_input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdgdb/gdb_inp…
==============================================================================
--- trunk/reactos/drivers/base/kdgdb/gdb_input.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kdgdb/gdb_input.c [iso-8859-1] Sun Sep 14 14:27:58 2014
@@ -276,6 +276,35 @@
#endif
static
+void
+ReadMemorySendHandler(
+ _In_ ULONG PacketType,
+ _In_ PSTRING MessageHeader,
+ _In_ PSTRING MessageData)
+{
+ DBGKD_MANIPULATE_STATE64* State =
(DBGKD_MANIPULATE_STATE64*)MessageHeader->Buffer;
+
+ if (PacketType != PACKET_TYPE_KD_STATE_MANIPULATE)
+ {
+ // KdAssert
+ KDDBGPRINT("Wrong packet type (%lu) received after DbgKdReadVirtualMemoryApi
request.\n", PacketType);
+ while (1);
+ }
+
+ if (State->ApiNumber != DbgKdReadVirtualMemoryApi)
+ {
+ KDDBGPRINT("Wrong API number (%lu) after DbgKdReadVirtualMemoryApi
request.\n", State->ApiNumber);
+ }
+
+ /* Check status */
+ if (!NT_SUCCESS(State->ReturnStatus))
+ send_gdb_ntstatus(State->ReturnStatus);
+ else
+ send_gdb_memory(MessageData->Buffer, MessageData->Length);
+ KdpSendPacketHandler = NULL;
+}
+
+static
KDSTATUS
handle_gdb_read_mem(
_Out_ DBGKD_MANIPULATE_STATE64* State,
@@ -292,6 +321,10 @@
State->u.ReadMemory.TargetBaseAddress = hex_to_address(&gdb_input[1]);
State->u.ReadMemory.TransferCount = hex_to_address(strstr(&gdb_input[1],
",") + 1);
+
+ /* KD will reply with KdSendPacket. Catch it */
+ KdpSendPacketHandler = ReadMemorySendHandler;
+
return KdPacketReceived;
}
Modified: trunk/reactos/drivers/base/kdgdb/gdb_send.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdgdb/gdb_sen…
==============================================================================
--- trunk/reactos/drivers/base/kdgdb/gdb_send.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kdgdb/gdb_send.c [iso-8859-1] Sun Sep 14 14:27:58 2014
@@ -185,3 +185,15 @@
ptr += sprintf(ptr, "core:%x;", CurrentStateChange.Processor);
send_gdb_packet(gdb_out);
}
+
+void
+send_gdb_ntstatus(
+ _In_ NTSTATUS Status)
+{
+ /* Just build a EXX packet and send it */
+ char gdb_out[4];
+ gdb_out[0] = 'E';
+ exception_code_to_gdb(Status, &gdb_out[1]);
+ gdb_out[3] = '\0';
+ send_gdb_packet(gdb_out);
+}
Modified: trunk/reactos/drivers/base/kdgdb/kdgdb.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdgdb/kdgdb.h…
==============================================================================
--- trunk/reactos/drivers/base/kdgdb/kdgdb.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kdgdb/kdgdb.h [iso-8859-1] Sun Sep 14 14:27:58 2014
@@ -52,6 +52,7 @@
void send_gdb_memory(_In_ VOID* Buffer, size_t Length);
void gdb_send_debug_io(_In_ PSTRING String);
void gdb_send_exception(void);
+void send_gdb_ntstatus(_In_ NTSTATUS Status);
/* kdcom.c */
KDSTATUS NTAPI KdpPollBreakIn(VOID);
Modified: trunk/reactos/drivers/base/kdgdb/kdpacket.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdgdb/kdpacke…
==============================================================================
--- trunk/reactos/drivers/base/kdgdb/kdpacket.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kdgdb/kdpacket.c [iso-8859-1] Sun Sep 14 14:27:58 2014
@@ -100,10 +100,6 @@
gdb_send_registers((CONTEXT*)MessageData->Buffer);
return;
#endif
- case DbgKdReadVirtualMemoryApi:
- /* Answer to 'm' GDB request */
- send_gdb_memory(MessageData->Buffer, State->u.ReadMemory.ActualBytesRead);
- break;
case DbgKdGetVersionApi:
{
LIST_ENTRY* DebuggerDataList;