@@ -86,6 +86,42 @@ impl MyContext {
8686 }
8787}
8888
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+
89125#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
90126#[ inline( always) ]
91127pub 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) {
167203 Some ( StackWalkEx ) => {
168204 let mut stack_frame_ex: STACKFRAME_EX = mem:: zeroed ( ) ;
169205 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 ;
171207 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 ;
173209 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 ;
175211 stack_frame_ex. AddrFrame . Mode = AddrModeFlat ;
176212
177213 while StackWalkEx (
@@ -205,11 +241,11 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
205241 }
206242 None => {
207243 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 ;
209245 stack_frame64. AddrPC . Mode = AddrModeFlat ;
210- stack_frame64. AddrStack . Offset = context. 0 . Esp as u64 ;
246+ stack_frame64. AddrStack . Offset = context. sp ( ) as u64 ;
211247 stack_frame64. AddrStack . Mode = AddrModeFlat ;
212- stack_frame64. AddrFrame . Offset = context. 0 . Ebp as u64 ;
248+ stack_frame64. AddrFrame . Offset = context. fp ( ) as u64 ;
213249 stack_frame64. AddrFrame . Mode = AddrModeFlat ;
214250
215251 while dbghelp. StackWalk64 ( ) (
0 commit comments