forked from qt-creator/qt-creator
Nanotrace: Make nanotrace commonly usable
CMake's auto symbol export is a plain hack and does not work for other build systems. Besides fixing some non-working implicit conversions when using Qt5.15. Change-Id: I80b77a4ebf8cad30c78c1c2ef2034e62d2063399 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -206,12 +206,12 @@ void NodeInstanceClientProxy::writeCommand(const QVariant &command)
|
|||||||
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
||||||
NANOTRACE_INSTANT_ARGS("Sync", "writeCommand",
|
NANOTRACE_INSTANT_ARGS("Sync", "writeCommand",
|
||||||
{"name", cmd.name().toStdString()},
|
{"name", cmd.name().toStdString()},
|
||||||
{"counter", m_writeCommandCounter});
|
{"counter", int64_t(m_writeCommandCounter)});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NANOTRACE_INSTANT_ARGS("Update", "writeCommand",
|
NANOTRACE_INSTANT_ARGS("Update", "writeCommand",
|
||||||
{"name", command.typeName()},
|
{"name", command.typeName()},
|
||||||
{"counter", m_writeCommandCounter});
|
{"counter", int64_t(m_writeCommandCounter)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -409,14 +409,14 @@ void NodeInstanceClientProxy::readDataStream()
|
|||||||
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
||||||
NANOTRACE_INSTANT_ARGS("Sync", "readCommand",
|
NANOTRACE_INSTANT_ARGS("Sync", "readCommand",
|
||||||
{"name", cmd.name().toStdString()},
|
{"name", cmd.name().toStdString()},
|
||||||
{"counter", readCommandCounter});
|
{"counter", int64_t(readCommandCounter)});
|
||||||
// Do not dispatch this command.
|
// Do not dispatch this command.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NANOTRACE_INSTANT_ARGS("Update", "readCommand",
|
NANOTRACE_INSTANT_ARGS("Update", "readCommand",
|
||||||
{"name", command.typeName()},
|
{"name", command.typeName()},
|
||||||
{"counter", readCommandCounter});
|
{"counter", int64_t(readCommandCounter)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -7,6 +7,5 @@ add_qtc_library(Nanotrace
|
|||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_VISIBILITY_PRESET default
|
CXX_VISIBILITY_PRESET default
|
||||||
VISIBILITY_INLINES_HIDDEN OFF
|
VISIBILITY_INLINES_HIDDEN OFF
|
||||||
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -25,6 +25,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if defined(NANOTRACE_LIBRARY)
|
||||||
|
# define NANOTRACESHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define NANOTRACESHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -68,7 +77,7 @@ using Units = std::chrono::nanoseconds;
|
|||||||
using Clock = std::chrono::high_resolution_clock;
|
using Clock = std::chrono::high_resolution_clock;
|
||||||
using TimePoint = std::chrono::time_point< Clock >;
|
using TimePoint = std::chrono::time_point< Clock >;
|
||||||
|
|
||||||
class Arg
|
class NANOTRACESHARED_EXPORT Arg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using SupportedType = std::variant<int, int64_t, double, std::string>;
|
using SupportedType = std::variant<int, int64_t, double, std::string>;
|
||||||
@@ -82,19 +91,19 @@ private:
|
|||||||
SupportedType m_value;
|
SupportedType m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
void init(const std::string &process, const std::string &thread, const std::string &path);
|
NANOTRACESHARED_EXPORT void init(const std::string &process, const std::string &thread, const std::string &path);
|
||||||
|
|
||||||
void shutdown();
|
NANOTRACESHARED_EXPORT void shutdown();
|
||||||
|
|
||||||
void flush();
|
NANOTRACESHARED_EXPORT void flush();
|
||||||
|
|
||||||
void addTracePoint(
|
NANOTRACESHARED_EXPORT void addTracePoint(
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
const std::string &cat,
|
const std::string &cat,
|
||||||
char phase,
|
char phase,
|
||||||
std::initializer_list< Nanotrace::Arg > arguments);
|
std::initializer_list< Nanotrace::Arg > arguments);
|
||||||
|
|
||||||
class ScopeTracer
|
class NANOTRACESHARED_EXPORT ScopeTracer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopeTracer(
|
ScopeTracer(
|
||||||
|
@@ -2,7 +2,6 @@ QtcLibrary {
|
|||||||
name: "Nanotrace"
|
name: "Nanotrace"
|
||||||
|
|
||||||
cpp.defines: base.concat("NANOTRACE_LIBRARY", "NANOTRACE_ENABLED")
|
cpp.defines: base.concat("NANOTRACE_LIBRARY", "NANOTRACE_ENABLED")
|
||||||
cpp.visibility: "default"
|
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"nanotrace.cpp",
|
"nanotrace.cpp",
|
||||||
|
@@ -134,7 +134,7 @@ void BaseConnectionManager::readDataStream(Connection &connection)
|
|||||||
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
||||||
NANOTRACE_INSTANT_ARGS("Sync", "readCommand",
|
NANOTRACE_INSTANT_ARGS("Sync", "readCommand",
|
||||||
{"name", cmd.name().toStdString()},
|
{"name", cmd.name().toStdString()},
|
||||||
{"counter", commandCounter});
|
{"counter", int64_t(commandCounter)});
|
||||||
|
|
||||||
writeCommand(command);
|
writeCommand(command);
|
||||||
// Do not dispatch this command.
|
// Do not dispatch this command.
|
||||||
@@ -143,7 +143,7 @@ void BaseConnectionManager::readDataStream(Connection &connection)
|
|||||||
} else {
|
} else {
|
||||||
NANOTRACE_INSTANT_ARGS("Update", "readCommand",
|
NANOTRACE_INSTANT_ARGS("Update", "readCommand",
|
||||||
{"name", command.typeName()},
|
{"name", command.typeName()},
|
||||||
{"counter", commandCounter});
|
{"counter", int64_t(commandCounter)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -196,12 +196,12 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
|
|||||||
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>();
|
||||||
NANOTRACE_INSTANT_ARGS("Sync", "writeCommand",
|
NANOTRACE_INSTANT_ARGS("Sync", "writeCommand",
|
||||||
{"name", cmd.name().toStdString()},
|
{"name", cmd.name().toStdString()},
|
||||||
{"counter", m_connectionManager.writeCounter()});
|
{"counter", int64_t(m_connectionManager.writeCounter())});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NANOTRACE_INSTANT_ARGS("Update", "writeCommand",
|
NANOTRACE_INSTANT_ARGS("Update", "writeCommand",
|
||||||
{"name", command.typeName()},
|
{"name", command.typeName()},
|
||||||
{"counter", m_connectionManager.writeCounter()});
|
{"counter", int64_t(m_connectionManager.writeCounter())});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user