valgrind 下运行的程序被中断时线程堆栈回溯
我有一个服务器程序,它没有非常干净/优雅的关闭(一般不应该终止)。当跟踪内存泄漏时,我在 valgrind 下运行它,但最终必须通过信号终止进程(^C)。一般来说,我会尝试在环境安静时终止进程,但仍然有些线程可能正忙于处理作业,并且它们持有的内存会导致误报。为了协助这样的分析,valgrind中是否有任何方法(工具),以便它可以在程序退出时打印线程的回溯(通过信号?)。
I have a server program, which doesn't have a very clean/graceful shutdown (not supposed to terminate in general). When tracing memory leaks, I run it under valgrind, but finally have to kill the process by a signal (^C). Generally I try to terminate the process when the ambiance is quiet but still then some threads might have been busy processing jobs and memory held by them cause false alarms. To assist such analysis, is there any way (tool) in valgrind, so that it can print the backtrace of threads when the program exits (by a signal?).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这很不方便,但是您能让程序在收到此信号时转储核心,然后使用 gdb 诊断核心转储吗?
I know it's inconvenient, but could you get your program to dump core when it gets this signal, then diagnose the core dump with
gdb
?不确定我完全理解你的问题,但你可以通过 gdb 打印所有 pthread 的回溯:
Don't sure I quite understand your question, but you can print backtrace of all pthreads by gdb: