当前线程Trace
Java
Thread.currentThread().dumpStack(); //方法1
android.util.Log.d(TAG,"Gityuan", new RuntimeException("Gityuan")); //方法2
android.util.Log.d(TAG, android.util.Log.getStackTraceString(new Throwable())); // 方法3
new RuntimeException("Gityuan").printStackTrace(); //方法4
Native
#include <utils/CallStack.h>
android::CallStack stack(("Gityuan"));
目标进程Trace
Java
adb shell kill -3 [pid] //方法1
Process.sendSignal(pid, Process.SIGNAL_QUIT) //方法2
Native
adb shell debuggerd -b [tid] //方法1
Debug.dumpNativeBacktraceToFile(pid, tracesPath) //方法2
Kernel
adb shell cat /proc/[tid]/stack //方法1
WatchDog.dumpKernelStackTraces() //方法2
小结
以下分别列举输出Java, Native, Kernel的调用栈方式:
类别 | 函数式 | 命令式 |
---|---|---|
Java | Process.sendSignal(pid, Process.SIGNAL_QUIT) | kill -3 [pid] |
Native | Debug.dumpNativeBacktraceToFile(pid, tracesPath) | debuggerd -b [pid] |
Kernel | WD.dumpKernelStackTraces() | cat /proc/[tid]/stack |
FEATURED TAGS
Android
debug
dumpsys
shell
linux
Permission
心理学
ubuntu
JNI
android
IMS
systemui
selinux
eSIM
androidstudio
performance
pms
wms
view
iptables
netd
property
c++
kernel
mqtt
usb
company
statusbar
docker
hardware
webrtc
recovery
web
camera
rk3288
A133
driver
rockchip
rk3399
chip
rk3588
a133
qt
t113
buildroot
AI
MCU