build-oneplus3t/debug-info.md
调试信息
-1. 修改备忘
framework/base/core/jni/Android.bp
的 cflags 、 cppflags 增加-g3
:
https://gitlab.com/LineageOS-z/android_frameworks_base/-/commit/56dae322b094cc5f1308786f7c9210435622af66
external/skia/Android.bp
的 cflags 、 cppflags 增加-g3
:
https://gitlab.com/LineageOS-z/android_external_skia/-/commit/053d06f67bf2496fe85c958ec56a3f7ad778648e
0. libandroid_runtime.so 原样
https://gitee.com/imagg/android_framework/blob/master/oneplus3/doc/libandroid_runtime.so-origin.md
1. 修改编译选项 增加调试信息
/app4/lineage16_oneplus3t/frameworks/base/core/jni/Android.bp
: https://gitlab.com/LineageOS-z/android_frameworks_base/-/commit/5b55f6a66a6f898e73f26026cca0420729b1b37b
或者 将 lineage_oneplus3-userdebug
改为 lineage_oneplus3-eng
2. gdb调试
TODO : frida 跟踪函数 skia/mapPoints , 在函数返回时 打印第二个参数的数值
android端(gdbServer): /system/bin/gdbserver64 remote:9999 --attach $(pidof com.tencent.mobileqq)
(或 com.example.myapplication
)
PC端(gdbClient):
adb forward tcp:9999 tcp:9999
/app4/lineage16_oneplus3t/prebuilts/gdb/linux-x86/bin/gdb /app4/lineage16_oneplus3t/out/target/product/oneplus3/symbols/system/bin/app_process64
(gdb) directory /app4/lineage16_oneplus3t/
(gdb) show debug-file-directory
(gdb) set solib-absolute-prefix /app4/lineage16_oneplus3t/out/target/product/oneplus3/symbols/
(gdb) set solib-search-path /app4/lineage16_oneplus3t/out/target/product/oneplus3/symbols/
(gdb) target remote localhost:9999
#此时会加载大量x.so.debug调试符号文件, 最终停在:
#__epoll_pwait () at bionic/libc/arch-arm64/syscalls/__epoll_pwait.S:9
#9 cmn x0, #(MAX_ERRNO + 1)
(gdb) handle SIGQUIT nostop
(gdb) handle SIG35 nostop
(gdb) break android::CanvasJNI::drawTextString
(gdb) continue
#在android手机上 按两次 屏幕底下左边键三条线,
# 则 再次回到 本应用com.example.myapplication 且 引发 界面重新绘制, 从而触发该drawTextString处断点
#Thread 1 "e.myapplication" hit Breakpoint 1, android::CanvasJNI::drawTextString (env=0x7899ee0460, canvasHandle=517480295424, text=0x7fc5810988, start=0, end=14, x=0, y=56, bidiFlags=2,
# paintHandle=517978350304) at frameworks/base/core/jni/android_graphics_Canvas.cpp:585
#585 const jchar* jchars = env->GetStringChars(text, NULL);
#当停止在函数 android::CanvasJNI::log_abs_x_y_ZHelper 内时,执行以下gdb调试语句
set $skPoint=malloc(sizeof(SkPoint))
set ((SkPoint*)($skPoint))->fX=4
call skMatrix.mapPoints ((SkPoint*)$skPoint,1)
print *( (SkPoint*)($skPoint))
#为啥 结果没变? {fX = 4, fY = 0}
屏幕底下左边键三条线
== 查看当前打开的应用们
若android手机上该应用(com.example.myapplication
)窗口中间显示小弹窗Messaging keeps stopping
: App info
, Close app
, 请在小窗口外点击一下 以忽略该小弹窗
参考1: https://blog.csdn.net/zhuyong006/article/details/83789600