Cache the .debug_aranges section and merge overlapping ranges
By caching .debug_aranges we speed up CU DIE lookups, as libdwarf requires us to allocate a copy of the ranges between trace frames. Because all contents in .debug_aranges are read we can also merge overlapping ranges and discard those with invalid information (a zero in start, length or die offset)
The more memory we allocate, the more likely something bad can happen if you are expecting a stacktrace on some cpu exception...
Agreed. I need to refresh the pull request because we kept evolving the code, but I've been quite busy to keep out fork cleaned up and ready to commit. We only enable this for debug builds as, in those, we know that our crashes are in parts of the code where we can use malloc with no problems.
I wanted to bring this up, enabling features on demand, but I wasn't sure if you wanted to keep backward free of those options or not. Right now we have #ifdefs to enable this caching or not, to scan DIEs recursively if searching in .debug_aranges fails, and some others. Would you be open to get those in? I can submit a pull request for you to check it out.