Make winkd somewhat portable.
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 10 Dec 2008 01:25:09 +0000 (01:25 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 10 Dec 2008 01:25:09 +0000 (01:25 +0000)
svn path=/branches/ros-amd64-bringup/; revision=37989

reactos/ntoskrnl/include/internal/kd64.h
reactos/ntoskrnl/kd64/amd64/kd-amd64.c [new file with mode: 0644]
reactos/ntoskrnl/kd64/i386/kd-i386.c [new file with mode: 0644]
reactos/ntoskrnl/kd64/kdapi.c
reactos/ntoskrnl/kd64/kddata.c
reactos/ntoskrnl/kd64/kdinit.c
reactos/ntoskrnl/kd64/kdlock.c
reactos/ntoskrnl/kd64/kdtrap.c
reactos/ntoskrnl/ntoskrnl-generic.rbuild

index b129260..3967c23 100644 (file)
@@ -244,6 +244,20 @@ KdpAddBreakpoint(
     IN PVOID Address\r
 );\r
 \r
+VOID\r
+NTAPI\r
+KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,\r
+                   IN PCONTEXT Context);\r
+\r
+BOOLEAN\r
+NTAPI\r
+KdpReport(IN PKTRAP_FRAME TrapFrame,\r
+          IN PKEXCEPTION_FRAME ExceptionFrame,\r
+          IN PEXCEPTION_RECORD ExceptionRecord,\r
+          IN PCONTEXT ContextRecord,\r
+          IN KPROCESSOR_MODE PreviousMode,\r
+          IN BOOLEAN SecondChanceException);\r
+\r
 //\r
 // Global KD Data\r
 //\r
diff --git a/reactos/ntoskrnl/kd64/amd64/kd-amd64.c b/reactos/ntoskrnl/kd64/amd64/kd-amd64.c
new file mode 100644 (file)
index 0000000..0f7e746
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * PROJECT:         ReactOS Kernel
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            ntoskrnl/kd64/i386/kdapi-i386.c
+ * PURPOSE:         KD64 i386 Support
+ * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* PRIVATE FUNCTIONS *********************************************************/
+
+VOID
+NTAPI
+KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
+                   IN PCONTEXT Context)
+{
+    PKPRCB Prcb = KeGetCurrentPrcb();
+
+    /* Copy i386 specific debug registers */
+    WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.
+                                         KernelDr6;
+    WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.
+                                         KernelDr7;
+
+    /* Copy i386 specific segments */
+    WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;
+    WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;
+    WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;
+    WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;
+
+    /* Copy EFlags */
+    WaitStateChange->ControlReport.EFlags = Context->EFlags;
+
+    /* Set Report Flags */
+    WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;
+    if (WaitStateChange->ControlReport.SegCs == KGDT_64_R0_CODE)
+    {
+        WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_CS;
+    }
+}
+
+BOOLEAN
+NTAPI
+KdpTrap(IN PKTRAP_FRAME TrapFrame,
+        IN PKEXCEPTION_FRAME ExceptionFrame,
+        IN PEXCEPTION_RECORD ExceptionRecord,
+        IN PCONTEXT ContextRecord,
+        IN KPROCESSOR_MODE PreviousMode,
+        IN BOOLEAN SecondChanceException)
+{
+    BOOLEAN Unload = FALSE;
+    ULONG64 Rip, Rax;
+    BOOLEAN Status = FALSE;
+
+    /*
+     * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
+     * Load/Unload symbols.
+     */
+    if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
+        (ExceptionRecord->ExceptionInformation[0] != BREAKPOINT_BREAK))
+    {
+        /* Save EIP */
+        Rip = ContextRecord->Rip;
+
+        /* Check what kind of operation was requested from us */
+        switch (ExceptionRecord->ExceptionInformation[0])
+        {
+            /* DbgPrint */
+            case BREAKPOINT_PRINT:
+
+                /* Call the worker routine */
+                Rax = KdpPrint(ContextRecord->R8, // ComponentId
+                               ContextRecord->R9, // ComponentMask
+                               (LPSTR)ExceptionRecord->ExceptionInformation[1], // String
+                               (ULONG)ExceptionRecord->ExceptionInformation[2], // Length
+                               PreviousMode,
+                               TrapFrame,
+                               ExceptionFrame,
+                               &Status);
+
+                /* Update the return value for the caller */
+                ContextRecord->Rax = Rax;
+                break;
+
+            /* DbgPrompt */
+            case BREAKPOINT_PROMPT:
+
+                /* Call the worker routine */
+                while (TRUE);
+                Rax = 0;
+                Status = TRUE;
+
+                /* Update the return value for the caller */
+                ContextRecord->Rax = Rax;
+                break;
+
+            /* DbgUnloadSymbols */
+            case BREAKPOINT_UNLOAD_SYMBOLS:
+
+                /* Drop into the load case below, with the unload parameter */
+                Unload = TRUE;
+
+            /* DbgLoadSymbols */
+            case BREAKPOINT_LOAD_SYMBOLS:
+
+                /* Call the worker routine */
+                KdpSymbol((PVOID)ExceptionRecord->ExceptionInformation[1],
+                          (PVOID)ExceptionRecord->ExceptionInformation[2],
+                          Unload,
+                          PreviousMode,
+                          ContextRecord,
+                          TrapFrame,
+                          ExceptionFrame);
+                Status = TRUE;
+                break;
+
+            /* DbgCommandString*/
+            case BREAKPOINT_COMMAND_STRING:
+
+                /* Call the worker routine */
+                while (TRUE);
+                Status = TRUE;
+
+            /* Anything else, do nothing */
+            default:
+
+                /* Get out */
+                break;
+        }
+
+        /*
+         * If EIP was not updated, we'll increment it ourselves so execution
+         * continues past the breakpoint.
+         */
+        if (ContextRecord->Rip == Rip) ContextRecord->Rip++;
+    }
+    else
+    {
+        /* Call the worker routine */
+        Status = KdpReport(TrapFrame,
+                           ExceptionFrame,
+                           ExceptionRecord,
+                           ContextRecord,
+                           PreviousMode,
+                           SecondChanceException);
+    }
+
+    /* Return TRUE or FALSE to caller */
+    return Status;
+}
diff --git a/reactos/ntoskrnl/kd64/i386/kd-i386.c b/reactos/ntoskrnl/kd64/i386/kd-i386.c
new file mode 100644 (file)
index 0000000..696ee62
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * PROJECT:         ReactOS Kernel
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            ntoskrnl/kd64/i386/kdapi-i386.c
+ * PURPOSE:         KD64 i386 Support
+ * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* PRIVATE FUNCTIONS *********************************************************/
+
+VOID
+NTAPI
+KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
+                   IN PCONTEXT Context)
+{
+    PKPRCB Prcb = KeGetCurrentPrcb();
+
+    /* Copy i386 specific debug registers */
+    WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.
+                                         KernelDr6;
+    WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.
+                                         KernelDr7;
+
+    /* Copy i386 specific segments */
+    WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;
+    WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;
+    WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;
+    WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;
+
+    /* Copy EFlags */
+    WaitStateChange->ControlReport.EFlags = Context->EFlags;
+
+    /* Set Report Flags */
+    WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;
+    if (WaitStateChange->ControlReport.SegCs == KGDT_R0_CODE)
+    {
+        WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_CS;
+    }
+}
+
+BOOLEAN
+NTAPI
+KdpTrap(IN PKTRAP_FRAME TrapFrame,
+        IN PKEXCEPTION_FRAME ExceptionFrame,
+        IN PEXCEPTION_RECORD ExceptionRecord,
+        IN PCONTEXT ContextRecord,
+        IN KPROCESSOR_MODE PreviousMode,
+        IN BOOLEAN SecondChanceException)
+{
+    BOOLEAN Unload = FALSE;
+    ULONG Eip, Eax;
+    BOOLEAN Status = FALSE;
+
+    /*
+     * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
+     * Load/Unload symbols.
+     */
+    if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
+        (ExceptionRecord->ExceptionInformation[0] != BREAKPOINT_BREAK))
+    {
+        /* Save EIP */
+        Eip = ContextRecord->Eip;
+
+        /* Check what kind of operation was requested from us */
+        switch (ExceptionRecord->ExceptionInformation[0])
+        {
+            /* DbgPrint */
+            case BREAKPOINT_PRINT:
+
+                /* Call the worker routine */
+                Eax = KdpPrint(ContextRecord->Ebx,
+                               ContextRecord->Edi,
+                               (LPSTR)ExceptionRecord->ExceptionInformation[1],
+                               (ULONG)ExceptionRecord->ExceptionInformation[2],
+                               PreviousMode,
+                               TrapFrame,
+                               ExceptionFrame,
+                               &Status);
+
+                /* Update the return value for the caller */
+                ContextRecord->Eax = Eax;
+                break;
+
+            /* DbgPrompt */
+            case BREAKPOINT_PROMPT:
+
+                /* Call the worker routine */
+                while (TRUE);
+                Eax = 0;
+                Status = TRUE;
+
+                /* Update the return value for the caller */
+                ContextRecord->Eax = Eax;
+                break;
+
+            /* DbgUnloadSymbols */
+            case BREAKPOINT_UNLOAD_SYMBOLS:
+
+                /* Drop into the load case below, with the unload parameter */
+                Unload = TRUE;
+
+            /* DbgLoadSymbols */
+            case BREAKPOINT_LOAD_SYMBOLS:
+
+                /* Call the worker routine */
+                KdpSymbol((PVOID)ExceptionRecord->ExceptionInformation[1],
+                          (PVOID)ExceptionRecord->ExceptionInformation[2],
+                          Unload,
+                          PreviousMode,
+                          ContextRecord,
+                          TrapFrame,
+                          ExceptionFrame);
+                Status = TRUE;
+                break;
+
+            /* DbgCommandString*/
+            case BREAKPOINT_COMMAND_STRING:
+
+                /* Call the worker routine */
+                while (TRUE);
+                Status = TRUE;
+
+            /* Anything else, do nothing */
+            default:
+
+                /* Get out */
+                break;
+        }
+
+        /*
+         * If EIP was not updated, we'll increment it ourselves so execution
+         * continues past the breakpoint.
+         */
+        if (ContextRecord->Eip == Eip) ContextRecord->Eip++;
+    }
+    else
+    {
+        /* Call the worker routine */
+        Status = KdpReport(TrapFrame,
+                           ExceptionFrame,
+                           ExceptionRecord,
+                           ContextRecord,
+                           PreviousMode,
+                           SecondChanceException);
+    }
+
+    /* Return TRUE or FALSE to caller */
+    return Status;
+}
index f062508..265904c 100644 (file)
@@ -173,7 +173,13 @@ KdpSetCommonState(IN ULONG NewState,
     WaitStateChange->Processor = (USHORT)KeGetCurrentPrcb()->Number;\r
     WaitStateChange->NumberProcessors = (ULONG)KeNumberProcessors;\r
     WaitStateChange->Thread = (ULONG)(LONG_PTR)KeGetCurrentThread();\r
+#if defined(_M_X86_)\r
     WaitStateChange->ProgramCounter = (ULONG)(LONG_PTR)Context->Eip;\r
+#elif defined(_AMD64)\r
+    WaitStateChange->ProgramCounter = (ULONG)(LONG_PTR)Context->Rip;\r
+#else\r
+#error Unknown platform\r
+#endif\r
 \r
     /* Zero out the Control Report */\r
     RtlZeroMemory(&WaitStateChange->ControlReport,\r
@@ -189,7 +195,7 @@ KdpSetCommonState(IN ULONG NewState,
     /* Clear all the breakpoints in this region */\r
     HadBreakpoints =\r
         KdpDeleteBreakpointRange((PVOID)(LONG_PTR)WaitStateChange->ProgramCounter,\r
-                                 (PVOID)((ULONG)WaitStateChange->ProgramCounter +\r
+                                 (PVOID)((ULONG_PTR)WaitStateChange->ProgramCounter +\r
                                          WaitStateChange->ControlReport.InstructionCount - 1));\r
     if (HadBreakpoints)\r
     {\r
@@ -200,36 +206,6 @@ KdpSetCommonState(IN ULONG NewState,
     }\r
 }\r
 \r
-VOID\r
-NTAPI\r
-KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,\r
-                   IN PCONTEXT Context)\r
-{\r
-    PKPRCB Prcb = KeGetCurrentPrcb();\r
-\r
-    /* Copy i386 specific debug registers */\r
-    WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.\r
-                                         KernelDr6;\r
-    WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.\r
-                                         KernelDr7;\r
-\r
-    /* Copy i386 specific segments */\r
-    WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;\r
-    WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;\r
-    WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;\r
-    WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;\r
-\r
-    /* Copy EFlags */\r
-    WaitStateChange->ControlReport.EFlags = Context->EFlags;\r
-\r
-    /* Set Report Flags */\r
-    WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;\r
-    if (WaitStateChange->ControlReport.SegCs == KGDT_R0_CODE)\r
-    {\r
-        WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_CS;\r
-    }\r
-}\r
-\r
 VOID\r
 NTAPI\r
 KdpSysGetVersion(IN PDBGKD_GET_VERSION64 Version)\r
index 746fe98..9e9c25a 100644 (file)
@@ -328,6 +328,8 @@ DBGKD_GET_VERSION64 KdVersionBlock =
     DBGKD_VERS_FLAG_DATA,\r
 #if defined(_M_IX86)\r
     IMAGE_FILE_MACHINE_I386,\r
+#elif defined (_M_AMD64)\r
+    IMAGE_FILE_MACHINE_AMD64,\r
 #elif defined(_M_PPC)\r
     IMAGE_FILE_MACHINE_POWERPC,\r
 #elif defined(_M_MIPS)\r
@@ -348,26 +350,32 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
 {\r
     {{0}},\r
     0,\r
-    {PtrToUlong(RtlpBreakWithStatusInstruction)},\r
+    {(ULONG_PTR)RtlpBreakWithStatusInstruction},\r
     0,\r
     FIELD_OFFSET(KTHREAD, CallbackStack),\r
     CBSTACK_CALLBACK_STACK,\r
+#if defined(_M_X86)\r
     CBSTACK_EBP,\r
+#elif defined (_M_AMD64)\r
+    CBSTACK_RBP,\r
+#else\r
+#error Invalid architecture\r
+#endif\r
     0,\r
-    {PtrToUlong(KiCallUserMode)},\r
+    {(ULONG_PTR)KiCallUserMode},\r
     {0},\r
-    {PtrToUlong(&PsLoadedModuleList)},\r
-    {PtrToUlong(&PsActiveProcessHead)},\r
-    {PtrToUlong(&PspCidTable)},\r
-    {PtrToUlong(&ExpSystemResourcesList)},\r
+    {(ULONG_PTR)&PsLoadedModuleList},\r
+    {(ULONG_PTR)&PsActiveProcessHead},\r
+    {(ULONG_PTR)&PspCidTable},\r
+    {(ULONG_PTR)&ExpSystemResourcesList},\r
     {0},                                                        // ExpPagedPoolDescriptor\r
     {0},                                                        // ExpNumberOfPagedPools\r
-    {PtrToUlong(&KeTimeIncrement)},\r
-    {PtrToUlong(&KeBugcheckCallbackListHead)},\r
-    {PtrToUlong(KiBugCheckData)},\r
-    {PtrToUlong(&IopErrorLogListHead)},\r
-    {PtrToUlong(&ObpRootDirectoryObject)},\r
-    {PtrToUlong(&ObpTypeObjectType)},\r
+    {(ULONG_PTR)&KeTimeIncrement},\r
+    {(ULONG_PTR)&KeBugcheckCallbackListHead},\r
+    {(ULONG_PTR)KiBugCheckData},\r
+    {(ULONG_PTR)&IopErrorLogListHead},\r
+    {(ULONG_PTR)&ObpRootDirectoryObject},\r
+    {(ULONG_PTR)&ObpTypeObjectType},\r
     {0},                                                        // MmSystemCacheStart\r
     {0},                                                        // MmSystemCacheEnd\r
     {0},                                                        // MmSystemCacheWs\r
@@ -404,17 +412,17 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     {0},                                                        // MmResidentAvailablePages\r
     {0},                                                        // PoolTrackTable\r
     {0},                                                        // NonPagedPoolDescriptor\r
-    {PtrToUlong(&MmHighestUserAddress)},\r
-    {PtrToUlong(&MmSystemRangeStart)},\r
-    {PtrToUlong(&MmUserProbeAddress)},\r
-    {PtrToUlong(KdPrintDefaultCircularBuffer)},\r
-    {PtrToUlong(KdPrintDefaultCircularBuffer + 1)},\r
-    {PtrToUlong(&KdPrintWritePointer)},\r
-    {PtrToUlong(&KdPrintRolloverCount)},\r
+    {(ULONG_PTR)&MmHighestUserAddress},\r
+    {(ULONG_PTR)&MmSystemRangeStart},\r
+    {(ULONG_PTR)&MmUserProbeAddress},\r
+    {(ULONG_PTR)KdPrintDefaultCircularBuffer},\r
+    {(ULONG_PTR)(KdPrintDefaultCircularBuffer + 1)},\r
+    {(ULONG_PTR)&KdPrintWritePointer},\r
+    {(ULONG_PTR)&KdPrintRolloverCount},\r
     {0},                                                        // MmLoadedUserImageList\r
-    {PtrToUlong(&NtBuildLab)},\r
+    {(ULONG_PTR)&NtBuildLab},\r
     {0},\r
-    {PtrToUlong(KiProcessorBlock)},\r
+    {(ULONG_PTR)KiProcessorBlock},\r
     {0},                                                        // MmUnloadedDrivers\r
     {0},                                                        // MmLastUnloadedDrivers\r
     {0},                                                        // MmTriageActionTaken\r
@@ -424,7 +432,7 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     {0},                                                        // MmAllocatedNonPagedPool\r
     {0},                                                        // MmPeakCommitment\r
     {0},                                                        // MmtotalCommitLimitMaximum\r
-    {PtrToUlong(&CmNtCSDVersion)},\r
+    {(ULONG_PTR)&CmNtCSDVersion},\r
     {0},                                                        // MmPhysicalMemoryBlock\r
     {0},                                                        // MmSessionBase\r
     {0},                                                        // MmSessionSize\r
@@ -451,18 +459,31 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     FIELD_OFFSET(KPRCB, ProcessorState.ContextFrame),\r
     FIELD_OFFSET(KPRCB, Number),\r
     sizeof(ETHREAD),\r
-    {PtrToUlong(KdPrintDefaultCircularBuffer)},\r
-    {PtrToUlong(&KdPrintBufferSize)},\r
-    {PtrToUlong(&KeLoaderBlock)},\r
+    {(ULONG_PTR)KdPrintDefaultCircularBuffer},\r
+    {(ULONG_PTR)&KdPrintBufferSize},\r
+    {(ULONG_PTR)&KeLoaderBlock},\r
     sizeof(KIPCR) + sizeof(KPRCB),\r
     FIELD_OFFSET(KIPCR, Self),\r
+#if defined(_M_X86)\r
     FIELD_OFFSET(KPCR, Prcb),\r
+#elif defined(_M_AMD64)\r
+    FIELD_OFFSET(KPCR, CurrentPrcb),\r
+#else\r
+ #error Invalid architecture\r
+#endif\r
+#if defined(_M_X86)\r
     FIELD_OFFSET(KIPCR, PrcbData),\r
+#elif defined(_M_AMD64)\r
+    FIELD_OFFSET(KIPCR, Prcb),\r
+#else\r
+ #error Invalid architecture\r
+#endif\r
     0,\r
     0,\r
     0,\r
     0,\r
     0,\r
+#if defined(_M_X86)\r
     FIELD_OFFSET(KIPCR, PrcbData) +\r
     FIELD_OFFSET(KPRCB, ProcessorState.SpecialRegisters),\r
     KGDT_R0_CODE,\r
@@ -473,6 +494,20 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     KGDT_R3_TEB,\r
     KGDT_LDT,\r
     KGDT_TSS,\r
+#elif defined(_M_AMD64)\r
+    FIELD_OFFSET(KIPCR, Prcb) +\r
+    FIELD_OFFSET(KPRCB, ProcessorState.SpecialRegisters),\r
+    KGDT_64_R0_CODE,\r
+    KGDT_64_DATA,\r
+    KGDT_64_DATA,\r
+    KGDT_64_R3_CODE,\r
+    KGDT_64_DATA,\r
+    KGDT_64_DATA,\r
+    0,\r
+    KGDT_TSS,\r
+#else\r
+ #error Invalid architecture\r
+#endif\r
     0,\r
     0,\r
     {0},                                                        // IopNumTriagDumpDataBlocks\r
index 8a88e3a..0574829 100644 (file)
@@ -133,7 +133,7 @@ KdInitSystem(IN ULONG BootPhase,
                                      InLoadOrderLinks);\r
 \r
         /* Save the Kernel Base */\r
-        PsNtosImageBase = (ULONG)LdrEntry->DllBase;\r
+        PsNtosImageBase = (ULONG_PTR)LdrEntry->DllBase;\r
         KdVersionBlock.KernBase = (ULONGLONG)(LONG_PTR)LdrEntry->DllBase;\r
 \r
         /* Check if we have a command line */\r
index f7a72a4..7a3acbf 100644 (file)
@@ -75,7 +75,7 @@ NTAPI
 KdPollBreakIn(VOID)\r
 {\r
     BOOLEAN DoBreak = FALSE;\r
-    ULONG Flags = 0;\r
+    ULONG_PTR Flags = 0;\r
 \r
     /* First make sure that KD is enabled */\r
     if (KdDebuggerEnabled)\r
index 264b283..33ea3b4 100644 (file)
@@ -79,116 +79,6 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
     return Status;\r
 }\r
 \r
-BOOLEAN\r
-NTAPI\r
-KdpTrap(IN PKTRAP_FRAME TrapFrame,\r
-        IN PKEXCEPTION_FRAME ExceptionFrame,\r
-        IN PEXCEPTION_RECORD ExceptionRecord,\r
-        IN PCONTEXT ContextRecord,\r
-        IN KPROCESSOR_MODE PreviousMode,\r
-        IN BOOLEAN SecondChanceException)\r
-{\r
-    BOOLEAN Unload = FALSE;\r
-    ULONG Eip, Eax;\r
-    BOOLEAN Status = FALSE;\r
-\r
-    /*\r
-     * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or\r
-     * Load/Unload symbols.\r
-     */\r
-    if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&\r
-        (ExceptionRecord->ExceptionInformation[0] != BREAKPOINT_BREAK))\r
-    {\r
-        /* Save EIP */\r
-        Eip = ContextRecord->Eip;\r
-\r
-        /* Check what kind of operation was requested from us */\r
-        switch (ExceptionRecord->ExceptionInformation[0])\r
-        {\r
-            /* DbgPrint */\r
-            case BREAKPOINT_PRINT:\r
-\r
-                /* Call the worker routine */\r
-                Eax = KdpPrint(ContextRecord->Ebx,\r
-                               ContextRecord->Edi,\r
-                               (LPSTR)ExceptionRecord->ExceptionInformation[1],\r
-                               (ULONG)ExceptionRecord->ExceptionInformation[2],\r
-                               PreviousMode,\r
-                               TrapFrame,\r
-                               ExceptionFrame,\r
-                               &Status);\r
-\r
-                /* Update the return value for the caller */\r
-                ContextRecord->Eax = Eax;\r
-                break;\r
-\r
-            /* DbgPrompt */\r
-            case BREAKPOINT_PROMPT:\r
-\r
-                /* Call the worker routine */\r
-                while (TRUE);\r
-                Eax = 0;\r
-                Status = TRUE;\r
-\r
-                /* Update the return value for the caller */\r
-                ContextRecord->Eax = Eax;\r
-                break;\r
-\r
-            /* DbgUnloadSymbols */\r
-            case BREAKPOINT_UNLOAD_SYMBOLS:\r
-\r
-                /* Drop into the load case below, with the unload parameter */\r
-                Unload = TRUE;\r
-\r
-            /* DbgLoadSymbols */\r
-            case BREAKPOINT_LOAD_SYMBOLS:\r
-\r
-                /* Call the worker routine */\r
-                KdpSymbol((PVOID)ExceptionRecord->ExceptionInformation[1],\r
-                          (PVOID)ExceptionRecord->ExceptionInformation[2],\r
-                          Unload,\r
-                          PreviousMode,\r
-                          ContextRecord,\r
-                          TrapFrame,\r
-                          ExceptionFrame);\r
-                Status = TRUE;\r
-                break;\r
-\r
-            /* DbgCommandString*/\r
-            case BREAKPOINT_COMMAND_STRING:\r
-\r
-                /* Call the worker routine */\r
-                while (TRUE);\r
-                Status = TRUE;\r
-\r
-            /* Anything else, do nothing */\r
-            default:\r
-\r
-                /* Get out */\r
-                break;\r
-        }\r
-\r
-        /*\r
-         * If EIP was not updated, we'll increment it ourselves so execution\r
-         * continues past the breakpoint.\r
-         */\r
-        if (ContextRecord->Eip == Eip) ContextRecord->Eip++;\r
-    }\r
-    else\r
-    {\r
-        /* Call the worker routine */\r
-        Status = KdpReport(TrapFrame,\r
-                           ExceptionFrame,\r
-                           ExceptionRecord,\r
-                           ContextRecord,\r
-                           PreviousMode,\r
-                           SecondChanceException);\r
-    }\r
-\r
-    /* Return TRUE or FALSE to caller */\r
-    return Status;\r
-}\r
-\r
 BOOLEAN\r
 NTAPI\r
 KdpStub(IN PKTRAP_FRAME TrapFrame,\r
@@ -209,7 +99,13 @@ KdpStub(IN PKTRAP_FRAME TrapFrame,
          (ExceptionCommand == BREAKPOINT_PRINT)))\r
     {\r
         /* This we can handle: simply bump EIP */\r
+#if defined (_M_X86)\r
         ContextRecord->Eip++;\r
+#elif defined (_M_AMD64)\r
+        ContextRecord->Rip++;\r
+#else\r
+#error Unknown platform\r
+#endif\r
         return TRUE;\r
     }\r
     else if (KdPitchDebugger)\r
index a33596b..d4db736 100644 (file)
                        <file>kdlock.c</file>
                        <file>kdprint.c</file>
                        <file>kdtrap.c</file>
+                       <if property="ARCH" value="i386">
+                               <directory name="i386">
+                                       <file>kd-i386.c</file>
+                               </directory>
+                       </if>
+                       <if property="ARCH" value="amd64">
+                               <directory name="amd64">
+                                       <file>kd-amd64.c</file>
+                               </directory>
+                       </if>
                </directory>
        </if>
        <directory name="lpc">