- Add STATUS_ASSERTION_FAILURE status code required for NT_ASSERT.

- Check KdReceivePacket return for KdPacketReceived instead of 0 for correctness.
- Use KdpDprintf instead of setting CR2 for unhandled cases.
- Add more variables to KdDebuggerDataBlock.

svn path=/trunk/; revision=43291
This commit is contained in:
Stefan Ginsberg 2009-10-04 20:19:43 +00:00
parent 8d668541e1
commit 1c3808ef76
8 changed files with 74 additions and 56 deletions

View file

@ -178,7 +178,7 @@
// Fill Memory Flags // Fill Memory Flags
// //
#define DBGKD_FILL_MEMORY_VIRTUAL 0x01 #define DBGKD_FILL_MEMORY_VIRTUAL 0x01
#define DBGKD_FILL_MEMORY_PHYSICAL 0x002 #define DBGKD_FILL_MEMORY_PHYSICAL 0x02
// //
// Physical Memory Caching Flags // Physical Memory Caching Flags

View file

@ -14,13 +14,14 @@ extern ULONG MmTotalPagedPoolQuota;
extern ULONG MmTotalNonPagedPoolQuota; extern ULONG MmTotalNonPagedPoolQuota;
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
extern ULONG MmNumberOfPhysicalPages; extern ULONG MmNumberOfPhysicalPages;
extern ULONG MmLowestPhysicalPage;
extern ULONG MmHighestPhysicalPage;
extern PVOID MmPagedPoolBase; extern PVOID MmPagedPoolBase;
extern ULONG MmPagedPoolSize; extern ULONG MmPagedPoolSize;
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor; extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg; extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
extern ULONG MmHighestPhysicalPage;
struct _KTRAP_FRAME; struct _KTRAP_FRAME;
struct _EPROCESS; struct _EPROCESS;

View file

