summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-06 01:00:07 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-06 01:00:08 +0200
commitce7f14d2e0791acc92622fdc23886a06d6712e90 (patch)
tree5f2b0f0a6c4a37dfaa1f31abf7e58d8a3cec1e3c /src
parent0998a9d1d53361e572d7377af8cb41a49bbfad72 (diff)
parentf4c41b9797f08f173049502fa7bd465cf5bde938 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qlogging.cpp3
-rw-r--r--src/corelib/global/qtrace_p.h17
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp9
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/corelib/qtcore.tracepoints10
-rw-r--r--src/corelib/tools/qstring.cpp4
-rw-r--r--src/gui/image/qpnghandler.cpp8
-rw-r--r--src/gui/kernel/qguiapplication.cpp8
-rw-r--r--src/gui/painting/qbrush.cpp4
-rw-r--r--src/gui/qtgui.tracepoints6
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp88
-rw-r--r--src/tools/tracegen/etw.cpp27
-rw-r--r--src/tools/tracegen/lttng.cpp17
-rw-r--r--src/tools/tracegen/provider.cpp19
-rw-r--r--src/tools/tracegen/provider.h1
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--src/widgets/qtwidgets.tracepoints7
17 files changed, 167 insertions, 71 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)
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 1809861fc6..c2c3b2702b 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -86,15 +86,6 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u
#endif
}
-static inline QString displayName(QStandardPaths::StandardLocation type)
-{
-#ifndef QT_BOOTSTRAPPED
- return QStandardPaths::displayName(type);
-#else
- return QString::number(type);
-#endif
-}
-
static inline void appendTestMode(QString &path)
{
if (QStandardPaths::isTestModeEnabled())
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2250f91dc3..30994d3056 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -778,7 +778,7 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
void QCoreApplicationPrivate::init()
{
- Q_TRACE(QCoreApplicationPrivate_init_entry);
+ Q_TRACE_SCOPE(QCoreApplicationPrivate_init);
#if defined(Q_OS_MACOS)
QMacAutoReleasePool pool;
@@ -883,8 +883,6 @@ void QCoreApplicationPrivate::init()
#ifndef QT_NO_QOBJECT
is_app_running = true; // No longer starting up.
#endif
-
- Q_TRACE(QCoreApplicationPrivate_init_exit);
}
/*!
@@ -1199,7 +1197,7 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event)
{
// Note: when adjusting the tracepoints in here
// consider adjusting QApplicationPrivate::notify_helper too.
- Q_TRACE(QCoreApplication_notify_entry, receiver, event, event->type());
+ Q_TRACE_SCOPE(QCoreApplication_notify, receiver, event, event->type());
// send to all application event filters (only does anything in the main thread)
if (QCoreApplication::self
@@ -1498,7 +1496,7 @@ bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event)
*/
void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
{
- Q_TRACE(QCoreApplication_postEvent_entry, receiver, event, event->type());
+ Q_TRACE_SCOPE(QCoreApplication_postEvent, receiver, event, event->type());
if (receiver == 0) {
qWarning("QCoreApplication::postEvent: Unexpected null receiver");
diff --git a/src/corelib/qtcore.tracepoints b/src/corelib/qtcore.tracepoints
index 33734a4274..3a70136741 100644
--- a/src/corelib/qtcore.tracepoints
+++ b/src/corelib/qtcore.tracepoints
@@ -1,3 +1,9 @@
+{
+QT_BEGIN_NAMESPACE
+class QEvent;
+QT_END_NAMESPACE
+}
+
QCoreApplicationPrivate_init_entry()
QCoreApplicationPrivate_init_exit()
@@ -10,6 +16,7 @@ QEvent_ctor(QEvent *event, int type)
QEvent_dtor(QEvent *event, int type)
QCoreApplication_postEvent_entry(QObject *receiver, QEvent *event, int type)
+QCoreApplication_postEvent_exit(QObject *receiver, QEvent *event, int type)
QCoreApplication_postEvent_event_compressed(QObject *receiver, QEvent *event)
QCoreApplication_postEvent_event_posted(QObject *receiver, QEvent *event, int type)
@@ -17,6 +24,7 @@ QCoreApplication_sendEvent(QObject *receiver, QEvent *event, int type)
QCoreApplication_sendSpontaneousEvent(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_entry(QObject *receiver, QEvent *event, int type)
+QCoreApplication_notify_exit(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_event_filtered(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_before_delivery(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_after_delivery(QObject *receiver, QEvent *event, int type, bool consumed)
@@ -32,3 +40,5 @@ QMetaObject_activate_begin_slot_functor(void *slotObject)
QMetaObject_activate_end_slot_functor(void *slotObject)
QMetaObject_activate_begin_declarative_signal(QObject *sender, int signalIndex)
QMetaObject_activate_end_declarative_signal(QObject *sender, int signalIndex)
+
+qt_message_print(int type, const char *category, const char *function, const char *file, int line, const QString &message)
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 9d6e0cbdd8..a123aa8e75 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -501,7 +501,11 @@ bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW
while (ptr + 4 <= end) {
quint32 data = qFromUnaligned<quint32>(ptr);
if (data &= 0x80808080U) {
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ uint idx = qCountLeadingZeroBits(data);
+#else
uint idx = qCountTrailingZeroBits(data);
+#endif
ptr += idx / 8;
return false;
}
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 140196004b..1c269213e2 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -231,8 +231,8 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal
if (screen_gamma != 0.0 && file_gamma != 0.0)
png_set_gamma(png_ptr, 1.0f / screen_gamma, file_gamma);
- png_uint_32 width;
- png_uint_32 height;
+ png_uint_32 width = 0;
+ png_uint_32 height = 0;
int bit_depth = 0;
int color_type = 0;
png_bytep trans_alpha = 0;
@@ -240,7 +240,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal
int num_trans;
png_colorp palette = 0;
int num_palette;
- int interlace_method;
+ int interlace_method = PNG_INTERLACE_LAST;
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, 0, 0);
png_set_interlace_handling(png_ptr);
@@ -689,7 +689,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage)
QImage::Format QPngHandlerPrivate::readImageFormat()
{
QImage::Format format = QImage::Format_Invalid;
- png_uint_32 width, height;
+ png_uint_32 width = 0, height = 0;
int bit_depth = 0, color_type = 0;
png_colorp palette;
int num_palette;
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 4e0c45d8ae..3a93b09941 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1425,7 +1425,7 @@ void QGuiApplicationPrivate::eventDispatcherReady()
void QGuiApplicationPrivate::init()
{
- Q_TRACE(QGuiApplicationPrivate_init_entry);
+ Q_TRACE_SCOPE(QGuiApplicationPrivate_init);
#if defined(Q_OS_MACOS)
QMacAutoReleasePool pool;
@@ -1589,8 +1589,6 @@ void QGuiApplicationPrivate::init()
if (!QGuiApplicationPrivate::displayName)
QObject::connect(q, &QGuiApplication::applicationNameChanged,
q, &QGuiApplication::applicationDisplayNameChanged);
-
- Q_TRACE(QGuiApplicationPrivate_init_exit);
}
extern void qt_cleanupFontDatabase();
@@ -1834,7 +1832,7 @@ bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArra
void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
{
- Q_TRACE(QGuiApplicationPrivate_processWindowSystemEvent_entry, e->type);
+ Q_TRACE_SCOPE(QGuiApplicationPrivate_processWindowSystemEvent, e->type);
switch(e->type) {
case QWindowSystemInterfacePrivate::Mouse:
@@ -1944,8 +1942,6 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
qWarning() << "Unknown user input event type:" << e->type;
break;
}
-
- Q_TRACE(QGuiApplicationPrivate_processWindowSystemEvent_exit, e->type);
}
/*! \internal
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index ed575abf54..f56be55325 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -1378,10 +1378,8 @@ QGradient::QGradient(Preset preset)
}();
const QJsonValue presetData = jsonPresets[preset - 1];
- if (!presetData.isObject()) {
- qWarning("QGradient: Undefined preset %i", preset);
+ if (!presetData.isObject())
return;
- }
m_type = LinearGradient;
setCoordinateMode(ObjectMode);
diff --git a/src/gui/qtgui.tracepoints b/src/gui/qtgui.tracepoints
index aed6c35c03..0a96a589b1 100644
--- a/src/gui/qtgui.tracepoints
+++ b/src/gui/qtgui.tracepoints
@@ -1,3 +1,9 @@
+{
+QT_BEGIN_NAMESPACE
+class QImageReader;
+QT_END_NAMESPACE
+}
+
QGuiApplicationPrivate_init_entry()
QGuiApplicationPrivate_init_exit()
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 1b17759b5f..ba441a1921 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -569,12 +569,10 @@ public:
bool isFileSystem() const { return (m_attributes & SFGAO_FILESYSTEM) != 0; }
bool isDir() const { return (m_attributes & SFGAO_FOLDER) != 0; }
- // Copy using IFileOperation
- bool canCopy() const { return (m_attributes & SFGAO_CANCOPY) != 0; }
// Supports IStream
bool canStream() const { return (m_attributes & SFGAO_STREAM) != 0; }
- bool copyData(QIODevice *out);
+ bool copyData(QIODevice *out, QString *errorMessage);
static IShellItems itemsFromItemArray(IShellItemArray *items);
@@ -666,14 +664,19 @@ QWindowsShellItem::IShellItems QWindowsShellItem::itemsFromItemArray(IShellItemA
return result;
}
-bool QWindowsShellItem::copyData(QIODevice *out)
+bool QWindowsShellItem::copyData(QIODevice *out, QString *errorMessage)
{
- if (!canCopy() || !canStream())
+ if (!canStream()) {
+ *errorMessage = QLatin1String("Item not streamable");
return false;
+ }
IStream *istream = nullptr;
HRESULT hr = m_item->BindToHandler(nullptr, BHID_Stream, IID_PPV_ARGS(&istream));
- if (FAILED(hr))
+ if (FAILED(hr)) {
+ *errorMessage = QLatin1String("BindToHandler() failed: ")
+ + QLatin1String(QWindowsContext::comErrorString(hr));
return false;
+ }
enum : ULONG { bufSize = 102400 };
char buffer[bufSize];
ULONG bytesRead;
@@ -686,7 +689,12 @@ bool QWindowsShellItem::copyData(QIODevice *out)
break;
}
istream->Release();
- return hr == S_OK || hr == S_FALSE;
+ if (hr != S_OK && hr != S_FALSE) {
+ *errorMessage = QLatin1String("Read() failed: ")
+ + QLatin1String(QWindowsContext::comErrorString(hr));
+ return false;
+ }
+ return true;
}
// Helper for "Libraries": collections of folders appearing from Windows 7
@@ -735,8 +743,6 @@ void QWindowsShellItem::format(QDebug &d) const
d << " [dir]";
if (canStream())
d << " [stream]";
- if (canCopy())
- d << " [copyable]";
d << ", normalDisplay=\"" << normalDisplay()
<< "\", desktopAbsoluteParsing=\"" << desktopAbsoluteParsing()
<< "\", urlString=\"" << urlString() << "\", fileSysPath=\"" << fileSysPath() << '"';
@@ -1395,21 +1401,50 @@ static void cleanupTemporaryItemCopies()
QFile::remove(file);
}
-static QString createTemporaryItemCopy(QWindowsShellItem &qItem)
+// Determine temporary file pattern from a shell item's display
+// name. This can be a URL.
+
+static bool validFileNameCharacter(QChar c)
{
- if (!qItem.canCopy() || !qItem.canStream())
+ return c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('-');
+}
+
+QString tempFilePattern(QString name)
+{
+ const int lastSlash = qMax(name.lastIndexOf(QLatin1Char('/')),
+ name.lastIndexOf(QLatin1Char('\\')));
+ if (lastSlash != -1)
+ name.remove(0, lastSlash + 1);
+
+ int lastDot = name.lastIndexOf(QLatin1Char('.'));
+ if (lastDot < 0)
+ lastDot = name.size();
+ name.insert(lastDot, QStringLiteral("_XXXXXX"));
+
+ for (int i = lastDot - 1; i >= 0; --i) {
+ if (!validFileNameCharacter(name.at(i)))
+ name[i] = QLatin1Char('_');
+ }
+
+ name.prepend(QDir::tempPath() + QLatin1Char('/'));
+ return name;
+}
+
+static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorMessage)
+{
+ if (!qItem.canStream()) {
+ *errorMessage = QLatin1String("Item not streamable");
return QString();
- QString pattern = qItem.normalDisplay();
- const int lastDot = pattern.lastIndexOf(QLatin1Char('.'));
- const QString placeHolder = QStringLiteral("_XXXXXX");
- if (lastDot >= 0)
- pattern.insert(lastDot, placeHolder);
- else
- pattern.append(placeHolder);
-
- QTemporaryFile targetFile(QDir::tempPath() + QLatin1Char('/') + pattern);
+ }
+
+ QTemporaryFile targetFile(tempFilePattern(qItem.normalDisplay()));
targetFile.setAutoRemove(false);
- if (!targetFile.open() || !qItem.copyData(&targetFile))
+ if (!targetFile.open()) {
+ *errorMessage = QLatin1String("Cannot create temporary file: ")
+ + targetFile.errorString();
+ return QString();
+ }
+ if (!qItem.copyData(&targetFile, errorMessage))
return QString();
const QString result = targetFile.fileName();
if (temporaryItemCopies()->isEmpty())
@@ -1427,11 +1462,14 @@ QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
QWindowsShellItem qItem(item);
const QString path = qItem.path();
if (path.isEmpty() && !qItem.isDir()) {
- const QString temporaryCopy = createTemporaryItemCopy(qItem);
- if (temporaryCopy.isEmpty())
- qWarning() << "Unable to create a local copy of" << qItem;
- else
+ QString errorMessage;
+ const QString temporaryCopy = createTemporaryItemCopy(qItem, &errorMessage);
+ if (temporaryCopy.isEmpty()) {
+ qWarning().noquote() << "Unable to create a local copy of" << qItem
+ << ": " << errorMessage;
+ } else {
result.append(QUrl::fromLocalFile(temporaryCopy));
+ }
} else {
result.append(qItem.url());
}
diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp
index 8c065f93c9..e839137915 100644
--- a/src/tools/tracegen/etw.cpp
+++ b/src/tools/tracegen/etw.cpp
@@ -110,19 +110,21 @@ static QString createGuid(const QUuid &uuid)
return guid;
}
-static void writePrologue(QTextStream &stream, const QString &fileName, const QString &providerName)
+static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
- QUuid uuid = QUuid::createUuidV5(QUuid(), providerName.toLocal8Bit());
+ QUuid uuid = QUuid::createUuidV5(QUuid(), provider.name.toLocal8Bit());
- const QString provider = providerVar(providerName);
+ const QString providerV = providerVar(provider.name);
const QString guard = includeGuard(fileName);
const QString guid = createGuid(uuid);
const QString guidString = uuid.toString();
stream << "#ifndef " << guard << "\n"
<< "#define " << guard << "\n"
+ << "\n"
<< "#include <windows.h>\n"
- << "#include <TraceLoggingProvider.h>\n";
+ << "#include <TraceLoggingProvider.h>\n"
+ << "\n";
/* TraceLogging API macros cannot deal with UTF8
* source files, so we work around it like this
@@ -132,30 +134,33 @@ static void writePrologue(QTextStream &stream, const QString &fileName, const QS
"#define _TlgPragmaUtf8Begin\n"
"#define _TlgPragmaUtf8End\n";
+ stream << "\n";
stream << qtHeaders();
-
stream << "\n";
+ if (!provider.prefixText.isEmpty())
+ stream << provider.prefixText.join(QLatin1Char('\n')) << "\n\n";
+
stream << "#ifdef TRACEPOINT_DEFINE\n"
<< "/* " << guidString << " */\n"
- << "TRACELOGGING_DEFINE_PROVIDER(" << provider << ", \""
- << providerName <<"\", " << guid << ");\n\n";
+ << "TRACELOGGING_DEFINE_PROVIDER(" << providerV << ", \""
+ << provider.name <<"\", " << guid << ");\n\n";
stream << "static inline void registerProvider()\n"
<< "{\n"
- << " TraceLoggingRegister(" << provider << ");\n"
+ << " TraceLoggingRegister(" << providerV << ");\n"
<< "}\n\n";
stream << "static inline void unregisterProvider()\n"
<< "{\n"
- << " TraceLoggingUnregister(" << provider << ");\n"
+ << " TraceLoggingUnregister(" << providerV << ");\n"
<< "}\n";
stream << "Q_CONSTRUCTOR_FUNCTION(registerProvider)\n"
<< "Q_DESTRUCTOR_FUNCTION(unregisterProvider)\n\n";
stream << "#else\n"
- << "TRACELOGGING_DECLARE_PROVIDER(" << provider << ");\n"
+ << "TRACELOGGING_DECLARE_PROVIDER(" << providerV << ");\n"
<< "#endif // TRACEPOINT_DEFINE\n\n";
}
@@ -224,7 +229,7 @@ void writeEtw(QFile &file, const Provider &provider)
const QString fileName = QFileInfo(file.fileName()).fileName();
- writePrologue(stream, fileName, provider.name);
+ writePrologue(stream, fileName, provider);
writeTracepoints(stream, provider);
writeEpilogue(stream, fileName);
}
diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp
index 5d41bf5f1f..f0fbca9e16 100644
--- a/src/tools/tracegen/lttng.cpp
+++ b/src/tools/tracegen/lttng.cpp
@@ -104,16 +104,21 @@ static void writeCtfMacro(QTextStream &stream, const Tracepoint::Field &field)
}
}
-static void writePrologue(QTextStream &stream, const QString &fileName, const QString &providerName)
+static void writePrologue(QTextStream &stream, const QString &fileName, const Provider &provider)
{
+ const QString guard = includeGuard(fileName);
+
stream << "#undef TRACEPOINT_PROVIDER\n";
- stream << "#define TRACEPOINT_PROVIDER " << providerName << "\n\n";
+ stream << "#define TRACEPOINT_PROVIDER " << provider.name << "\n";
+ stream << "\n";
+ // include prefix text or qt headers only once
+ stream << "#if !defined(" << guard << ")\n";
stream << qtHeaders();
-
- const QString guard = includeGuard(fileName);
-
stream << "\n";
+ if (!provider.prefixText.isEmpty())
+ stream << provider.prefixText.join(QLatin1Char('\n')) << "\n\n";
+ stream << "#endif\n\n";
/* the first guard is the usual one, the second is required
* by LTTNG to force the re-evaluation of TRACEPOINT_* macros
@@ -213,7 +218,7 @@ void writeLttng(QFile &file, const Provider &provider)
const QString fileName = QFileInfo(file.fileName()).fileName();
- writePrologue(stream, fileName, provider.name);
+ writePrologue(stream, fileName, provider);
writeTracepoints(stream, provider);
writeEpilogue(stream, fileName);
}
diff --git a/src/tools/tracegen/provider.cpp b/src/tools/tracegen/provider.cpp
index a6523a2e3d..39633efe5d 100644
--- a/src/tools/tracegen/provider.cpp
+++ b/src/tools/tracegen/provider.cpp
@@ -275,9 +275,21 @@ Provider parseProvider(const QString &filename)
Provider provider;
provider.name = QFileInfo(filename).baseName();
+ bool parsingPrefixText = false;
for (int lineNumber = 1; !s.atEnd(); ++lineNumber) {
QString line = s.readLine().trimmed();
+ if (line == QLatin1String("{")) {
+ parsingPrefixText = true;
+ continue;
+ } else if (parsingPrefixText && line == QLatin1String("}")) {
+ parsingPrefixText = false;
+ continue;
+ } else if (parsingPrefixText) {
+ provider.prefixText.append(line);
+ continue;
+ }
+
if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
continue;
@@ -296,7 +308,14 @@ Provider parseProvider(const QString &filename)
}
}
+ if (parsingPrefixText) {
+ panic("Syntax error while processing '%s': "
+ "no closing brace found for prefix text block",
+ qPrintable(filename));
+ }
+
#ifdef TRACEGEN_DEBUG
+ qDebug() << provider.prefixText;
for (auto i = provider.tracepoints.constBegin(); i != provider.tracepoints.constEnd(); ++i)
dumpTracepoint(*i);
#endif
diff --git a/src/tools/tracegen/provider.h b/src/tools/tracegen/provider.h
index 9771e62f4d..9be0c33d89 100644
--- a/src/tools/tracegen/provider.h
+++ b/src/tools/tracegen/provider.h
@@ -86,6 +86,7 @@ struct Provider
{
QString name;
QVector<Tracepoint> tracepoints;
+ QStringList prefixText;
};
Provider parseProvider(const QString &filename);
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 7c44bfe39d..0ab9ed6ec2 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3700,7 +3700,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
// to the ones in QCoreApplicationPrivate::notify_helper; the reason for their
// duplication is because tracepoint symbols are not exported by QtCore.
// If you adjust the tracepoints here, consider adjusting QCoreApplicationPrivate too.
- Q_TRACE(QApplication_notify_entry, receiver, e, e->type());
+ Q_TRACE_SCOPE(QApplication_notify, receiver, e, e->type());
// send to all application event filters
if (threadRequiresCoreApplication()
diff --git a/src/widgets/qtwidgets.tracepoints b/src/widgets/qtwidgets.tracepoints
index 01a1383670..9c40cdb3e7 100644
--- a/src/widgets/qtwidgets.tracepoints
+++ b/src/widgets/qtwidgets.tracepoints
@@ -1,4 +1,11 @@
+{
+QT_BEGIN_NAMESPACE
+class QEvent;
+QT_END_NAMESPACE
+}
+
QApplication_notify_entry(QObject *receiver, QEvent *event, int type)
+QApplication_notify_exit(QObject *receiver, QEvent *event, int type)
QApplication_notify_event_filtered(QObject *receiver, QEvent *event, int type)
QApplication_notify_before_delivery(QObject *receiver, QEvent *event, int type)
QApplication_notify_after_delivery(QObject *receiver, QEvent *event, int type, bool consumed)