问题描述
我正在寻找一种简单的方法,以编程方式从Linux核心转储文件中提取堆栈跟踪,而不必调用gdb。有人有主意吗?
I am looking for a simple way to pull the stack trace out of a Linux core dump file programmatically, without having to invoke gdb. Anybody has an idea?
为避免混淆:我不是正在寻找一种方法来从流程内部获取自己的追溯信息。我正在寻找一种从我拥有的完全独立的核心转储文件中回溯的方法。
To avoid confusion: I am not looking for a way to get my own back trace from inside a process. I am looking for a way to get a backtrace out of a completely independent core dump file I have.
推荐答案
如果真的可以不要调用gdb,但是想要像它提供的那样的回溯,您可以将gdb所需的源代码复制到您的项目中。显然,仅调用gdb会更容易,更可维护且不会引起人们的注意,所以也许您应该这样做。
If you really can't invoke gdb, but want a backtrace like the ones it provides, you could just copy the bits of gdb's source that are needed for that into your project. Obviously just invoking gdb will be easier, more maintainable, and less eyebrow-raising, so maybe you should just do that.
这篇关于如何在不调用外部工具(例如gdb)的情况下从C中的核心转储文件生成堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!