在 Mac 上哪里可以使用 BackTrace 调用
我想从崩溃的 C++ Mac 应用程序中获取 BackTrace,但是我是 Mac 新手,不确定如何最好地执行此操作。
我在 stackoverflow 上发现了一个详细说明其用法的问题: 获取当前mac os x 上的堆栈跟踪
但是我的问题是我看不到代码的所在位置?
- 它在main.cpp中吗?
- 它是否生活在一个 尝试捕获块?
我可以使用一些完整的代码示例,但找不到它们。
I want to get a BackTrace from my crashing C++ Mac application however I am new to the Mac and am not sure how best to go about it.
I found a question on stackoverflow that details its usage: getting the current stack trace on mac os x
However my problem is that I do not see where the code is meant to live?
- Does it go in the main.cpp?
- Does it live in the catch part of a
try catch block?
I could do with some full code examples but am having trouble finding them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一个问题中提到的代码需要转到崩溃后执行的位置。根据发生的情况,如果抛出异常,则可能位于 catch 块中;如果程序因段错误或总线错误等原因崩溃,则可能位于信号处理程序中。
这是捕获信号的示例。它将进入 main()。
The code referred to in the other question needs to go where it will get executed after the crash. Depending on what is happening that could either be in a catch block if an exception is getting thrown, or in a signal handler if the program is crashing because of, for example, a seg fault or bus error.
Here is an example for catching signals. It would go in main().