New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture function info from call stack for memory leak detection. #1146
base: master
Are you sure you want to change the base?
Conversation
When the new operator override macros are not used (e.g. to avoid STL errors), the function that called the new operator is traced by inspecting the call stack. Currently only works for GCC when the backtrace function is supported (i.e. no support for MinGW).
This is a preliminary PR just to discuss this feature, as started in #34. The next step I'll do is to call addr2line to obtain file and line info when printing report. Afterwards, many different improvement can be done: Add support for Win32 equivalent functionality, maybe clang support also, partially import addr2line functionality to avoid executing external calls (and break dependency with addr2line being installed / accessible), etc. Also, not related to mem leaks, I'll also explore adding callstack printing when a failure is raised. |
Some specific tail call optimizations have been disabled in GCC and Clang to ensure call stack distance is constant and consistent
Thanks for the initial PR. This will definitively not be integrated as-is. It'll require a lot of work still. As a starting point though. Could you make a pull request for the rfind in SimpleString. But please rename it properly, fix the implementation to be more in the style of the rest of CppUTest, and add proper test to it. It is a good chance for practices TDD as it is such an isolated piece of code. |
Also, the eventual implementation will need to be so that there are much much much less #if in the code. |
@basvodde This is just a proof of concept, I wanted to keep it simple so you an others can test it a bit, see if it is useful, see quickly what needs to be changed, etc. A final version will definitely need some "preparation" PRs to make some structural changes, will need to add some optimization to keep the memory footprint of memory allocation info nodes the same than now, etc., but will of course be a bit more complex (even if tidier) and a bit harder to review. Regarding the rfind functions, I've just cherry picked that quickly from a dangling branch I've got here for another feature I'm playing with, it's got its UT, so I can push that quickly. However, what do you mean by "fix the implementation to be more in the style of the rest of CppUTest"? Just code style? |
Ok. I'll ignore this for now then :) |
When the new operator override macros are not used (e.g. to avoid STL
errors), the function that called the new operator is traced by
inspecting the call stack.
Currently only works for GCC when the backtrace function is supported
(i.e. no support for MinGW).