Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update event schema docs to support iOS exceptions #1047

Open
abhaysood opened this issue Aug 16, 2024 · 3 comments · May be fixed by #1118
Open

Update event schema docs to support iOS exceptions #1047

abhaysood opened this issue Aug 16, 2024 · 3 comments · May be fixed by #1118
Assignees
Labels
docs user facing documentation ios ios related

Comments

@abhaysood
Copy link
Contributor

No description provided.

@abhaysood
Copy link
Contributor Author

abhaysood commented Aug 16, 2024

Summary

iOS exceptions have the following differences.

  1. Threads contain a thread ID or number using which the stacktrace should be sorted. Any thread number could have crashed and the stacktrace for this thread must be expanded.
  2. Stack frames are very different from java/dart or other VM based languages and are more similar to C/C++. The stack frames will require addition of atleast the following (require better naming and description):
binary_name: String
binary_address: String
offset: String
frame_index: Int
symbol_address: String
base_address: String
path: String
  1. The crash report contains a signal (like SIGABRT) and an exception type (like NSRangeException) — some crashes will only contain a signal while some can contain both signal and the exception type.
  2. Should architecture (example x86_64) be part of attributes or the exception object? — we don't need the architecture name for symbolication. We only need OS version, which should be part of attributes.

Sample crash report

Exception Type:  SIGABRT
Exception Codes: #0 at 0x10bd4a14a
Crashed Thread:  0

Thread 0 Crashed:
0   libsystem_kernel.dylib              0x000000010bd4a14a 0x10bd42000 + 33098
1   libsystem_pthread.dylib             0x000000010bdcaebd 0x10bdc5000 + 24253
2   libsystem_c.dylib                   0x00007ff80016dd1c 0x7ff8000f1000 + 511260
3   MeasureDemo                         0x000000010b82e5bb 0x10b82c000 + 9659
4   MeasureDemo                         0x000000010b82e323 0x10b82c000 + 8995
5   MeasureDemo                         0x000000010b82e3c1 0x10b82c000 + 9153
6   UIKitCore                           0x00007ff805faed4d 0x7ff804cbc000 + 19869005
7   UIKitCore                           0x00007ff805faf13d 0x7ff804cbc000 + 19870013
8   UIKitCore                           0x00007ff805faf24f 0x7ff804cbc000 + 19870287
9   UIKitCore                           0x00007ff806346231 0x7ff804cbc000 + 23634481
10  UIKitCore                           0x00007ff806346717 0x7ff804cbc000 + 23635735

Thread 1:
0   libsystem_kernel.dylib              0x000000010bd44af6 0x10bd42000 + 10998
1   libsystem_pthread.dylib             0x000000010bdc7bdd 0x10bdc5000 + 11229
2   libsystem_pthread.dylib             0x000000010bdc6acf 0x10bdc5000 + 6863

Thread 0 crashed with X86-64 Thread State:
   rip: 0x000000010bd4a14a    rbp: 0x00007ff7b46d0a00    rsp: 0x00007ff7b46d09d8    rax: 0x0000000000000000 
   rbx: 0x0000000000000006    rcx: 0x00007ff7b46d09d8    rdx: 0x0000000000000000    rdi: 0x0000000000000103 
   rsi: 0x0000000000000006     r8: 0x0000000000000000     r9: 0x000000010cd074e0    r10: 0x0000000000000000 
   r11: 0x0000000000000246    r12: 0x0000000000000103    r13: 0x000000010cd074e0    r14: 0x000000011343e240 
   r15: 0x0000000000000016 rflags: 0x0000000000000246     cs: 0x0000000000000007     fs: 0x0000000000000000 
    gs: 0x0000000000000000 

