source: webkit/trunk/JavaScriptCore/kjs/debugger.h@ 19894

Last change on this file since 19894 was 15593, checked in by thatcher, 19 years ago

JavaScriptCore:

Reviewed by Maciej.

Bug 9686: [Drosera] Need the ability to break into Drosera on Javascript exceptions
http://bugzilla.opendarwin.org/show_bug.cgi?id=9686

JavaScriptCore portion of the fix.

  • JavaScriptCore.exp: Update symbol for change in argument type.
  • kjs/debugger.cpp: (Debugger::detach): Clear map of recent exceptions. (Debugger::hasHandledException): Track the most recent exception thrown by an interpreter. (Debugger::exception): Change exception argument to a JSValue.
  • kjs/debugger.h:
  • kjs/nodes.cpp: (Node::debugExceptionIfNeeded): Notify the debugger of an exception if it hasn't seen it before. (ThrowNode::execute): Notify the debugger that an exception is being thrown.
  • kjs/nodes.h:

2006-07-23 Geoffrey Garen <[email protected]>

Patch by Eric Albert, reviewed by Darin and me.


  • Fixed <rdar://problem/4645931> JavaScriptCore stack-scanning code crashes (Collector::markStackObjectsConservatively)


  • bindings/jni/jni_jsobject.cpp: On 64bit systems, jint is a long, not an int. (JavaJSObject::getSlot): (JavaJSObject::setSlot):
  • kjs/collector.cpp: (KJS::Collector::markCurrentThreadConservatively): Use a pointer instead of an int as 'dummy,' because on LP64 systems, an int is not pointer-aligned, and we want to scan the stack for pointers.
  • JavaScriptCore.xcodeproj/project.pbxproj: After a tense cease-fire, the XCode war has started up again!

WebCore:

Reviewed by maciej.

Bug 9686: [Drosera] Need the ability to break into Drosera on Javascript exceptions
http://bugzilla.opendarwin.org/show_bug.cgi?id=9686

WebCore portion of the fix.

  • bridge/mac/WebCoreScriptDebugger.h: (-[WebScriptDebugger exceptionRaised:sourceId:line::]): Add delegate method.
  • bridge/mac/WebCoreScriptDebugger.mm: (WebCoreScriptDebuggerImp::exception): Call delegate method when an exception is raised.

WebKit:

Reviewed by Maciej.

Bug 9686: [Drosera] Need the ability to break into Drosera on Javascript exceptions
http://bugzilla.opendarwin.org/show_bug.cgi?id=9686

WebKit portion of the fix.

  • DefaultDelegates/WebDefaultScriptDebugDelegate.m: (-[WebDefaultScriptDebugDelegate webView:exceptionWasRaised:sourceId:line:forWebFrame:]):
  • DefaultDelegates/WebScriptDebugServer.h:
  • DefaultDelegates/WebScriptDebugServer.m: (-[WebScriptDebugServer webView:exceptionWasRaised:sourceId:line:forWebFrame:]): Notify listeners that an exception has been raised.
  • WebView/WebScriptDebugDelegate.h:
  • WebView/WebScriptDebugDelegate.m: (-[WebScriptCallFrame exceptionRaised:sourceId:line:]): Dispatch through to delegate and WebScriptDebugServer.
  • Property svn:eol-style set to native
