java调用栈中行号

Posted lin-0410

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java调用栈中行号相关的知识,希望对你有一定的参考价值。

java stacktrace line numer
java调用栈中行号:
行号表:https://book.51cto.com/art/201701/528010.htm

行号获取:https://docs.oracle.com/javase/10/docs/api/java/lang/StackTraceElement.html#getLineNumber()

行号是负数的情况:
https://stackoverflow.com/questions/49070987/why-some-stack-trace-have-negative-line-number

A value of -2 indicates that the method containing the execution point is a native method

-1 means that the line number information is not available, for some reason. As you already noticed this is usually a case for classes from libs.

如果用 python systrace不能成功抓取到数据,可以考虑用atrace抓取后,在转换:

#!/bin/bash

echo "capture tace -> $1.trace"
#adb shell atrace -b 8192 -t 5 gfx input view wm am sm audio video camera hal res dalvik rs bionic power pm ss database network adb aidl pdx sched irq i2c freq idle disk mmc sync workq memreclaim regulators binder_driver binder_lock pagecache |tee $1.trace
categories=`adb shell atrace --list_categories |awk  'print $1'`
items=""
for i in $categories
do
	items="$items $i"
done

echo "adb shell atrace -b 16384 -t 5 $items"

adb shell atrace -b 16384 -t 5 -a com.**.**	 $items |tee $1.trace
#adb shell atrace -b 16384 -t 5 -a com.**.**	 $items |tee $1.trace

python ~/Library/android/sdk/platform-tools/systrace/systrace.py --from-file=$1.trace

rm $1.trace

附录:
Adb root ;adb remount; adb shell debuggerd64/32 -b pid //保存所有线程(包括native线程)堆栈
Adb shell kill -3 pid // 保存java线程堆栈,就是执行了ANR
kill -3 需要root权限,可以adb shell ; su
命令输出保存在/data/anr/traces.txt中

cat proc/[pid]/stack ==> 查看kernel调用栈

lsof [pid] ==> 查看进程所打开的文件

Thread.getAllStackTraces();

https://www.jianshu.com/u/383970bef0a0 Carson带你学安卓

以上是关于java调用栈中行号的主要内容,如果未能解决你的问题,请参考以下文章

java调用栈中行号

HD,3G视频数据中行号的插入方法---Verilog代码实现

如何增加vim中行号边距的间距?

微信公众号给微信用户转账的Java实现

python pystack

(第一期)大厂面试系列_ArrayList 公众号java源码栈