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

Last change on this file since 15118 was 15026, checked in by thatcher, 19 years ago

JavaScriptCore:

Reviewed by Darin.

Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574

Pass the starting line number and error message to the debugger.

  • kjs/debugger.cpp: (Debugger::sourceParsed):
  • kjs/debugger.h:
  • kjs/function.cpp: (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function_object.cpp: (FunctionObjectImp::construct):
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate):

WebCore:

Reviewed by Darin.

Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574

  • Pass the starting line number and error message to the debugger.
  • Call parsedSource even if there was a script parse error so the debugger can show the parse error.
  • Pass NSURL objects to the ObjC delegate for the script URLs.
  • bridge/mac/WebCoreScriptDebugger.h:
  • bridge/mac/WebCoreScriptDebugger.mm: (toNSURL): (WebCoreScriptDebuggerImp::sourceParsed):

WebKit:

Reviewed by Darin.

Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574

  • Adds a new version of the didParseSource delegate callback with base line number.
  • Adds a new delegate callback for when a script fails to parse.
  • These new callbacks use NSURLs for the url parameter.
  • Adds a new script listener callback to notify when the main resource loads.
  • Adds a WebScriptErrorDomian and other keys for use with NSError.
  • DefaultDelegates/WebDefaultScriptDebugDelegate.m: (-[WebDefaultScriptDebugDelegate webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]): (-[WebDefaultScriptDebugDelegate webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
  • DefaultDelegates/WebScriptDebugServer.h:
  • DefaultDelegates/WebScriptDebugServer.m: (-[WebScriptDebugServer webView:didLoadMainResourceForDataSource:]): (-[WebScriptDebugServer webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]): (-[WebScriptDebugServer webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
  • DefaultDelegates/WebScriptDebugServerPrivate.h:
  • WebKit.exp:
  • WebView/WebDataSource.m: (-[WebDataSource _setPrimaryLoadComplete:]):
  • WebView/WebScriptDebugDelegate.h:
  • WebView/WebScriptDebugDelegate.m: (-[WebScriptCallFrame parsedSource:fromURL:sourceId:startLine:errorLine:errorMessage:]):

WebKitTools:

Reviewed by Darin.

Bug 9574: Drosera should show inline scripts within the original HTML
http://bugzilla.opendarwin.org/show_bug.cgi?id=9574

Refactor the JavaScript code to have a distinction between files
and scripts. Show the script in the context of the HTML file if
it's URL is the same as the frame's main resource. At the time of
the disParseScript callback the main resource might not be completely
loaded, but Drosera needs to show whatever we have at the time. Once
the main resource is finished, update the file source and reload the file.

  • Drosera/DebuggerDocument.m: (-[DebuggerDocument pause]): (-[DebuggerDocument webView:didLoadMainResourceForDataSource:]): (-[DebuggerDocument webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:]): (-[DebuggerDocument webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:]):
  • Drosera/debugger.css:
  • Drosera/debugger.js:
  • Property svn:eol-style set to native
File size: 8.1 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
26namespace KJS {
27
28 class DebuggerImp;
29 class Interpreter;
30 class ExecState;
31 class JSObject;
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 atStatement()
104 * @param sourceURL Where the source code that was parsed came from
105 * @param source The source code that was parsed
106 * @param startingLineNumber The line number at which parsing started
107 * @param errorLine The line number at which parsing encountered an
108 * error, or -1 if the source code was valid and parsed successfully
109 * @param errorMsg The error description, or null if the source code
110 was valid and parsed successfully
111 * @return true if execution should be continue, false if it should
112 * be aborted
113 */
114 virtual bool sourceParsed(ExecState *exec, int sourceId, const UString &sourceURL,
115 const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg);
116
117 /**
118 * Called when all functions/programs associated with a particular
119 * sourceId have been deleted. After this function has been called for
120 * a particular sourceId, that sourceId will not be used again.
121 *
122 * The default implementation does nothing. Override this method if
123 * you want to process this event.
124 *
125 * @param exec The current execution state
126 * @param sourceId The ID of the source code (corresponds to the
127 * sourceId supplied in other functions such as atLine()
128 * @return true if execution should be continue, false if it should
129 * be aborted
130 */
131 virtual bool sourceUnused(ExecState *exec, int sourceId);
132
133 /**
134 * Called when an exception is thrown during script execution.
135 *
136 * The default implementation does nothing. Override this method if
137 * you want to process this event.
138 *
139 * @param exec The current execution state
140 * @param sourceId The ID of the source code being executed
141 * @param lineno The line at which the error occurred
142 * @param exceptionObj The exception object
143 * @return true if execution should be continue, false if it should
144 * be aborted
145 */
146 virtual bool exception(ExecState *exec, int sourceId, int lineno,
147 JSObject *exceptionObj);
148
149 /**
150 * Called when a line of the script is reached (before it is executed)
151 *
152 * The default implementation does nothing. Override this method if
153 * you want to process this event.
154 *
155 * @param exec The current execution state
156 * @param sourceId The ID of the source code being executed
157 * @param firstLine The starting line of the statement that is about to be
158 * executed
159 * @param lastLine The ending line of the statement that is about to be
160 * executed (usually the same as firstLine)
161 * @return true if execution should be continue, false if it should
162 * be aborted
163 */
164 virtual bool atStatement(ExecState *exec, int sourceId, int firstLine,
165 int lastLine);
166 /**
167 * Called on each function call. Use together with @ref #returnEvent
168 * if you want to keep track of the call stack.
169 *
170 * Note: This only gets called for functions that are declared in ECMAScript
171 * source code or passed to eval(), not for internal KJS or
172 * application-supplied functions.
173 *
174 * The default implementation does nothing. Override this method if
175 * you want to process this event.
176 *
177 * @param exec The current execution state
178 * @param sourceId The ID of the source code being executed
179 * @param lineno The line that is about to be executed
180 * @param function The function being called
181 * @param args The arguments that were passed to the function
182 * line is being executed
183 * @return true if execution should be continue, false if it should
184 * be aborted
185 */
186 virtual bool callEvent(ExecState *exec, int sourceId, int lineno,
187 JSObject *function, const List &args);
188
189 /**
190 * Called on each function exit. The function being returned from is that
191 * which was supplied in the last callEvent().
192 *
193 * Note: This only gets called for functions that are declared in ECMAScript
194 * source code or passed to eval(), not for internal KJS or
195 * application-supplied functions.
196 *
197 * The default implementation does nothing. Override this method if
198 * you want to process this event.
199 *
200 * @param exec The current execution state
201 * @param sourceId The ID of the source code being executed
202 * @param lineno The line that is about to be executed
203 * @param function The function being called
204 * @return true if execution should be continue, false if it should
205 * be aborted
206 */
207 virtual bool returnEvent(ExecState *exec, int sourceId, int lineno,
208 JSObject *function);
209
210 private:
211 DebuggerImp *rep;
212
213 public:
214 static int debuggersPresent;
215 };
216
217}
218
219#endif
Note: See TracBrowser for help on using the repository browser.