From 88cc420211bede33bbcc8dfedd9ca09bc7678a24 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 11 May 2013 16:45:04 -0400 Subject: [PATCH] Improve basic profiler output a little. If on gcc4, use the built-in demangling functions to present demangled names in the output where possible. --- src/bin/debug/profile/BasicProfileResult.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/bin/debug/profile/BasicProfileResult.cpp b/src/bin/debug/profile/BasicProfileResult.cpp index 15e8fa3f85..52f707fbd2 100644 --- a/src/bin/debug/profile/BasicProfileResult.cpp +++ b/src/bin/debug/profile/BasicProfileResult.cpp @@ -6,6 +6,9 @@ #include "BasicProfileResult.h" +#if __GNUC__ > 2 +#include +#endif #include #include @@ -210,10 +213,23 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container) for (int32 i = 0; i < hitSymbolCount; i++) { const HitSymbol& hitSymbol = hitSymbols[i]; const Symbol* symbol = hitSymbol.symbol; +#if __GNUC__ > 2 + int status; + const char* symbolName = __cxxabiv1::__cxa_demangle(symbol->Name(), + NULL, NULL, &status); + if (symbolName == NULL) + symbolName = symbol->Name(); +#else + const char* symbolName = symbol->Name(); +#endif fprintf(gOptions.output, " %10lld %10lld %6.2f %6ld %s\n", hitSymbol.hits, hitSymbol.hits * fInterval, 100.0 * hitSymbol.hits / totalTicks, hitSymbol.imageID, - symbol->Name()); + symbolName); +#if __GNUC__ > 2 + if (status == 0) + free(const_cast(symbolName)); +#endif } } else fprintf(gOptions.output, " no functions were hit\n");