How to get the full call stack from Valgrind?

谁说我不能喝 提交于 2019-11-30 21:57:32

问题


I run Valgrind with the following parameters:

--leak-check=full --show-reachable=yes --leak-resolution=high --num-callers=100 --trace-children=yes

In memory leaks log, I see some error messages with full stack trace up to main, but some messages look like following:

==3956== 1,999,140 (68,796 direct, 1,930,344 indirect) bytes in 5,733 blocks are definitely lost in loss record 8,842 of 8,845
==3956==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==3956== 

How can I get the full stack trace for these errors?


回答1:


Getting the full stack trace will require debug symbols for all the libraries/executables that may be involved in a leak (and within the limits set by --num-callers).

If you're building any of them yourself, you need to specify the -g flag in gcc (or the relevant flag in any other compiler).

Note that valgrind is not foolproof, and may occasionally miss leaks or be unable to provide full stack traces (especially if you're using threads, or complicated class implementations).

For libraries without debug information, the stack trace will stop at that library.

For a free tool, valgrind is very good at what it does, but there is a reason places like IBM can sell memory profiles for big money.



来源:https://stackoverflow.com/questions/11242795/how-to-get-the-full-call-stack-from-valgrind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!