blob: 85215bd3804bcc3458dbe17c662bb0296e64320a [file] [log] [blame]
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +00001/*
mark.lam@apple.com7f569782022-05-04 17:44:44 +00002 * Copyright (C) 2008-2022 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"
mark.lam@apple.com65a636f2014-02-01 01:24:39 +000037#include "JSFunction.h"
joepeck@webkit.org70d6a302016-05-10 19:16:19 +000038#include "JSWithScope.h"
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000039#include "ShadowChickenInlines.h"
mark.lam@apple.come72693d2013-09-24 23:52:57 +000040#include "StackVisitor.h"
mark.lam@apple.com268dda72014-08-29 00:48:59 +000041#include "StrongInlines.h"
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000042
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000043namespace JSC {
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000044
mark.lam@apple.come72693d2013-09-24 23:52:57 +000045class LineAndColumnFunctor {
46public:
mark.lam@apple.com7f569782022-05-04 17:44:44 +000047 IterationStatus operator()(StackVisitor& visitor) const
mark.lam@apple.come72693d2013-09-24 23:52:57 +000048 {
49 visitor->computeLineAndColumn(m_line, m_column);
mark.lam@apple.com7f569782022-05-04 17:44:44 +000050 return IterationStatus::Done;
mark.lam@apple.come72693d2013-09-24 23:52:57 +000051 }
52
53 unsigned line() const { return m_line; }
54 unsigned column() const { return m_column; }
55
56private:
ddkilzer@apple.com137187c2018-07-01 00:06:38 +000057 mutable unsigned m_line { 0 };
58 mutable unsigned m_column { 0 };
mark.lam@apple.come72693d2013-09-24 23:52:57 +000059};
60
sbarati@apple.com5db42f82017-04-04 22:23:37 +000061Ref<DebuggerCallFrame> DebuggerCallFrame::create(VM& vm, CallFrame* callFrame)
mark.lam@apple.come72693d2013-09-24 23:52:57 +000062{
ysuzuki@apple.com52e98bb2019-10-22 09:24:48 +000063 if (UNLIKELY(!callFrame)) {
64 ShadowChicken::Frame emptyFrame;
65 RELEASE_ASSERT(!emptyFrame.isTailDeleted);
66 return adoptRef(*new DebuggerCallFrame(vm, callFrame, emptyFrame));
67 }
68
ysuzuki@apple.com8db58e82022-04-13 21:01:19 +000069 if (callFrame->isEmptyTopLevelCallFrameForDebugger()) {
sbarati@apple.com867f8842016-05-27 23:42:08 +000070 ShadowChicken::Frame emptyFrame;
71 RELEASE_ASSERT(!emptyFrame.isTailDeleted);
sbarati@apple.com5db42f82017-04-04 22:23:37 +000072 return adoptRef(*new DebuggerCallFrame(vm, callFrame, emptyFrame));
sbarati@apple.com867f8842016-05-27 23:42:08 +000073 }
74
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000075 Vector<ShadowChicken::Frame> frames;
ysuzuki@apple.com0a831252019-01-29 04:33:33 +000076 vm.ensureShadowChicken();
77 vm.shadowChicken()->iterate(vm, callFrame, [&] (const ShadowChicken::Frame& frame) -> bool {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000078 frames.append(frame);
79 return true;
80 });
81
82 RELEASE_ASSERT(frames.size());
sbarati@apple.comed3e9f52016-05-27 20:26:06 +000083 ASSERT(!frames[0].isTailDeleted); // The top frame should never be tail deleted.
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000084
85 RefPtr<DebuggerCallFrame> currentParent = nullptr;
sbarati@apple.comed3e9f52016-05-27 20:26:06 +000086 // This walks the stack from the entry stack frame to the top of the stack.
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000087 for (unsigned i = frames.size(); i--; ) {
88 const ShadowChicken::Frame& frame = frames[i];
89 if (!frame.isTailDeleted)
ysuzuki@apple.com52e98bb2019-10-22 09:24:48 +000090 callFrame = frame.frame;
91 Ref<DebuggerCallFrame> currentFrame = adoptRef(*new DebuggerCallFrame(vm, callFrame, frame));
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000092 currentFrame->m_caller = currentParent;
93 currentParent = WTFMove(currentFrame);
94 }
95 return *currentParent;
96}
97
sbarati@apple.com5db42f82017-04-04 22:23:37 +000098DebuggerCallFrame::DebuggerCallFrame(VM& vm, CallFrame* callFrame, const ShadowChicken::Frame& frame)
sbarati@apple.comce5b05e2016-05-16 23:31:39 +000099 : m_validMachineFrame(callFrame)
100 , m_shadowChickenFrame(frame)
101{
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000102 m_position = currentPosition(vm);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000103}
104
gyuyoung.kim@webkit.orgbe3842f2015-06-13 03:52:06 +0000105RefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame()
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000106{
107 ASSERT(isValid());
108 if (!isValid())
gyuyoung.kim@webkit.orgbe3842f2015-06-13 03:52:06 +0000109 return nullptr;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000110
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000111 return m_caller;
112}
113
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000114JSGlobalObject* DebuggerCallFrame::globalObject(VM& vm)
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000115{
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000116 return scope(vm)->globalObject();
mark.lam@apple.come72693d2013-09-24 23:52:57 +0000117}
118
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000119SourceID DebuggerCallFrame::sourceID() const
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000120{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000121 ASSERT(isValid());
122 if (!isValid())
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000123 return noSourceID;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000124 if (isTailDeleted())
ysuzuki@apple.comc9db6aa2019-02-09 00:29:21 +0000125 return m_shadowChickenFrame.codeBlock->ownerExecutable()->sourceID();
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000126 return sourceIDForCallFrame(m_validMachineFrame);
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000127}
128
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000129String DebuggerCallFrame::functionName(VM& vm) const
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000130{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000131 ASSERT(isValid());
132 if (!isValid())
ggaren@apple.com0030e132012-09-12 06:14:56 +0000133 return String();
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000134
135 if (isTailDeleted()) {
ysuzuki@apple.com984775d2022-04-16 00:00:35 +0000136 if (JSFunction* func = jsDynamicCast<JSFunction*>(m_shadowChickenFrame.callee))
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000137 return func->calculatedDisplayName(vm);
cdumez@apple.com78ea99a2022-04-06 19:05:23 +0000138 return String::fromLatin1(m_shadowChickenFrame.codeBlock->inferredName().data());
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000139 }
140
141 return m_validMachineFrame->friendlyFunctionName();
aroben@apple.com261f1ff2009-05-15 18:13:28 +0000142}
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000143
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000144DebuggerScope* DebuggerCallFrame::scope(VM& vm)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000145{
146 ASSERT(isValid());
147 if (!isValid())
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000148 return nullptr;
mark.lam@apple.com65a636f2014-02-01 01:24:39 +0000149
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000150 if (!m_scope) {
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000151 JSScope* scope;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000152 CodeBlock* codeBlock = m_validMachineFrame->codeBlock();
153 if (isTailDeleted())
154 scope = m_shadowChickenFrame.scope;
155 else if (codeBlock && codeBlock->scopeRegister().isValid())
156 scope = m_validMachineFrame->scope(codeBlock->scopeRegister().offset());
ysuzuki@apple.com984775d2022-04-16 00:00:35 +0000157 else if (JSCallee* callee = jsDynamicCast<JSCallee*>(m_validMachineFrame->jsCallee()))
msaboff@apple.com95c43152015-02-26 06:05:02 +0000158 scope = callee->scope();
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000159 else
ysuzuki@apple.com60f63df2019-10-24 05:34:21 +0000160 scope = m_validMachineFrame->lexicalGlobalObject(vm)->globalLexicalEnvironment();
mark.lam@apple.com8fe56b82014-08-09 06:50:19 +0000161
msaboff@apple.com5e62e3f2014-11-21 23:41:26 +0000162 m_scope.set(vm, DebuggerScope::create(vm, scope));
mark.lam@apple.com268dda72014-08-29 00:48:59 +0000163 }
164 return m_scope.get();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000165}
166
ysuzuki@apple.com984775d2022-04-16 00:00:35 +0000167DebuggerCallFrame::Type DebuggerCallFrame::type(VM&) const
timothy@apple.comc14b52c2008-06-17 22:33:07 +0000168{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000169 ASSERT(isValid());
170 if (!isValid())
171 return ProgramType;
172
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000173 if (isTailDeleted())
174 return FunctionType;
175
ysuzuki@apple.com984775d2022-04-16 00:00:35 +0000176 if (jsDynamicCast<JSFunction*>(m_validMachineFrame->jsCallee()))
timothy@apple.comc14b52c2008-06-17 22:33:07 +0000177 return FunctionType;
178
179 return ProgramType;
180}
181
ysuzuki@apple.com60f63df2019-10-24 05:34:21 +0000182JSValue DebuggerCallFrame::thisValue(VM& vm) const
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000183{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000184 ASSERT(isValid());
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000185 if (!isValid())
186 return jsUndefined();
187
188 CodeBlock* codeBlock = nullptr;
189 JSValue thisValue;
190 if (isTailDeleted()) {
191 thisValue = m_shadowChickenFrame.thisValue;
192 codeBlock = m_shadowChickenFrame.codeBlock;
193 } else {
194 thisValue = m_validMachineFrame->thisValue();
195 codeBlock = m_validMachineFrame->codeBlock();
196 }
197
198 if (!thisValue)
199 return jsUndefined();
200
tzagallo@apple.coma6b8c342020-04-07 22:32:21 +0000201 ECMAMode ecmaMode = ECMAMode::sloppy();
202 if (codeBlock && codeBlock->ownerExecutable()->isInStrictContext())
203 ecmaMode = ECMAMode::strict();
ysuzuki@apple.com60f63df2019-10-24 05:34:21 +0000204 return thisValue.toThis(m_validMachineFrame->lexicalGlobalObject(vm), ecmaMode);
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000205}
206
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000207// Evaluate some JavaScript code in the scope of this frame.
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000208JSValue DebuggerCallFrame::evaluateWithScopeExtension(VM& vm, const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000209{
drousso@apple.com9d5c1162020-09-03 17:53:21 +0000210 CallFrame* callFrame = nullptr;
211 CodeBlock* codeBlock = nullptr;
212
213 auto* debuggerCallFrame = this;
214 while (debuggerCallFrame) {
215 ASSERT(debuggerCallFrame->isValid());
216
217 callFrame = debuggerCallFrame->m_validMachineFrame;
218 if (callFrame) {
219 if (debuggerCallFrame->isTailDeleted())
220 codeBlock = debuggerCallFrame->m_shadowChickenFrame.codeBlock;
221 else
222 codeBlock = callFrame->codeBlock();
223 }
224
225 if (callFrame && codeBlock)
226 break;
227
228 debuggerCallFrame = debuggerCallFrame->m_caller.get();
229 }
230
231 if (!callFrame || !codeBlock)
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000232 return jsUndefined();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000233
mark.lam@apple.com451de992016-09-07 22:10:50 +0000234 JSLockHolder lock(vm);
235 auto catchScope = DECLARE_CATCH_SCOPE(vm);
oliver@apple.comba10bec2011-03-08 23:17:32 +0000236
ysuzuki@apple.com52e98bb2019-10-22 09:24:48 +0000237 JSGlobalObject* globalObject = codeBlock->globalObject();
238 DebuggerEvalEnabler evalEnabler(globalObject, DebuggerEvalEnabler::Mode::EvalOnGlobalObjectAtDebuggerEntry);
saambarati1@gmail.com144f17c2015-07-15 21:41:08 +0000239
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000240 EvalContextType evalContextType;
241
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000242 if (isFunctionParseMode(codeBlock->unlinkedCodeBlock()->parseMode()))
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000243 evalContextType = EvalContextType::FunctionEvalContext;
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000244 else if (codeBlock->unlinkedCodeBlock()->codeType() == EvalCode)
245 evalContextType = codeBlock->unlinkedCodeBlock()->evalContextType();
gskachkov@gmail.coma3f0cdf2016-04-03 07:59:19 +0000246 else
247 evalContextType = EvalContextType::None;
248
sbarati@apple.com1ffc4442020-10-28 19:25:14 +0000249 TDZEnvironment variablesUnderTDZ;
ticaiolima@gmail.comc2ba2ac2021-02-09 16:30:24 +0000250 PrivateNameEnvironment privateNameEnvironment;
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000251 JSScope::collectClosureVariablesUnderTDZ(scope(vm)->jsScope(), variablesUnderTDZ, privateNameEnvironment);
saambarati1@gmail.com144f17c2015-07-15 21:41:08 +0000252
tzagallo@apple.coma6b8c342020-04-07 22:32:21 +0000253 ECMAMode ecmaMode = codeBlock->ownerExecutable()->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy();
ticaiolima@gmail.comc2ba2ac2021-02-09 16:30:24 +0000254 auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()->privateBrandRequirement(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), codeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNameEnvironment, ecmaMode);
mark.lam@apple.com451de992016-09-07 22:10:50 +0000255 if (UNLIKELY(catchScope.exception())) {
256 exception = catchScope.exception();
257 catchScope.clearException();
mark.lam@apple.com8f98b6b2014-01-25 03:15:13 +0000258 return jsUndefined();
oliver@apple.comba10bec2011-03-08 23:17:32 +0000259 }
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000260
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000261 if (scopeExtensionObject) {
262 JSScope* ignoredPreviousScope = globalObject->globalScope();
commit-queue@webkit.org30be13d2017-08-16 01:10:01 +0000263 globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, ignoredPreviousScope, scopeExtensionObject));
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000264 }
265
ysuzuki@apple.com3b713e32022-04-14 21:56:27 +0000266 JSValue result = vm.interpreter->execute(eval, globalObject, debuggerCallFrame->thisValue(vm), debuggerCallFrame->scope(vm)->jsScope());
mark.lam@apple.com451de992016-09-07 22:10:50 +0000267 if (UNLIKELY(catchScope.exception())) {
268 exception = catchScope.exception();
269 catchScope.clearException();
barraclough@apple.com2607dd02010-10-27 20:46:09 +0000270 }
joepeck@webkit.org70d6a302016-05-10 19:16:19 +0000271
272 if (scopeExtensionObject)
273 globalObject->clearGlobalScopeExtension();
274
barraclough@apple.com2607dd02010-10-27 20:46:09 +0000275 ASSERT(result);
276 return result;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000277}
278
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000279void DebuggerCallFrame::invalidate()
mark.lam@apple.com649480f2013-09-12 16:27:55 +0000280{
mark.lam@apple.com51d13152014-09-23 22:29:35 +0000281 RefPtr<DebuggerCallFrame> frame = this;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000282 while (frame) {
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000283 frame->m_validMachineFrame = nullptr;
mark.lam@apple.com51d13152014-09-23 22:29:35 +0000284 if (frame->m_scope) {
285 frame->m_scope->invalidateChain();
286 frame->m_scope.clear();
287 }
krollin@apple.com77db1802016-06-20 20:52:45 +0000288 frame = WTFMove(frame->m_caller);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000289 }
290}
291
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000292TextPosition DebuggerCallFrame::currentPosition(VM& vm)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000293{
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000294 if (!m_validMachineFrame)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000295 return TextPosition();
296
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000297 if (isTailDeleted()) {
298 CodeBlock* codeBlock = m_shadowChickenFrame.codeBlock;
darin@apple.coma4ddc782021-05-30 16:11:40 +0000299 if (std::optional<BytecodeIndex> bytecodeIndex = codeBlock->bytecodeIndexFromCallSiteIndex(m_shadowChickenFrame.callSiteIndex)) {
keith_miller@apple.com0f985ec2019-10-23 00:55:38 +0000300 return TextPosition(OrdinalNumber::fromOneBasedInt(codeBlock->lineNumberForBytecodeIndex(*bytecodeIndex)),
301 OrdinalNumber::fromOneBasedInt(codeBlock->columnNumberForBytecodeIndex(*bytecodeIndex)));
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000302 }
303 }
304
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000305 return positionForCallFrame(vm, m_validMachineFrame);
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000306}
307
sbarati@apple.com5db42f82017-04-04 22:23:37 +0000308TextPosition DebuggerCallFrame::positionForCallFrame(VM& vm, CallFrame* callFrame)
sbarati@apple.comce5b05e2016-05-16 23:31:39 +0000309{
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000310 LineAndColumnFunctor functor;
ysuzuki@apple.com8db58e82022-04-13 21:01:19 +0000311 if (!callFrame)
312 return TextPosition(OrdinalNumber::fromOneBasedInt(0), OrdinalNumber::fromOneBasedInt(0));
ysuzuki@apple.com638dc2a2019-10-22 21:23:26 +0000313 StackVisitor::visit(callFrame, vm, functor);
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000314 return TextPosition(OrdinalNumber::fromOneBasedInt(functor.line()), OrdinalNumber::fromOneBasedInt(functor.column()));
315}
316
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000317SourceID DebuggerCallFrame::sourceIDForCallFrame(CallFrame* callFrame)
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000318{
ysuzuki@apple.com52e98bb2019-10-22 09:24:48 +0000319 if (!callFrame)
320 return noSourceID;
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000321 CodeBlock* codeBlock = callFrame->codeBlock();
tzagallo@apple.com9fd9b242019-11-08 00:37:52 +0000322 if (!codeBlock || callFrame->callee().isWasm())
mark.lam@apple.com26c53402013-11-08 20:03:50 +0000323 return noSourceID;
ysuzuki@apple.comc9db6aa2019-02-09 00:29:21 +0000324 return codeBlock->ownerExecutable()->sourceID();
mark.lam@apple.comaf032dd2013-10-05 00:51:31 +0000325}
326
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +0000327} // namespace JSC