File size: 8.3 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten ([email protected])
5 * Copyright (C) 2001 Peter Kelly ([email protected])
6 *
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.
11 *
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.
16 *
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
20 *
21 */
22
23#ifndef _KJSDEBUGGER_H_
24#define _KJSDEBUGGER_H_
25
26#include <wtf/HashMap.h>
27#include "protect.h"
28
29namespace KJS {
30
31 class DebuggerImp;
32 class Interpreter;
33 class ExecState;
34 class JSObject;
35 class JSValue;
36 class UString;
37 class List;
38
39 /**
40 * @internal
41 *
42 * Provides an interface which receives notification about various
43 * script-execution related events such as statement execution and function
44 * calls.
45 *
46 * WARNING: This interface is still a work in progress and is not yet
47 * offically publicly available. It is likely to change in binary incompatible
48 * (and possibly source incompatible) ways in future versions. It is
49 * anticipated that at some stage the interface will be frozen and made
50 * available for general use.
51 */
52 class Debugger {
53 public:
54
55 /**
56 * Creates a new debugger
57 */
58 Debugger();
59
60 /**
61 * Destroys the debugger. If the debugger is attached to any interpreters,
62 * it is automatically detached.
63 */
64 virtual ~Debugger();
65
66 DebuggerImp *imp() const { return rep; }
67
68 /**
69 * Attaches the debugger to specified interpreter. This will cause this
70 * object to receive notification of events from the interpreter.
71 *
72 * If the interpreter is deleted, the debugger will automatically be
73 * detached.
74 *
75 * Note: only one debugger can be attached to an interpreter at a time.
76 * Attaching another debugger to the same interpreter will cause the
77 * original debugger to be detached from that interpreter.
78 *
79 * @param interp The interpreter to attach to
80 *
81 * @see detach()
82 */
83 void attach(Interpreter *interp);
84
85 /**
86 * Detach the debugger from an interpreter
87 *
88 * @param interp The interpreter to detach from. If 0, the debugger will be
89 * detached from all interpreters to which it is attached.
90 *
91 * @see attach()
92 */
93 void detach(Interpreter *interp);
94
95 /**
96 * Called to notify the debugger that some javascript source code has
97 * been parsed. For calls to Interpreter::evaluate(), this will be called
98 * with the supplied source code before any other code is parsed.
99 * Other situations in which this may be called include creation of a
100 * function using the Function() constructor, or the eval() function.
101 *
102 * The default implementation does nothing. Override this method if
103 * you want to process this event.
104 *
105 * @param exec The current execution state
106 * @param sourceId The ID of the source code (corresponds to the
107 * sourceId supplied in other functions such as atStatement()
108 * @param sourceURL Where the source code that was parsed came from
109 * @param source The source code that was parsed
110 * @param startingLineNumber The line number at which parsing started
111 * @param errorLine The line number at which parsing encountered an
112 * error, or -1 if the source code was valid and parsed successfully
113 * @param errorMsg The error description, or null if the source code
114 was valid and parsed successfully
115 * @return true if execution should be continue, false if it should
116 * be aborted
117 */
118 virtual bool sourceParsed(ExecState *exec, int sourceId, const UString &sourceURL,
119 const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg);
120
121 /**
122 * Called when all functions/programs associated with a particular
123 * sourceId have been deleted. After this function has been called for
124 * a particular sourceId, that sourceId will not be used again.
125 *
126 * The default implementation does nothing. Override this method if
127 * you want to process this event.
128 *
129 * @param exec The current execution state
130 * @param sourceId The ID of the source code (corresponds to the
131 * sourceId supplied in other functions such as atLine()
132 * @return true if execution should be continue, false if it should
133 * be aborted
134 */
135 virtual bool sourceUnused(ExecState *exec, int sourceId);
136
137 /**
138 * Called when an exception is thrown during script execution.
139 *
140 * The default implementation does nothing. Override this method if
141 * you want to process this event.
142 *
143 * @param exec The current execution state
144 * @param sourceId The ID of the source code being executed
145 * @param lineno The line at which the error occurred
146 * @param exceptionObj The exception object
147 * @return true if execution should be continue, false if it should
148 * be aborted
149 */
150 virtual bool exception(ExecState *exec, int sourceId, int lineno,
151 JSValue *exception);
152
153 bool hasHandledException(ExecState *, JSValue *);
154
155 /**
156 * Called when a line of the script is reached (before it is executed)
157 *
158 * The default implementation does nothing. Override this method if
159 * you want to process this event.
160 *
161 * @param exec The current execution state
162 * @param sourceId The ID of the source code being executed
163 * @param firstLine The starting line of the statement that is about to be
164 * executed
165 * @param lastLine The ending line of the statement that is about to be
166 * executed (usually the same as firstLine)
167 * @return true if execution should be continue, false if it should
168 * be aborted
169 */
170 virtual bool atStatement(ExecState *exec, int sourceId, int firstLine,
171 int lastLine);
172 /**
173 * Called on each function call. Use together with @ref #returnEvent
174 * if you want to keep track of the call stack.
175 *
176 * Note: This only gets called for functions that are declared in ECMAScript
177 * source code or passed to eval(), not for internal KJS or
178 * application-supplied functions.
179 *
180 * The default implementation does nothing. Override this method if
181 * you want to process this event.
182 *
183 * @param exec The current execution state
184 * @param sourceId The ID of the source code being executed
185 * @param lineno The line that is about to be executed
186 * @param function The function being called
187 * @param args The arguments that were passed to the function
188 * line is being executed
189 * @return true if execution should be continue, false if it should
190 * be aborted
191 */
192 virtual bool callEvent(ExecState *exec, int sourceId, int lineno,
193 JSObject *function, const List &args);
194
195 /**
196 * Called on each function exit. The function being returned from is that
197 * which was supplied in the last callEvent().
198 *
199 * Note: This only gets called for functions that are declared in ECMAScript
200 * source code or passed to eval(), not for internal KJS or
201 * application-supplied functions.
202 *
203 * The default implementation does nothing. Override this method if
204 * you want to process this event.
205 *
206 * @param exec The current execution state
207 * @param sourceId The ID of the source code being executed
208 * @param lineno The line that is about to be executed
209 * @param function The function being called
210 * @return true if execution should be continue, false if it should
211 * be aborted
212 */
213 virtual bool returnEvent(ExecState *exec, int sourceId, int lineno,
214 JSObject *function);
215
216 private:
217 DebuggerImp *rep;
218 HashMap<Interpreter*, ProtectedPtr<JSValue> > latestExceptions;
219
220 public:
221 static int debuggersPresent;
222 };
223
224}
225
226#endif
Note: See TracBrowser for help on using the repository browser.