堆栈跟踪停在叶寄存器(lr) [英] stack traces stop at the leaf register (lr)

查看:296
本文介绍了堆栈跟踪停在叶寄存器(lr)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我看到用 lr 指针终止的ARM堆栈跟踪(读取:Android NDK堆栈跟踪),如下所示:

Often I see ARM stack traces (read: Android NDK stack traces) that terminate with an lr pointer, like so:

      #00  pc 001c6c20  /data/data/com.audia.dev.qt/lib/libQtGui.so
      #01  lr 80a356cc  /data/data/com.audia.dev.rta/lib/librta.so

我知道 LR 链接寄存器 ARM和其他架构,而且它的存储返回地址的快速方法,但我不明白为什么它总是似乎存储一个无用的地址。在此示例中, 80a356cc 无法使用 addr2line gdb

I know that lr stands for link register on ARM and other architectures, and that it's a quick way to store a return address, but I don't understand why it always seems to store a useless address. In this example, 80a356cc cannot be mapped to any code using addr2line or gdb.

有没有办法获得更多信息?为什么必须跟踪停止在 lr 地址?

Is there any way to get more information? Why must the trace stop at the lr address anyway?

推荐答案

在答案终于。我只是更加谨慎。看看下面的短堆栈跟踪和它之后的信息:

Stumbled on the answer finally. I just had to be more observant. Look at the following short stack trace and the information that comes after it:

         #00  pc 000099d6  /system/lib/libandroid.so
         #01  lr 80b6c17c  /data/data/com.audia.dev.rta/lib/librta.so

code around pc:
a9d899b4 bf00bd0e 2102b507 aa016d43 28004798 
a9d899c4 9801bfa8 bf00bd0e 460eb573 93004615 
a9d899d4 6d842105 462b4632 200047a0 bf00bd7c 
a9d899e4 b100b510 f7fe3808 2800edf4 f04fbf14 
a9d899f4 200030ff bf00bd10 b097b5f0 4614af01 

code around lr:
80b6c15c e51b3078 e5933038 e5932024 e51b302c 
80b6c16c e1a00002 e3a01000 e3a02000 ebfeee5c 
80b6c17c e1a03000 e50b303c e51b303c e1a03fa3 
80b6c18c e6ef3073 e3530000 0a000005 e59f34fc 
80b6c19c e08f3003 e1a00003 e51b103c ebfeebe6 

现在 lr 地址仍然是 80xxxxxx

pc 打印的地址是 000099d6 ,但看看下一节, pc 附近的代码。第一列是地址的列表(你可以从它由16每次递增的事实告诉我们。)这些地址都看起来像 PC 地址,除非你砍关闭前16位。然后你会注意到 a9d899d4 必须对应于 000099d4 ,程序停止的代码是两个字节

The address it prints from the pc is 000099d6, but look at the next section, code around pc. The first column is a list of addresses (you can tell from the fact that it increments by 16 each time.) None of those addresses looks like the pc address, unless you chop off the first 16 bits. Then you'll notice that the a9d899d4 must correspond to 000099d4, and the code where the program stopped is two bytes in from that.

Android的堆栈跟踪似乎已经截断了 pc 地址的前2个字节我,但无论什么原因,它不会为叶寄存器中的地址做。这给我们带来了解决方案:

Android's stack trace seems to have "chopped off" the first 2 bytes of the pc address for me, but for whatever reason it does not do it for addresses in the leaf register. Which brings us to the solution:

总之,我能够从 切断前16位 80b6c17c 地址,使它 0000c17c ,到目前为止,每次都给我一个有效的代码地址,我可以查找 gdb addr2line 。 (修改我发现它实际上是一般的在第12位或第3十六进制数字,您可以通过观察决定自己这一点。堆栈跟踪输出,如上所述。)我可以确认它是代码地址。这肯定使调试更容易一些!

In short, I was able to chop off the first 16 bits from the 80b6c17c address to make it 0000c17c, and so far that has given me a valid code address every time that I can look up with gdb or addr2line. (edit: I've found it's actually usually the first 12 bits or first 3 hexadecimal digits. You can decide this for yourself by looking at the stack trace output like I described above.) I can confirm that it is the right code address as well. This has definitely made debugging a great bit easier!

这篇关于堆栈跟踪停在叶寄存器(lr)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