Xcode:GDB 和信号处理程序
我在 Objective-C 应用程序中使用信号处理程序来捕获致命错误,例如 SIGSEGV、SIGBUS 等。
当发出这样的信号时,我正在编写一个日志文件,其中包含回溯和有关错误的详细信息(我知道我可能会遇到重入问题,但这不是重点)。
这样,我可以在下次启动时知道应用程序已崩溃,并且可以询问用户是否要填写错误报告。
当我手动启动应用程序时,它工作正常。
但是当我从 Xcode(使用 GDB)运行它时,不会调用信号处理程序。
我尝试使用 signal
或 sigaction
设置它们,但没有区别。
我还检查了信息信号,这些信号是否设置为通过,这意味着它们应该传递给应用程序。
这不是什么大问题,因为我只是在调试应用程序时遇到这个问题,但是如果它也能与 GDB 一起工作,那就太好了。
有没有人经历过并解决过这样的问题?
I'm using signal handlers in an Objective-C application to catch fatal errors, as SIGSEGV
, SIGBUS
and the like.
When such an signal is raised, I'm writing a log file, with a backtrace and details about the error (I know I can have reentrancy issues, but that's not the point).
This way, I can know on the next launch that the application has crashed, and I can ask the user if he want to fill a bug report.
It works fine when I launch the app manually.
But when I run it from Xcode (with GDB), the signal handlers are not called.
I've try to set them with signal
or sigaction
, but there's no difference.
I've also checked with info signals
that those signals are set to pass
, meaning they should be passed to the application.
That's not a big deal, as I only got this problem when I'm debugging my application, but it will be very nice to have that working also with GDB.
Has anyone experienced and solved such a problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想尝试在 gdb 中将这些信号设置为 nostop,以便它由您的应用程序管理。
You might want to try to set these signals to nostop in gdb, so it is managed by your application.