@@ -56,14 +56,15 @@ pub fn unwind_backtrace(frames: &mut [Frame])
56
56
// Fetch the symbols necessary from dbghelp.dll
57
57
let SymInitialize = sym ! ( dbghelp, "SymInitialize" , SymInitializeFn ) ?;
58
58
let SymCleanup = sym ! ( dbghelp, "SymCleanup" , SymCleanupFn ) ?;
59
- let StackWalk64 = sym ! ( dbghelp, "StackWalk64 " , StackWalk64Fn ) ?;
59
+ let StackWalkEx = sym ! ( dbghelp, "StackWalkEx " , StackWalkExFn ) ?;
60
60
61
61
// Allocate necessary structures for doing the stack walk
62
62
let process = unsafe { c:: GetCurrentProcess ( ) } ;
63
63
let thread = unsafe { c:: GetCurrentThread ( ) } ;
64
64
let mut context: c:: CONTEXT = unsafe { mem:: zeroed ( ) } ;
65
65
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 ;
67
68
let image = init_frame ( & mut frame, & context) ;
68
69
69
70
let backtrace_context = BacktraceContext {
@@ -79,24 +80,22 @@ pub fn unwind_backtrace(frames: &mut [Frame])
79
80
}
80
81
81
82
// 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.
84
83
let mut i = 0 ;
85
84
unsafe {
86
85
while i < frames. len ( ) &&
87
- StackWalk64 ( image, process, thread, & mut frame, & mut context,
86
+ StackWalkEx ( image, process, thread, & mut frame, & mut context,
88
87
ptr:: null_mut ( ) ,
89
88
ptr:: null_mut ( ) ,
90
89
ptr:: null_mut ( ) ,
91
- ptr:: null_mut ( ) ) == c:: TRUE
90
+ ptr:: null_mut ( ) ,
91
+ 0 ) == c:: TRUE
92
92
{
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 ;
96
94
97
95
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 ,
100
99
} ;
101
100
i += 1 ;
102
101
}
@@ -111,14 +110,14 @@ type SymInitializeFn =
111
110
type SymCleanupFn =
112
111
unsafe extern "system" fn ( c:: HANDLE ) -> c:: BOOL ;
113
112
114
- type StackWalk64Fn =
113
+ type StackWalkExFn =
115
114
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 ,
117
116
* 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 ;
119
118
120
119
#[ cfg( target_arch = "x86" ) ]
121
- fn init_frame ( frame : & mut c:: STACKFRAME64 ,
120
+ fn init_frame ( frame : & mut c:: STACKFRAME_EX ,
122
121
ctx : & c:: CONTEXT ) -> c:: DWORD {
123
122
frame. AddrPC . Offset = ctx. Eip as u64 ;
124
123
frame. AddrPC . Mode = c:: ADDRESS_MODE :: AddrModeFlat ;
@@ -130,7 +129,7 @@ fn init_frame(frame: &mut c::STACKFRAME64,
130
129
}
131
130
132
131
#[ cfg( target_arch = "x86_64" ) ]
133
- fn init_frame ( frame : & mut c:: STACKFRAME64 ,
132
+ fn init_frame ( frame : & mut c:: STACKFRAME_EX ,
134
133
ctx : & c:: CONTEXT ) -> c:: DWORD {
135
134
frame. AddrPC . Offset = ctx. Rip as u64 ;
136
135
frame. AddrPC . Mode = c:: ADDRESS_MODE :: AddrModeFlat ;
0 commit comments