[PATCH v3 3/4] ntdll: Also capture first frame in back trace on x86.

Paul Gofman pgofman at codeweavers.com
Thu Oct 28 11:47:00 CDT 2021


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
v2:
    - get rid of parameter intermediate load to %eax.

 dlls/ntdll/signal_i386.c     | 20 +++++++++++++++++++-
 dlls/ntdll/tests/exception.c |  2 --
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 14971032ce6..69ce62c4168 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -480,6 +480,24 @@ __ASM_STDCALL_FUNC( RtlRaiseException, 4,
                     "ret $4" )  /* actually never returns */
 
 
+/***********************************************************************
+ *		capture_context_wrapper (NTDLL.@)
+ */
+void WINAPI capture_context_wrapper(CONTEXT *);
+__ASM_STDCALL_FUNC( capture_context_wrapper, 4,
+                    "pushl %ebp\n\t"
+                    __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
+                    __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
+                    "movl %esp,%ebp\n\t"
+                    __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                    "pushl 8(%ebp)\n\t"        /* context */
+                    "call " __ASM_STDCALL("RtlCaptureContext",4) "\n\t"
+                    "leave\n\t"
+                    __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
+                    __ASM_CFI(".cfi_same_value %ebp\n\t")
+                    "ret $4" )
+
+
 /*************************************************************************
  *		RtlCaptureStackBackTrace (NTDLL.@)
  */
@@ -489,7 +507,7 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer,
     ULONG i;
     ULONG *frame;
 
-    RtlCaptureContext( &context );
+    capture_context_wrapper( &context );
     if (hash) *hash = 0;
     frame = (ULONG *)context.Ebp;
 
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index d73e75ee529..121fbedc72e 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -9134,10 +9134,8 @@ static void test_walk_stack(void)
 
     start = test_walk_stack;
     end = (BYTE *)start + 0x1000;
-    todo_wine_if(sizeof(void *) == 4)
     ok(addrs[0] >= start && addrs[0] < end, "Address is not inside test function, start %p, end %p, addr %p.\n",
             start, end, addrs[0]);
-    todo_wine_if(sizeof(void *) == 4)
     ok(addrs2[0] >= start && addrs2[0] < end, "Address is not inside test function, start %p, end %p, addr %p.\n",
             start, end, addrs2[0]);
 
-- 
2.31.1




More information about the wine-devel mailing list