Coverage Report

Created: 2025-12-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hermes/include/hermes/VM/Debugger/DebugCommand.h
Line
Count
Source
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
#ifndef HERMES_VM_DEBUGGER_DEBUGCOMMAND_H
9
#define HERMES_VM_DEBUGGER_DEBUGCOMMAND_H
10
11
#ifdef HERMES_ENABLE_DEBUGGER
12
13
#include "hermes/Public/DebuggerTypes.h"
14
15
#include "llvh/ADT/ArrayRef.h"
16
#include "llvh/ADT/StringExtras.h"
17
#include "llvh/ADT/StringRef.h"
18
#include "llvh/Support/raw_ostream.h"
19
20
#include <string>
21
22
namespace hermes {
23
namespace vm {
24
25
class Debugger;
26
struct InterpreterState;
27
28
/// Commands that can be sent to the debugger.
29
enum class DebugCommandType { NONE, CONTINUE, STEP, EVAL };
30
31
struct CreateBreakpointArgs {
32
  uint32_t filenameId;
33
  uint32_t line;
34
  uint32_t column;
35
};
36
37
struct PrintVarsArgs {
38
  /// Index of the call stack frame to print. 0 means the topmost frame.
39
  uint32_t frameIdx;
40
};
41
42
struct EvalArgs {
43
  /// Index of the call stack frame in which to eval. 0 means the topmost frame.
44
  uint32_t frameIdx;
45
};
46
47
struct StepArgs {
48
  /// Stepping mode.
49
  ::facebook::hermes::debugger::StepMode mode;
50
};
51
52
struct DebugCommand {
53
  DebugCommandType type;
54
  union {
55
    EvalArgs evalArgs;
56
    StepArgs stepArgs;
57
  };
58
59
  /// A generic string argument, whose interpretation is command dependent.
60
  std::string text = {};
61
62
0
  DebugCommand(DebugCommandType type) : type(type) {}
63
64
0
  static DebugCommand makeNone() {
65
0
    return DebugCommand{DebugCommandType::NONE};
66
0
  }
67
68
0
  static DebugCommand makeContinue() {
69
0
    return DebugCommand{DebugCommandType::CONTINUE};
70
0
  }
71
72
0
  static DebugCommand makeStep(::facebook::hermes::debugger::StepMode mode) {
73
0
    DebugCommand cmd = {DebugCommandType::STEP};
74
0
    cmd.stepArgs = StepArgs{mode};
75
0
    return cmd;
76
0
  }
77
78
0
  static DebugCommand makeEval(uint32_t frameIdx, std::string text) {
79
0
    DebugCommand cmd{DebugCommandType::EVAL};
80
0
    cmd.evalArgs.frameIdx = frameIdx;
81
0
    cmd.text = std::move(text);
82
0
    return cmd;
83
0
  }
84
};
85
86
} // namespace vm
87
} // namespace hermes
88
89
#endif
90
91
#endif