comphelper/source/misc/traceevent.cxx | 3 +-- include/comphelper/profilezone.hxx | 26 ++++++++++++++------------ include/comphelper/traceevent.hxx | 1 - 3 files changed, 15 insertions(+), 15 deletions(-)
New commits: commit b9c12bcf9b442e43fbc535c30caab513d07b9067 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue Apr 27 13:32:19 2021 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Thu Apr 29 10:38:01 2021 +0200 Re-think what the nesting means in ProfileZones The "Complete" type of Trace Events should be properly nested. Use the nesting counter to verify that. Add a nesting level indication to the ProfileZone object. Assert that it is used properly. Change-Id: I3a1f0e55ea6054dab9baf8550097446f07b0fbf3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114795 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx index 325ba59b131d..2cd2db829169 100644 --- a/comphelper/source/misc/traceevent.cxx +++ b/comphelper/source/misc/traceevent.cxx @@ -24,7 +24,7 @@ namespace comphelper { std::atomic<bool> TraceEvent::s_bRecording = false; -int TraceEvent::s_nNesting = 0; // level of overlapped zones +int ProfileZone::s_nNesting = 0; namespace { @@ -70,7 +70,6 @@ void TraceEvent::addInstantEvent(const char* sProfileId) void TraceEvent::startRecording() { ::osl::MutexGuard aGuard(g_aMutex); - s_nNesting = 0; s_bRecording = true; } diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx index b401ddbdc6be..767a00de08e0 100644 --- a/include/comphelper/profilezone.hxx +++ b/include/comphelper/profilezone.hxx @@ -20,11 +20,14 @@ namespace comphelper { class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent { + static int s_nNesting; // level of nested zones. + const char *m_sProfileId; long long m_nCreateTime; bool m_bConsole; void stopConsole(); int m_nPid; + int m_nNesting; void addRecording(); @@ -54,31 +57,30 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent TimeValue systemTime; osl_getSystemTime( &systemTime ); m_nCreateTime = static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec/1000; - } - else - m_nCreateTime = 0; - if (s_bRecording) - { oslProcessInfo aProcessInfo; aProcessInfo.Size = sizeof(oslProcessInfo); if (osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER, &aProcessInfo) == osl_Process_E_None) m_nPid = aProcessInfo.Ident; - s_nNesting++; + m_nNesting = s_nNesting++; } + else + m_nCreateTime = 0; } ~ProfileZone() { - if (s_bRecording) + if (m_nCreateTime > 0) { s_nNesting--; - addRecording(); - } - if (m_bConsole) - { - stopConsole(); + assert(m_nNesting == s_nNesting); + + if (s_bRecording) + addRecording(); + + if (m_bConsole) + stopConsole(); } } diff --git a/include/comphelper/traceevent.hxx b/include/comphelper/traceevent.hxx index 14e25da9b791..ff66a834e639 100644 --- a/include/comphelper/traceevent.hxx +++ b/include/comphelper/traceevent.hxx @@ -28,7 +28,6 @@ class COMPHELPER_DLLPUBLIC TraceEvent { protected: static std::atomic<bool> s_bRecording; // true during recording - static int s_nNesting; static void addRecording(const OUString& sObject); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits