Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/debugger.cpp
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/debugger.cpp
r28473 r33979 1 1 // -*- c-basic-offset: 2 -*- 2 2 /* 3 * This file is part of the KDE libraries3 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 4 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 5 5 * Copyright (C) 2001 Peter Kelly ([email protected]) … … 25 25 26 26 #include "JSGlobalObject.h" 27 #include "internal.h"28 #include "ustring.h"29 30 using namespace KJS;31 32 // ------------------------------ Debugger -------------------------------------33 27 34 28 namespace KJS { 35 struct AttachedGlobalObject36 {37 public:38 AttachedGlobalObject(JSGlobalObject* o, AttachedGlobalObject* ai) : globalObj(o), next(ai) { ++Debugger::debuggersPresent; }39 ~AttachedGlobalObject() { --Debugger::debuggersPresent; }40 JSGlobalObject* globalObj;41 AttachedGlobalObject* next;42 };43 44 }45 46 int Debugger::debuggersPresent = 0;47 29 48 30 Debugger::Debugger() 49 31 { 50 rep = new DebuggerImp();51 32 } 52 33 53 34 Debugger::~Debugger() 54 35 { 55 detach(0); 56 delete rep; 36 HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end(); 37 for (HashSet<JSGlobalObject*>::iterator it = m_globalObjects.begin(); it != end; ++it) 38 (*it)->setDebugger(0); 57 39 } 58 40 59 41 void Debugger::attach(JSGlobalObject* globalObject) 60 42 { 61 Debugger* other = globalObject->debugger(); 62 if (other == this) 63 return; 64 if (other) 65 other->detach(globalObject); 66 globalObject->setDebugger(this); 67 rep->globalObjects = new AttachedGlobalObject(globalObject, rep->globalObjects); 43 ASSERT(!globalObject->debugger()); 44 globalObject->setDebugger(this); 45 m_globalObjects.add(globalObject); 68 46 } 69 47 70 void Debugger::detach(JSGlobalObject* globalObj )48 void Debugger::detach(JSGlobalObject* globalObject) 71 49 { 72 // iterate the addresses where AttachedGlobalObject pointers are stored 73 // so we can unlink items from the list 74 AttachedGlobalObject **p = &rep->globalObjects; 75 AttachedGlobalObject *q; 76 while ((q = *p)) { 77 if (!globalObj || q->globalObj == globalObj) { 78 *p = q->next; 79 q->globalObj->setDebugger(0); 80 delete q; 81 } else 82 p = &q->next; 83 } 84 85 if (globalObj) 86 latestExceptions.remove(globalObj); 87 else 88 latestExceptions.clear(); 50 ASSERT(m_globalObjects.contains(globalObject)); 51 m_globalObjects.remove(globalObject); 52 globalObject->setDebugger(0); 89 53 } 90 54 91 bool Debugger::hasHandledException(ExecState *exec, JSValue *exception) 92 { 93 if (latestExceptions.get(exec->dynamicGlobalObject()).get() == exception) 94 return true; 95 96 latestExceptions.set(exec->dynamicGlobalObject(), exception); 97 return false; 98 } 99 100 bool Debugger::sourceParsed(ExecState*, int /*sourceId*/, const UString &/*sourceURL*/, 101 const UString &/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString & /*errorMsg*/) 102 { 103 return true; 104 } 105 106 bool Debugger::sourceUnused(ExecState*, int /*sourceId*/) 107 { 108 return true; 109 } 110 111 bool Debugger::exception(ExecState*, int /*sourceId*/, int /*lineno*/, 112 JSValue* /*exception */) 113 { 114 return true; 115 } 116 117 bool Debugger::atStatement(ExecState*, int /*sourceId*/, int /*firstLine*/, 118 int /*lastLine*/) 119 { 120 return true; 121 } 122 123 bool Debugger::callEvent(ExecState*, int /*sourceId*/, int /*lineno*/, 124 JSObject* /*function*/, const List &/*args*/) 125 { 126 return true; 127 } 128 129 bool Debugger::returnEvent(ExecState*, int /*sourceId*/, int /*lineno*/, 130 JSObject* /*function*/) 131 { 132 return true; 133 } 134 55 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.