WIP kdbg work.

This commit is contained in:
Hermès Bélusca-Maïto 2019-12-26 13:53:50 +01:00
parent 22f883278b
commit 5e14dbd648
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 73 additions and 24 deletions

View file

@ -39,9 +39,8 @@ extern ANSI_STRING KdpLogFileName;
/* PRIVATE FUNCTIONS *********************************************************/
INIT_FUNCTION
static INIT_FUNCTION
PCHAR
NTAPI
KdpGetDebugMode(PCHAR Currentp2)
{
PCHAR p1, p2 = Currentp2;
@ -135,9 +134,8 @@ KdpGetDebugMode(PCHAR Currentp2)
return p2;
}
INIT_FUNCTION
static INIT_FUNCTION
VOID
NTAPI
KdpCallInitRoutine(ULONG BootPhase)
{
PLIST_ENTRY CurrentEntry;

View file

@ -423,10 +423,12 @@ KdpScreenAcquire(VOID)
InbvEnableDisplayString(TRUE);
InbvSetScrollRegion(0, 0, 639, 479);
}
else
{
DbgPrint("********* -----> Could NOT acquire SCREEN!! <----- *********\n");
}
}
// extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
VOID
KdpScreenRelease(VOID)
{
@ -434,7 +436,6 @@ KdpScreenRelease(VOID)
InbvCheckDisplayOwnership())
{
/* Release the display */
// InbvSetDisplayOwnership(FALSE);
InbvNotifyDisplayOwnershipLost(NULL);
}
}
@ -632,6 +633,14 @@ KdpPromptString(
USHORT i;
ULONG DummyScanCode;
/*************************/
/**/if (!(KdbDebugState & KD_DEBUG_KDSERIAL))/**/
KbdDisableMouse();
/* Take control of the display */
if (KdpDebugMode.Screen)
KdpScreenAcquire();
/*************************/
StringChar.Buffer = &Response;
StringChar.Length = StringChar.MaximumLength = sizeof(Response);
@ -648,8 +657,8 @@ KdpPromptString(
/* Acquire the printing spinlock without waiting at raised IRQL */
OldIrql = KdpAcquireLock(&KdpSerialSpinLock);
if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
KbdDisableMouse();
// if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
// KbdDisableMouse();
/* Loop the whole string */
for (i = 0; i < ResponseString->MaximumLength; i++)
@ -711,8 +720,8 @@ KdpPromptString(
/* Return the length */
ResponseString->Length = i;
if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
KbdEnableMouse();
// if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
// KbdEnableMouse();
/* Release the spinlock */
KdpReleaseLock(&KdpSerialSpinLock, OldIrql);
@ -721,6 +730,14 @@ KdpPromptString(
*StringChar.Buffer = '\n';
KdpPrintString(&StringChar);
/*************************/
/* Release the display */
if (KdpDebugMode.Screen)
KdpScreenRelease();
/**/if (!(KdbDebugState & KD_DEBUG_KDSERIAL))/**/
KbdEnableMouse();
/*************************/
/* Success; we don't need to resend */
return FALSE;
}

View file

@ -1216,11 +1216,11 @@ KdbpInternalEnter(VOID)
PVOID SavedInitialStack, SavedStackBase, SavedKernelStack;
ULONG SavedStackLimit;
KbdDisableMouse();
// KbdDisableMouse();
/* Take control of the display */
if (KdpDebugMode.Screen)
KdpScreenAcquire();
// /* Take control of the display */
// if (KdpDebugMode.Screen)
// KdpScreenAcquire();
/* Call the interface's main loop on a different stack */
Thread = PsGetCurrentThread();
@ -1241,11 +1241,11 @@ KdbpInternalEnter(VOID)
Thread->Tcb.StackLimit = SavedStackLimit;
Thread->Tcb.KernelStack = SavedKernelStack;
/* Release the display */
if (KdpDebugMode.Screen)
KdpScreenRelease();
// /* Release the display */
// if (KdpDebugMode.Screen)
// KdpScreenRelease();
KbdEnableMouse();
// KbdEnableMouse();
}
static ULONG
@ -1356,6 +1356,13 @@ KdbEnterDebuggerException(
EnterConditionMet = FALSE;
}
/*************************/
KbdDisableMouse();
/* Take control of the display */
if (KdpDebugMode.Screen)
KdpScreenAcquire();
/*************************/
/* If we stopped on one of our breakpoints then let the user know */
KdbLastBreakPointNr = -1;
KdbEnteredOnSingleStep = FALSE;
@ -1531,7 +1538,9 @@ KdbEnterDebuggerException(
{
if (!EnterConditionMet)
{
return kdHandleException;
// return kdHandleException;
ContinueType = kdHandleException;
goto cleanup_quit;
}
KdbpPrint("\nEntered debugger on unexpected debug trap!\n");
@ -1546,7 +1555,9 @@ KdbEnterDebuggerException(
}
if (!EnterConditionMet)
{
return kdHandleException;
// return kdHandleException;
ContinueType = kdHandleException;
goto cleanup_quit;
}
KdbpPrint("\nEntered debugger on embedded INT3 at 0x%04x:0x%08x.\n",
@ -1560,7 +1571,8 @@ KdbEnterDebuggerException(
if (!EnterConditionMet)
{
return ContinueType;
// return ContinueType;
goto cleanup_quit;
}
KdbpPrint("\nEntered debugger on %s-chance exception (Exception Code: 0x%x) (%s)\n",
@ -1616,7 +1628,9 @@ KdbEnterDebuggerException(
if (InterlockedIncrement(&KdbEntryCount) > 1)
{
__writeeflags(OldEflags);
return kdHandleException;
// return kdHandleException;
ContinueType = kdHandleException;
goto cleanup_quit;
}
/* Call the main loop */
@ -1669,6 +1683,14 @@ KdbEnterDebuggerException(
}
continue_execution:
/*************************/
/* Release the display */
if (KdpDebugMode.Screen)
KdpScreenRelease();
KbdEnableMouse();
/*************************/
/* Clear debug status */
if (ExceptionCode == STATUS_BREAKPOINT) /* FIXME: Why clear DR6 on INT3? */
{
@ -1688,6 +1710,17 @@ continue_execution:
}
}
return ContinueType;
cleanup_quit:
/*************************/
/* Release the display */
if (KdpDebugMode.Screen)
KdpScreenRelease();
KbdEnableMouse();
/*************************/
return ContinueType;
}
@ -1699,7 +1732,8 @@ KdbpGetCommandLineSettings(
{
#define CONST_STR_LEN(x) (sizeof(x)/sizeof(x[0]) - 1)
while (p1 && (p1 = strchr(p1, ' ')))
/* Loop through the switches */
for (; p1 && *p1; p1 = strchr(p1, ' '))
{
/* Skip other spaces */
while (*p1 == ' ') ++p1;