]>
git.saurik.com Git - apple/javascriptcore.git/blob - kjs/debugger.h
2d5cb6f5162d3493ac61d4967666bae5babf6170
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
23 #ifndef _KJSDEBUGGER_H_
24 #define _KJSDEBUGGER_H_
26 #include <wtf/HashMap.h>
42 * Provides an interface which receives notification about various
43 * script-execution related events such as statement execution and function
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.
56 * Creates a new debugger
61 * Destroys the debugger. If the debugger is attached to any global objects,
62 * it is automatically detached.
66 DebuggerImp
*imp() const { return rep
; }
69 * Attaches the debugger to specified global object. This will cause this
70 * object to receive notification of events during execution.
72 * If the global object is deleted, it will detach the debugger.
74 * Note: only one debugger can be attached to a global object at a time.
75 * Attaching another debugger to the same global object will cause the
76 * original debugger to be detached.
78 * @param The global object to attach to.
82 void attach(JSGlobalObject
*);
85 * Detach the debugger from a global object.
87 * @param The global object to detach from. If 0, the debugger will be
88 * detached from all global objects to which it is attached.
92 void detach(JSGlobalObject
*);
95 * Called to notify the debugger that some javascript source code has
96 * been parsed. For calls to Interpreter::evaluate(), this will be called
97 * with the supplied source code before any other code is parsed.
98 * Other situations in which this may be called include creation of a
99 * function using the Function() constructor, or the eval() function.
101 * The default implementation does nothing. Override this method if
102 * you want to process this event.
104 * @param exec The current execution state
105 * @param sourceId The ID of the source code (corresponds to the
106 * sourceId supplied in other functions such as atStatement()
107 * @param sourceURL Where the source code that was parsed came from
108 * @param source The source code that was parsed
109 * @param startingLineNumber The line number at which parsing started
110 * @param errorLine The line number at which parsing encountered an
111 * error, or -1 if the source code was valid and parsed successfully
112 * @param errorMsg The error description, or null if the source code
113 was valid and parsed successfully
114 * @return true if execution should be continue, false if it should
117 virtual bool sourceParsed(ExecState
*exec
, int sourceId
, const UString
&sourceURL
,
118 const UString
&source
, int startingLineNumber
, int errorLine
, const UString
&errorMsg
);
121 * Called when all functions/programs associated with a particular
122 * sourceId have been deleted. After this function has been called for
123 * a particular sourceId, that sourceId will not be used again.
125 * The default implementation does nothing. Override this method if
126 * you want to process this event.
128 * @param exec The current execution state
129 * @param sourceId The ID of the source code (corresponds to the
130 * sourceId supplied in other functions such as atLine()
131 * @return true if execution should be continue, false if it should
134 virtual bool sourceUnused(ExecState
*exec
, int sourceId
);
137 * Called when an exception is thrown during script execution.
139 * The default implementation does nothing. Override this method if
140 * you want to process this event.
142 * @param exec The current execution state
143 * @param sourceId The ID of the source code being executed
144 * @param lineno The line at which the error occurred
145 * @param exceptionObj The exception object
146 * @return true if execution should be continue, false if it should
149 virtual bool exception(ExecState
*exec
, int sourceId
, int lineno
,
152 bool hasHandledException(ExecState
*, JSValue
*);
155 * Called when a line of the script is reached (before it is executed)
157 * The default implementation does nothing. Override this method if
158 * you want to process this event.
160 * @param exec The current execution state
161 * @param sourceId The ID of the source code being executed
162 * @param firstLine The starting line of the statement that is about to be
164 * @param lastLine The ending line of the statement that is about to be
165 * executed (usually the same as firstLine)
166 * @return true if execution should be continue, false if it should
169 virtual bool atStatement(ExecState
*exec
, int sourceId
, int firstLine
,
172 * Called on each function call. Use together with @ref #returnEvent
173 * if you want to keep track of the call stack.
175 * Note: This only gets called for functions that are declared in ECMAScript
176 * source code or passed to eval(), not for internal KJS or
177 * application-supplied functions.
179 * The default implementation does nothing. Override this method if
180 * you want to process this event.
182 * @param exec The current execution state
183 * @param sourceId The ID of the source code being executed
184 * @param lineno The line that is about to be executed
185 * @param function The function being called
186 * @param args The arguments that were passed to the function
187 * line is being executed
188 * @return true if execution should be continue, false if it should
191 virtual bool callEvent(ExecState
*exec
, int sourceId
, int lineno
,
192 JSObject
*function
, const List
&args
);
195 * Called on each function exit. The function being returned from is that
196 * which was supplied in the last callEvent().
198 * Note: This only gets called for functions that are declared in ECMAScript
199 * source code or passed to eval(), not for internal KJS or
200 * application-supplied functions.
202 * The default implementation does nothing. Override this method if
203 * you want to process this event.
205 * @param exec The current execution state
206 * @param sourceId The ID of the source code being executed
207 * @param lineno The line that is about to be executed
208 * @param function The function being called
209 * @return true if execution should be continue, false if it should
212 virtual bool returnEvent(ExecState
*exec
, int sourceId
, int lineno
,
217 HashMap
<JSGlobalObject
*, ProtectedPtr
<JSValue
> > latestExceptions
;
220 static int debuggersPresent
;