Android NDK:获取回溯 [英] Android NDK: getting the backtrace

查看:28
本文介绍了Android NDK:获取回溯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 NDK 开发可与 Android 配合使用的本机应用程序.当发生崩溃时,我需要调用 backtrace() 函数.问题是 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?

推荐答案

backtrace() 是一个非标准的 Glibc 扩展,即使在 ARM 上也有些不稳定(你需要用-funwind-tables,我想,然后有一个有点新的 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 使用的 Bionic C 库中不包含此功能.

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

您可以尝试将 Glibc backtrace 的源代码提取到您的项目中,然后使用 unwind table 重建有趣的东西,但这对我来说听起来很困难.

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,所以很多很好,安装细节可能有问题?)您可以通过以某种方式转储核心(Bionic 支持吗?)并事后分析来进一步了解.

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.

这篇关于Android NDK:获取回溯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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