@@ -86,6 +86,42 @@ impl MyContext {
86
86
}
87
87
}
88
88
89
+ #[ cfg( target_arch = "x86" ) ]
90
+ impl MyContext {
91
+ #[ inline( always) ]
92
+ fn ip ( & self ) -> DWORD {
93
+ self . 0 . Eip
94
+ }
95
+
96
+ #[ inline( always) ]
97
+ fn sp ( & self ) -> DWORD {
98
+ self . 0 . Esp
99
+ }
100
+
101
+ #[ inline( always) ]
102
+ fn fp ( & self ) -> DWORD {
103
+ self . 0 . Ebp
104
+ }
105
+ }
106
+
107
+ #[ cfg( target_arch = "arm" ) ]
108
+ impl MyContext {
109
+ #[ inline( always) ]
110
+ fn ip ( & self ) -> DWORD {
111
+ self . 0 . Pc
112
+ }
113
+
114
+ #[ inline( always) ]
115
+ fn sp ( & self ) -> DWORD {
116
+ self . 0 . Sp
117
+ }
118
+
119
+ #[ inline( always) ]
120
+ fn fp ( & self ) -> DWORD {
121
+ self . 0 . R11
122
+ }
123
+ }
124
+
89
125
#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
90
126
#[ inline( always) ]
91
127
pub unsafe fn trace ( cb : & mut dyn FnMut ( & super :: Frame ) -> bool ) {
@@ -167,11 +203,11 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
167
203
Some ( StackWalkEx ) => {
168
204
let mut stack_frame_ex: STACKFRAME_EX = mem:: zeroed ( ) ;
169
205
stack_frame_ex. StackFrameSize = mem:: size_of :: < STACKFRAME_EX > ( ) as DWORD ;
170
- stack_frame_ex. AddrPC . Offset = context. 0 . Eip as u64 ;
206
+ stack_frame_ex. AddrPC . Offset = context. ip ( ) as u64 ;
171
207
stack_frame_ex. AddrPC . Mode = AddrModeFlat ;
172
- stack_frame_ex. AddrStack . Offset = context. 0 . Esp as u64 ;
208
+ stack_frame_ex. AddrStack . Offset = context. sp ( ) as u64 ;
173
209
stack_frame_ex. AddrStack . Mode = AddrModeFlat ;
174
- stack_frame_ex. AddrFrame . Offset = context. 0 . Ebp as u64 ;
210
+ stack_frame_ex. AddrFrame . Offset = context. fp ( ) as u64 ;
175
211
stack_frame_ex. AddrFrame . Mode = AddrModeFlat ;
176
212
177
213
while StackWalkEx (
@@ -205,11 +241,11 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
205
241
}
206
242
None => {
207
243
let mut stack_frame64: STACKFRAME64 = mem:: zeroed ( ) ;
208
- stack_frame64. AddrPC . Offset = context. 0 . Eip as u64 ;
244
+ stack_frame64. AddrPC . Offset = context. ip ( ) as u64 ;
209
245
stack_frame64. AddrPC . Mode = AddrModeFlat ;
210
- stack_frame64. AddrStack . Offset = context. 0 . Esp as u64 ;
246
+ stack_frame64. AddrStack . Offset = context. sp ( ) as u64 ;
211
247
stack_frame64. AddrStack . Mode = AddrModeFlat ;
212
- stack_frame64. AddrFrame . Offset = context. 0 . Ebp as u64 ;
248
+ stack_frame64. AddrFrame . Offset = context. fp ( ) as u64 ;
213
249
stack_frame64. AddrFrame . Mode = AddrModeFlat ;
214
250
215
251
while dbghelp. StackWalk64 ( ) (
0 commit comments