Hi Jules,
I’m currently debugging/profiling a plugin where I’d like to have a feedback from where some functions are called. To keep the debug output tidy, I added the following static function which allows to reduce the backtrace size and can also return it in one line.
String SystemStats::getStackBacktrace(int numEntries, bool oneLine)
{
StringArray backtrace(StringArray::fromLines(SystemStats::getStackBacktrace()));
if (backtrace[0].contains("getStackBacktrace"))
backtrace.remove(0);
if (backtrace[0].contains("getStackBacktrace"))
backtrace.remove(0);
while (bt.size() > numEntries)
backtrace.remove(bt.size()-1);
return backtrace.joinIntoString(oneLine ? " <= " : "\n");
}
It should also remove the entries for getStackBacktrace if debug symbols are available. I’m not sure, if this is the best approach to do this but it suffices for my application. (An alternative might be to always remove the first two entries but I’m not familiar enough with compilers to be sure whether one of these calls might be inlined)
What do you think about adding this to JUCE?
Chris