RtlCaptureContext can throw an exception. As we need to push the flags on the stack, we need to create unwind info to make sure we can properly unwind. So instead of pushing the flags and then popping them back, push them on the stack at the beginning of the function, reference the location later, clean up the stack at the function end. Also add .cif_adjust_cfa_offset unwind op.

svn path=/branches/ros-amd64-bringup/; revision=37370
This commit is contained in:
Timo Kreuzer
2008-11-15 01:21:50 +00:00
parent da81081fc1
commit 7a6bb9e3e7
+18 -11
View File
@@ -23,40 +23,45 @@
_RtlCaptureContext:
.cfi_startproc
/* Push eflags */
/* Push rflags */
pushfq
.cfi_adjust_cfa_offset 8
/* Save the basic register context */
mov [rcx + CONTEXT_Rax], rax
mov [rcx + CONTEXT_Rcx], rcx
mov [rcx + CONTEXT_Rdx], rdx
/* Load rflags into rax */
mov rax, [rsp]
mov [rcx + CONTEXT_Rbx], rbx
/* pop eflags */
pop [rcx + CONTEXT_EFlags]
mov [rcx + CONTEXT_Rsi], rsi
mov [rcx + CONTEXT_Rdi], rdi
/* Store rflags */
mov [rcx + CONTEXT_EFlags], rax
mov [rcx + CONTEXT_Rbp], rbp
/* Load former stack pointer in rax */
lea rax, [rsp + 8]
mov [rcx + CONTEXT_R8], r8
mov [rcx + CONTEXT_R9], r9
/* Load former stack pointer in rax */
lea rax, [rsp + 0x10]
mov [rcx + CONTEXT_R10], r10
mov [rcx + CONTEXT_R11], r11
mov [rcx + CONTEXT_R12], r12
/* Store stack pointer */
mov [rcx + CONTEXT_Rsp], rax
mov [rcx + CONTEXT_R12], r12
mov [rcx + CONTEXT_R13], r13
mov [rcx + CONTEXT_R14], r14
mov [rcx + CONTEXT_R15], r15
/* Load return address in rax */
mov rax, [rsp]
mov rax, [rsp + 8]
/* Safe segment selectors */
mov [rcx + CONTEXT_SegCs], cs
@@ -87,6 +92,8 @@ _RtlCaptureContext:
movdqa [rcx + CONTEXT_Xmm14], xmm14
movdqa [rcx + CONTEXT_Xmm15], xmm15
*/
/* Cleanup stack and return */
add rsp, 8
ret
.cfi_endproc
.endfunc