mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 00:50:23 +00:00
[KDGDB] Various fixes and improvements
This commit is contained in:
parent
0b5033e2ff
commit
de369ce26b
5 changed files with 53 additions and 23 deletions
|
@ -368,15 +368,16 @@ handle_gdb_query(void)
|
||||||
PLDR_DATA_TABLE_ENTRY TableEntry = CONTAINING_RECORD(CurrentEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
PLDR_DATA_TABLE_ENTRY TableEntry = CONTAINING_RECORD(CurrentEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
||||||
PVOID DllBase = (PVOID)((ULONG_PTR)TableEntry->DllBase + 0x1000);
|
PVOID DllBase = (PVOID)((ULONG_PTR)TableEntry->DllBase + 0x1000);
|
||||||
LONG mem_length;
|
LONG mem_length;
|
||||||
char* ptr;
|
USHORT i;
|
||||||
|
|
||||||
/* Convert names to lower case. Yes this _is_ ugly */
|
/* Convert names to lower case. Yes this _is_ ugly */
|
||||||
_snprintf(name_helper, 64, "%wZ", &TableEntry->BaseDllName);
|
for (i = 0; i < (TableEntry->BaseDllName.Length / sizeof(WCHAR)); i++)
|
||||||
for (ptr = name_helper; *ptr; ptr++)
|
|
||||||
{
|
{
|
||||||
if (*ptr >= 'A' && *ptr <= 'Z')
|
name_helper[i] = (char)TableEntry->BaseDllName.Buffer[i];
|
||||||
*ptr += 'a' - 'A';
|
if (name_helper[i] >= 'A' && name_helper[i] <= 'Z')
|
||||||
|
name_helper[i] += 'a' - 'A';
|
||||||
}
|
}
|
||||||
|
name_helper[i] = 0;
|
||||||
|
|
||||||
/* GDB doesn't load the file if you don't prefix it with a drive letter... */
|
/* GDB doesn't load the file if you don't prefix it with a drive letter... */
|
||||||
mem_length = _snprintf(str_helper, 256, "<library name=\"C:\\%s\"><segment address=\"0x%p\"/></library>", &name_helper, DllBase);
|
mem_length = _snprintf(str_helper, 256, "<library name=\"C:\\%s\"><segment address=\"0x%p\"/></library>", &name_helper, DllBase);
|
||||||
|
@ -404,7 +405,6 @@ handle_gdb_query(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
return finish_gdb_packet();
|
return finish_gdb_packet();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KDDBGPRINT("KDGDB: Unknown query: %s\n", gdb_input);
|
KDDBGPRINT("KDGDB: Unknown query: %s\n", gdb_input);
|
||||||
|
|
|
@ -30,24 +30,22 @@ KDSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext)
|
gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext)
|
||||||
{
|
{
|
||||||
UCHAR* ByteBuffer = (UCHAR*)gdb_input;
|
UCHAR* ByteBuffer;
|
||||||
UCHAR Byte;
|
UCHAR Byte;
|
||||||
KDSTATUS Status;
|
KDSTATUS Status;
|
||||||
CHAR CheckSum = 0, ReceivedCheckSum;
|
CHAR CheckSum, ReceivedCheckSum;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Status = KdpReceiveByte(&Byte);
|
Status = KdpReceiveByte(&Byte);
|
||||||
if (Status != KdPacketReceived)
|
if (Status != KdPacketReceived)
|
||||||
return Status;
|
return Status;
|
||||||
if (Byte == 0x03)
|
|
||||||
{
|
|
||||||
KDDBGPRINT("BREAK!");
|
|
||||||
KdContext->KdpControlCPending = TRUE;
|
|
||||||
return KdPacketNeedsResend;
|
|
||||||
}
|
|
||||||
} while (Byte != '$');
|
} while (Byte != '$');
|
||||||
|
|
||||||
|
get_packet:
|
||||||
|
CheckSum = 0;
|
||||||
|
ByteBuffer = (UCHAR*)gdb_input;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
/* Try to get a byte from the port */
|
/* Try to get a byte from the port */
|
||||||
|
@ -94,6 +92,20 @@ end:
|
||||||
return KdPacketNeedsResend;
|
return KdPacketNeedsResend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure there is nothing left in the pipe */
|
||||||
|
while (KdpPollByte(&Byte) == KdPacketReceived)
|
||||||
|
{
|
||||||
|
switch (Byte)
|
||||||
|
{
|
||||||
|
case '$':
|
||||||
|
KDDBGPRINT("Received new packet just after %s.\n", gdb_input);
|
||||||
|
goto get_packet;
|
||||||
|
case 0x03:
|
||||||
|
KdContext->KdpControlCPending = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Acknowledge */
|
/* Acknowledge */
|
||||||
KdpSendByte('+');
|
KdpSendByte('+');
|
||||||
|
|
||||||
|
|
|
@ -129,11 +129,9 @@ KdpPortInitialize(IN ULONG ComPortNumber,
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
KdComPortInUse = KdComPort.Address;
|
||||||
KdComPortInUse = KdComPort.Address;
|
return STATUS_SUCCESS;
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -300,7 +298,13 @@ KDSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpReceiveByte(_Out_ PUCHAR OutByte)
|
KdpReceiveByte(_Out_ PUCHAR OutByte)
|
||||||
{
|
{
|
||||||
USHORT CpStatus = CpGetByte(&KdComPort, OutByte, TRUE, FALSE);
|
USHORT CpStatus;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
CpStatus = CpGetByte(&KdComPort, OutByte, TRUE, FALSE);
|
||||||
|
} while (CpStatus == CP_GET_NODATA);
|
||||||
|
|
||||||
/* Get the byte */
|
/* Get the byte */
|
||||||
if (CpStatus == CP_GET_SUCCESS)
|
if (CpStatus == CP_GET_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,7 @@ extern const char hex_chars[];
|
||||||
KDSTATUS NTAPI KdpPollBreakIn(VOID);
|
KDSTATUS NTAPI KdpPollBreakIn(VOID);
|
||||||
VOID NTAPI KdpSendByte(_In_ UCHAR Byte);
|
VOID NTAPI KdpSendByte(_In_ UCHAR Byte);
|
||||||
KDSTATUS NTAPI KdpReceiveByte(_Out_ PUCHAR OutByte);
|
KDSTATUS NTAPI KdpReceiveByte(_Out_ PUCHAR OutByte);
|
||||||
|
KDSTATUS NTAPI KdpPollByte(OUT PUCHAR OutByte);
|
||||||
|
|
||||||
/* kdpacket.c */
|
/* kdpacket.c */
|
||||||
extern DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange;
|
extern DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange;
|
||||||
|
|
|
@ -360,15 +360,25 @@ KdReceivePacket(
|
||||||
_Out_ PULONG DataLength,
|
_Out_ PULONG DataLength,
|
||||||
_Inout_ PKD_CONTEXT KdContext)
|
_Inout_ PKD_CONTEXT KdContext)
|
||||||
{
|
{
|
||||||
KDDBGPRINT("KdReceivePacket.\n");
|
KDDBGPRINT("KdReceivePacket --> ");
|
||||||
|
|
||||||
if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
|
if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
|
||||||
{
|
{
|
||||||
|
static BOOLEAN firstTime = TRUE;
|
||||||
|
KDDBGPRINT("Polling break in.\n");
|
||||||
|
if (firstTime)
|
||||||
|
{
|
||||||
|
/* Force debug break on init */
|
||||||
|
firstTime = FALSE;
|
||||||
|
return KdPacketReceived;
|
||||||
|
}
|
||||||
|
|
||||||
return KdpPollBreakIn();
|
return KdpPollBreakIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
|
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
|
||||||
{
|
{
|
||||||
|
KDDBGPRINT("Debug prompt.\n");
|
||||||
/* HACK ! RtlAssert asks for (boipt), always say "o" --> break once. */
|
/* HACK ! RtlAssert asks for (boipt), always say "o" --> break once. */
|
||||||
MessageData->Length = 1;
|
MessageData->Length = 1;
|
||||||
MessageData->Buffer[0] = 'o';
|
MessageData->Buffer[0] = 'o';
|
||||||
|
@ -379,14 +389,17 @@ KdReceivePacket(
|
||||||
{
|
{
|
||||||
DBGKD_MANIPULATE_STATE64* State = (DBGKD_MANIPULATE_STATE64*)MessageHeader->Buffer;
|
DBGKD_MANIPULATE_STATE64* State = (DBGKD_MANIPULATE_STATE64*)MessageHeader->Buffer;
|
||||||
|
|
||||||
|
KDDBGPRINT("State manipulation: ");
|
||||||
|
|
||||||
/* Maybe we are in a send<->receive loop that GDB doesn't need to know about */
|
/* Maybe we are in a send<->receive loop that GDB doesn't need to know about */
|
||||||
if (KdpManipulateStateHandler != NULL)
|
if (KdpManipulateStateHandler != NULL)
|
||||||
{
|
{
|
||||||
KDDBGPRINT("KDGBD: We have a manipulate state handler.\n");
|
KDDBGPRINT("We have a manipulate state handler.\n");
|
||||||
return KdpManipulateStateHandler(State, MessageData, DataLength, KdContext);
|
return KdpManipulateStateHandler(State, MessageData, DataLength, KdContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Receive data from GDB and interpret it */
|
/* Receive data from GDB and interpret it */
|
||||||
|
KDDBGPRINT("Receiving data from GDB.\n");
|
||||||
return gdb_receive_and_interpret_packet(State, MessageData, DataLength, KdContext);
|
return gdb_receive_and_interpret_packet(State, MessageData, DataLength, KdContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue