Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 03/11/21 11:41, Paul Gofman wrote:
Signed-off-by: Paul Gofman pgofman@codeweavers.com
v5: - fix max USHORT value.
dlls/ntdll/exception.c | 12 ++++++++++++ dlls/ntdll/ntdll_misc.h | 2 ++ dlls/ntdll/signal_arm.c | 4 ++-- dlls/ntdll/signal_arm64.c | 4 ++-- dlls/ntdll/signal_i386.c | 6 ++++-- dlls/ntdll/signal_x86_64.c | 10 ++++++---- 6 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index c3714e8369b..e956d8a722f 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -1065,3 +1065,15 @@ NTSTATUS WINAPI RtlCopyExtendedContext( CONTEXT_EX *dst, ULONG context_flags, CO memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) ); return STATUS_SUCCESS; }
+/*************************************************************************
RtlCaptureStackBackTrace (NTDLL.@)
- */
+USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +{
- ULONG ret;
- ret = capture_stack_back_trace( skip, count, buffer, hash );
- return min( ret, (USHORT)~0 );
+} diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 34af6b780cf..31a33b04dbf 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -57,6 +57,8 @@ extern void WINAPI KiUserCallbackDispatcher(ULONG,void*,ULONG) DECLSPEC_HIDDEN; extern RUNTIME_FUNCTION *lookup_function_info( ULONG_PTR pc, ULONG_PTR *base, LDR_DATA_TABLE_ENTRY **module ) DECLSPEC_HIDDEN; #endif
+extern ULONG WINAPI capture_stack_back_trace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) DECLSPEC_HIDDEN;
- /* debug helpers */ extern LPCSTR debugstr_us( const UNICODE_STRING *str ) DECLSPEC_HIDDEN; extern const char *debugstr_exception_code( DWORD code ) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index 0ef210a0331..241ddc3ce70 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -300,9 +300,9 @@ __ASM_STDCALL_FUNC( RtlRaiseException, 4, "bl " __ASM_NAME("RtlRaiseStatus") )
/*************************************************************************
RtlCaptureStackBackTrace (NTDLL.@)
*/
capture_stack_back_trace
-USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +ULONG WINAPI capture_stack_back_trace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) { FIXME( "(%d, %d, %p, %p) stub!\n", skip, count, buffer, hash ); return 0; diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 290639b676b..1bffbe7efe9 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -1473,9 +1473,9 @@ __ASM_STDCALL_FUNC( RtlRaiseException, 4, "bl " __ASM_NAME("RtlRaiseStatus") /* does not return */ );
/*************************************************************************
RtlCaptureStackBackTrace (NTDLL.@)
*/
capture_stack_back_trace
-USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +ULONG WINAPI capture_stack_back_trace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) { FIXME( "(%d, %d, %p, %p) stub!\n", skip, count, buffer, hash ); return 0; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 14971032ce6..26150ce877b 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -481,14 +481,16 @@ __ASM_STDCALL_FUNC( RtlRaiseException, 4,
/*************************************************************************
RtlCaptureStackBackTrace (NTDLL.@)
*/
capture_stack_back_trace
-USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +ULONG WINAPI capture_stack_back_trace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) { CONTEXT context; ULONG i; ULONG *frame;
- ++skip;
RtlCaptureContext( &context ); if (hash) *hash = 0; frame = (ULONG *)context.Ebp;
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index ef32eba68b7..5f3c8f70208 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -1490,19 +1490,21 @@ static inline ULONG hash_pointers( void **ptrs, ULONG count )
/*************************************************************************
RtlCaptureStackBackTrace (NTDLL.@)
*/
capture_stack_back_trace
-USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) +ULONG WINAPI capture_stack_back_trace( ULONG skip, ULONG count, PVOID *buffer, ULONG *hash ) { UNWIND_HISTORY_TABLE table; DISPATCHER_CONTEXT dispatch; CONTEXT context; NTSTATUS status; ULONG i;
- USHORT num_entries = 0;
ULONG num_entries = 0;
TRACE( "(%u, %u, %p, %p)\n", skip, count, buffer, hash );
++skip;
RtlCaptureContext( &context ); dispatch.TargetIp = 0; dispatch.ContextRecord = &context;
@@ -1529,7 +1531,7 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, if (i >= skip) buffer[num_entries++] = (void *)context.Rip; } if (hash && num_entries > 0) *hash = hash_pointers( buffer, num_entries );
- TRACE( "captured %hu frames\n", num_entries );
- TRACE( "captured %u frames\n", num_entries ); return num_entries; }