- 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
//
#define DBGKD_FILL_MEMORY_VIRTUAL 0x01
#define DBGKD_FILL_MEMORY_PHYSICAL 0x002
#define DBGKD_FILL_MEMORY_PHYSICAL 0x02
//
// Physical Memory Caching Flags

View file

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

View file

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

View file

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

View file

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

View file

@ -61,6 +61,7 @@ KdpCommandString(IN ULONG Length,
IN PKEXCEPTION_FRAME ExceptionFrame)
{
/* FIXME */
KdpDprintf("KdpCommandString called\n");
while (TRUE);
}
@ -118,6 +119,7 @@ KdpPrompt(IN LPSTR InString,
IN PKEXCEPTION_FRAME ExceptionFrame)
{
/* FIXME */
KdpDprintf("KdpPrompt called\n");
while (TRUE);
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 */
if ((ExceptionCode == STATUS_BREAKPOINT) ||
(ExceptionCode == STATUS_SINGLE_STEP) ||
//(ExceptionCode == STATUS_ASSERTION_FAILURE) ||
(ExceptionCode == STATUS_ASSERTION_FAILURE) ||
(NtGlobalFlag & FLG_STOP_ON_EXCEPTION))
{
/* 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) == sizeof(LIST_ENTRY));
extern POOL_DESCRIPTOR NonPagedPoolDescriptor;
//
// END FIXFIX
//
@ -119,9 +121,15 @@ extern MMPTE HyperTemplatePte;
extern ULONG MmSizeOfNonPagedPoolInBytes;
extern ULONG MmMaximumNonPagedPoolInBytes;
extern PVOID MmNonPagedSystemStart;
extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart;
extern PVOID MmNonPagedPoolEnd;
extern ULONG MmSizeOfPagedPoolInBytes;
extern PVOID MmPagedPoolStart;
extern PVOID MmPagedPoolEnd;
extern PVOID MmSessionBase;
extern ULONG MmSessionSize;
extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
extern PMMPTE MiFirstReservedZeroingPte;
extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType];