From 0c3ac95899afa29e0b9e671d7d0ca7aa8c0a13b8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Feb 2022 15:33:51 -0800 Subject: [PATCH] Logging: use GCC #pragma to suppress the frame pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a few lambdas now. However, GCC probably inlines everything anyway in release mode, so this is likely moot. Change-Id: Ic15405335d804bdea761fffd16d50573621446ab Reviewed-by: Kai Koehne Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Tor Arne Vestbø --- src/corelib/global/qlogging.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 55f2e63519b..c6bd52668bf 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1279,11 +1279,12 @@ void QMessagePattern::setPattern(const QString &pattern) */ static constexpr int TypicalBacktraceFrameCount = 8; -#if (defined(Q_CC_GNU) || __has_attribute(optimize)) \ - && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) // force skipping the frame pointer, to save the backtrace() function some work -__attribute__((optimize("omit-frame-pointer"))) -#endif +# pragma GCC push_options +# pragma GCC optimize ("omit-frame-pointer") +# endif + static QStringList backtraceFramesForLogMessage(int frameCount) { struct DecodedFrame { @@ -1422,6 +1423,10 @@ static QString formatBacktraceForLogMessage(const QMessagePattern::BacktracePara return frames.join(backtraceSeparator); } + +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) +# pragma GCC pop_options +# endif #endif // QLOGGING_HAVE_BACKTRACE && !QT_BOOTSTRAPPED Q_GLOBAL_STATIC(QMessagePattern, qMessagePattern)