Bug 1298541: Tracelogger: Part 1: Add debugging to check start and stop correspond, r=bbouvier

This commit is contained in:
Hannes Verschore 2016-09-02 18:19:27 +02:00
parent 64a98fc3b7
commit 4cd9e8a154
2 changed files with 30 additions and 0 deletions

View File

@ -491,6 +491,14 @@ TraceLoggerThread::startEvent(uint32_t id)
if (!traceLoggerState->isTextIdEnabled(id))
return;
#ifdef DEBUG
if (enabled > 0) {
AutoEnterOOMUnsafeRegion oomUnsafe;
if (!graphStack.append(id))
oomUnsafe.crash("Could not add item to debug stack.");
}
#endif
log(id);
}
@ -516,6 +524,23 @@ TraceLoggerThread::stopEvent(uint32_t id)
if (!traceLoggerState->isTextIdEnabled(id))
return;
#ifdef DEBUG
if (enabled > 0) {
uint32_t prev = graphStack.popCopy();
if (id == TraceLogger_Engine) {
MOZ_ASSERT(prev == TraceLogger_IonMonkey || prev == TraceLogger_Baseline ||
prev == TraceLogger_Interpreter);
} else if (id == TraceLogger_Scripts) {
MOZ_ASSERT(prev >= TraceLogger_Last);
} else if (id >= TraceLogger_Last) {
MOZ_ASSERT(prev >= TraceLogger_Last);
MOZ_ASSERT_IF(prev != id, strcmp(eventText(id), eventText(prev)) == 0);
} else {
MOZ_ASSERT(id == prev);
}
}
#endif
log(TraceLogger_Stop);
}

View File

@ -183,6 +183,11 @@ class TraceLoggerThread
// event.
uint32_t iteration_;
#ifdef DEBUG
typedef Vector<uint32_t, 1, js::SystemAllocPolicy > GraphStack;
GraphStack graphStack;
#endif
public:
AutoTraceLog* top;