@ -282,7 +282,8 @@ KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
#if 0 #if 0
if (!MmIsAddressValid((PVOID)(ULONG_PTR)State->u.ReadMemory.TargetBaseAddress)) if (!MmIsAddressValid((PVOID)(ULONG_PTR)State->u.ReadMemory.TargetBaseAddress))
{ {
Ke386SetCr2(State->u.ReadMemory.TargetBaseAddress); KdpDprintf("Tried to read invalid address %p\n",
(PVOID)(ULONG_PTR)State->u.ReadMemory.TargetBaseAddress);
while (TRUE); while (TRUE);
} }
#endif #endif
@ -484,6 +485,7 @@ KdpGetContext(IN PDBGKD_MANIPULATE_STATE64 State,
else else
{ {
/* SMP not yet handled */ /* SMP not yet handled */
KdpDprintf("SMP UNHANDLED\n");
ControlStart = NULL; ControlStart = NULL;
while (TRUE); while (TRUE);
} }
@ -534,6 +536,7 @@ KdpSetContext(IN PDBGKD_MANIPULATE_STATE64 State,
else else
{ {
/* SMP not yet handled */ /* SMP not yet handled */
KdpDprintf("SMP UNHANDLED\n");
ControlStart = NULL; ControlStart = NULL;
while (TRUE); while (TRUE);
} }
@ -620,7 +623,7 @@ SendPacket:
case DbgKdWriteVirtualMemoryApi: case DbgKdWriteVirtualMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWriteVirtualMemoryApi); KdpDprintf("DbgKdWriteVirtualMemoryApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -668,14 +671,14 @@ SendPacket:
case DbgKdReadIoSpaceApi: case DbgKdReadIoSpaceApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdReadIoSpaceApi); KdpDprintf("DbgKdReadIoSpaceApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdWriteIoSpaceApi: case DbgKdWriteIoSpaceApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWriteIoSpaceApi); KdpDprintf("DbgKdWriteIoSpaceApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -704,64 +707,65 @@ SendPacket:
case DbgKdReadPhysicalMemoryApi: case DbgKdReadPhysicalMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
goto fail; KdpDprintf("DbgKdReadPhysicalMemoryApi called for address %I64X\n",
Ke386SetCr2(DbgKdReadPhysicalMemoryApi); ManipulateState.u.ReadMemory.TargetBaseAddress);
goto Hack;
while (TRUE); while (TRUE);
break; break;
case DbgKdWritePhysicalMemoryApi: case DbgKdWritePhysicalMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWritePhysicalMemoryApi); KdpDprintf("DbgKdWritePhysicalMemoryApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdQuerySpecialCallsApi: case DbgKdQuerySpecialCallsApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdQuerySpecialCallsApi); KdpDprintf("DbgKdQuerySpecialCallsApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdSetSpecialCallApi: case DbgKdSetSpecialCallApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSetSpecialCallApi); KdpDprintf("DbgKdSetSpecialCallApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdClearSpecialCallsApi: case DbgKdClearSpecialCallsApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdClearSpecialCallsApi); KdpDprintf("DbgKdClearSpecialCallsApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdSetInternalBreakPointApi: case DbgKdSetInternalBreakPointApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSetInternalBreakPointApi); KdpDprintf("DbgKdSetInternalBreakPointApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdGetInternalBreakPointApi: case DbgKdGetInternalBreakPointApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdGetInternalBreakPointApi); KdpDprintf("DbgKdGetInternalBreakPointApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdReadIoSpaceExtendedApi: case DbgKdReadIoSpaceExtendedApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdReadIoSpaceExtendedApi); KdpDprintf("DbgKdReadIoSpaceExtendedApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdWriteIoSpaceExtendedApi: case DbgKdWriteIoSpaceExtendedApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWriteIoSpaceExtendedApi); KdpDprintf("DbgKdWriteIoSpaceExtendedApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -774,14 +778,14 @@ SendPacket:
case DbgKdWriteBreakPointExApi: case DbgKdWriteBreakPointExApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWriteBreakPointExApi); KdpDprintf("DbgKdWriteBreakPointExApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdRestoreBreakPointExApi: case DbgKdRestoreBreakPointExApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdRestoreBreakPointExApi); KdpDprintf("DbgKdRestoreBreakPointExApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -794,70 +798,70 @@ SendPacket:
case DbgKdSwitchProcessor: case DbgKdSwitchProcessor:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSwitchProcessor); KdpDprintf("DbgKdSwitchProcessor called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdPageInApi: case DbgKdPageInApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdPageInApi); KdpDprintf("DbgKdPageInApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdReadMachineSpecificRegister: case DbgKdReadMachineSpecificRegister:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdReadMachineSpecificRegister); KdpDprintf("DbgKdReadMachineSpecificRegister called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdWriteMachineSpecificRegister: case DbgKdWriteMachineSpecificRegister:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdWriteMachineSpecificRegister); KdpDprintf("DbgKdWriteMachineSpecificRegister called\n");
while (TRUE); while (TRUE);
break; break;
case OldVlm1: case OldVlm1:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(OldVlm1); KdpDprintf("OldVlm1 called\n");
while (TRUE); while (TRUE);
break; break;
case OldVlm2: case OldVlm2:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(OldVlm2); KdpDprintf("OldVlm2 called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdSearchMemoryApi: case DbgKdSearchMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSearchMemoryApi); KdpDprintf("DbgKdSearchMemoryApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdGetBusDataApi: case DbgKdGetBusDataApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdGetBusDataApi); KdpDprintf("DbgKdGetBusDataApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdSetBusDataApi: case DbgKdSetBusDataApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSetBusDataApi); KdpDprintf("DbgKdSetBusDataApi called\n");
while (TRUE); while (TRUE);
break; break;
case DbgKdCheckLowMemoryApi: case DbgKdCheckLowMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdCheckLowMemoryApi); KdpDprintf("DbgKdCheckLowMemoryApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -870,7 +874,7 @@ SendPacket:
case DbgKdFillMemoryApi: case DbgKdFillMemoryApi:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdFillMemoryApi); KdpDprintf("DbgKdFillMemoryApi called\n");
while (TRUE); while (TRUE);
break; break;
@ -883,7 +887,7 @@ SendPacket:
case DbgKdSwitchPartition: case DbgKdSwitchPartition:
/* FIXME: TODO */ /* FIXME: TODO */
Ke386SetCr2(DbgKdSwitchPartition); KdpDprintf("DbgKdSwitchPartition called\n");
while (TRUE); while (TRUE);
break; break;
@ -891,8 +895,9 @@ SendPacket:
default: default:
/* Setup an empty message, with failure */ /* Setup an empty message, with failure */
KdpDprintf("Received unknown API Number %lx\n", ManipulateState.ApiNumber);
while (TRUE); while (TRUE);
fail: Hack:
Data.Length = 0; Data.Length = 0;
ManipulateState.ReturnStatus = STATUS_UNSUCCESSFUL; ManipulateState.ReturnStatus = STATUS_UNSUCCESSFUL;
@ -1247,6 +1252,7 @@ NTAPI
KdEnableDebugger(VOID) KdEnableDebugger(VOID)
{ {
/* Use the internal routine */ /* Use the internal routine */
KdpDprintf("KdEnableDebugger called\n");
while (TRUE); while (TRUE);
return KdEnableDebuggerWithLock(TRUE); return KdEnableDebuggerWithLock(TRUE);
} }

View file

@ -9,6 +9,7 @@
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#include "../mm/arm3/miarm.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -51,7 +52,7 @@ BREAKPOINT_ENTRY KdpBreakpointTable[20];
#if defined(_M_IX86) || defined(_M_AMD64) #if defined(_M_IX86) || defined(_M_AMD64)
ULONG KdpBreakpointInstruction = 0xCC; // INT3 ULONG KdpBreakpointInstruction = 0xCC; // INT3
#else #else
#error TODO #error Define the breakpoint instruction for this architecture
#endif #endif
BOOLEAN KdpOweBreakpoint; BOOLEAN KdpOweBreakpoint;
BOOLEAN BreakpointsSuspended; BOOLEAN BreakpointsSuspended;
@ -367,23 +368,23 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
{0}, // MmSystemCacheStart {0}, // MmSystemCacheStart
{0}, // MmSystemCacheEnd {0}, // MmSystemCacheEnd
{0}, // MmSystemCacheWs {0}, // MmSystemCacheWs
{0}, // MmPfnDatabase {PtrToUlong(&MmPfnDatabase)},
{0}, // MmSystemPtesStart {PtrToUlong(MmSystemPtesStart)},
{0}, // MmSystemPtesEnd {PtrToUlong(MmSystemPtesEnd)},
{0}, // MmSubsectionBase {0}, // MmSubsectionBase
{0}, // MmNumberOfPagingFiles {0}, // MmNumberOfPagingFiles
{0}, // MmLowestPhysicalPage {PtrToUlong(&MmLowestPhysicalPage)},
{0}, // MmHighestPhysicalPage {PtrToUlong(&MmHighestPhysicalPage)},
{0}, // MmNumberOfPhysicalPages {PtrToUlong(&MmNumberOfPhysicalPages)},
{0}, // MmMaximumNonPagedPoolInBytes {PtrToUlong(&MmMaximumNonPagedPoolInBytes)},
{0}, // MmNonPagedSystemStart {PtrToUlong(&MmNonPagedSystemStart)},
{0}, // MmNonPagedPoolStart {PtrToUlong(&MmNonPagedPoolStart)},
{0}, // MmNonPagedPoolEnd {PtrToUlong(&MmNonPagedPoolEnd)},
{0}, // MmPagedPoolStart {PtrToUlong(&MmPagedPoolStart)},
{0}, // MmPagedPoolEnd {PtrToUlong(&MmPagedPoolEnd)},
{0}, // MmPagedPoolInfo {PtrToUlong(&MmPagedPoolInfo)},
PAGE_SIZE, PAGE_SIZE,
{0}, // MmSizeOfPagedPoolInBytes {PtrToUlong(&MmSizeOfPagedPoolInBytes)},
{0}, // MmTotalCommitLimit {0}, // MmTotalCommitLimit
{0}, // MmTotalCommittedPages {0}, // MmTotalCommittedPages
{0}, // MmSharedCommit {0}, // MmSharedCommit
@ -399,7 +400,7 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
{0}, // MmAvailablePages {0}, // MmAvailablePages
{0}, // MmResidentAvailablePages {0}, // MmResidentAvailablePages
{0}, // PoolTrackTable {0}, // PoolTrackTable
{0}, // NonPagedPoolDescriptor {PtrToUlong(&NonPagedPoolDescriptor)},
{PtrToUlong(&MmHighestUserAddress)}, {PtrToUlong(&MmHighestUserAddress)},
{PtrToUlong(&MmSystemRangeStart)}, {PtrToUlong(&MmSystemRangeStart)},
{PtrToUlong(&MmUserProbeAddress)}, {PtrToUlong(&MmUserProbeAddress)},
@ -421,9 +422,9 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
{0}, // MmPeakCommitment {0}, // MmPeakCommitment
{0}, // MmtotalCommitLimitMaximum {0}, // MmtotalCommitLimitMaximum
{PtrToUlong(&CmNtCSDVersion)}, {PtrToUlong(&CmNtCSDVersion)},
{0}, // MmPhysicalMemoryBlock {PtrToUlong(&MmPhysicalMemoryBlock)},
{0}, // MmSessionBase {PtrToUlong(&MmSessionBase)},
{0}, // MmSessionSize {PtrToUlong(&MmSessionSize)},
{0}, {0},
{0}, {0},
FIELD_OFFSET(KTHREAD, NextProcessor), FIELD_OFFSET(KTHREAD, NextProcessor),
@ -471,6 +472,6 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
KGDT_TSS, KGDT_TSS,
0, 0,
0, 0,
{0}, // IopNumTriagDumpDataBlocks {0}, // IopNumTriageDumpDataBlocks
{0}, // IopTriageDumpDataBlocks {0}, // IopTriageDumpDataBlocks
}; };

