X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fformat.hpp;h=73b363408f49cf499f326f601c1bdd0cd8835478;hb=5bb4ff54d92e0a4520f02d08601a0c25f4d2505f;hp=b49a793b9a83808e4ea2203dffe54e0b45f74982;hpb=bd2c951e542d484ca308a0e8de6b1b420ffef2ce;p=lttng-tools.git diff --git a/src/common/format.hpp b/src/common/format.hpp index b49a793b9..73b363408 100644 --- a/src/common/format.hpp +++ b/src/common/format.hpp @@ -9,6 +9,9 @@ #include +#include +#include + DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES @@ -16,4 +19,19 @@ DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES #include DIAGNOSTIC_POP +template <> +struct fmt::formatter : fmt::formatter { + template + typename FormatCtx::iterator format(const std::type_info& type_info, FormatCtx& ctx) + { + int status; + auto demangled_name = abi::__cxa_demangle(type_info.name(), nullptr, 0, &status); + auto it = status == 0 ? fmt::formatter::format(demangled_name, ctx) : + fmt::formatter::format(type_info.name(), ctx); + + free(demangled_name); + return it; + } +}; + #endif /* LTTNG_FORMAT_H */