- Implement RtlCaptureContext
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 12 Nov 2008 23:38:33 +0000 (23:38 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 12 Nov 2008 23:38:33 +0000 (23:38 +0000)
- Reenable KeRosDumpStackFrames

svn path=/branches/ros-amd64-bringup/; revision=37324

reactos/lib/rtl/amd64/except_asm.S [new file with mode: 0644]
reactos/lib/rtl/rtl.rbuild
reactos/ntoskrnl/amd64stubs.c
reactos/ntoskrnl/ke/bug.c

diff --git a/reactos/lib/rtl/amd64/except_asm.S b/reactos/lib/rtl/amd64/except_asm.S
new file mode 100644 (file)
index 0000000..0c9b86f
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS Runtime Library (RTL)
+ * FILE:            lib/rtl/amd64/except_asm.S
+ * PURPOSE:         Exception support for AMD64
+ * PROGRAMMERS:     Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <ndk/asm.h>
+.intel_syntax noprefix
+
+/* FUNCTIONS *****************************************************************/
+
+/* 
+ * VOID NTAPI
+ * RtlCaptureContext(
+ *     PCONTEXT ContextRecord); <rcx>
+ */
+.func RtlCaptureContext
+.global _RtlCaptureContext
+_RtlCaptureContext:
+    .cfi_startproc
+
+    /* Safe segment selectors */
+    mov [rcx + CONTEXT_SegCs], cs
+    mov [rcx + CONTEXT_SegDs], ds
+    mov [rcx + CONTEXT_SegEs], es
+    mov [rcx + CONTEXT_SegFs], fs
+    mov [rcx + CONTEXT_SegGs], gs
+    mov [rcx + CONTEXT_SegSs], ss
+
+    /* Save the basic register context */
+    mov [rcx + CONTEXT_Rax], rax
+    mov [rcx + CONTEXT_Rcx], rcx
+    mov [rcx + CONTEXT_Rdx], rdx
+    mov [rcx + CONTEXT_Rbx], rbx
+    mov [rcx + CONTEXT_Rsp], rsp
+    mov [rcx + CONTEXT_Rbp], rbp
+    mov [rcx + CONTEXT_Rsi], rsi
+    mov [rcx + CONTEXT_Rdi], rdi
+    mov [rcx + CONTEXT_R8], r8
+    mov [rcx + CONTEXT_R9], r9
+    mov [rcx + CONTEXT_R10], r10
+    mov [rcx + CONTEXT_R11], r11
+    mov [rcx + CONTEXT_R12], r12
+    mov [rcx + CONTEXT_R13], r13
+    mov [rcx + CONTEXT_R14], r14
+    mov [rcx + CONTEXT_R15], r15
+
+    /* Capture eflags */
+    pushfq
+    pop rax
+    mov [rcx + CONTEXT_EFlags], rax
+
+    /* Put return address in rip member */
+    mov rax, [rsp]
+    mov [rcx + CONTEXT_Rip], rax
+
+    /* Safe mmx registers */
+/*    movdqa [rcx + CONTEXT_Xmm0], xmm0
+    movdqa [rcx + CONTEXT_Xmm1], xmm1
+    movdqa [rcx + CONTEXT_Xmm2], xmm2
+    movdqa [rcx + CONTEXT_Xmm3], xmm3
+    movdqa [rcx + CONTEXT_Xmm4], xmm4
+    movdqa [rcx + CONTEXT_Xmm5], xmm5
+    movdqa [rcx + CONTEXT_Xmm6], xmm6
+    movdqa [rcx + CONTEXT_Xmm7], xmm7
+    movdqa [rcx + CONTEXT_Xmm8], xmm8
+    movdqa [rcx + CONTEXT_Xmm9], xmm9
+    movdqa [rcx + CONTEXT_Xmm10], xmm10
+    movdqa [rcx + CONTEXT_Xmm11], xmm11
+    movdqa [rcx + CONTEXT_Xmm12], xmm12
+    movdqa [rcx + CONTEXT_Xmm13], xmm13
+    movdqa [rcx + CONTEXT_Xmm14], xmm14
+    movdqa [rcx + CONTEXT_Xmm15], xmm15
+*/
+    ret
+    .cfi_endproc
+.endfunc
+
index 719c0f8..f689d83 100644 (file)
@@ -39,6 +39,7 @@
        <if property="ARCH" value="amd64">
                <directory name="amd64">
                        <file>debug_asm.S</file>
+                       <file>except_asm.S</file>
                        <file>unwind.c</file>
                        <file>stubs.c</file>
                </directory>
index f36c0e8..54a2131 100644 (file)
@@ -56,8 +56,6 @@ STUB(MmPfnDatabase)
 STUB(MmHighestPhysicalPage)
 STUB(MiFreeDescriptorOrg)
 STUB(ExEventObjectType)
-STUB(KeRosDumpStackFrames)
-STUB(RtlWalkFrameChain)
 STUB(ExSystemLookasideListHead)
 STUB(PspGetOrSetContextKernelRoutine)
 STUB(KeConnectInterrupt)
index a29261b..bd2f2fa 100644 (file)
@@ -227,13 +227,13 @@ KeRosCaptureUserStackBackTrace(IN ULONG FramesToSkip,
     return (USHORT)i;
 }
 
-#ifndef _M_AMD64
 VOID
 FASTCALL
 KeRosDumpStackFrameArray(IN PULONG Frames,
                          IN ULONG FrameCount)
 {
-    ULONG i, Addr;
+    ULONG i;
+    ULONG_PTR Addr;
     BOOLEAN InSystem;
     PVOID p;
     PLDR_DATA_TABLE_ENTRY LdrEntry;
@@ -316,7 +316,7 @@ KeRosDumpStackFrames(IN PULONG Frame OPTIONAL,
         }
     }
 }
-#endif
+
 
 VOID
 NTAPI