Bug 1231170: TraceLogger - Use size in debugger instead of the current id to track last logged item, r=bbouvier

This commit is contained in:
Hannes Verschore 2015-12-18 18:32:24 -05:00
parent ca592eaae5
commit 9d7265ff77
4 changed files with 23 additions and 20 deletions

View File

@ -0,0 +1,3 @@
var du = new Debugger();
if (typeof du.drainTraceLogger === "function")
du.drainTraceLogger();

View File

@ -377,10 +377,10 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
objects(cx),
environments(cx),
#ifdef NIGHTLY_BUILD
traceLoggerLastDrainedId(0),
traceLoggerLastDrainedSize(0),
traceLoggerLastDrainedIteration(0),
#endif
traceLoggerScriptedCallsLastDrainedId(0),
traceLoggerScriptedCallsLastDrainedSize(0),
traceLoggerScriptedCallsLastDrainedIteration(0)
{
assertSameCompartment(cx, dbg);
@ -4402,9 +4402,9 @@ Debugger::drainTraceLogger(JSContext* cx, unsigned argc, Value* vp)
size_t num;
TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
bool lostEvents = logger->lostEvents(dbg->traceLoggerLastDrainedIteration,
dbg->traceLoggerLastDrainedId);
dbg->traceLoggerLastDrainedSize);
EventEntry* events = logger->getEventsStartingAt(&dbg->traceLoggerLastDrainedIteration,
&dbg->traceLoggerLastDrainedId,
&dbg->traceLoggerLastDrainedSize,
&num);
RootedObject array(cx, NewDenseEmptyArray(cx));
@ -4497,10 +4497,10 @@ Debugger::drainTraceLoggerScriptCalls(JSContext* cx, unsigned argc, Value* vp)
size_t num;
TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
bool lostEvents = logger->lostEvents(dbg->traceLoggerScriptedCallsLastDrainedIteration,
dbg->traceLoggerScriptedCallsLastDrainedId);
dbg->traceLoggerScriptedCallsLastDrainedSize);
EventEntry* events = logger->getEventsStartingAt(
&dbg->traceLoggerScriptedCallsLastDrainedIteration,
&dbg->traceLoggerScriptedCallsLastDrainedId,
&dbg->traceLoggerScriptedCallsLastDrainedSize,
&num);
RootedObject array(cx, NewDenseEmptyArray(cx));

View File

@ -448,10 +448,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
* lost events.
*/
#ifdef NIGHTLY_BUILD
uint32_t traceLoggerLastDrainedId;
uint32_t traceLoggerLastDrainedSize;
uint32_t traceLoggerLastDrainedIteration;
#endif
uint32_t traceLoggerScriptedCallsLastDrainedId;
uint32_t traceLoggerScriptedCallsLastDrainedSize;
uint32_t traceLoggerScriptedCallsLastDrainedIteration;
class FrameRange;

View File

@ -208,22 +208,22 @@ class TraceLoggerThread
bool fail(JSContext* cx, const char* error);
public:
// Given the previous iteration and lastEntryId, return an array of events
// Given the previous iteration and size, return an array of events
// (there could be lost events). At the same time update the iteration and
// lastEntry and gives back how many events there are.
EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastEntryId, size_t* num) {
// size and gives back how many events there are.
EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastSize, size_t* num) {
EventEntry* start;
if (iteration_ == *lastIteration) {
MOZ_ASSERT(*lastEntryId < events.size());
*num = events.lastEntryId() - *lastEntryId;
start = events.data() + *lastEntryId + 1;
MOZ_ASSERT(*lastSize <= events.size());
*num = events.size() - *lastSize;
start = events.data() + *lastSize;
} else {
*num = events.size();
start = events.data();
}
*lastIteration = iteration_;
*lastEntryId = events.lastEntryId();
*lastSize = events.size();
return start;
}
@ -233,16 +233,16 @@ class TraceLoggerThread
const char** lineno, size_t* lineno_len, const char** colno,
size_t* colno_len);
bool lostEvents(uint32_t lastIteration, uint32_t lastEntryId) {
bool lostEvents(uint32_t lastIteration, uint32_t lastSize) {
// If still logging in the same iteration, there are no lost events.
if (lastIteration == iteration_) {
MOZ_ASSERT(lastEntryId < events.size());
MOZ_ASSERT(lastSize <= events.size());
return false;
}
// When proceeded to the next iteration and lastEntryId points to
// the maximum capacity there are no logs that are lost.
if (lastIteration + 1 == iteration_ && lastEntryId == events.capacity())
// If we are in a consecutive iteration we are only sure we didn't lose any events,
// when the lastSize equals the maximum size 'events' can get.
if (lastIteration == iteration_ - 1 && lastSize == CONTINUOUSSPACE_LIMIT)
return false;
return true;