Coverage Report

Created: 2025-01-28 06:38

/src/hermes/lib/VM/StackFrame.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#include "hermes/VM/StackFrame.h"
9
10
#include "llvh/Support/Format.h"
11
#include "llvh/Support/raw_ostream.h"
12
13
namespace hermes {
14
namespace vm {
15
16
void dumpStackFrame(
17
    ConstStackFramePtr frame,
18
    llvh::raw_ostream &OS,
19
0
    const PinnedHermesValue *next) {
20
0
  auto format_ptr = [](const void *p) {
21
0
    return llvh::format_hex((uintptr_t)p, 10);
22
0
  };
23
24
0
  OS << "Frame @" << format_ptr(frame.ptr()) << "\n";
25
0
  if (next) {
26
0
    OS << "  size [regs]     : " << frame.ptr() - next << "\n";
27
0
  }
28
0
  OS << "  PreviousFrame   : " << format_ptr(frame.getPreviousFramePointer())
29
0
     << "\n"
30
0
     << "  SavedIP         : " << format_ptr(frame.getSavedIP()) << "\n"
31
0
     << "  SavedCodeBlock  : " << format_ptr(frame.getSavedCodeBlock()) << "\n"
32
0
     << "  ArgCount        : " << frame.getArgCount() << "\n"
33
0
     << "  NewTarget       : " << frame.getNewTargetRef() << "\n"
34
0
     << "  CalleeClosure   : " << frame.getCalleeClosureOrCBRef() << "\n"
35
0
     << "  ThisArg         : " << frame.getThisArgRef() << "\n"
36
0
     << "  Args: ";
37
0
  for (uint32_t i = 0, count = frame.getArgCount(); i != count; ++i) {
38
0
    if (i != 0)
39
0
      OS << ", ";
40
0
    OS << frame.getArgRef(i);
41
0
  }
42
0
  OS << "\n";
43
0
}
44
45
LLVM_ATTRIBUTE_NOINLINE
46
0
void dumpStackFrame(ConstStackFramePtr frame) {
47
0
  dumpStackFrame(frame, llvh::errs());
48
0
}
49
50
LLVM_ATTRIBUTE_NOINLINE
51
0
void dumpStackFrame(StackFramePtr frame) {
52
0
  dumpStackFrame(frame, llvh::errs());
53
0
}
54
55
} // namespace vm
56
} // namespace hermes