source: webkit/trunk/JavaScriptCore/debugger/Debugger.cpp@ 40274

Last change on this file since 40274 was 40274, checked in by [email protected], 16 years ago

2009-01-26 Cameron Zwarich <[email protected]>

Reviewed by Gavin Barraclough.

Bug 23552: Dashcode evaluator no longer works after making ExecStates actual call frames
<https://bugs.webkit.org/show_bug.cgi?id=23552>
<rdar://problem/6398839>

Dashcode will crash when using the evaluator because it saves a global call
frame, even after global code has finished executing, and then uses this as
a launching pad to execute new JS in the evaluator. The fix is to detect
when Dashcode is attempting to do this and execute code from a global call
frame instead.

JavaScriptCore:

  • JavaScriptCore.exp:
  • debugger/Debugger.cpp: (JSC::evaluateInGlobalCallFrame): Added so that WebScriptCallFrame can evaluate JS starting from a global call frame.
  • debugger/Debugger.h:

WebKit/mac:

  • ForwardingHeaders/runtime/Protect.h: Added.
  • WebView/WebScriptDebugDelegate.mm: (-[WebScriptCallFrame _initWithGlobalObject:debugger:caller:debuggerCallFrame:]): Added debugger, a WebScriptDebugger* argument. (-[WebScriptCallFrame evaluateWebScript:]): Detect when Dashcode is using a stale WebScriptCallFrame to execute new JS and evaluate it starting from the global object's global call frame instead.
  • WebView/WebScriptDebugger.h: (WebScriptDebugger::globalObject): Added. (WebScriptDebugger::globalCallFrame): Added.
  • WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger): Initialize m_globalObject. (WebScriptDebugger::initGlobalCallFrame): Created as a clone of callEvent so that the global call frame can be saved immediately after being created. (WebScriptDebugger::callEvent): Pass 'this' as the debugger argument of WebScriptCallFrame's _initWithGlobalObject method.
  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 1999-2001 Harri Porten ([email protected])
4 * Copyright (C) 2001 Peter Kelly ([email protected])
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22#include "config.h"
23#include "Debugger.h"
24
25#include "JSGlobalObject.h"
26
27namespace JSC {
28
29Debugger::Debugger()
30{
31}
32
33Debugger::~Debugger()
34{
35 HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end();
36 for (HashSet<JSGlobalObject*>::iterator it = m_globalObjects.begin(); it != end; ++it)
37 (*it)->setDebugger(0);
38}
39
40void Debugger::attach(JSGlobalObject* globalObject)
41{
42 ASSERT(!globalObject->debugger());
43 globalObject->setDebugger(this);
44 m_globalObjects.add(globalObject);
45}
46
47void Debugger::detach(JSGlobalObject* globalObject)
48{
49 ASSERT(m_globalObjects.contains(globalObject));
50 m_globalObjects.remove(globalObject);
51 globalObject->setDebugger(0);
52}
53
54JSValuePtr evaluateInGlobalCallFrame(const UString& script, JSValuePtr& exception, JSGlobalObject* globalObject)
55{
56 CallFrame* globalCallFrame = globalObject->globalExec();
57
58 int errLine;
59 UString errMsg;
60 SourceCode source = makeSource(script);
61 RefPtr<EvalNode> evalNode = globalObject->globalData()->parser->parse<EvalNode>(globalCallFrame, globalObject->debugger(), source, &errLine, &errMsg);
62 if (!evalNode)
63 return Error::create(globalCallFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
64
65 return globalObject->globalData()->interpreter->execute(evalNode.get(), globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception);
66}
67
68} // namespace JSC
Note: See TracBrowser for help on using the repository browser.