Work on thread-awareness in gdbstub

svn path=/trunk/; revision=8103
This commit is contained in:
Gé van Geldorp 2004-02-08 22:12:53 +00:00
parent 30ada1654d
commit d8e8ec2a96

View file

@ -699,6 +699,7 @@ GspSetThread(PCHAR Request)
if(GspRunThread) ObDereferenceObject(GspRunThread); if(GspRunThread) ObDereferenceObject(GspRunThread);
GspRunThread = ThreadInfo; GspRunThread = ThreadInfo;
if (GspRunThread) ObReferenceObject(GspRunThread);
} }
else else
{ {
@ -1057,6 +1058,7 @@ 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 */
@ -1079,6 +1081,20 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
} }
else else
{ {
/* Don't switch threads */
OldIrql = KeGetCurrentIrql();
if (OldIrql < DISPATCH_LEVEL)
{
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
}
/* Always use the current thread when entering the exception handler */
if (NULL != GspDbgThread)
{
ObDereferenceObject(GspDbgThread);
GspDbgThread = NULL;
}
/* reply to host that an exception has occurred */ /* reply to host that an exception has occurred */
SigVal = GspComputeSignal (ExceptionRecord->ExceptionCode); SigVal = GspComputeSignal (ExceptionRecord->ExceptionCode);
@ -1129,17 +1145,24 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
GspRemoteDebug = !GspRemoteDebug; /* toggle debug flag */ GspRemoteDebug = !GspRemoteDebug; /* toggle debug flag */
break; break;
case 'g': /* return the value of the CPU Registers */ case 'g': /* return the value of the CPU Registers */
if (GspDbgThread) if (NULL != GspDbgThread)
GspGetRegistersFromTrapFrame (&GspOutBuffer[0], Context, GspDbgThread->Tcb.TrapFrame); {
GspGetRegistersFromTrapFrame (&GspOutBuffer[0], Context, GspDbgThread->Tcb.TrapFrame);
}
else else
GspGetRegistersFromTrapFrame (&GspOutBuffer[0], Context, TrapFrame); {
GspGetRegistersFromTrapFrame (&GspOutBuffer[0], Context, TrapFrame);
}
break; break;
case 'G': /* set the value of the CPU Registers - return OK */ case 'G': /* set the value of the CPU Registers - return OK */
if (GspDbgThread) if (NULL != GspDbgThread)
/* GspSetRegistersInTrapFrame (ptr, Context, GspDbgThread->Tcb.TrapFrame);*/ {
GspSetRegistersInTrapFrame (ptr, Context, TrapFrame); GspSetRegistersInTrapFrame (ptr, Context, GspDbgThread->Tcb.TrapFrame);
}
else else
GspSetRegistersInTrapFrame (ptr, Context, TrapFrame); {
GspSetRegistersInTrapFrame (ptr, Context, TrapFrame);
}
strcpy (GspOutBuffer, "OK"); strcpy (GspOutBuffer, "OK");
break; break;
case 'P': /* set the value of a single CPU register - return OK */ case 'P': /* set the value of a single CPU register - return OK */
@ -1150,11 +1173,14 @@ GspSetRegistersInTrapFrame (ptr, Context, TrapFrame);
if ((Register >= 0) && (Register < NUMREGS)) if ((Register >= 0) && (Register < NUMREGS))
{ {
if (GspDbgThread) if (GspDbgThread)
/* GspSetSingleRegisterInTrapFrame (ptr, Register, {
Context, GspDbgThread->Tcb.TrapFrame);*/ GspSetSingleRegisterInTrapFrame(ptr, Register,
GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame); Context, GspDbgThread->Tcb.TrapFrame);
}
else else
GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame); {
GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
}
strcpy (GspOutBuffer, "OK"); strcpy (GspOutBuffer, "OK");
break; break;
} }
@ -1222,7 +1248,7 @@ GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
/* try to read optional parameter, pc unchanged if no parm */ /* try to read optional parameter, pc unchanged if no parm */
if (GspHex2Long (&ptr, &Address)) if (GspHex2Long (&ptr, &Address))
Context->Eip = Address; Context->Eip = Address;
NewPC = Context->Eip; NewPC = Context->Eip;
@ -1263,6 +1289,10 @@ GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
#else #else
#error Unknown compiler for inline assembler #error Unknown compiler for inline assembler
#endif #endif
if (OldIrql < DISPATCH_LEVEL)
{
KeLowerIrql(OldIrql);
}
return kdHandleException; return kdHandleException;
break; break;