Ignore:
Timestamp:
Jul 1, 2014, 4:40:32 PM (11 years ago)
Author:
[email protected]
Message:

Debugger's breakpoint list should not be a Vector.
<https://webkit.org/b/134514>

Reviewed by Geoffrey Garen.

The debugger currently stores breakpoint data as entries in a Vector (see
BreakpointsInLine). It also keeps a fast map look up of breakpoint IDs to
the breakpoint data (see m_breakpointIDToBreakpoint). Because a Vector can
compact or reallocate its backing store, this can causes all sorts of havoc.
The m_breakpointIDToBreakpoint map assumes that the breakpoint data doesn't
move in memory.

The fix is to replace the BreakpointsInLine Vector with a BreakpointsList
doubly linked list.

  • debugger/Breakpoint.h:

(JSC::Breakpoint::Breakpoint):
(JSC::BreakpointsList::~BreakpointsList):

  • debugger/Debugger.cpp:

(JSC::Debugger::setBreakpoint):
(JSC::Debugger::removeBreakpoint):
(JSC::Debugger::hasBreakpoint):

  • debugger/Debugger.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/Breakpoint.h

    r162970 r170677  
    2828
    2929#include "DebuggerPrimitives.h"
     30#include <wtf/DoublyLinkedList.h>
     31#include <wtf/RefCounted.h>
    3032#include <wtf/text/WTFString.h>
    3133
    3234namespace JSC {
    3335
    34 struct Breakpoint {
     36struct Breakpoint : public DoublyLinkedListNode<Breakpoint> {
    3537    Breakpoint()
    3638        : id(noBreakpointID)
     
    5254    }
    5355
     56    Breakpoint(const Breakpoint& other)
     57        : id(other.id)
     58        , sourceID(other.sourceID)
     59        , line(other.line)
     60        , column(other.column)
     61        , condition(other.condition)
     62        , autoContinue(other.autoContinue)
     63    {
     64    }
     65
    5466    BreakpointID id;
    5567    SourceID sourceID;
     
    6072
    6173    static const unsigned unspecifiedColumn = UINT_MAX;
     74
     75private:
     76    Breakpoint* m_prev;
     77    Breakpoint* m_next;
     78
     79    friend class WTF::DoublyLinkedListNode<Breakpoint>;
     80};
     81
     82class BreakpointsList : public DoublyLinkedList<Breakpoint>,
     83    public RefCounted<BreakpointsList> {
     84public:
     85    ~BreakpointsList()
     86    {
     87        Breakpoint* breakpoint;
     88        while ((breakpoint = removeHead()))
     89            delete breakpoint;
     90        ASSERT(isEmpty());
     91    }
    6292};
    6393
Note: See TracChangeset for help on using the changeset viewer.