View file

@ -49,11 +49,11 @@ KdpPollBreakInWithPortLock(VOID)
else else
{ {
/* Now get a packet */ /* Now get a packet */
if (!KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN, if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL)) NULL) == KdPacketReceived)
{ {
/* Successful breakin */ /* Successful breakin */
DoBreak = TRUE; DoBreak = TRUE;
@ -96,11 +96,11 @@ KdPollBreakIn(VOID)
if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock)) if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock))
{ {
/* Now get a packet */ /* Now get a packet */
if (!KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN, if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL)) NULL) == KdPacketReceived)
{ {
/* Successful breakin */ /* Successful breakin */
DoBreak = TRUE; DoBreak = TRUE;

View file

@ -61,6 +61,7 @@ KdpCommandString(IN ULONG Length,
IN PKEXCEPTION_FRAME ExceptionFrame) IN PKEXCEPTION_FRAME ExceptionFrame)
{ {
/* FIXME */ /* FIXME */
KdpDprintf("KdpCommandString called\n");
while (TRUE); while (TRUE);
} }
@ -118,6 +119,7 @@ KdpPrompt(IN LPSTR InString,
IN PKEXCEPTION_FRAME ExceptionFrame) IN PKEXCEPTION_FRAME ExceptionFrame)
{ {
/* FIXME */ /* FIXME */
KdpDprintf("KdpPrompt called\n");
while (TRUE); while (TRUE);
return FALSE; return FALSE;
} }

