diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-06 01:00:07 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-06 01:00:08 +0200 |
commit | ce7f14d2e0791acc92622fdc23886a06d6712e90 (patch) | |
tree | 5f2b0f0a6c4a37dfaa1f31abf7e58d8a3cec1e3c /src/corelib/global | |
parent | 0998a9d1d53361e572d7377af8cb41a49bbfad72 (diff) | |
parent | f4c41b9797f08f173049502fa7bd465cf5bde938 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Iec860bb703f983b7438e67c695b9c454e72b3e0f
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qlogging.cpp | 3 | ||||
-rw-r--r-- | src/corelib/global/qtrace_p.h | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index b2093101fa..ece97077c1 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -57,6 +57,7 @@ #include "private/qloggingregistry_p.h" #include "private/qcoreapplication_p.h" #include "private/qsimd_p.h" +#include <qtcore_tracepoints_p.h> #endif #ifdef Q_OS_WIN #include <qt_windows.h> @@ -1811,6 +1812,8 @@ static void ungrabMessageHandler() { } static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message) { #ifndef QT_BOOTSTRAPPED + Q_TRACE(qt_message_print, msgType, context.category, context.function, context.file, context.line, message); + // qDebug, qWarning, ... macros do not check whether category is enabled if (isDefaultCategory(context.category)) { if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) { diff --git a/src/corelib/global/qtrace_p.h b/src/corelib/global/qtrace_p.h index 3d04a7311d..20f2beac98 100644 --- a/src/corelib/global/qtrace_p.h +++ b/src/corelib/global/qtrace_p.h @@ -52,11 +52,18 @@ // /* - * The Qt tracepoints API consists of only three macros: + * The Qt tracepoints API consists of only five macros: * * - Q_TRACE(tracepoint, args...) * Fires 'tracepoint' if it is enabled. * + * - Q_TRACE_EXIT(tracepoint, args...) + * Fires 'tracepoint' if it is enabled when the current scope exists. + * + * - Q_TRACE_SCOPE(tracepoint, args...) + * Wrapper around Q_TRACE/_EXIT to trace entry and exit. First it traces + * `${tracepoint}_entry` and then `${tracepoint}_exit` on scope exit. + * * - Q_UNCONDITIONAL_TRACE(tracepoint, args...) * Fires 'tracepoint' unconditionally: no check is performed to query * whether 'tracepoint' is enabled. @@ -110,15 +117,23 @@ */ #include <QtCore/qglobal.h> +#include <QtCore/qscopeguard.h> QT_BEGIN_NAMESPACE #if defined(Q_TRACEPOINT) && !defined(QT_BOOTSTRAPPED) # define Q_TRACE(x, ...) QtPrivate::trace_ ## x(__VA_ARGS__) +# define Q_TRACE_EXIT(x, ...) \ + const auto qTraceExit_ ## x ## __COUNTER__ = qScopeGuard([&]() { Q_TRACE(x, __VA_ARGS__); }); +# define Q_TRACE_SCOPE(x, ...) \ + Q_TRACE(x ## _entry, __VA_ARGS__); \ + Q_TRACE_EXIT(x ## _exit, __VA_ARGS__); # define Q_UNCONDITIONAL_TRACE(x, ...) QtPrivate::do_trace_ ## x(__VA_ARGS__) # define Q_TRACE_ENABLED(x) QtPrivate::trace_ ## x ## _enabled() #else # define Q_TRACE(x, ...) +# define Q_TRACE_EXIT(x, ...) +# define Q_TRACE_SCOPE(x, ...) # define Q_UNCONDITIONAL_TRACE(x, ...) # define Q_TRACE_ENABLED(x) false #endif // defined(Q_TRACEPOINT) && !defined(QT_BOOTSTRAPPED) |