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