如何从 C 语言的核心转储文件生成堆栈跟踪,而不调用 gdb 等外部工具
我正在寻找一种简单的方法,以编程方式从 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实无法调用 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.