View file

@ -30,7 +30,7 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
/* Check if this is INT1 or 3, or if we're forced to handle it */ /* Check if this is INT1 or 3, or if we're forced to handle it */
if ((ExceptionCode == STATUS_BREAKPOINT) || if ((ExceptionCode == STATUS_BREAKPOINT) ||
(ExceptionCode == STATUS_SINGLE_STEP) || (ExceptionCode == STATUS_SINGLE_STEP) ||
//(ExceptionCode == STATUS_ASSERTION_FAILURE) || (ExceptionCode == STATUS_ASSERTION_FAILURE) ||
(NtGlobalFlag & FLG_STOP_ON_EXCEPTION)) (NtGlobalFlag & FLG_STOP_ON_EXCEPTION))
{ {
/* Check if we can't really handle this */ /* Check if we can't really handle this */

View file

@ -83,6 +83,8 @@ typedef struct _POOL_HEADER
C_ASSERT(sizeof(POOL_HEADER) == 8); C_ASSERT(sizeof(POOL_HEADER) == 8);
C_ASSERT(sizeof(POOL_HEADER) == sizeof(LIST_ENTRY)); C_ASSERT(sizeof(POOL_HEADER) == sizeof(LIST_ENTRY));
extern POOL_DESCRIPTOR NonPagedPoolDescriptor;
// //
// END FIXFIX // END FIXFIX
// //
@ -119,9 +121,15 @@ extern MMPTE HyperTemplatePte;
extern ULONG MmSizeOfNonPagedPoolInBytes; extern ULONG MmSizeOfNonPagedPoolInBytes;
extern ULONG MmMaximumNonPagedPoolInBytes; extern ULONG MmMaximumNonPagedPoolInBytes;
extern PVOID MmNonPagedSystemStart;
extern PVOID MmNonPagedPoolStart; extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart; extern PVOID MmNonPagedPoolExpansionStart;
extern PVOID MmNonPagedPoolEnd; extern PVOID MmNonPagedPoolEnd;
extern ULONG MmSizeOfPagedPoolInBytes;
extern PVOID MmPagedPoolStart;
extern PVOID MmPagedPoolEnd;
extern PVOID MmSessionBase;
extern ULONG MmSessionSize;
extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte; extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
extern PMMPTE MiFirstReservedZeroingPte; extern PMMPTE MiFirstReservedZeroingPte;
extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]; extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType];