[KDGDB] Support "int 0x2c" for x86 & amd64 targets

This commit is contained in:
Jérôme Gardou 2021-06-30 00:29:27 +02:00
parent e278b59d3a
commit 6e0d8de013

View file

@ -914,7 +914,7 @@ handle_gdb_c(
ULONG_PTR ProgramCounter = KdpGetContextPc(&CurrentContext); ULONG_PTR ProgramCounter = KdpGetContextPc(&CurrentContext);
/* See if we should update the program counter */ /* See if we should update the program counter */
if (Exception && (Exception->ExceptionRecord.ExceptionCode == STATUS_BREAKPOINT) if ((Exception->ExceptionRecord.ExceptionCode == STATUS_BREAKPOINT)
&& ((*(KD_BREAKPOINT_TYPE*)ProgramCounter) == KD_BREAKPOINT_VALUE)) && ((*(KD_BREAKPOINT_TYPE*)ProgramCounter) == KD_BREAKPOINT_VALUE))
{ {
/* We must get past the breakpoint instruction */ /* We must get past the breakpoint instruction */
@ -924,34 +924,21 @@ handle_gdb_c(
KdpManipulateStateHandler = ContinueManipulateStateHandler; KdpManipulateStateHandler = ContinueManipulateStateHandler;
return KdPacketReceived; return KdPacketReceived;
} }
} #if defined(_M_IX86) || defined(_M_AMD64)
if ((Exception->ExceptionRecord.ExceptionCode == STATUS_ASSERTION_FAILURE)
return ContinueManipulateStateHandler(State, MessageData, MessageLength, KdContext); && ((*(KD_BREAKPOINT_TYPE*)ProgramCounter) == 0xCD)
} && (*((KD_BREAKPOINT_TYPE*)ProgramCounter + 1) == 0x2C))
static
KDSTATUS
handle_gdb_C(
_Out_ DBGKD_MANIPULATE_STATE64* State,
_Out_ PSTRING MessageData,
_Out_ PULONG MessageLength,
_Inout_ PKD_CONTEXT KdContext)
{ {
KDSTATUS Status; /* INT 2C (a.k.a. runtime check failure) */
KdpSetContextPc(&CurrentContext, ProgramCounter + 2);
/* Tell GDB everything is fine, we will handle it */ SetContextManipulateHandler(State, MessageData, MessageLength, KdContext);
Status = send_gdb_packet("OK"); KdpManipulateStateHandler = ContinueManipulateStateHandler;
if (Status != KdPacketReceived)
return Status;
if (CurrentStateChange.NewState == DbgKdExceptionStateChange)
{
/* Debugger didn't handle the exception, report it back to the kernel */
State->u.Continue2.ContinueStatus = CurrentStateChange.u.Exception.ExceptionRecord.ExceptionCode;
State->ApiNumber = DbgKdContinueApi2;
return KdPacketReceived; return KdPacketReceived;
} }
/* We should never reach this ? */ #endif
}
return ContinueManipulateStateHandler(State, MessageData, MessageLength, KdContext); return ContinueManipulateStateHandler(State, MessageData, MessageLength, KdContext);
} }
@ -1033,10 +1020,8 @@ gdb_receive_and_interpret_packet(
Status = LOOP_IF_SUCCESS(send_gdb_packet("OK")); Status = LOOP_IF_SUCCESS(send_gdb_packet("OK"));
break; break;
case 'c': case 'c':
Status = handle_gdb_c(State, MessageData, MessageLength, KdContext);
break;
case 'C': case 'C':
Status = handle_gdb_C(State, MessageData, MessageLength, KdContext); Status = handle_gdb_c(State, MessageData, MessageLength, KdContext);
break; break;
case 'g': case 'g':
Status = LOOP_IF_SUCCESS(gdb_send_registers()); Status = LOOP_IF_SUCCESS(gdb_send_registers());