如何在GNU运行时和不使用GNUStep的情况下打印Objective-C异常的异常堆栈跟踪? [英] How to print exception stack trace of Objective-C exceptions with GNU runtime and without GNUStep?

查看:91
本文介绍了如何在GNU运行时和不使用GNUStep的情况下打印Objective-C异常的异常堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用GCC 4.3且使用 no 特定框架的Linux(仅GNU运行时)上的Objective-C应用程序。我正在使用Objective-C异常(通过'-fobjc-exceptions'编译器标志)。

I have an Objective-C app build on Linux with GCC 4.3 using no specific framework (only GNU-runtime). I am using Objective-C exceptions (via the '-fobjc-exceptions' compiler flag).

现在,我想在捕获到此异常时打印堆栈跟踪一些。
还是让我更高兴的是:将轨迹放在字符串或某种结构中以便稍后评估或打印。

Now I want to print the stack trace of such an exception when I caught some. Or what would make me even happier: put the trace in a string or some kind of structure to evaluate or print it later on.

那怎么可能

推荐答案

由于没有更多的知识浮出水面,所以我自己发现了以下内容:

Since no more knowledge is floating in, here is what I found out by myself:

至少在Linux下,我可以使用GNU扩展 backtrace backtrace_symbols 来获取调用堆栈的地址和相应的符号。这会有所帮助,但与gdb提供的信息相去甚远。没有行号也没有参数值。

At least under Linux I can use the GNU extensions backtrace and backtrace_symbols to get addresses of the call stack and the corresponding symbols. This helps a little but is far away from the information that gdb gives. There are neither line numbers nor arguments values.

使用glibc扩展名 dladdr ,我可以获得类似的信息,但没有更多。

With the glibc extension dladdr I can get similar information but not further.

这仍然不是我要找的东西,但是没有人提供这样的子句-所以我会接受我自己的回答:(。

This is still not exactly what I'm looking for but no one got so clause – so I would accept my own answer :(.

这篇关于如何在GNU运行时和不使用GNUStep的情况下打印Objective-C异常的异常堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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