summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-06-17 13:31:27 +0300
committerTor Lillqvist <tml@iki.fi>2021-06-21 12:43:17 +0300
commitd6569159b7afc5b9453bfe61f1e0b0c42c8954b7 (patch)
tree5e63976a73e15f8d2507f9c93ef2f49cdce828db /common
parentGuard against multiple threads writing to the Trace Event log file (diff)
downloadonline-d6569159b7afc5b9453bfe61f1e0b0c42c8954b7.tar.gz
online-d6569159b7afc5b9453bfe61f1e0b0c42c8954b7.zip
Output a Trace Event metadata event identifying each named thread
Move the generic dummy implementation of TraceEvent::emitOneRecording() to a source file of its own. (That is the one which is used in test and tool executables.) Signed-off-by: Tor Lillqvist <tml@collabora.com> Change-Id: I81cab07e5a6852b42d278a5446c13c3825cf546e
Diffstat (limited to 'common')
-rw-r--r--common/DummyTraceEventEmitter.cpp18
-rw-r--r--common/TraceEvent.hpp8
-rw-r--r--common/Util.cpp11
3 files changed, 33 insertions, 4 deletions
diff --git a/common/DummyTraceEventEmitter.cpp b/common/DummyTraceEventEmitter.cpp
new file mode 100644
index 0000000000..cb1d0dc2fb
--- /dev/null
+++ b/common/DummyTraceEventEmitter.cpp
@@ -0,0 +1,18 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+// Compile and link this into test and utility executables that need it to link
+
+#include <common/TraceEvent.hpp>
+
+void TraceEvent::emitOneRecording(const std::string &recording)
+{
+ // Dummy.
+ (void) recording;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/TraceEvent.hpp b/common/TraceEvent.hpp
index 7e2fc3ac49..8780bb24e7 100644
--- a/common/TraceEvent.hpp
+++ b/common/TraceEvent.hpp
@@ -102,10 +102,6 @@ protected:
}
}
- // This method needs to be implemented separately in the WSD and Kit processes. (WSD writes the
- // actual Trace Event log file, Kit just forwards the Trace Events to WSD for output.)
- static void emitOneRecording(const std::string &recording);
-
public:
static void startRecording();
static void stopRecording();
@@ -120,6 +116,10 @@ public:
emitInstantEvent(name, createArgsString(args));
}
+ // This method needs to be implemented separately in the WSD and Kit processes. (WSD writes the
+ // actual Trace Event log file, Kit just forwards the Trace Events to WSD for output.)
+ static void emitOneRecording(const std::string &recording);
+
TraceEvent(const TraceEvent&) = delete;
void operator=(const TraceEvent&) = delete;
};
diff --git a/common/Util.cpp b/common/Util.cpp
index 5af9d6b4e2..15875e16db 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -62,6 +62,7 @@
#include "Common.hpp"
#include "Log.hpp"
#include "Protocol.hpp"
+#include "TraceEvent.hpp"
namespace Util
{
@@ -573,6 +574,16 @@ namespace Util
[[NSThread currentThread] setName:[NSString stringWithUTF8String:ThreadName]];
LOG_INF("Thread " << getThreadId() << ") is now called [" << s << ']');
#endif
+
+ // Emit a metadata Trace Event identifying this thread. This will invoke a different function
+ // depending on which executable this is in.
+ TraceEvent::emitOneRecording("{\"name\":\"thread_name\",\"ph\":\"M\",\"args\":{\"name\":\""
+ + s
+ + "\"},\"pid\":"
+ + std::to_string(getpid())
+ + ",\"tid\":"
+ + std::to_string(Util::getThreadId())
+ + "},");
}
const char *getThreadName()