| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#include "debugger/ExecutionTracer.h" |
| 8 |
|
| 9 |
#include "debugger/Frame.h" // DebuggerFrameType |
| 10 |
#include "vm/ObjectOperations.h" // DefineDataElement |
| 11 |
#include "vm/Time.h" |
| 12 |
|
| 13 |
#include "debugger/Debugger-inl.h" |
| 14 |
#include "vm/Stack-inl.h" |
| 15 |
|
| 16 |
using namespace js; |
| 17 |
|
| 18 |
enum class OutOfLineEntryType : uint8_t { |
| 19 |
ScriptURL, |
| 20 |
Atom, |
| 21 |
}; |
| 22 |
|
| 23 |
enum class InlineEntryType : uint8_t { |
| 24 |
StackFunctionEnter, |
| 25 |
StackFunctionLeave, |
| 26 |
LabelEnter, |
| 27 |
LabelLeave, |
| 28 |
Error, |
| 29 |
}; |
| 30 |
|
| 31 |
MOZ_RUNINIT mozilla::Vector<ExecutionTracer*> ExecutionTracer::globalInstances; |
| 32 |
MOZ_RUNINIT Mutex |
| 33 |
ExecutionTracer::globalInstanceLock(mutexid::ExecutionTracerGlobalLock); |
| 34 |
|
| 35 |
static JS::ExecutionTrace::ImplementationType GetImplementation( |
| 36 |
AbstractFramePtr frame) { |
| 37 |
if (frame.isBaselineFrame()) { |
| 38 |
return JS::ExecutionTrace::ImplementationType::Baseline; |
| 39 |
} |
| 40 |
|
| 41 |
if (frame.isRematerializedFrame()) { |
| 42 |
return JS::ExecutionTrace::ImplementationType::Ion; |
| 43 |
} |
| 44 |
|
| 45 |
if (frame.isWasmDebugFrame()) { |
| 46 |
return JS::ExecutionTrace::ImplementationType::Wasm; |
| 47 |
} |
| 48 |
|
| 49 |
return JS::ExecutionTrace::ImplementationType::Interpreter; |
| 50 |
} |
| 51 |
|
| 52 |
static DebuggerFrameType GetFrameType(AbstractFramePtr frame) { |
| 53 |
// Indirect eval frames are both isGlobalFrame() and isEvalFrame(), so the |
| 54 |
// order of checks here is significant. |
| 55 |
if (frame.isEvalFrame()) { |
| 56 |
return DebuggerFrameType::Eval; |
| 57 |
} |
| 58 |
|
| 59 |
if (frame.isGlobalFrame()) { |
| 60 |
return DebuggerFrameType::Global; |
| 61 |
} |
| 62 |
|
| 63 |
if (frame.isFunctionFrame()) { |
| 64 |
return DebuggerFrameType::Call; |
| 65 |
} |
| 66 |
|
| 67 |
if (frame.isModuleFrame()) { |
| 68 |
return DebuggerFrameType::Module; |
| 69 |
} |
| 70 |
|
| 71 |
if (frame.isWasmDebugFrame()) { |
| 72 |
return DebuggerFrameType::WasmCall; |
| 73 |
} |
| 74 |
|
| 75 |
MOZ_CRASH("Unknown frame type"); |
| 76 |
} |
| 77 |
|
| 78 |
[[nodiscard]] static bool GetFunctionName(JSContext* cx, |
| 79 |
JS::Handle<JSFunction*> fun, |
| 80 |
JS::MutableHandle<JSAtom*> result) { |
| 81 |
if (!fun->getDisplayAtom(cx, result)) { |
| 82 |
return false; |
| 83 |
} |
| 84 |
|
| 85 |
if (result) { |
| 86 |
cx->markAtom(result); |
| 87 |
} |
| 88 |
return true; |
| 89 |
} |
| 90 |
|
| 91 |
static double GetNowMilliseconds() { |
| 92 |
return (mozilla::TimeStamp::Now() - mozilla::TimeStamp::ProcessCreation()) |
| 93 |
.ToMilliseconds(); |
| 94 |
} |
| 95 |
|
| 96 |
void ExecutionTracer::handleError(JSContext* cx) { |
| 97 |
inlineData_.beginWritingEntry(); |
| 98 |
inlineData_.write(uint8_t(InlineEntryType::Error)); |
| 99 |
inlineData_.finishWritingEntry(); |
| 100 |
cx->clearPendingException(); |
| 101 |
cx->suspendExecutionTracing(); |
| 102 |
} |
| 103 |
|
| 104 |
void ExecutionTracer::writeScriptUrl(ScriptSource* scriptSource) { |
| 105 |
outOfLineData_.beginWritingEntry(); |
| 106 |
outOfLineData_.write(uint8_t(OutOfLineEntryType::ScriptURL)); |
| 107 |
outOfLineData_.write(scriptSource->id()); |
| 108 |
|
| 109 |
if (scriptSource->hasDisplayURL()) { |
| 110 |
outOfLineData_.writeCString<char16_t, TracerStringEncoding::TwoByte>( |
| 111 |
scriptSource->displayURL()); |
| 112 |
} else { |
| 113 |
const char* filename = |
| 114 |
scriptSource->filename() ? scriptSource->filename() : ""; |
| 115 |
outOfLineData_.writeCString<char, TracerStringEncoding::UTF8>(filename); |
| 116 |
} |
| 117 |
outOfLineData_.finishWritingEntry(); |
| 118 |
} |
| 119 |
|
| 120 |
bool ExecutionTracer::writeAtom(JSContext* cx, JS::Handle<JSAtom*> atom, |
| 121 |
uint32_t id) { |
| 122 |
outOfLineData_.beginWritingEntry(); |
| 123 |
outOfLineData_.write(uint8_t(OutOfLineEntryType::Atom)); |
| 124 |
outOfLineData_.write(id); |
| 125 |
|
| 126 |
if (!atom) { |
| 127 |
outOfLineData_.writeEmptyString(); |
| 128 |
} else { |
| 129 |
if (!outOfLineData_.writeString(cx, atom)) { |
| 130 |
return false; |
| 131 |
} |
| 132 |
} |
| 133 |
outOfLineData_.finishWritingEntry(); |
| 134 |
return true; |
| 135 |
} |
| 136 |
|
| 137 |
bool ExecutionTracer::writeFunctionFrame(JSContext* cx, |
| 138 |
AbstractFramePtr frame) { |
| 139 |
JS::Rooted<JSFunction*> fn(cx, frame.callee()); |
| 140 |
TracingCaches& caches = cx->caches().tracingCaches; |
| 141 |
if (fn->baseScript()) { |
| 142 |
uint32_t scriptSourceId = fn->baseScript()->scriptSource()->id(); |
| 143 |
TracingCaches::GetOrPutResult scriptSourceRes = |
| 144 |
caches.putScriptSourceIfMissing(scriptSourceId); |
| 145 |
if (scriptSourceRes == TracingCaches::GetOrPutResult::OOM) { |
| 146 |
ReportOutOfMemory(cx); |
| 147 |
return false; |
| 148 |
} |
| 149 |
if (scriptSourceRes == TracingCaches::GetOrPutResult::NewlyAdded) { |
| 150 |
writeScriptUrl(fn->baseScript()->scriptSource()); |
| 151 |
} |
| 152 |
inlineData_.write(fn->baseScript()->lineno()); |
| 153 |
inlineData_.write(fn->baseScript()->column().oneOriginValue()); |
| 154 |
inlineData_.write(scriptSourceId); |
| 155 |
inlineData_.write( |
| 156 |
fn->baseScript()->realm()->creationOptions().profilerRealmID()); |
| 157 |
} else { |
| 158 |
// In the case of no baseScript, we just fill it out with 0s. 0 is an |
| 159 |
// invalid script source ID, so it is distinguishable from a real one |
| 160 |
inlineData_.write(uint32_t(0)); // line number |
| 161 |
inlineData_.write(uint32_t(0)); // column |
| 162 |
inlineData_.write(uint32_t(0)); // script source id |
| 163 |
} |
| 164 |
|
| 165 |
JS::Rooted<JSAtom*> functionName(cx); |
| 166 |
if (!GetFunctionName(cx, fn, &functionName)) { |
| 167 |
return false; |
| 168 |
} |
| 169 |
uint32_t functionNameId = 0; |
| 170 |
TracingCaches::GetOrPutResult fnNameRes = |
| 171 |
caches.getOrPutAtom(functionName, &functionNameId); |
| 172 |
if (fnNameRes == TracingCaches::GetOrPutResult::OOM) { |
| 173 |
ReportOutOfMemory(cx); |
| 174 |
return false; |
| 175 |
} |
| 176 |
if (fnNameRes == TracingCaches::GetOrPutResult::NewlyAdded) { |
| 177 |
if (!writeAtom(cx, functionName, functionNameId)) { |
| 178 |
// It's worth noting here that this will leave the caches out of sync |
| 179 |
// with what has actually been written into the out of line data. |
| 180 |
// This is a normal and allowed situation for the tracer, so we have |
| 181 |
// no special handling here for it. However, if we ever want to make |
| 182 |
// a stronger guarantee in the future, we need to revisit this. |
| 183 |
return false; |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
inlineData_.write(functionNameId); |
| 188 |
inlineData_.write(uint8_t(GetImplementation(frame))); |
| 189 |
inlineData_.write(GetNowMilliseconds()); |
| 190 |
return true; |
| 191 |
} |
| 192 |
|
| 193 |
void ExecutionTracer::onEnterFrame(JSContext* cx, AbstractFramePtr frame) { |
| 194 |
LockGuard<Mutex> guard(bufferLock_); |
| 195 |
|
| 196 |
DebuggerFrameType type = GetFrameType(frame); |
| 197 |
if (type == DebuggerFrameType::Call) { |
| 198 |
if (frame.isFunctionFrame() && !frame.callee()->isSelfHostedBuiltin()) { |
| 199 |
inlineData_.beginWritingEntry(); |
| 200 |
inlineData_.write(uint8_t(InlineEntryType::StackFunctionEnter)); |
| 201 |
if (!writeFunctionFrame(cx, frame)) { |
| 202 |
handleError(cx); |
| 203 |
return; |
| 204 |
} |
| 205 |
|
| 206 |
inlineData_.finishWritingEntry(); |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
void ExecutionTracer::onLeaveFrame(JSContext* cx, AbstractFramePtr frame) { |
| 212 |
LockGuard<Mutex> guard(bufferLock_); |
| 213 |
|
| 214 |
DebuggerFrameType type = GetFrameType(frame); |
| 215 |
if (type == DebuggerFrameType::Call) { |
| 216 |
if (frame.isFunctionFrame() && !frame.callee()->isSelfHostedBuiltin()) { |
| 217 |
inlineData_.beginWritingEntry(); |
| 218 |
inlineData_.write(uint8_t(InlineEntryType::StackFunctionLeave)); |
| 219 |
if (!writeFunctionFrame(cx, frame)) { |
| 220 |
handleError(cx); |
| 221 |
return; |
| 222 |
} |
| 223 |
inlineData_.finishWritingEntry(); |
| 224 |
} |
| 225 |
} |
| 226 |
} |
| 227 |
|
| 228 |
template <typename CharType, TracerStringEncoding Encoding> |
| 229 |
void ExecutionTracer::onEnterLabel(const CharType* eventType) { |
| 230 |
LockGuard<Mutex> guard(bufferLock_); |
| 231 |
|
| 232 |
inlineData_.beginWritingEntry(); |
| 233 |
inlineData_.write(uint8_t(InlineEntryType::LabelEnter)); |
| 234 |
inlineData_.writeCString<CharType, Encoding>(eventType); |
| 235 |
inlineData_.write(GetNowMilliseconds()); |
| 236 |
inlineData_.finishWritingEntry(); |
| 237 |
} |
| 238 |
|
| 239 |
template <typename CharType, TracerStringEncoding Encoding> |
| 240 |
void ExecutionTracer::onLeaveLabel(const CharType* eventType) { |
| 241 |
LockGuard<Mutex> guard(bufferLock_); |
| 242 |
|
| 243 |
inlineData_.beginWritingEntry(); |
| 244 |
inlineData_.write(uint8_t(InlineEntryType::LabelLeave)); |
| 245 |
inlineData_.writeCString<CharType, Encoding>(eventType); |
| 246 |
inlineData_.write(GetNowMilliseconds()); |
| 247 |
inlineData_.finishWritingEntry(); |
| 248 |
} |
| 249 |
|
| 250 |
bool ExecutionTracer::readFunctionFrame( |
| 251 |
JS::ExecutionTrace::EventKind kind, |
| 252 |
JS::ExecutionTrace::TracedEvent& event) { |
| 253 |
MOZ_ASSERT(kind == JS::ExecutionTrace::EventKind::FunctionEnter || |
| 254 |
kind == JS::ExecutionTrace::EventKind::FunctionLeave); |
| 255 |
|
| 256 |
event.kind = kind; |
| 257 |
|
| 258 |
uint8_t implementation; |
| 259 |
inlineData_.read(&event.functionEvent.lineNumber); |
| 260 |
inlineData_.read(&event.functionEvent.column); |
| 261 |
inlineData_.read(&event.functionEvent.scriptId); |
| 262 |
inlineData_.read(&event.functionEvent.realmID); |
| 263 |
inlineData_.read(&event.functionEvent.functionNameId); |
| 264 |
inlineData_.read(&implementation); |
| 265 |
inlineData_.read(&event.time); |
| 266 |
|
| 267 |
event.functionEvent.implementation = |
| 268 |
JS::ExecutionTrace::ImplementationType(implementation); |
| 269 |
|
| 270 |
return true; |
| 271 |
} |
| 272 |
|
| 273 |
bool ExecutionTracer::readLabel(JS::ExecutionTrace::EventKind kind, |
| 274 |
JS::ExecutionTrace::TracedEvent& event, |
| 275 |
TracingScratchBuffer& scratchBuffer, |
| 276 |
mozilla::Vector<char>& stringBuffer) { |
| 277 |
MOZ_ASSERT(kind == JS::ExecutionTrace::EventKind::LabelEnter || |
| 278 |
kind == JS::ExecutionTrace::EventKind::LabelLeave); |
| 279 |
|
| 280 |
event.kind = kind; |
| 281 |
size_t index; |
| 282 |
if (!inlineData_.readString(scratchBuffer, stringBuffer, &index)) { |
| 283 |
return false; |
| 284 |
} |
| 285 |
event.labelEvent.label = index; |
| 286 |
|
| 287 |
double time; |
| 288 |
inlineData_.read(&time); |
| 289 |
event.time = time; |
| 290 |
|
| 291 |
return true; |
| 292 |
} |
| 293 |
|
| 294 |
bool ExecutionTracer::readInlineEntry( |
| 295 |
mozilla::Vector<JS::ExecutionTrace::TracedEvent>& events, |
| 296 |
TracingScratchBuffer& scratchBuffer, mozilla::Vector<char>& stringBuffer) { |
| 297 |
uint8_t entryType; |
| 298 |
inlineData_.read(&entryType); |
| 299 |
|
| 300 |
switch (InlineEntryType(entryType)) { |
| 301 |
case InlineEntryType::StackFunctionEnter: |
| 302 |
case InlineEntryType::StackFunctionLeave: { |
| 303 |
JS::ExecutionTrace::EventKind kind; |
| 304 |
if (InlineEntryType(entryType) == InlineEntryType::StackFunctionEnter) { |
| 305 |
kind = JS::ExecutionTrace::EventKind::FunctionEnter; |
| 306 |
} else { |
| 307 |
kind = JS::ExecutionTrace::EventKind::FunctionLeave; |
| 308 |
} |
| 309 |
JS::ExecutionTrace::TracedEvent event; |
| 310 |
if (!readFunctionFrame(kind, event)) { |
| 311 |
return false; |
| 312 |
} |
| 313 |
|
| 314 |
if (!events.append(std::move(event))) { |
| 315 |
return false; |
| 316 |
} |
| 317 |
return true; |
| 318 |
} |
| 319 |
case InlineEntryType::LabelEnter: |
| 320 |
case InlineEntryType::LabelLeave: { |
| 321 |
JS::ExecutionTrace::EventKind kind; |
| 322 |
if (InlineEntryType(entryType) == InlineEntryType::LabelEnter) { |
| 323 |
kind = JS::ExecutionTrace::EventKind::LabelEnter; |
| 324 |
} else { |
| 325 |
kind = JS::ExecutionTrace::EventKind::LabelLeave; |
| 326 |
} |
| 327 |
|
| 328 |
JS::ExecutionTrace::TracedEvent event; |
| 329 |
if (!readLabel(kind, event, scratchBuffer, stringBuffer)) { |
| 330 |
return false; |
| 331 |
} |
| 332 |
|
| 333 |
if (!events.append(std::move(event))) { |
| 334 |
return false; |
| 335 |
} |
| 336 |
|
| 337 |
return true; |
| 338 |
} |
| 339 |
case InlineEntryType::Error: { |
| 340 |
JS::ExecutionTrace::TracedEvent event; |
| 341 |
event.kind = JS::ExecutionTrace::EventKind::Error; |
| 342 |
|
| 343 |
if (!events.append(std::move(event))) { |
| 344 |
return false; |
| 345 |
} |
| 346 |
|
| 347 |
return true; |
| 348 |
} |
| 349 |
default: |
| 350 |
return false; |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
bool ExecutionTracer::readOutOfLineEntry( |
| 355 |
mozilla::HashMap<uint32_t, size_t>& scriptUrls, |
| 356 |
mozilla::HashMap<uint32_t, size_t>& atoms, |
| 357 |
TracingScratchBuffer& scratchBuffer, mozilla::Vector<char>& stringBuffer) { |
| 358 |
uint8_t entryType; |
| 359 |
outOfLineData_.read(&entryType); |
| 360 |
|
| 361 |
switch (OutOfLineEntryType(entryType)) { |
| 362 |
case OutOfLineEntryType::ScriptURL: { |
| 363 |
uint32_t id; |
| 364 |
outOfLineData_.read(&id); |
| 365 |
|
| 366 |
size_t index; |
| 367 |
if (!outOfLineData_.readString(scratchBuffer, stringBuffer, &index)) { |
| 368 |
return false; |
| 369 |
} |
| 370 |
|
| 371 |
if (!scriptUrls.put(id, index)) { |
| 372 |
return false; |
| 373 |
} |
| 374 |
|
| 375 |
return true; |
| 376 |
} |
| 377 |
case OutOfLineEntryType::Atom: { |
| 378 |
uint32_t id; |
| 379 |
outOfLineData_.read(&id); |
| 380 |
|
| 381 |
size_t index; |
| 382 |
if (!outOfLineData_.readString(scratchBuffer, stringBuffer, &index)) { |
| 383 |
return false; |
| 384 |
} |
| 385 |
|
| 386 |
if (!atoms.put(id, index)) { |
| 387 |
return false; |
| 388 |
} |
| 389 |
|
| 390 |
return true; |
| 391 |
} |
| 392 |
default: |
| 393 |
return false; |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
bool ExecutionTracer::readInlineEntries( |
| 398 |
mozilla::Vector<JS::ExecutionTrace::TracedEvent>& events, |
| 399 |
TracingScratchBuffer& scratchBuffer, mozilla::Vector<char>& stringBuffer) { |
| 400 |
while (inlineData_.readable()) { |
| 401 |
inlineData_.beginReadingEntry(); |
| 402 |
if (!readInlineEntry(events, scratchBuffer, stringBuffer)) { |
| 403 |
inlineData_.skipEntry(); |
| 404 |
return false; |
| 405 |
} |
| 406 |
inlineData_.finishReadingEntry(); |
| 407 |
} |
| 408 |
return true; |
| 409 |
} |
| 410 |
|
| 411 |
bool ExecutionTracer::readOutOfLineEntries( |
| 412 |
mozilla::HashMap<uint32_t, size_t>& scriptUrls, |
| 413 |
mozilla::HashMap<uint32_t, size_t>& atoms, |
| 414 |
TracingScratchBuffer& scratchBuffer, mozilla::Vector<char>& stringBuffer) { |
| 415 |
while (outOfLineData_.readable()) { |
| 416 |
outOfLineData_.beginReadingEntry(); |
| 417 |
if (!readOutOfLineEntry(scriptUrls, atoms, scratchBuffer, stringBuffer)) { |
| 418 |
outOfLineData_.skipEntry(); |
| 419 |
return false; |
| 420 |
} |
| 421 |
outOfLineData_.finishReadingEntry(); |
| 422 |
} |
| 423 |
return true; |
| 424 |
} |
| 425 |
|
| 426 |
bool ExecutionTracer::getNativeTrace( |
| 427 |
JS::ExecutionTrace::TracedJSContext& context, |
| 428 |
TracingScratchBuffer& scratchBuffer, mozilla::Vector<char>& stringBuffer) { |
| 429 |
LockGuard<Mutex> guard(bufferLock_); |
| 430 |
|
| 431 |
if (!readOutOfLineEntries(context.scriptUrls, context.atoms, scratchBuffer, |
| 432 |
stringBuffer)) { |
| 433 |
return false; |
| 434 |
} |
| 435 |
|
| 436 |
if (!readInlineEntries(context.events, scratchBuffer, stringBuffer)) { |
| 437 |
return false; |
| 438 |
} |
| 439 |
|
| 440 |
return true; |
| 441 |
} |
| 442 |
|
| 443 |
bool ExecutionTracer::getNativeTraceForAllContexts(JS::ExecutionTrace& trace) { |
| 444 |
LockGuard<Mutex> guard(globalInstanceLock); |
| 445 |
TracingScratchBuffer scratchBuffer; |
| 446 |
for (ExecutionTracer* tracer : globalInstances) { |
| 447 |
JS::ExecutionTrace::TracedJSContext* context = nullptr; |
| 448 |
for (JS::ExecutionTrace::TracedJSContext& t : trace.contexts) { |
| 449 |
if (t.id == tracer->threadId_) { |
| 450 |
context = &t; |
| 451 |
break; |
| 452 |
} |
| 453 |
} |
| 454 |
if (!context) { |
| 455 |
if (!trace.contexts.append(JS::ExecutionTrace::TracedJSContext())) { |
| 456 |
return false; |
| 457 |
} |
| 458 |
context = &trace.contexts[trace.contexts.length() - 1]; |
| 459 |
context->id = tracer->threadId_; |
| 460 |
} |
| 461 |
if (!tracer->getNativeTrace(*context, scratchBuffer, trace.stringBuffer)) { |
| 462 |
return false; |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
return true; |
| 467 |
} |
| 468 |
|
| 469 |
void JS_TracerEnterLabelTwoByte(JSContext* cx, const char16_t* label) { |
| 470 |
CHECK_THREAD(cx); |
| 471 |
if (cx->hasExecutionTracer()) { |
| 472 |
cx->getExecutionTracer() |
| 473 |
.onEnterLabel<char16_t, TracerStringEncoding::TwoByte>(label); |
| 474 |
} |
| 475 |
} |
| 476 |
|
| 477 |
void JS_TracerEnterLabelLatin1(JSContext* cx, const char* label) { |
| 478 |
CHECK_THREAD(cx); |
| 479 |
if (cx->hasExecutionTracer()) { |
| 480 |
cx->getExecutionTracer().onEnterLabel<char, TracerStringEncoding::Latin1>( |
| 481 |
label); |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
void JS_TracerLeaveLabelTwoByte(JSContext* cx, const char16_t* label) { |
| 486 |
CHECK_THREAD(cx); |
| 487 |
if (cx->hasExecutionTracer()) { |
| 488 |
cx->getExecutionTracer() |
| 489 |
.onLeaveLabel<char16_t, TracerStringEncoding::TwoByte>(label); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
void JS_TracerLeaveLabelLatin1(JSContext* cx, const char* label) { |
| 494 |
CHECK_THREAD(cx); |
| 495 |
if (cx->hasExecutionTracer()) { |
| 496 |
cx->getExecutionTracer().onLeaveLabel<char, TracerStringEncoding::Latin1>( |
| 497 |
label); |
| 498 |
} |
| 499 |
} |
| 500 |
|
| 501 |
bool JS_TracerIsTracing(JSContext* cx) { return cx->hasExecutionTracer(); } |
| 502 |
|
| 503 |
bool JS_TracerBeginTracing(JSContext* cx) { |
| 504 |
CHECK_THREAD(cx); |
| 505 |
return cx->enableExecutionTracing(); |
| 506 |
} |
| 507 |
|
| 508 |
bool JS_TracerEndTracing(JSContext* cx) { |
| 509 |
CHECK_THREAD(cx); |
| 510 |
cx->disableExecutionTracing(); |
| 511 |
return true; |
| 512 |
} |
| 513 |
|
| 514 |
bool JS_TracerSnapshotTrace(JS::ExecutionTrace& trace) { |
| 515 |
return ExecutionTracer::getNativeTraceForAllContexts(trace); |
| 516 |
} |