Don't crash when debugger asks for invalid memory location

svn path=/trunk/; revision=14116
This commit is contained in:
Gé van Geldorp 2005-03-15 23:47:13 +00:00
parent 82c445e96b
commit fbfe053b9b

View file

@ -377,7 +377,9 @@ GspMem2Hex (PCHAR Address,
ch = *Address; ch = *Address;
GspAccessLocation = NULL; GspAccessLocation = NULL;
if (MayFault && GspMemoryError) if (MayFault && GspMemoryError)
return (Buffer); {
return (Buffer);
}
*Buffer++ = HexChars[(ch >> 4) & 0xf]; *Buffer++ = HexChars[(ch >> 4) & 0xf];
*Buffer++ = HexChars[ch & 0xf]; *Buffer++ = HexChars[ch & 0xf];
Address++; Address++;
@ -427,7 +429,7 @@ GspHex2Mem (PCHAR Buffer,
ch = (CHAR)(HexValue (*Buffer++) << 4); ch = (CHAR)(HexValue (*Buffer++) << 4);
ch = (CHAR)(ch + HexValue (*Buffer++)); ch = (CHAR)(ch + HexValue (*Buffer++));
GspAccessLocation = Address; GspAccessLocation = current;
*current = ch; *current = ch;
GspAccessLocation = NULL; GspAccessLocation = NULL;
current++; current++;
@ -436,7 +438,9 @@ GspHex2Mem (PCHAR Buffer,
{ {
MmSetPageProtect (NULL, page, oldprot); MmSetPageProtect (NULL, page, oldprot);
if (GspMemoryError) if (GspMemoryError)
return (Buffer); {
return (Buffer);
}
} }
} }
@ -1103,7 +1107,6 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
LONG NewPC; LONG NewPC;
PCHAR ptr; PCHAR ptr;
LONG Esp; LONG Esp;
KIRQL OldIrql;
/* FIXME: Stop on other CPUs too */ /* FIXME: Stop on other CPUs too */
/* Disable hardware debugging while we are inside the stub */ /* Disable hardware debugging while we are inside the stub */
@ -1122,16 +1125,11 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
{ {
GspAccessLocation = NULL; GspAccessLocation = NULL;
GspMemoryError = TRUE; GspMemoryError = TRUE;
Context->Eip += 2; TrapFrame->Eip += 2;
} }
else else
{ {
/* Don't switch threads */ /* Don't switch threads */
OldIrql = KeGetCurrentIrql();
if (OldIrql < DISPATCH_LEVEL)
{
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
}
/* Always use the current thread when entering the exception handler */ /* Always use the current thread when entering the exception handler */
if (NULL != GspDbgThread) if (NULL != GspDbgThread)
@ -1334,10 +1332,6 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
#else #else
#error Unknown compiler for inline assembler #error Unknown compiler for inline assembler
#endif #endif
if (OldIrql < DISPATCH_LEVEL)
{
KeLowerIrql(OldIrql);
}
KeContextToTrapFrame(Context, TrapFrame); KeContextToTrapFrame(Context, TrapFrame);
return ((SigVal == 5) ? (kdContinue) : (kdHandleException)); return ((SigVal == 5) ? (kdContinue) : (kdHandleException));
@ -1475,17 +1469,17 @@ KdGdbStubInit(ULONG Phase)
if (Phase == 0) if (Phase == 0)
{ {
DbgPrint("Module 'hal.dll' loaded at 0x%.08x.\n", LdrHalBase); GspInitialized = TRUE;
GspRunThread = PsGetCurrentThread();
GspInitialized = TRUE;
GspRunThread = PsGetCurrentThread();
ObReferenceObject(GspRunThread); ObReferenceObject(GspRunThread);
/* GspDbgThread = PsGetCurrentThread(); */ /* GspDbgThread = PsGetCurrentThread(); */
GspDbgThread = NULL; GspDbgThread = NULL;
GspEnumThread = NULL; GspEnumThread = NULL;
HalDisplayString("Waiting for GDB to attach\n");
DbgPrint("Module 'hal.dll' loaded at 0x%.08x.\n", LdrHalBase);
DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C); DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
} }
else if (Phase == 1) else if (Phase == 1)
@ -1543,8 +1537,6 @@ KdGdbDebugPrint(LPSTR Message)
GspOutBuffer[3 + Length] = '\0'; GspOutBuffer[3 + Length] = '\0';
GspPutPacketNoWait (&GspOutBuffer[0]); GspPutPacketNoWait (&GspOutBuffer[0]);
} }
#else
HalDisplayString(Message);
#endif #endif
} }