summaryrefslogtreecommitdiff
path: root/include/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-04-27 13:32:19 +0300
committerTor Lillqvist <tml@collabora.com>2021-04-28 16:32:28 +0200
commit969ddb6899b453194001e6743cc4d8003d5b050a (patch)
tree5813cf0745778c0b5ec69101baa3e855b0af27d8 /include/comphelper
parentd57ac8ff9c0b4ec8706d1d64c4a0ee9eb23de66c (diff)
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/+/114735 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/profilezone.hxx26
-rw-r--r--include/comphelper/traceevent.hxx1
2 files changed, 14 insertions, 13 deletions
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 32dc02e14f74..dec5b35928bc 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,32 +57,31 @@ public:
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);