Binary Images:
       0x10b82c000 -        0x10b838fff +MeasureDemo x86_64  <281b325574813abeb859eae0fe527533> /Users/edpu/Library/Developer/CoreSimulator/Devices/B2E2BC7F-41AA-45C4-B5BC-68BC02E0AD8B/data/Containers/Bundle/Application/A738472D-7B48-4AAA-B1D4-9A19D12A32C7/MeasureDemo.app/MeasureDemo
       0x10ba8e000 -        0x10ba9afff  libobjc-trampolines.dylib x86_64  <168784a215c535338fcd1ac6a7e8b1b6> 

@adwinross
Copy link
Collaborator

adwinross commented Aug 16, 2024

Currently exception object consists of type, message and frames. This will be updated to include a signal field which mentions what type of POSIX signal was encountered leading to the crash. When a NSException is encountered, type will be the exception name and message will be the exception reason.

type - string
message - string
frames - array
signal - string

The thread object will be updated to include a sequence key which mentions the the sequence in which tells the backend in which order the threads need to be shown.

name - string
frames - array
sequence - int

The frame object will be updated to include iOS specific info as mentioned in the point 2 here.

@adwinross
Copy link
Collaborator

adwinross commented Aug 19, 2024

Data after symbollication

Below is a stacktrace that is to be symbolicated.

<frameIndex> <binaryName>         <addressToSymbolicate> <binaryAddress> <offset>
0   libsystem_kernel.dylib              0x00000001e3c2e974 0x1e3c24000 + 43380
1   libsystem_c.dylib                   0x00000001a3677b80 0x1a3602000 + 482176
2   MeasureDemo                         0x0000000102c18f40 0x102c10000 + 36672
3   MeasureDemo                         0x0000000102c18c3c 0x102c10000 + 35900
4   MeasureDemo                         0x0000000102c18cf0 0x102c10000 + 36080
5   UIKitCore                           0x000000019e94ba80 0x19d93e000 + 16833152
6   UIKitCore                           0x000000019e94bdac 0x19d93e000 + 16833964
7   UIKitCore                           0x000000019e94beac 0x19d93e000 + 16834220
8   UIKitCore                           0x000000019d9e98f0 0x19d93e000 + 702704
9   UIKitCore                           0x000000019d9e96d4 0x19d93e000 + 702164
10  UIKitCore                           0x000000019d9e95ec 0x19d93e000 + 701932
11  UIKitCore                           0x000000019d9e9378 0x19d93e000 + 701304
12  UIKitCore                           0x000000019d9e9274 0x19d93e000 + 701044
13  UIKitCore                           0x000000019d9e8d78 0x19d93e000 + 699768
14  UIKitCore                           0x000000019d9e8468 0x19d93e000 + 697448
15  UIKitCore                           0x000000019d9e8524 0x19d93e000 + 697636
16  CoreFoundation                      0x000000019b6f962c 0x19b6c2000 + 226860
17  CoreFoundation                      0x000000019b6f88a8 0x19b6c2000 + 223400
18  CoreFoundation                      0x000000019b6f7058 0x19b6c2000 + 217176
19  CoreFoundation                      0x000000019b6f5d88 0x19b6c2000 + 212360
20  CoreFoundation                      0x000000019b6f5968 0x19b6c2000 + 211304
21  GraphicsServices                    0x00000001df9f34e0 0x1df9f0000 + 13536
22  UIKitCore                           0x000000019db68edc 0x19d93e000 + 2272988
23  UIKitCore                           0x000000019db68518 0x19d93e000 + 2270488
24  UIKitCore                           0x000000019dda1734 0x19d93e000 + 4601652
25  MeasureDemo                         0x0000000102c1b794 0x102c10000 + 46996
26  MeasureDemo                         0x0000000102c1b70c 0x102c10000 + 46860
27  MeasureDemo                         0x0000000102c1b810 0x102c10000 + 47120
28  ???                                 0x00000001bec16d84 0x0 + 0

To Symbolicate the app symbols(MeasureDemo), the below datapoints are needed

  • DSYM file
  • offsets
  • CPU architecture (arm64e, x86_64, arm64, armv7k, armv6, armv7, armv7f, armv7s, arm, i386, arm64)

