Changeset 170677 in webkit for trunk/Source/JavaScriptCore/debugger
- Timestamp:
- Jul 1, 2014, 4:40:32 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore/debugger
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/debugger/Breakpoint.h
r162970 r170677 28 28 29 29 #include "DebuggerPrimitives.h" 30 #include <wtf/DoublyLinkedList.h> 31 #include <wtf/RefCounted.h> 30 32 #include <wtf/text/WTFString.h> 31 33 32 34 namespace JSC { 33 35 34 struct Breakpoint {36 struct Breakpoint : public DoublyLinkedListNode<Breakpoint> { 35 37 Breakpoint() 36 38 : id(noBreakpointID) … … 52 54 } 53 55 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 54 66 BreakpointID id; 55 67 SourceID sourceID; … … 60 72 61 73 static const unsigned unspecifiedColumn = UINT_MAX; 74 75 private: 76 Breakpoint* m_prev; 77 Breakpoint* m_next; 78 79 friend class WTF::DoublyLinkedListNode<Breakpoint>; 80 }; 81 82 class BreakpointsList : public DoublyLinkedList<Breakpoint>, 83 public RefCounted<BreakpointsList> { 84 public: 85 ~BreakpointsList() 86 { 87 Breakpoint* breakpoint; 88 while ((breakpoint = removeHead())) 89 delete breakpoint; 90 ASSERT(isEmpty()); 91 } 62 92 }; 63 93 -
trunk/Source/JavaScriptCore/debugger/Debugger.cpp
r167396 r170677 358 358 LineToBreakpointsMap::iterator breaksIt = it->value.find(line); 359 359 if (breaksIt == it->value.end()) 360 breaksIt = it->value.set(line, BreakpointsInLine()).iterator; 361 362 BreakpointsInLine& breakpoints = breaksIt->value; 363 unsigned breakpointsCount = breakpoints.size(); 364 for (unsigned i = 0; i < breakpointsCount; i++) 365 if (breakpoints[i].column == column) { 360 breaksIt = it->value.set(line, adoptRef(new BreakpointsList)).iterator; 361 362 BreakpointsList& breakpoints = *breaksIt->value; 363 for (Breakpoint* current = breakpoints.head(); current; current = current->next()) { 364 if (current->column == column) { 366 365 // The breakpoint already exists. We're not allowed to create a new 367 366 // breakpoint at this location. Rather than returning the breakpointID … … 370 369 return noBreakpointID; 371 370 } 371 } 372 372 373 373 BreakpointID id = ++m_topBreakpointID; … … 378 378 actualColumn = column; 379 379 380 breakpoints.append(breakpoint); 381 m_breakpointIDToBreakpoint.set(id, &breakpoints.last()); 380 Breakpoint* newBreakpoint = new Breakpoint(breakpoint); 381 breakpoints.append(newBreakpoint); 382 m_breakpointIDToBreakpoint.set(id, newBreakpoint); 382 383 383 384 toggleBreakpoint(breakpoint, BreakpointEnabled); … … 392 393 BreakpointIDToBreakpointMap::iterator idIt = m_breakpointIDToBreakpoint.find(id); 393 394 ASSERT(idIt != m_breakpointIDToBreakpoint.end()); 394 Breakpoint & breakpoint = *idIt->value;395 396 SourceID sourceID = breakpoint .sourceID;395 Breakpoint* breakpoint = idIt->value; 396 397 SourceID sourceID = breakpoint->sourceID; 397 398 ASSERT(sourceID); 398 399 SourceIDToBreakpointsMap::iterator it = m_sourceIDToBreakpoints.find(sourceID); 399 400 ASSERT(it != m_sourceIDToBreakpoints.end()); 400 LineToBreakpointsMap::iterator breaksIt = it->value.find(breakpoint .line);401 LineToBreakpointsMap::iterator breaksIt = it->value.find(breakpoint->line); 401 402 ASSERT(breaksIt != it->value.end()); 402 403 403 toggleBreakpoint(breakpoint, BreakpointDisabled); 404 405 BreakpointsInLine& breakpoints = breaksIt->value; 406 unsigned breakpointsCount = breakpoints.size(); 407 for (unsigned i = 0; i < breakpointsCount; i++) { 408 if (breakpoints[i].id == breakpoint.id) { 409 breakpoints.remove(i); 410 m_breakpointIDToBreakpoint.remove(idIt); 411 412 if (breakpoints.isEmpty()) { 413 it->value.remove(breaksIt); 414 if (it->value.isEmpty()) 415 m_sourceIDToBreakpoints.remove(it); 416 } 417 break; 418 } 404 toggleBreakpoint(*breakpoint, BreakpointDisabled); 405 406 BreakpointsList& breakpoints = *breaksIt->value; 407 #if !ASSERT_DISABLED 408 bool found = false; 409 for (Breakpoint* current = breakpoints.head(); current && !found; current = current->next()) { 410 if (current->id == breakpoint->id) 411 found = true; 412 } 413 ASSERT(found); 414 #endif 415 416 m_breakpointIDToBreakpoint.remove(idIt); 417 breakpoints.remove(breakpoint); 418 delete breakpoint; 419 420 if (breakpoints.isEmpty()) { 421 it->value.remove(breaksIt); 422 if (it->value.isEmpty()) 423 m_sourceIDToBreakpoints.remove(it); 419 424 } 420 425 } … … 437 442 438 443 bool hit = false; 439 const BreakpointsInLine& breakpoints = breaksIt->value; 440 unsigned breakpointsCount = breakpoints.size(); 441 unsigned i; 442 for (i = 0; i < breakpointsCount; i++) { 443 unsigned breakLine = breakpoints[i].line; 444 unsigned breakColumn = breakpoints[i].column; 444 const BreakpointsList& breakpoints = *breaksIt->value; 445 Breakpoint* breakpoint; 446 for (breakpoint = breakpoints.head(); breakpoint; breakpoint = breakpoint->next()) { 447 unsigned breakLine = breakpoint->line; 448 unsigned breakColumn = breakpoint->column; 445 449 // Since frontend truncates the indent, the first statement in a line must match the breakpoint (line,0). 446 450 ASSERT(this == m_currentCallFrame->codeBlock()->globalObject()->debugger()); … … 455 459 456 460 if (hitBreakpoint) 457 *hitBreakpoint = breakpoints[i];458 459 if (breakpoint s[i].condition.isEmpty())461 *hitBreakpoint = *breakpoint; 462 463 if (breakpoint->condition.isEmpty()) 460 464 return true; 461 465 … … 466 470 JSValue exception; 467 471 DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); 468 JSValue result = debuggerCallFrame->evaluate(breakpoint s[i].condition, exception);472 JSValue result = debuggerCallFrame->evaluate(breakpoint->condition, exception); 469 473 470 474 // We can lose the debugger while executing JavaScript. -
trunk/Source/JavaScriptCore/debugger/Debugger.h
r165005 r170677 30 30 #include <wtf/HashSet.h> 31 31 #include <wtf/RefPtr.h> 32 #include <wtf/Vector.h>33 32 #include <wtf/text/TextPosition.h> 34 33 … … 129 128 typedef HashMap<BreakpointID, Breakpoint*> BreakpointIDToBreakpointMap; 130 129 131 typedef Vector<Breakpoint> BreakpointsInLine; 132 typedef HashMap<unsigned, BreakpointsInLine, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> LineToBreakpointsMap; 130 typedef HashMap<unsigned, RefPtr<BreakpointsList>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> LineToBreakpointsMap; 133 131 typedef HashMap<SourceID, LineToBreakpointsMap, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> SourceIDToBreakpointsMap; 134 132
Note:
See TracChangeset
for help on using the changeset viewer.