]>
git.saurik.com Git - apple/javascriptcore.git/blob - kjs/debugger.cpp
1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
5 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "JSGlobalObject.h"
32 // ------------------------------ Debugger -------------------------------------
35 struct AttachedGlobalObject
38 AttachedGlobalObject(JSGlobalObject
* o
, AttachedGlobalObject
* ai
) : globalObj(o
), next(ai
) { ++Debugger::debuggersPresent
; }
39 ~AttachedGlobalObject() { --Debugger::debuggersPresent
; }
40 JSGlobalObject
* globalObj
;
41 AttachedGlobalObject
* next
;
46 int Debugger::debuggersPresent
= 0;
50 rep
= new DebuggerImp();
59 void Debugger::attach(JSGlobalObject
* globalObject
)
61 Debugger
* other
= globalObject
->debugger();
65 other
->detach(globalObject
);
66 globalObject
->setDebugger(this);
67 rep
->globalObjects
= new AttachedGlobalObject(globalObject
, rep
->globalObjects
);
70 void Debugger::detach(JSGlobalObject
* globalObj
)
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
;
77 if (!globalObj
|| q
->globalObj
== globalObj
) {
79 q
->globalObj
->setDebugger(0);
86 latestExceptions
.remove(globalObj
);
88 latestExceptions
.clear();
91 bool Debugger::hasHandledException(ExecState
*exec
, JSValue
*exception
)
93 if (latestExceptions
.get(exec
->dynamicGlobalObject()).get() == exception
)
96 latestExceptions
.set(exec
->dynamicGlobalObject(), exception
);
100 bool Debugger::sourceParsed(ExecState
*, int /*sourceId*/, const UString
&/*sourceURL*/,
101 const UString
&/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString
& /*errorMsg*/)
106 bool Debugger::sourceUnused(ExecState
*, int /*sourceId*/)
111 bool Debugger::exception(ExecState
*, int /*sourceId*/, int /*lineno*/,
112 JSValue
* /*exception */)
117 bool Debugger::atStatement(ExecState
*, int /*sourceId*/, int /*firstLine*/,
123 bool Debugger::callEvent(ExecState
*, int /*sourceId*/, int /*lineno*/,
124 JSObject
* /*function*/, const List
&/*args*/)
129 bool Debugger::returnEvent(ExecState
*, int /*sourceId*/, int /*lineno*/,
130 JSObject
* /*function*/)