1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] simpleperf + Flutter: How to symbolicate libapp.so when `--split-debug-info`?

Discussão em 'Mobile' iniciado por Stack, Novembro 5, 2024 às 19:42.

  1. Stack

    Stack Membro Participativo

    I compiled the Flutter app into an apk file using --profile so it is in profile mode, and also using --split-debug-info because I want to test when debug info is splitted. Then I used simpleperf to get data from it:

    cp /.../build/split-debug-info/app.android-arm64.symbols /Users/tom/temp/20220312_symbols/libapp.so && $SPDIR/app_profiler.py -p com.myapp -lib /Users/tom/temp/20220312_symbols


    Then I get the report:

    (base) ➜ temp $SPDIR/report.py | head -n 20
    Cmdline: /data/data/com.cjy.yplusplus/simpleperf record --app com.cjy.yplusplus --in-app --tracepoint-events /data/local/tmp/tracepoint_events --out-fd 3 --stop-signal-fd 4 -e task-clock:u -f 1000 -g --duration 10 --symfs /data/local/tmp/native_libs/
    Arch: arm64
    Event: task-clock:u (type 1, config 1)
    Samples: 2751
    Event count: 2751000000

    Overhead Command Pid Tid Shared Object Symbol
    35.55% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8d8]
    15.38% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8c0]
    8.14% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8dc]
    7.60% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8b4]
    4.65% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8f4]
    4.07% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8d4]
    4.03% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8bc]
    4.03% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8d0]
    3.85% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8c8]
    3.82% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8e4]
    3.45% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8c4]
    3.05% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libapp.so libapp.so[+17cc8b0]
    0.15% 1.ui 11557 11585 /data/app/com.cjy.yplusplus-nKS0Krl0LnESZxSFCneDAw==/lib/arm64/libflutter.so fmod


    However, as you can see, the symbol is not symbolicated. It is just an address.

    I have tried to manually use addr2line but failed:

    addr2line -f -e /Users/tom/temp/20220312_symbols/libapp.so 0x17cc8d8
    ??
    ??:0


    And, I have also checked the libapp.so bundled in the .apk file.

    unzip -p /.../build/app/outputs/flutter-apk/app-profile.apk lib/arm64-v8a/libapp.so > /Users/tom/temp/from_apk_libapp.so

    objdump -h /Users/tom/temp/from_apk_libapp.so

    /Users/tom/temp/from_apk_libapp.so: file format elf64-littleaarch64

    Sections:
    Idx Name Size VMA LMA File off Algn
    0 .note.gnu.build-id 00000020 0000000000000190 0000000000000190 00000190 2**2
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    1 .rodata 0062c990 00000000000001b0 00000000000001b0 000001b0 2**4
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    2 .eh_frame 00000048 000000000062cb40 000000000062cb40 0062cb40 2**0
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    3 .dynsym 00000090 000000000062cc10 000000000062cc10 0062cc10 2**3
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    4 .dynstr 00000085 000000000062cb88 000000000062cb88 0062cb88 2**3
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    5 .hash 00000038 000000000062cca0 000000000062cca0 0062cca0 2**3
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    6 .text 00b81910 0000000000630000 0000000000630000 00630000 2**4
    CONTENTS, ALLOC, LOAD, READONLY, CODE
    7 .bss 00000018 00000000011b4000 00000000011b4000 011b4000 2**3
    CONTENTS, ALLOC, LOAD, DATA
    8 .dynamic 00000060 00000000011b4018 00000000011b4018 011b4018 2**3
    CONTENTS, ALLOC, LOAD, DATA


    More info (objdump -D) if you like:

    objdump -D /Users/tom/temp/from_apk_libapp.so > 1b.txt

    /Users/tom/temp/from_apk_libapp.so: file format elf64-littleaarch64

    ...
    // near end of file

    11b18a8: d1014529 sub x9, x9, #0x51
    11b18ac: f100093f cmp x9, #0x2
    11b18b0: 54000269 b.ls 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.plast
    11b18b4: d1006529 sub x9, x9, #0x19
    11b18b8: f100a53f cmp x9, #0x29
    11b18bc: 54000209 b.ls 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.plast
    11b18c0: f1203929 subs x9, x9, #0x80e
    11b18c4: 540001c0 b.eq 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.none
    11b18c8: d103d929 sub x9, x9, #0xf6
    11b18cc: f100053f cmp x9, #0x1
    11b18d0: 54000169 b.ls 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.plast
    11b18d4: 928247f1 mov x17, #0xffffffffffffedc0 // #-4672
    11b18d8: ab110129 adds x9, x9, x17
    11b18dc: 54000100 b.eq 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.none
    11b18e0: f104e929 subs x9, x9, #0x13a
    11b18e4: 540000c0 b.eq 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.none
    11b18e8: d1083529 sub x9, x9, #0x20d
    11b18ec: f100393f cmp x9, #0xe
    11b18f0: 54000069 b.ls 11b18fc <_kDartIsolateSnapshotInstructions+0xb7c7bc> // b.plast
    11b18f4: f10bf129 subs x9, x9, #0x2fc
    11b18f8: 54000041 b.ne 11b1900 <_kDartIsolateSnapshotInstructions+0xb7c7c0> // b.any
    11b18fc: d65f03c0 ret
    11b1900: f9414350 ldr x16, [x26, #640]
    11b1904: d61f0200 br x16
    11b1908: d4200000 brk #0x0
    11b190c: d4200000 brk #0x0

    Disassembly of section .bss:

    00000000011b4000 <.bss>:
    ...

    Disassembly of section .dynamic:

    00000000011b4018 <.dynamic>:
    11b4018: 00000004 udf #4
    11b401c: 00000000 udf #0
    11b4020: 0062cca0 .inst 0x0062cca0 ; undefined
    11b4024: 00000000 udf #0
    11b4028: 00000005 udf #5
    11b402c: 00000000 udf #0
    11b4030: 0062cb88 .inst 0x0062cb88 ; undefined
    11b4034: 00000000 udf #0
    11b4038: 0000000a udf #10
    11b403c: 00000000 udf #0
    11b4040: 00000085 udf #133
    11b4044: 00000000 udf #0
    11b4048: 00000006 udf #6
    11b404c: 00000000 udf #0
    11b4050: 0062cc10 .inst 0x0062cc10 ; undefined
    11b4054: 00000000 udf #0
    11b4058: 0000000b udf #11
    11b405c: 00000000 udf #0
    11b4060: 00000018 udf #24
    ...

    // end of file


    As you can see, the maximum address is about 11b4060. But symbol address says libapp.so[+17cc8d8], which is even larger. So that symbol is even not exist in the libapp.so?

    I am quite confused, and cannot symbolicate those symbols. Any help is appreciated!

    Continue reading...

Compartilhe esta Página