@@ -56,14 +56,15 @@ pub fn unwind_backtrace(frames: &mut [Frame])
5656 // Fetch the symbols necessary from dbghelp.dll
5757 let SymInitialize = sym ! ( dbghelp, "SymInitialize" , SymInitializeFn ) ?;
5858 let SymCleanup = sym ! ( dbghelp, "SymCleanup" , SymCleanupFn ) ?;
59- let StackWalk64 = sym ! ( dbghelp, "StackWalk64 " , StackWalk64Fn ) ?;
59+ let StackWalkEx = sym ! ( dbghelp, "StackWalkEx " , StackWalkExFn ) ?;
6060
6161 // Allocate necessary structures for doing the stack walk
6262 let process = unsafe { c:: GetCurrentProcess ( ) } ;
6363 let thread = unsafe { c:: GetCurrentThread ( ) } ;
6464 let mut context: c:: CONTEXT = unsafe { mem:: zeroed ( ) } ;
6565 unsafe { c:: RtlCaptureContext ( & mut context) } ;
66- let mut frame: c:: STACKFRAME64 = unsafe { mem:: zeroed ( ) } ;
66+ let mut frame: c:: STACKFRAME_EX = unsafe { mem:: zeroed ( ) } ;
67+ frame. StackFrameSize = mem:: size_of_val ( & frame) as c:: DWORD ;
6768 let image = init_frame ( & mut frame, & context) ;
6869
6970 let backtrace_context = BacktraceContext {
@@ -79,24 +80,22 @@ pub fn unwind_backtrace(frames: &mut [Frame])
7980 }
8081
8182 // And now that we're done with all the setup, do the stack walking!
82- // Start from -1 to avoid printing this stack frame, which will
83- // always be exactly the same.
8483 let mut i = 0 ;
8584 unsafe {
8685 while i < frames. len ( ) &&
87- StackWalk64 ( image, process, thread, & mut frame, & mut context,
86+ StackWalkEx ( image, process, thread, & mut frame, & mut context,
8887 ptr:: null_mut ( ) ,
8988 ptr:: null_mut ( ) ,
9089 ptr:: null_mut ( ) ,
91- ptr:: null_mut ( ) ) == c:: TRUE
90+ ptr:: null_mut ( ) ,
91+ 0 ) == c:: TRUE
9292 {
93- let addr = frame. AddrPC . Offset ;
94- if addr == frame. AddrReturn . Offset || addr == 0 ||
95- frame. AddrReturn . Offset == 0 { break }
93+ let addr = ( frame. AddrPC . Offset - 1 ) as * const u8 ;
9694
9795 frames[ i] = Frame {
98- symbol_addr : ( addr - 1 ) as * const u8 ,
99- exact_position : ( addr - 1 ) as * const u8 ,
96+ symbol_addr : addr,
97+ exact_position : addr,
98+ inline_context : frame. InlineFrameContext ,
10099 } ;
101100 i += 1 ;
102101 }
@@ -111,14 +110,14 @@ type SymInitializeFn =
111110type SymCleanupFn =
112111 unsafe extern "system" fn ( c:: HANDLE ) -> c:: BOOL ;
113112
114- type StackWalk64Fn =
113+ type StackWalkExFn =
115114 unsafe extern "system" fn ( c:: DWORD , c:: HANDLE , c:: HANDLE ,
116- * mut c:: STACKFRAME64 , * mut c:: CONTEXT ,
115+ * mut c:: STACKFRAME_EX , * mut c:: CONTEXT ,
117116 * mut c_void , * mut c_void ,
118- * mut c_void , * mut c_void ) -> c:: BOOL ;
117+ * mut c_void , * mut c_void , c :: DWORD ) -> c:: BOOL ;
119118
120119#[ cfg( target_arch = "x86" ) ]
121- fn init_frame ( frame : & mut c:: STACKFRAME64 ,
120+ fn init_frame ( frame : & mut c:: STACKFRAME_EX ,
122121 ctx : & c:: CONTEXT ) -> c:: DWORD {
123122 frame. AddrPC . Offset = ctx. Eip as u64 ;
124123 frame. AddrPC . Mode = c:: ADDRESS_MODE :: AddrModeFlat ;
@@ -130,7 +129,7 @@ fn init_frame(frame: &mut c::STACKFRAME64,
130129}
131130
132131#[ cfg( target_arch = "x86_64" ) ]
133- fn init_frame ( frame : & mut c:: STACKFRAME64 ,
132+ fn init_frame ( frame : & mut c:: STACKFRAME_EX ,
134133 ctx : & c:: CONTEXT ) -> c:: DWORD {
135134 frame. AddrPC . Offset = ctx. Rip as u64 ;
136135 frame. AddrPC . Mode = c:: ADDRESS_MODE :: AddrModeFlat ;
0 commit comments