Android的NDK:得到回溯Android、NDK

2023-09-12 08:47:03 作者:敢不敢将心比心

我开发了与Android通过NDK工作的本地应用程序。 我需要调用回溯()函数时,有一个崩溃。现在的问题是,有没有< execinfo.h> 的NDK。

I'm developing the native application that works with Android via the NDK. I need to call the backtrace() function when there is a crash. The problem is that there is no <execinfo.h> for the NDK.

有没有其他办法可以找回来跟踪?

Is there any other way to get that back trace?

推荐答案

回溯()是一个非标准的Glibc扩展,而且即便如此,ARM的有点摇摇欲坠(你需要有内置一切与 -funwind桌,我想,再有一个有点新的Glibc?)

backtrace() is a non-standard Glibc extension, and even then somewhat shaky on ARM (you need to have built everything with -funwind-tables, I think, and then have a somewhat new Glibc?)

据我所知,这个功能没有包含在使用Android的仿生C库。

As far as I know, this function is not included in the Bionic C library used by Android.

您可以尝试拉源的Glibc回溯到您的项目,然后重建有趣的事情的展开表,但它听起来像辛勤工作给我。

You could try pulling the source for Glibc backtrace into your project, and then rebuilding the interesting things with the unwind table, but it sounds like hard work to me.

如果您有调试信息,您可以尝试启动GDB与连接到你的进程,并打印回溯这样一个剧本,但我不知道,如果GDB工作在Android(虽然Android是基本的Linux,使多ID精细,安装细节可能有问题?)你可以通过某种方式倾倒核心进一步得到(仿生是否支持?)和后 - 事实分析它。

If you have debug info, you could try launching GDB with a script that attaches to your process, and prints a backtrace that way, but I have no idea if GDB works on Android (although Android is basically Linux, so that much id fine, the installation details may be problematic?) You may get further by dumping core somehow (does Bionic support that?) and analysing it after-the-fact.