backtrace-rs icon indicating copy to clipboard operation
backtrace-rs copied to clipboard

Gimli doesn't support iOS

Open alexcrichton opened this issue 4 years ago • 7 comments

I'm not really sure if libbacktrace supports this and if so how well. This is at least a placeholder to audit what happens tody with libbacktrace and switch gimli over to that.

alexcrichton avatar Jun 16 '20 18:06 alexcrichton

TL;DR: I don't think libbacktrace works on iOS currently, but adding iOS support to this crate shouldn't be a huge undertaking.

AFAICT libbacktrace relies on _Unwind_Backtrace for unwinding, which doesn't exist on iOS so I don't think libbacktrace works on iOS. Helpfully, the iOS ABIs for both AArch64 as well as ARMv7 mandate the use of a frame pointer, so unwinding is straightforward in practice. Apple's libc implementation of backtrace is pretty simple:

  • Call pthread_self to get the current thread
  • Call pthread_get_stackaddr_np and pthread_get_stacksize_np on the current thread to get the stack bounds
  • Invoke __builtin_frame_address to get the current frame pointer
  • Dereference the frame pointer in a loop to unwind the stack

I'd expect all of the existing Mach-O support in this crate to work fine for symbolication, but in practice backtraces from programs running on iOS devices won't have access to symbol files so it's immaterial. The standard practice for dealing with stack traces from iOS devices is to symbolicate them after the fact. It seems like this could be handled in tooling such as dinghy, although there's already an existing issue there about backtraces not working on iOS.

luser avatar Jul 22 '20 13:07 luser

Fixed by #378 ?

tesuji avatar Oct 23 '20 10:10 tesuji

The current state on iOS: #378 restores all functionality that libbacktrace had, but it doesn't show line-numbers or source files. I don't know if that's expected or not? But I don't remember ever seeing line-numbers in backtraces with Rust on iOS, so it's not a regression.

cutsoy avatar Oct 23 '20 11:10 cutsoy

Ok makes sense, thanks for the info! In light of that I think I'll leave this open until we can get line numbers and filenames working on iOS

alexcrichton avatar Oct 23 '20 15:10 alexcrichton

Hi, is there any updates? Can we have backtraces on ios? Thanks!

fzyzcjy avatar Oct 13 '21 09:10 fzyzcjy

Do .ipa packages include the .dSYM file? If not getting filenames and line numbers is impossible for the app itself and will need synbolication after the fact. As far as I understand #378 already fixed symbol names on iOS.

bjorn3 avatar Oct 13 '21 09:10 bjorn3

In production environment, there are no symbol names - otherwise it will be easier to reverse-engineering. However, as long as collect information on ios and can symbolize it afterwards, it is completely ok. (So can we do that?)

fzyzcjy avatar Oct 13 '21 09:10 fzyzcjy