blob: b30a8625d23ee069c6747072573c727f5eb2d22a [file] [log] [blame]
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +00001/*
fpizlo@apple.com39303e02016-04-05 22:17:35 +00002 * Copyright (C) 2008, 2013-2014, 2016 Apple Inc. All rights reserved.
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
mjs@apple.com92047332014-03-15 04:08:27 +000013 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000014 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "DebuggerCallFrame.h"
31
annulen@yandex.ru6712c2d2017-06-25 17:40:30 +000032#include "CatchScope.h"
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000033#include "CodeBlock.h"
commit-queue@webkit.org31d2ef02014-09-05 21:08:14 +000034#include "DebuggerEvalEnabler.h"
mark.lam@apple.com268dda72014-08-29 00:48:59 +000035#include "DebuggerScope.h"
ggaren@apple.com901a8a22008-11-17 20:57:18 +000036#include "Interpreter.h"
joepeck@webkit.org70d6a302016-05-10 19:16:19 +000037#include "JSCInlines.h"
mark.lam@apple.com65a636f2014-02-01 01:24:39 +000038#include "JSFunction.h"
oliver@apple.coma7dfb4d2014-09-11 18:18:14 +000039#include "JSLexicalEnvironment.h"
joepeck@webkit.org70d6a302016-05-10 19:16:19 +000040#include "JSWithScope.h"
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000041#include "Parser.h"
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000042#include "ShadowChickenInlines.h"
mark.lam@apple.come72693d2013-09-24 23:52:57 +000043#include "StackVisitor.h"
mark.lam@apple.com268dda72014-08-29 00:48:59 +000044#include "StrongInlines.h"
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000045
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000046namespace JSC {
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000047
mark.lam@apple.come72693d2013-09-24 23:52:57 +000048class LineAndColumnFunctor {
49public:
fpizlo@apple.com39303e02016-04-05 22:17:35 +000050 StackVisitor::Status operator()(StackVisitor& visitor) const
mark.lam@apple.come72693d2013-09-24 23:52:57 +000051 {
52 visitor->computeLineAndColumn(m_line, m_column);
53 return StackVisitor::Done;
54 }
55
56 unsigned line() const { return m_line; }
57 unsigned column() const { return m_column; }
58
59private:
ddkilzer@apple.com137187c2018-07-01 00:06:38 +000060 mutable unsigned m_line { 0 };
61 mutable unsigned m_column { 0 };
mark.lam@apple.come72693d2013-09-24 23:52:57 +000062};
63
sbarati@apple.com5db42f82017-04-04 22:23:37 +000064Ref<DebuggerCallFrame> DebuggerCallFrame::create(VM& vm, CallFrame* callFrame)
mark.lam@apple.come72693d2013-09-24 23:52:57 +000065{
sbarati@apple.com5db42f82017-04-04 22:23:37 +000066 if (UNLIKELY(callFrame == callFrame->wasmAwareLexicalGlobalObject(vm)->globalExec())) {
sbarati@apple.com867f8842016-05-27 23:42:08 +000067 ShadowChicken::Frame emptyFrame;
68 RELEASE_ASSERT(!emptyFrame.isTailDeleted);
sbarati@apple.com5db42f82017-04-04 22:23:37 +000069 return adoptRef(*new DebuggerCallFrame(vm, callFrame, emptyFrame));
sbarati@apple.com867f8842016-05-27 23:42:08 +000070 }
71
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000072 Vector<ShadowChicken::Frame> frames;
ysuzuki@apple.com0a831252019-01-29 04:33:33 +000073 vm.ensureShadowChicken();
74 vm.shadowChicken()->iterate(vm, callFrame, [&] (const ShadowChicken::Frame& frame) -> bool {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000075 frames.append(frame);
76 return true;
77 });
78
79 RELEASE_ASSERT(frames.size());
sbarati@apple.comed3e9f52016-05-27 20:26:06 +000080 ASSERT(!frames[0].isTailDeleted); // The top frame should never be tail deleted.
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000081
82 RefPtr<DebuggerCallFrame> currentParent = nullptr;
sbarati@apple.com5db42f82017-04-04 22:23:37 +000083 ExecState* exec = callFrame->wasmAwareLexicalGlobalObject(vm)->globalExec();
sbarati@apple.comed3e9f52016-05-27 20:26:06 +000084 // This walks the stack from the entry stack frame to the top of the stack.
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000085 for (unsigned i = frames.size(); i--; ) {
86 const ShadowChicken::Frame& frame = frames[i];
87 if (!frame.isTailDeleted)
88 exec = frame.frame;
sbarati@apple.com5db42f82017-04-04 22:23:37 +000089 Ref<DebuggerCallFrame> currentFrame = adoptRef(*new DebuggerCallFrame(vm, exec, frame));
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000090 currentFrame->m_caller = currentParent;
91 currentParent = WTFMove(currentFrame);
92 }
93 return *currentParent;
94}
95
sbarati@apple.com5db42f82017-04-04 22:23:37 +000096DebuggerCallFrame::DebuggerCallFrame(VM& vm, CallFrame* callFrame, const ShadowChicken::Frame& frame)
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000097 : m_validMachineFrame(callFrame)
98 , m_shadowChickenFrame(frame)
99{
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000100 m_position = currentPosition(vm);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000101}
102
gyuyoung.kim@webkit.orgbe3842f2015-06-13 03:52:06 +0000103RefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame()
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000104{
105 ASSERT(isValid());
106 if (!isValid())
gyuyoung.kim@webkit.orgbe3842f2015-06-13 03:52:06 +0000107 return nullptr;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000108
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000109 return m_caller;
110}
111
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000112ExecState* DebuggerCallFrame::globalExec()
113{
114 return scope()->globalObject()->globalExec();
115}
116
mark.lam@apple.com30721252013-11-21 05:29:42 +0000117JSC::JSGlobalObject* DebuggerCallFrame::vmEntryGlobalObject() const
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000118{
119 ASSERT(isValid());
120 if (!isValid())
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000121 return nullptr;
mark.lam@apple.com3816a302018-08-23 22:57:09 +0000122 VM& vm = m_validMachineFrame->vm();
123 return vm.vmEntryGlobalObject(m_validMachineFrame);
mark.lam@apple.come72693d2013-09-24 23:52:57 +0000124}
125
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000126SourceID DebuggerCallFrame::sourceID() const
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000127{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000128 ASSERT(isValid());
129 if (!isValid())
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000130 return noSourceID;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000131 if (isTailDeleted())
132 return m_shadowChickenFrame.codeBlock->ownerScriptExecutable()->sourceID();
133 return sourceIDForCallFrame(m_validMachineFrame);
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000134}
135
ggaren@apple.com0030e132012-09-12 06:14:56 +0000136String DebuggerCallFrame::functionName() const
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000137{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000138 ASSERT(isValid());
139 if (!isValid())
ggaren@apple.com0030e132012-09-12 06:14:56 +0000140 return String();
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000141
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000142 VM& vm = m_validMachineFrame->vm();
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000143 if (isTailDeleted()) {
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000144 if (JSFunction* func = jsDynamicCast<JSFunction*>(vm, m_shadowChickenFrame.callee))
145 return func->calculatedDisplayName(vm);
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000146 return m_shadowChickenFrame.codeBlock->inferredName().data();
147 }
148
149 return m_validMachineFrame->friendlyFunctionName();
aroben@apple.com261f1ff2009-05-15 18:13:28 +0000150}
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000151
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000152DebuggerScope* DebuggerCallFrame::scope()
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000153{
154 ASSERT(isValid());
155 if (!isValid())
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000156 return nullptr;
mark.lam@apple.com65a636f2014-02-01 01:24:39 +0000157
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000158 if (!m_scope) {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000159 VM& vm = m_validMachineFrame->vm();
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000160 JSScope* scope;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000161 CodeBlock* codeBlock = m_validMachineFrame->codeBlock();
162 if (isTailDeleted())
163 scope = m_shadowChickenFrame.scope;
164 else if (codeBlock && codeBlock->scopeRegister().isValid())
165 scope = m_validMachineFrame->scope(codeBlock->scopeRegister().offset());
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000166 else if (JSCallee* callee = jsDynamicCast<JSCallee*>(vm, m_validMachineFrame->jsCallee()))
msaboff@apple.com95c43152015-02-26 06:05:02 +0000167 scope = callee->scope();
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000168 else
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000169 scope = m_validMachineFrame->lexicalGlobalObject()->globalLexicalEnvironment();
mark.lam@apple.com8fe56b82014-08-09 06:50:19 +0000170
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000171 m_scope.set(vm, DebuggerScope::create(vm, scope));
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000172 }
173 return m_scope.get();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000174}
175
timothy@apple.comc14b52c2008-06-17 22:33:07 +0000176DebuggerCallFrame::Type DebuggerCallFrame::type() const
177{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000178 ASSERT(isValid());
179 if (!isValid())
180 return ProgramType;
181
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000182 if (isTailDeleted())
183 return FunctionType;
184
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000185 if (jsDynamicCast<JSFunction*>(m_validMachineFrame->vm(), m_validMachineFrame->jsCallee()))
timothy@apple.comc14b52c2008-06-17 22:33:07 +0000186 return FunctionType;
187
188 return ProgramType;
189}
190
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000191JSValue DebuggerCallFrame::thisValue() const
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000192{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000193 ASSERT(isValid());
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000194 if (!isValid())
195 return jsUndefined();
196
197 CodeBlock* codeBlock = nullptr;
198 JSValue thisValue;
199 if (isTailDeleted()) {
200 thisValue = m_shadowChickenFrame.thisValue;
201 codeBlock = m_shadowChickenFrame.codeBlock;
202 } else {
203 thisValue = m_validMachineFrame->thisValue();
204 codeBlock = m_validMachineFrame->codeBlock();
205 }
206
207 if (!thisValue)
208 return jsUndefined();
209
210 ECMAMode ecmaMode = NotStrictMode;
211 if (codeBlock && codeBlock->isStrictMode())
212 ecmaMode = StrictMode;
213 return thisValue.toThis(m_validMachineFrame, ecmaMode);
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000214}
215
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000216// Evaluate some JavaScript code in the scope of this frame.
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000217JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000218{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000219 ASSERT(isValid());
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000220 CallFrame* callFrame = m_validMachineFrame;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000221 if (!callFrame)
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000222 return jsUndefined();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000223
mark.lam@apple.com451de992016-09-07 22:10:50 +0000224 VM& vm = callFrame->vm();
225 JSLockHolder lock(vm);
226 auto catchScope = DECLARE_CATCH_SCOPE(vm);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000227
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000228 CodeBlock* codeBlock = nullptr;
229 if (isTailDeleted())
230 codeBlock = m_shadowChickenFrame.codeBlock;
231 else
232 codeBlock = callFrame->codeBlock();
233 if (!codeBlock)
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000234 return jsUndefined();
oliver@apple.comba10bec2011-03-08 23:17:32 +0000235
commit-queue@webkit.orgde3c7af2019-01-09 00:39:45 +0000236 DebuggerEvalEnabler evalEnabler(callFrame, DebuggerEvalEnabler::Mode::EvalOnCallFrameAtDebuggerEntry);
saambarati1@gmail.com144f17c2015-07-15 21:41:08 +0000237
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000238 EvalContextType evalContextType;
239
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000240 if (isFunctionParseMode(codeBlock->unlinkedCodeBlock()->parseMode()))
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000241 evalContextType = EvalContextType::FunctionEvalContext;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000242 else if (codeBlock->unlinkedCodeBlock()->codeType() == EvalCode)
243 evalContextType = codeBlock->unlinkedCodeBlock()->evalContextType();
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000244 else
245 evalContextType = EvalContextType::None;
246
saambarati1@gmail.com144f17c2015-07-15 21:41:08 +0000247 VariableEnvironment variablesUnderTDZ;
ggaren@apple.comd31d16d2016-11-14 22:57:12 +0000248 JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
saambarati1@gmail.com144f17c2015-07-15 21:41:08 +0000249
utatane.tea@gmail.comc4ec8e22016-12-26 06:35:07 +0000250 auto* eval = DirectEvalExecutable::create(callFrame, makeSource(script, callFrame->callerSourceOrigin()), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
mark.lam@apple.com451de992016-09-07 22:10:50 +0000251 if (UNLIKELY(catchScope.exception())) {
252 exception = catchScope.exception();
253 catchScope.clearException();
mark.lam@apple.com8f98b6b2014-01-25 03:15:13 +0000254 return jsUndefined();
oliver@apple.comba10bec2011-03-08 23:17:32 +0000255 }
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000256
mark.lam@apple.com3816a302018-08-23 22:57:09 +0000257 JSGlobalObject* globalObject = vm.vmEntryGlobalObject(callFrame);
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000258 if (scopeExtensionObject) {
259 JSScope* ignoredPreviousScope = globalObject->globalScope();
commit-queue@webkit.org30be13d2017-08-16 01:10:01 +0000260 globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, ignoredPreviousScope, scopeExtensionObject));
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000261 }
262
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000263 JSValue thisValue = this->thisValue();
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000264 JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope());
mark.lam@apple.com451de992016-09-07 22:10:50 +0000265 if (UNLIKELY(catchScope.exception())) {
266 exception = catchScope.exception();
267 catchScope.clearException();
barraclough@apple.com2607dd02010-10-27 20:46:09 +0000268 }
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000269
270 if (scopeExtensionObject)
271 globalObject->clearGlobalScopeExtension();
272
barraclough@apple.com2607dd02010-10-27 20:46:09 +0000273 ASSERT(result);
274 return result;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000275}
276
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000277void DebuggerCallFrame::invalidate()
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000278{
mark.lam@apple.com51d13152014-09-23 22:29:35 +0000279 RefPtr<DebuggerCallFrame> frame = this;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000280 while (frame) {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000281 frame->m_validMachineFrame = nullptr;
mark.lam@apple.com51d13152014-09-23 22:29:35 +0000282 if (frame->m_scope) {
283 frame->m_scope->invalidateChain();
284 frame->m_scope.clear();
285 }
krollin@apple.com77db1802016-06-20 20:52:45 +0000286 frame = WTFMove(frame->m_caller);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000287 }
288}
289
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000290TextPosition DebuggerCallFrame::currentPosition(VM& vm)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000291{
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000292 if (!m_validMachineFrame)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000293 return TextPosition();
294
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000295 if (isTailDeleted()) {
296 CodeBlock* codeBlock = m_shadowChickenFrame.codeBlock;
cdumez@apple.com8b7a0222018-12-20 04:41:11 +0000297 if (Optional<unsigned> bytecodeOffset = codeBlock->bytecodeOffsetFromCallSiteIndex(m_shadowChickenFrame.callSiteIndex)) {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000298 return TextPosition(OrdinalNumber::fromOneBasedInt(codeBlock->lineNumberForBytecodeOffset(*bytecodeOffset)),
299 OrdinalNumber::fromOneBasedInt(codeBlock->columnNumberForBytecodeOffset(*bytecodeOffset)));
300 }
301 }
302
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000303 return positionForCallFrame(vm, m_validMachineFrame);
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000304}
305
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000306TextPosition DebuggerCallFrame::positionForCallFrame(VM& vm, CallFrame* callFrame)
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000307{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000308 LineAndColumnFunctor functor;
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000309 StackVisitor::visit(callFrame, &vm, functor);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000310 return TextPosition(OrdinalNumber::fromOneBasedInt(functor.line()), OrdinalNumber::fromOneBasedInt(functor.column()));
311}
312
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000313SourceID DebuggerCallFrame::sourceIDForCallFrame(CallFrame* callFrame)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000314{
315 ASSERT(callFrame);
316 CodeBlock* codeBlock = callFrame->codeBlock();
317 if (!codeBlock)
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000318 return noSourceID;
commit-queue@webkit.orgfa196632015-08-28 21:07:22 +0000319 return codeBlock->ownerScriptExecutable()->sourceID();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000320}
321
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +0000322} // namespace JSC