Run the below command to get the symbolicated data

sh symbolicateWithDsym.sh MeasureDemo.app.dSYM/Contents/Resources/DWARF/MeasureDemo 36672 35900 36080 46996 46860 47120

Output
ViewController.triggerCrash(type:)
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/MeasureDemo/ViewController.swift:0

ViewController.tableView(_:didSelectRowAt:)
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/MeasureDemo/ViewController.swift:52

@objc ViewController.tableView(_:didSelectRowAt:)
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/<compiler-generated>:0

static UIApplicationDelegate.main()
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/<compiler-generated>:0

static AppDelegate.$main()
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/<compiler-generated>:0

main
/Users/edpu/Documents/Workspace/measure/ios/MeasureDemo/MeasureDemo/AppDelegate.swift:12
Output Format

<functionName>
<fileName>:<lineNumber>

<functionName>
<fileName>:<lineNumber>

...

To Symbolicate the system symbols(UIKitCore, CoreFoundation etc), the below datapoints are needed

  • System binary
  • Binary address
  • Linker address (from otool command, script needs to be updated to not require this command)
  • Address to symbolicate
  • CPU architecture (arm64e, x86_64, arm64, armv7k, armv6, armv7, armv7f, armv7s, arm, i386, arm64)
  • Operating System Build (eg. 21E219) to figure out which system binary version is to be used

Run the below command to get the symbolicated data

sh symbolicateSystemSymbols.sh UIKitCore 19d93e000 18a452000 000000019e94ba80 000000019e94bdac 000000019e94beac 000000019d9e98f0 000000019d9e96d4 000000019d9e95ec 000000019d9e9378 000000019d9e9274 000000019d9e8d78 000000019d9e8468 000000019d9e8524 000000019db68edc 000000019db68518 000000019dda1734

Output
-[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:isCellMultiSelect:deselectPrevious:performCustomSelectionAction:]
-[UITableView _userSelectRowAtPendingSelectionIndexPath:animatedSelection:]
-[UITableView _userSelectRowAtPendingSelectionIndexPath:]
-[_UIAfterCACommitBlock run]
-[_UIAfterCACommitQueue flush]
_runAfterCACommitDeferredBlocks
_cleanUpAfterCAFlushAndRunDeferredBlocks
_UIApplicationFlushCATransaction
_UIUpdateSequenceRun
schedulerStepScheduledMainSection
runloopSourceCallback
-[UIApplication _run]
UIApplicationMain
__swift_destroy_boxed_opaque_existential_1Tm
Output Format

<functionName>
<functionName>
...

Symbolication Scripts

StackFrame Info for iOS

binary_name: String
binary_address: String
offset: String
frame_index: Int
symbol_address: String

We do not need any binary info as the binary address is present in the StackFrame object itself. FilePath is also not needed as the files can be found using the find command on linux. All the binaries have a unique name, so this should work. Alternatively while uploading, all the binaries can be placed under one folder so the step to searching for binaries can be removed.

Data needed post symbolication

Data to be saved from the StackFrame Info

frame_index: Int
binary_name: String
symbol_address: String

Data to be saved from symbolication scripts:

  • CPU architecture (arm64e, x86_64, arm64, armv7k, armv6, armv7, armv7f, armv7s, arm, i386, arm64)
  • Operating System Build (eg. 21E219) to figure out which system binary version is to be used

Rest all data points can be discarded post symbolication

@abhaysood abhaysood moved this to In Progress in Measure Roadmap Aug 22, 2024
@anupcowkur anupcowkur added the docs user facing documentation label Aug 23, 2024
@abhaysood abhaysood changed the title Support iOS exceptions in exception event schema Update event schema docs to support iOS exceptions Aug 23, 2024
@anupcowkur anupcowkur added the ios ios related label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs user facing documentation ios ios related
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants