准备工作
- android ndk(里面包含64位的addr2line执行文件) developer.android.google.cn/ndk/downloa…
- not stripped的so文件(带symbols信息) 路径:out/target/product/qssi_64/symbols/system/lib64/*.so
查看bin文件的tripped状态
我们可以使用 file <file path>
来查看
可以看到symbols路径下的bin文件为not stripped状态,不带symbols的路径下的bin文件为stripped状态。
注意:symbols lib库必须是与用来复现问题的bin在同一次build出来的才可以
在执行文件中添加调用堆栈打印进行验证
- 导入CallStack头文件
- 调用CallStack::logStack方法打印堆栈
#include <utils/CallStack.h>
CallStack::logStack("qinbin");
使用方法
./android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-addr2line -C -f -e <file path> <address>
llvm-addr2line -h
OVERVIEW: llvm-addr2line
USAGE: llvm-addr2line [options] addresses...
OPTIONS:
--addresses Show address before line information
--adjust-vma=<offset> Add specified offset to object file addresses
-a Alias for --addresses
--basenames Strip directory names from paths
--build-id=<value> Build ID used to look up the object file
--cache-size=<value> Max size in bytes of the in-memory binary cache.
--color=<value> Whether to use color when symbolizing log markup: always, auto, never
--color Use color when symbolizing log markup.
-C Alias for --demangle
--debug-file-directory=<dir>
Path to directory where to look for debug files
--debuginfod Use debuginfod to find debug binaries
-demangle=false Alias for --no-demangle
-demangle=true Alias for --demangle
--demangle Demangle function names
--dia Use the DIA library to access symbols (Windows only)
--dwp=<file> Path to DWP file to be use for any split CUs
-e=<file> Alias for --obj
--exe=<file> Alias for --obj
--exe <file> Alias for --obj
-e <file> Alias for --obj
-f=<value> Alias for --functions=
--fallback-debug-path=<dir>
Fallback path for debug binaries
--filter-markup Filter symbolizer markup from stdin.
--functions=<value> Print function name for a given address
--functions Print function name for a given address
-f Alias for --functions
--help Display this help
--inlines Print all inlined frames for a given address
--inlining=false Alias for --no-inlines
--inlining=true Alias for --inlines
--inlining Alias for --inlines
-i Alias for --inlines
--no-debuginfod Don't use debuginfod to find debug binaries
--no-demangle Don't demangle function names
--no-inlines Do not print inlined frames
--no-untag-addresses Remove memory tags from addresses before symbolization
--obj=<file> Path to object file to be symbolized (if not provided, object file should be specified for each input line)
--output-style=style Specify print style. Supported styles: LLVM, GNU, JSON
--pretty-print Make the output more human friendly
--print-address Alias for --addresses
--print-source-context-lines=<value>
Print N lines of source file context
-p Alias for --pretty-print
--relative-address Interpret addresses as addresses relative to the image base
--relativenames Strip the compilation directory from paths
-s Alias for --basenames
--verbose Print verbose line info
--version Display the version
-v Alias for --version
llvm-symbolizer Mach-O Specific Options:
--default-arch=<value> Default architecture (for multi-arch objects)
--dsym-hint=<dir> Path to .dSYM bundles to search for debug info for the object files
Pass @FILE as argument to read options from FILE.