mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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);
|
||||
PVOID DllBase = (PVOID)((ULONG_PTR)TableEntry->DllBase + 0x1000);
|
||||
LONG mem_length;
|
||||
char* ptr;
|
||||
USHORT i;
|
||||
|
||||
/* Convert names to lower case. Yes this _is_ ugly */
|
||||
_snprintf(name_helper, 64, "%wZ", &TableEntry->BaseDllName);
|
||||
for (ptr = name_helper; *ptr; ptr++)
|
||||
for (i = 0; i < (TableEntry->BaseDllName.Length / sizeof(WCHAR)); i++)
|
||||
{
|
||||
if (*ptr >= 'A' && *ptr <= 'Z')
|
||||
*ptr += 'a' - 'A';
|
||||
name_helper[i] = (char)TableEntry->BaseDllName.Buffer[i];
|
||||
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... */
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
KDDBGPRINT("KDGDB: Unknown query: %s\n", gdb_input);
|
||||
|
|
|
@ -30,24 +30,22 @@ KDSTATUS
|
|||
NTAPI
|
||||
gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext)
|
||||
{
|
||||
UCHAR* ByteBuffer = (UCHAR*)gdb_input;
|
||||
UCHAR* ByteBuffer;
|
||||
UCHAR Byte;
|
||||
KDSTATUS Status;
|
||||
CHAR CheckSum = 0, ReceivedCheckSum;
|
||||
CHAR CheckSum, ReceivedCheckSum;
|
||||
|
||||
do
|
||||
{
|
||||
Status = KdpReceiveByte(&Byte);
|
||||
if (Status != KdPacketReceived)
|
||||
return Status;
|
||||
if (Byte == 0x03)
|
||||
{
|
||||
KDDBGPRINT("BREAK!");
|
||||
KdContext->KdpControlCPending = TRUE;
|
||||
return KdPacketNeedsResend;
|
||||
}
|
||||
} while (Byte != '$');
|
||||
|
||||
get_packet:
|
||||
CheckSum = 0;
|
||||
ByteBuffer = (UCHAR*)gdb_input;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
/* Try to get a byte from the port */
|
||||
|
@ -94,6 +92,20 @@ end:
|
|||
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 */
|
||||
KdpSendByte('+');
|
||||
|
||||
|
|
|
@ -129,11 +129,9 @@ KdpPortInitialize(IN ULONG ComPortNumber,
|
|||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
KdComPortInUse = KdComPort.Address;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
KdComPortInUse = KdComPort.Address;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -300,7 +298,13 @@ KDSTATUS
|
|||
NTAPI
|
||||
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 */
|
||||
if (CpStatus == CP_GET_SUCCESS)
|
||||
{
|
||||
|
|
|
@ -96,6 +96,7 @@ extern const char hex_chars[];
|
|||
KDSTATUS NTAPI KdpPollBreakIn(VOID);
|
||||
VOID NTAPI KdpSendByte(_In_ UCHAR Byte);
|
||||
KDSTATUS NTAPI KdpReceiveByte(_Out_ PUCHAR OutByte);
|
||||
KDSTATUS NTAPI KdpPollByte(OUT PUCHAR OutByte);
|
||||
|
||||
/* kdpacket.c */
|
||||
extern DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange;
|
||||
|
|
|
@ -360,15 +360,25 @@ KdReceivePacket(
|
|||
_Out_ PULONG DataLength,
|
||||
_Inout_ PKD_CONTEXT KdContext)
|
||||
{
|
||||
KDDBGPRINT("KdReceivePacket.\n");
|
||||
KDDBGPRINT("KdReceivePacket --> ");
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
|
||||
{
|
||||
KDDBGPRINT("Debug prompt.\n");
|
||||
/* HACK ! RtlAssert asks for (boipt), always say "o" --> break once. */
|
||||
MessageData->Length = 1;
|
||||
MessageData->Buffer[0] = 'o';
|
||||
|
@ -379,14 +389,17 @@ KdReceivePacket(
|
|||
{
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
|
||||
/* Receive data from GDB and interpret it */
|
||||
KDDBGPRINT("Receiving data from GDB.\n");
|
||||
return gdb_receive_and_interpret_packet(State, MessageData, DataLength, KdContext);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue