Ticket #3708: Bug_1231170_Mod.diff

File Bug_1231170_Mod.diff, 7.5 KB (added by Yves, 8 years ago)

Actually this one has to be modified too

  • new file js/src/jit-test/tests/tracelogger/bug1231170.js

    # HG changeset patch
    # User Hannes Verschore <hv1989@gmail.com>
    # Date 1450481544 18000
    # Node ID 6bc6cbcf117e2e230ab189c5d3f244f30a294232
    # Parent  e33b2a6d17d48e38f0a6f67ce1e4e65d73ed797e
    Bug 1231170: TraceLogger - Use size in debugger instead of the current id to track last logged item, r=bbouvier
    
    diff --git a/js/src/jit-test/tests/tracelogger/bug1231170.js b/js/src/jit-test/tests/tracelogger/bug1231170.js
    new file mode 100644
    - +  
     1var du = new Debugger();
     2if (typeof du.drainTraceLogger === "function")
     3    du.drainTraceLogger();
  • js/src/vm/Debugger.cpp

    diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp
    a b Debugger::Debugger(JSContext* cx, Native  
    372372    maxAllocationsLogLength(DEFAULT_MAX_LOG_LENGTH),
    373373    allocationsLogOverflowed(false),
    374374    frames(cx->runtime()),
    375375    scripts(cx),
    376376    sources(cx),
    377377    objects(cx),
    378378    environments(cx),
    379379#ifdef NIGHTLY_BUILD
    380     traceLoggerLastDrainedId(0),
     380    traceLoggerLastDrainedSize(0),
    381381    traceLoggerLastDrainedIteration(0),
    382382#endif
    383     traceLoggerScriptedCallsLastDrainedId(0),
     383    traceLoggerScriptedCallsLastDrainedSize(0),
    384384    traceLoggerScriptedCallsLastDrainedIteration(0)
    385385{
    386386    assertSameCompartment(cx, dbg);
    387387
    388388    cx->runtime()->debuggerList.insertBack(this);
    389389    JS_INIT_CLIST(&breakpoints);
    390390    JS_INIT_CLIST(&onNewGlobalObjectWatchersLink);
    391391}
    Debugger::drainTraceLogger(JSContext* cx  
    43974397{
    43984398    THIS_DEBUGGER(cx, argc, vp, "drainTraceLogger", args, dbg);
    43994399    if (!args.requireAtLeast(cx, "Debugger.drainTraceLogger", 0))
    44004400        return false;
    44014401
    44024402    size_t num;
    44034403    TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
    44044404    bool lostEvents = logger->lostEvents(dbg->traceLoggerLastDrainedIteration,
    4405                                          dbg->traceLoggerLastDrainedId);
     4405                                         dbg->traceLoggerLastDrainedSize);
    44064406    EventEntry* events = logger->getEventsStartingAt(&dbg->traceLoggerLastDrainedIteration,
    4407                                                      &dbg->traceLoggerLastDrainedId,
     4407                                                     &dbg->traceLoggerLastDrainedSize,
    44084408                                                     &num);
    44094409
    44104410    RootedObject array(cx, NewDenseEmptyArray(cx));
    44114411    JSAtom* dataAtom = Atomize(cx, "data", strlen("data"));
    44124412    if (!dataAtom)
    44134413        return false;
    44144414    RootedId dataId(cx, AtomToId(dataAtom));
    44154415
    Debugger::drainTraceLoggerScriptCalls(JS  
    44924492{
    44934493    THIS_DEBUGGER(cx, argc, vp, "drainTraceLoggerScriptCalls", args, dbg);
    44944494    if (!args.requireAtLeast(cx, "Debugger.drainTraceLoggerScriptCalls", 0))
    44954495        return false;
    44964496
    44974497    size_t num;
    44984498    TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
    44994499    bool lostEvents = logger->lostEvents(dbg->traceLoggerScriptedCallsLastDrainedIteration,
    4500                                          dbg->traceLoggerScriptedCallsLastDrainedId);
     4500                                         dbg->traceLoggerScriptedCallsLastDrainedSize);
    45014501    EventEntry* events = logger->getEventsStartingAt(
    45024502                                         &dbg->traceLoggerScriptedCallsLastDrainedIteration,
    4503                                          &dbg->traceLoggerScriptedCallsLastDrainedId,
     4503                                         &dbg->traceLoggerScriptedCallsLastDrainedSize,
    45044504                                         &num);
    45054505
    45064506    RootedObject array(cx, NewDenseEmptyArray(cx));
    45074507    RootedId fileNameId(cx, AtomToId(cx->names().fileName));
    45084508    RootedId lineNumberId(cx, AtomToId(cx->names().lineNumber));
    45094509    RootedId columnNumberId(cx, AtomToId(cx->names().columnNumber));
    45104510    JSAtom* logTypeAtom = Atomize(cx, "logType", strlen("logType"));
    45114511    if (!logTypeAtom)
  • js/src/vm/Debugger.h

    diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h
    a b class Debugger : private mozilla::Linked  
    443443    /* The map from debuggee Envs to Debugger.Environment instances. */
    444444    ObjectWeakMap environments;
    445445
    446446    /*
    447447     * Keep track of tracelogger last drained identifiers to know if there are
    448448     * lost events.
    449449     */
    450450#ifdef NIGHTLY_BUILD
    451     uint32_t traceLoggerLastDrainedId;
     451    uint32_t traceLoggerLastDrainedSize;
    452452    uint32_t traceLoggerLastDrainedIteration;
    453453#endif
    454     uint32_t traceLoggerScriptedCallsLastDrainedId;
     454    uint32_t traceLoggerScriptedCallsLastDrainedSize;
    455455    uint32_t traceLoggerScriptedCallsLastDrainedIteration;
    456456
    457457    class FrameRange;
    458458    class ScriptQuery;
    459459    class ObjectQuery;
    460460
    461461    bool addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> obj);
    462462    void removeDebuggeeGlobal(FreeOp* fop, GlobalObject* global,
  • js/src/vm/TraceLogging.h

    diff --git a/js/src/vm/TraceLogging.h b/js/src/vm/TraceLogging.h
    a b class TraceLoggerThread  
    203203    bool enable();
    204204    bool enable(JSContext* cx);
    205205    bool disable();
    206206
    207     // Given the previous iteration and lastEntryId, return an array of events
     207    // Given the previous iteration and size, return an array of events
    208208    // (there could be lost events). At the same time update the iteration and
    209     // lastEntry and gives back how many events there are.
    210     EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastEntryId, size_t* num) {
     209    // size and gives back how many events there are.
     210    EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastSize, size_t* num) {
    211211        EventEntry* start;
    212212        if (iteration_ == *lastIteration) {
    213             MOZ_ASSERT(*lastEntryId < events.size());
    214             *num = events.lastEntryId() - *lastEntryId;
    215             start = events.data() + *lastEntryId + 1;
     213            MOZ_ASSERT(*lastSize <= events.size());
     214            *num = events.size() - *lastSize;
     215            start = events.data() + *lastSize;
    216216        } else {
    217217            *num = events.size();
    218218            start = events.data();
    219219        }
    220220
    221221        *lastIteration = iteration_;
    222         *lastEntryId = events.lastEntryId();
     222        *lastSize = events.size();
    223223        return start;
    224224    }
    225225
    226226    // Extract the details filename, lineNumber and columnNumber out of a event
    227227    // containing script information.
    228228    void extractScriptDetails(uint32_t textId, const char** filename, size_t* filename_len,
    229229                              const char** lineno, size_t* lineno_len, const char** colno,
    230230                              size_t* colno_len);
    231231
    232     bool lostEvents(uint32_t lastIteration, uint32_t lastEntryId) {
     232    bool lostEvents(uint32_t lastIteration, uint32_t lastSize) {
    233233        // If still logging in the same iteration, there are no lost events.
    234234        if (lastIteration == iteration_) {
    235             MOZ_ASSERT(lastEntryId < events.size());
     235            MOZ_ASSERT(lastSize <= events.size());
    236236            return false;
    237237        }
    238238
    239         // When proceeded to the next iteration and lastEntryId points to
    240         // the maximum capacity there are no logs that are lost.
    241         if (lastIteration + 1 == iteration_ && lastEntryId == events.capacity())
     239        // If we are in a consecutive iteration we are only sure we didn't lose any events,
     240        // when the lastSize equals the maximum size 'events' can get.
     241        if (lastIteration == iteration_ - 1 && lastSize == CONTINUOUSSPACE_LIMIT)
    242242            return false;
    243243
    244244        return true;
    245245    }
    246246
    247247    const char* eventText(uint32_t id);
    248248    bool textIdIsScriptEvent(uint32_t id);
    249249