Cary Xiao" <xiaowave@gmail.com>

- Add some code to complete breakpoint of gdbstub.
See issue #1817 for more details.

svn path=/trunk/; revision=38024
This commit is contained in:
Aleksey Bragin 2008-12-11 19:44:56 +00:00
parent dd0e4d213f
commit f611b44733

View file

@ -1011,6 +1011,7 @@ typedef struct _GSPSWBREAKPOINT
#define MAX_SW_BREAKPOINTS 64 #define MAX_SW_BREAKPOINTS 64
static unsigned GspSwBreakpointCount = 0; static unsigned GspSwBreakpointCount = 0;
static GSPSWBREAKPOINT GspSwBreakpoints[MAX_SW_BREAKPOINTS]; static GSPSWBREAKPOINT GspSwBreakpoints[MAX_SW_BREAKPOINTS];
static CHAR GspSwBreakpointsInstructions[MAX_SW_BREAKPOINTS];
static void static void
GspSetHwBreakpoint(ULONG Type, ULONG_PTR Address, ULONG Length) GspSetHwBreakpoint(ULONG Type, ULONG_PTR Address, ULONG Length)
@ -1096,9 +1097,23 @@ GspSetSwBreakpoint(ULONG_PTR Address)
} }
else else
{ {
unsigned Index;
for (Index = 0; Index < GspSwBreakpointCount; Index++)
{
if (GspSwBreakpoints[Index].Address == Address)
{
strcpy(GspOutBuffer, "E22");
return;
}
}
DPRINT("Stored at index %u\n", GspSwBreakpointCount); DPRINT("Stored at index %u\n", GspSwBreakpointCount);
GspSwBreakpoints[GspSwBreakpointCount].Address = Address; GspSwBreakpoints[GspSwBreakpointCount].Address = Address;
GspSwBreakpoints[GspSwBreakpointCount].Active = FALSE; GspSwBreakpoints[GspSwBreakpointCount].Active = FALSE;
GspSwBreakpointsInstructions[GspSwBreakpointCount] =
GspReadMemSafe((PCHAR )Address);
GspWriteMemSafe((PCHAR )Address, 0xCC);
GspSwBreakpointCount++; GspSwBreakpointCount++;
strcpy(GspOutBuffer, "OK"); strcpy(GspOutBuffer, "OK");
} }
@ -1116,12 +1131,19 @@ GspRemoveSwBreakpoint(ULONG_PTR Address)
{ {
DPRINT("Found match at index %u\n", Index); DPRINT("Found match at index %u\n", Index);
ASSERT(! GspSwBreakpoints[Index].Active); ASSERT(! GspSwBreakpoints[Index].Active);
GspWriteMemSafe((PCHAR )Address,
GspSwBreakpointsInstructions[Index]);
if (Index + 1 < GspSwBreakpointCount) if (Index + 1 < GspSwBreakpointCount)
{ {
memmove(GspSwBreakpoints + Index, memmove(GspSwBreakpoints + Index,
GspSwBreakpoints + (Index + 1), GspSwBreakpoints + (Index + 1),
(GspSwBreakpointCount - Index - 1) * (GspSwBreakpointCount - Index - 1) *
sizeof(GSPSWBREAKPOINT)); sizeof(GSPSWBREAKPOINT));
memmove(GspSwBreakpointsInstructions + Index,
GspSwBreakpointsInstructions + (Index + 1),
(GspSwBreakpointCount - Index - 1) * sizeof(CHAR));
} }
GspSwBreakpointCount--; GspSwBreakpointCount--;
strcpy(GspOutBuffer, "OK"); strcpy(GspOutBuffer, "OK");
@ -1360,6 +1382,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
*ptr = '\0'; *ptr = '\0';
GspPutPacket(&GspOutBuffer[0]); GspPutPacket(&GspOutBuffer[0]);
/* DPRINT("------- replied status: (%s) -------\n", GspOutBuffer); */
} }
else else
{ {
@ -1373,6 +1396,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
/* Zero the buffer now so we don't have to worry about the terminating zero character */ /* Zero the buffer now so we don't have to worry about the terminating zero character */
memset(GspOutBuffer, 0, sizeof(GspInBuffer)); memset(GspOutBuffer, 0, sizeof(GspInBuffer));
ptr = GspGetPacket(); ptr = GspGetPacket();
/* DPRINT("------- Get (%s) command -------\n", ptr); */
switch(*ptr++) switch(*ptr++)
{ {
@ -1643,6 +1667,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
/* reply to the request */ /* reply to the request */
GspPutPacket(GspOutBuffer); GspPutPacket(GspOutBuffer);
/* DPRINT("------- reply command (%s) -------\n", GspOutBuffer); */
} }
/* not reached */ /* not reached */