1*288bf522SAndroid Build Coastguard Worker# JIT symbols 2*288bf522SAndroid Build Coastguard Worker 3*288bf522SAndroid Build Coastguard Worker[TOC] 4*288bf522SAndroid Build Coastguard Worker 5*288bf522SAndroid Build Coastguard Worker## Java JIT symbols 6*288bf522SAndroid Build Coastguard Worker 7*288bf522SAndroid Build Coastguard WorkerOn Android >= P, simpleperf supports profiling Java code, no matter whether it is executed by 8*288bf522SAndroid Build Coastguard Workerthe interpreter, or JITed, or compiled into native instructions. So you don't need to do anything. 9*288bf522SAndroid Build Coastguard Worker 10*288bf522SAndroid Build Coastguard WorkerFor details on Android O and N, see 11*288bf522SAndroid Build Coastguard Worker[android_application_profiling.md](./android_application_profiling.md#prepare-an-android-application). 12*288bf522SAndroid Build Coastguard Worker 13*288bf522SAndroid Build Coastguard Worker## Generic JIT symbols 14*288bf522SAndroid Build Coastguard Worker 15*288bf522SAndroid Build Coastguard WorkerSimpleperf supports picking up symbols from per-pid symbol map files, somewhat similar to what 16*288bf522SAndroid Build Coastguard WorkerLinux kernel perftool does. Application should create those files at specific locations. 17*288bf522SAndroid Build Coastguard Worker 18*288bf522SAndroid Build Coastguard Worker### Symbol map file location for application 19*288bf522SAndroid Build Coastguard Worker 20*288bf522SAndroid Build Coastguard WorkerApplication should create symbol map files in its data directory. 21*288bf522SAndroid Build Coastguard Worker 22*288bf522SAndroid Build Coastguard WorkerFor example, process `123` of application `foo.bar.baz` should create 23*288bf522SAndroid Build Coastguard Worker`/data/data/foo.bar.baz/perf-123.map`. 24*288bf522SAndroid Build Coastguard Worker 25*288bf522SAndroid Build Coastguard Worker### Symbol map file location for standalone program 26*288bf522SAndroid Build Coastguard Worker 27*288bf522SAndroid Build Coastguard WorkerStandalone programs should create symbol map files in `/data/local/tmp`. 28*288bf522SAndroid Build Coastguard Worker 29*288bf522SAndroid Build Coastguard WorkerFor example, standalone program process `123` should create `/data/local/tmp/perf-123.map`. 30*288bf522SAndroid Build Coastguard Worker 31*288bf522SAndroid Build Coastguard Worker### Symbol map file format 32*288bf522SAndroid Build Coastguard Worker 33*288bf522SAndroid Build Coastguard WorkerSymbol map file is a text file. 34*288bf522SAndroid Build Coastguard Worker 35*288bf522SAndroid Build Coastguard WorkerEvery line describes a new symbol. Line format is: 36*288bf522SAndroid Build Coastguard Worker``` 37*288bf522SAndroid Build Coastguard Worker<symbol-absolute-address> <symbol-size> <symbol-name> 38*288bf522SAndroid Build Coastguard Worker``` 39*288bf522SAndroid Build Coastguard Worker 40*288bf522SAndroid Build Coastguard WorkerFor example: 41*288bf522SAndroid Build Coastguard Worker``` 42*288bf522SAndroid Build Coastguard Worker0x10000000 0x16 jit_symbol_one 43*288bf522SAndroid Build Coastguard Worker0x20000000 0x332 jit_symbol_two 44*288bf522SAndroid Build Coastguard Worker0x20002004 0x8 jit_symbol_three 45*288bf522SAndroid Build Coastguard Worker``` 46*288bf522SAndroid Build Coastguard Worker 47*288bf522SAndroid Build Coastguard WorkerAll characters after the symbol size and until the end of the line are parsed as the symbol name, 48*288bf522SAndroid Build Coastguard Workerwith leading and trailing spaces removed. This means spaces are allowed in symbol names themselves. 49*288bf522SAndroid Build Coastguard Worker 50*288bf522SAndroid Build Coastguard Worker### Known issues 51*288bf522SAndroid Build Coastguard Worker 52*288bf522SAndroid Build Coastguard WorkerCurrent implementation gets confused if memory pages where JIT symbols reside are reused by mapping 53*288bf522SAndroid Build Coastguard Workera file either before or after. 54*288bf522SAndroid Build Coastguard Worker 55*288bf522SAndroid Build Coastguard WorkerFor example, if memory pages were first used by `dlopen("libfoo.so")`, then freed by `dlclose`, 56*288bf522SAndroid Build Coastguard Workerthen allocated for JIT symbols - simpleperf will report symbols from `libfoo.so` instead. 57