1

We've been tracking a crash for months, and we're not really getting any closer. The program crashes at seemingly random times. For some reason, we're not able to print out a stack backtrace. And to make it even harder, the crashes only occur on a specific hardware, which we haven't figured out how to debug, or how to use Valgrind and the likes.

Binary search through revisions could be an option. But as it usually takes around one workday to produce a crash, it will be extremely time-consuming.

So. I would like to print log messages (or something like that) in all/most the functions throughout our code. Of the type "Entering function X", "Leaving function Y" etc. Hopefully, that could give some pointers on which haystack to go looking for the needle in. Is there any simple way to do this, without having to manually go through (literally) thousands of functions? Anybody knows of any program or script or macro magic that could be used for this?

Thanks

7
  • I'd check AOP Commented Jul 2, 2014 at 13:13
  • If you're tracking a specific crash, you can always try an actual debugger, or a software solution such as valgrind. Valgrind is usually great for finding where you have memory errors. Commented Jul 2, 2014 at 13:42
  • @AdrianoRepetti : how do you reckon aspect-orientation will help? Commented Jul 2, 2014 at 13:54
  • @Happington : Thats the whole problem, that on the hardware that crashes, we can't actually use valgrind or a debugger.. Commented Jul 2, 2014 at 13:55
  • A "typical" use of AOP (and common usage example) is to add logging for method enter/exit. Commented Jul 2, 2014 at 13:55

1 Answer 1

1

You need to read your compilers manual. There probably are function entry/exit hooks that you can declare that will do exactly what you're looking for.

For example, in GCC you can use -finstrument-functions https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Code-Gen-Options.html. You can code in a printf for every function entry that dumps the function address to stdout (or wherever you like). You can then use addr2line (from binutils) to translate address to function name.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.