From c425acdb51f6b1dfcfd6e5ff56a4c3967507ccba Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 20 Mar 2026 13:45:24 -0400 Subject: Wrap LogTrace FV/F functions with BN_ENABLE_LOG_TRACE guard The *FV and *F variants were unconditionally calling fmt::vformat (allocating/formatting strings) even when trace logging was compiled out, since only the underlying LogTrace* callees were guarded. Co-Authored-By: Claude Sonnet 4.6 --- log.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'log.cpp') diff --git a/log.cpp b/log.cpp index 69285bb9..1f9635d2 100644 --- a/log.cpp +++ b/log.cpp @@ -408,8 +408,10 @@ void BinaryNinja::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_a void BinaryNinja::LogTraceFV(fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTrace("%s", value.c_str()); +#endif } @@ -423,8 +425,10 @@ void BinaryNinja::LogForExceptionFV( void BinaryNinja::LogTraceForExceptionFV(const std::exception& e, fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTraceForException(e, "%s", value.c_str()); +#endif } @@ -437,8 +441,10 @@ void BinaryNinja::LogWithStackTraceFV(BNLogLevel level, fmt::string_view format, void BinaryNinja::LogTraceWithStackTraceFV(fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTraceWithStackTrace("%s", value.c_str()); +#endif } @@ -700,8 +706,10 @@ void Logger::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_args a void Logger::LogTraceFV(fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTrace("%s", value.c_str()); +#endif } @@ -715,8 +723,10 @@ void Logger::LogForExceptionFV( void Logger::LogTraceForExceptionFV(const std::exception& e, fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTraceForException(e, "%s", value.c_str()); +#endif } @@ -729,8 +739,10 @@ void Logger::LogWithStackTraceFV(BNLogLevel level, fmt::string_view format, fmt: void Logger::LogTraceWithStackTraceFV(fmt::string_view format, fmt::format_args args) { +#ifdef BN_ENABLE_LOG_TRACE std::string value = fmt::vformat(format, args); LogTraceWithStackTrace("%s", value.c_str()); +#endif } -- cgit v1.3.1