diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-04-27 13:32:19 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-04-29 14:12:53 +0200 |
commit | 7afd3d08093371e797506c6b75223d0c2bead352 (patch) | |
tree | 9345f378677b2a8424d2519682bb4734ff017df2 | |
parent | Move some static functions from ProfileZone to TraceEvent where they belong (diff) | |
download | core-7afd3d08093371e797506c6b75223d0c2bead352.tar.gz core-7afd3d08093371e797506c6b75223d0c2bead352.zip |
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/+/114781
Tested-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r-- | comphelper/source/misc/traceevent.cxx | 3 | ||||
-rw-r--r-- | include/comphelper/profilezone.hxx | 12 | ||||
-rw-r--r-- | include/comphelper/traceevent.hxx | 1 |
3 files changed, 10 insertions, 6 deletions
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx index 59191884374c..30bc3d51e2d8 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 cb5e32547d7c..de38a0dad985 100644 --- a/include/comphelper/profilezone.hxx +++ b/include/comphelper/profilezone.hxx @@ -21,9 +21,12 @@ namespace comphelper class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent { + static int s_nNesting; // level of nested zones. + const char *m_sProfileId; long long m_nCreateTime; int m_nPid; + int m_nNesting; void addRecording(); @@ -46,7 +49,7 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent 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; @@ -54,10 +57,13 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent ~ProfileZone() { - if (s_bRecording) + if (m_nCreateTime > 0) { s_nNesting--; - addRecording(); + assert(m_nNesting == s_nNesting); + + if (s_bRecording) + addRecording(); } } 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); |