Author: ion
Date: Tue Feb 20 09:25:58 2007
New Revision: 25857
URL:
http://svn.reactos.org/svn/reactos?rev=25857&view=rev
Log:
- Add ExceptionRecord32To64.
- Implement KdpReportExceptionStateChange and fully support KdpReport.
- We now properly break inside HAL (with /BREAK) and WinDBG shows a nice stack trace, and
disassembly, and I can step through the HAL initialization code!
Modified:
branches/alex-kd-branch/reactos/include/ddk/winddk.h
branches/alex-kd-branch/reactos/include/reactos/windbgkd.h
branches/alex-kd-branch/reactos/ntoskrnl/include/internal/kd.h
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
Modified: branches/alex-kd-branch/reactos/include/ddk/winddk.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/include/…
==============================================================================
--- branches/alex-kd-branch/reactos/include/ddk/winddk.h (original)
+++ branches/alex-kd-branch/reactos/include/ddk/winddk.h Tue Feb 20 09:25:58 2007
@@ -634,6 +634,17 @@
IN struct _IRP *Irp,
IN PVOID MapRegisterBase,
IN PVOID Context);
+
+
+typedef struct _EXCEPTION_RECORD32
+{
+ NTSTATUS ExceptionCode;
+ ULONG ExceptionFlags;
+ ULONG ExceptionRecord;
+ ULONG ExceptionAddress;
+ ULONG NumberParameters;
+ ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
+} EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
typedef struct _EXCEPTION_RECORD64
{
Modified: branches/alex-kd-branch/reactos/include/reactos/windbgkd.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/include/…
==============================================================================
--- branches/alex-kd-branch/reactos/include/reactos/windbgkd.h (original)
+++ branches/alex-kd-branch/reactos/include/reactos/windbgkd.h Tue Feb 20 09:25:58 2007
@@ -5,6 +5,12 @@
// Dependencies
//
#include "wdbgexts.h"
+
+//
+// Conversion Macros
+//
+#define COPYSE(p64, p32, f) \
+ p64->f = (ULONG64)(LONG64)(LONG)p32->f
//
// Packet Size and Control Stream Size
@@ -460,4 +466,23 @@
} u;
} DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
+FORCEINLINE
+VOID
+ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
+ OUT PEXCEPTION_RECORD64 Ex64)
+{
+ ULONG i;
+
+ Ex64->ExceptionCode = Ex32->ExceptionCode;
+ Ex64->ExceptionFlags = Ex32->ExceptionFlags;
+ Ex64->ExceptionRecord = Ex32->ExceptionRecord;
+ COPYSE(Ex64,Ex32,ExceptionAddress);
+ Ex64->NumberParameters = Ex32->NumberParameters;
+
+ for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
+ {
+ COPYSE(Ex64,Ex32,ExceptionInformation[i]);
+ }
+}
+
#endif
Modified: branches/alex-kd-branch/reactos/ntoskrnl/include/internal/kd.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/include/internal/kd.h (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/include/internal/kd.h Tue Feb 20 09:25:58
2007
@@ -158,6 +158,14 @@
IN PKD_SYMBOLS_INFO SymbolInfo,
IN BOOLEAN Unload,
IN OUT PCONTEXT Context
+);
+
+BOOLEAN
+NTAPI
+KdpReportExceptionStateChange(
+ IN PEXCEPTION_RECORD ExceptionRecord,
+ IN OUT PCONTEXT Context,
+ IN BOOLEAN SecondChanceException
);
VOID
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c Tue Feb 20 09:25:58 2007
@@ -871,6 +871,45 @@
return Status;
}
+BOOLEAN
+NTAPI
+KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
+ IN OUT PCONTEXT Context,
+ IN BOOLEAN SecondChanceException)
+{
+ STRING Header, Data;
+ DBGKD_WAIT_STATE_CHANGE64 WaitStateChange;
+ BOOLEAN Status;
+
+ /* Start report loop */
+ do
+ {
+ /* Build the architecture common parts of the message */
+ KdpSetCommonState(DbgKdExceptionStateChange, Context, &WaitStateChange);
+
+ /* Convert the exception record to 64-bits and set First Chance flag */
+ ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord,
+ &WaitStateChange.u.Exception.ExceptionRecord);
+ WaitStateChange.u.Exception.FirstChance = !SecondChanceException;
+
+ /* Now finish creating the structure */
+ KdpSetContextState(&WaitStateChange, Context);
+
+ /* Setup the actual header to send to KD */
+ Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64);
+ Header.Buffer = (PCHAR)&WaitStateChange;
+
+ /* Send State Change packet and wait for a reply */
+ Status = KdpSendWaitContinue(PACKET_TYPE_KD_STATE_CHANGE64,
+ &Header,
+ &Data,
+ Context);
+ } while (Status == KdPacketNeedsResend);
+
+ /* Return */
+ return Status;
+}
+
VOID
NTAPI
KdpTimeSlipDpcRoutine(IN PKDPC Dpc,
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c Tue Feb 20 09:25:58 2007
@@ -62,22 +62,16 @@
sizeof(CONTEXT));
/* Report the new state */
- Ke386SetCr2(TrapFrame->HardwareEsp);
-#if 0
Status = KdpReportExceptionStateChange(ExceptionRecord,
&Prcb->ProcessorState.
ContextFrame,
SecondChanceException);
-#else
- while (TRUE);
- Status = FALSE;
-#endif
/* Now restore the processor state, manually again. */
RtlCopyMemory(ContextRecord,
&Prcb->ProcessorState.ContextFrame,
sizeof(CONTEXT));
- KiRestoreProcessorControlState(&Prcb->ProcessorState);
+ //KiRestoreProcessorControlState(&Prcb->ProcessorState);
/* Exit the debugger and clear the CTRL-C state */
KdExitDebugger(Entered);