Author: fireball Date: Thu Dec 11 13:44:56 2008 New Revision: 38024
URL: http://svn.reactos.org/svn/reactos?rev=38024&view=rev Log: Cary Xiao" xiaowave@gmail.com - Add some code to complete breakpoint of gdbstub. See issue #1817 for more details.
Modified: trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c
Modified: trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/wrappers/gdbstu... ============================================================================== --- trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/wrappers/gdbstub.c [iso-8859-1] Thu Dec 11 13:44:56 2008 @@ -1011,6 +1011,7 @@ #define MAX_SW_BREAKPOINTS 64 static unsigned GspSwBreakpointCount = 0; static GSPSWBREAKPOINT GspSwBreakpoints[MAX_SW_BREAKPOINTS]; +static CHAR GspSwBreakpointsInstructions[MAX_SW_BREAKPOINTS];
static void GspSetHwBreakpoint(ULONG Type, ULONG_PTR Address, ULONG Length) @@ -1096,9 +1097,23 @@ } 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); GspSwBreakpoints[GspSwBreakpointCount].Address = Address; GspSwBreakpoints[GspSwBreakpointCount].Active = FALSE; + GspSwBreakpointsInstructions[GspSwBreakpointCount] = + GspReadMemSafe((PCHAR )Address); + GspWriteMemSafe((PCHAR )Address, 0xCC); GspSwBreakpointCount++; strcpy(GspOutBuffer, "OK"); } @@ -1116,12 +1131,19 @@ { DPRINT("Found match at index %u\n", Index); ASSERT(! GspSwBreakpoints[Index].Active); + + GspWriteMemSafe((PCHAR )Address, + GspSwBreakpointsInstructions[Index]); + if (Index + 1 < GspSwBreakpointCount) { memmove(GspSwBreakpoints + Index, GspSwBreakpoints + (Index + 1), (GspSwBreakpointCount - Index - 1) * sizeof(GSPSWBREAKPOINT)); + memmove(GspSwBreakpointsInstructions + Index, + GspSwBreakpointsInstructions + (Index + 1), + (GspSwBreakpointCount - Index - 1) * sizeof(CHAR)); } GspSwBreakpointCount--; strcpy(GspOutBuffer, "OK"); @@ -1360,6 +1382,7 @@ *ptr = '\0';
GspPutPacket(&GspOutBuffer[0]); + /* DPRINT("------- replied status: (%s) -------\n", GspOutBuffer); */ } else { @@ -1373,6 +1396,7 @@ /* Zero the buffer now so we don't have to worry about the terminating zero character */ memset(GspOutBuffer, 0, sizeof(GspInBuffer)); ptr = GspGetPacket(); + /* DPRINT("------- Get (%s) command -------\n", ptr); */
switch(*ptr++) { @@ -1643,6 +1667,7 @@
/* reply to the request */ GspPutPacket(GspOutBuffer); + /* DPRINT("------- reply command (%s) -------\n", GspOutBuffer); */ }
/* not reached */