GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/inspector_agent.h Lines: 7 7 100.0 %
Date: 2017-10-21 Branches: 1 2 50.0 %

Line Branch Exec Source
1
#ifndef SRC_INSPECTOR_AGENT_H_
2
#define SRC_INSPECTOR_AGENT_H_
3
4
#include <memory>
5
6
#include <stddef.h>
7
8
#if !HAVE_INSPECTOR
9
#error("This header can only be used when inspector is enabled")
10
#endif
11
12
#include "node_debug_options.h"
13
#include "v8.h"
14
15
namespace v8_inspector {
16
class StringView;
17
}  // namespace v8_inspector
18
19
namespace node {
20
// Forward declaration to break recursive dependency chain with src/env.h.
21
class Environment;
22
class NodePlatform;
23
24
namespace inspector {
25
26
19
class InspectorSessionDelegate {
27
 public:
28
16
  virtual ~InspectorSessionDelegate() = default;
29
  virtual bool WaitForFrontendMessageWhilePaused() = 0;
30
  virtual void SendMessageToFrontend(const v8_inspector::StringView& message)
31
                                     = 0;
32
};
33
34
class InspectorIo;
35
class NodeInspectorClient;
36
37
class Agent {
38
 public:
39
  explicit Agent(node::Environment* env);
40
  ~Agent();
41
42
  // Create client_, may create io_ if option enabled
43
  bool Start(node::NodePlatform* platform, const char* path,
44
             const DebugOptions& options);
45
  // Stop and destroy io_
46
  void Stop();
47
48
3402
  bool IsStarted() { return !!client_; }
49
50
  // IO thread started, and client connected
51
  bool IsConnected();
52
  bool IsWaitingForConnect();
53
54
  void WaitForDisconnect();
55
  void FatalException(v8::Local<v8::Value> error,
56
                      v8::Local<v8::Message> message);
57
58
  // Async stack traces instrumentation.
59
  void AsyncTaskScheduled(const v8_inspector::StringView& taskName, void* task,
60
                          bool recurring);
61
  void AsyncTaskCanceled(void* task);
62
  void AsyncTaskStarted(void* task);
63
  void AsyncTaskFinished(void* task);
64
  void AllAsyncTasksCanceled();
65
66
  void RegisterAsyncHook(v8::Isolate* isolate,
67
    v8::Local<v8::Function> enable_function,
68
    v8::Local<v8::Function> disable_function);
69
70
  // These methods are called by the WS protocol and JS binding to create
71
  // inspector sessions.  The inspector responds by using the delegate to send
72
  // messages back.
73
  void Connect(InspectorSessionDelegate* delegate);
74
  void Disconnect();
75
  void Dispatch(const v8_inspector::StringView& message);
76
  InspectorSessionDelegate* delegate();
77
78
  void RunMessageLoop();
79
20027
  bool enabled() { return enabled_; }
80
  void PauseOnNextJavascriptStatement(const std::string& reason);
81
82
144
  InspectorIo* io() {
83
144
    return io_.get();
84
  }
85
86
  // Can only be called from the the main thread.
87
  bool StartIoThread(bool wait_for_connect);
88
89
  // Calls StartIoThread() from off the main thread.
90
  void RequestIoThreadStart();
91
92
1
  DebugOptions& options() { return debug_options_; }
93
  void ContextCreated(v8::Local<v8::Context> context);
94
95
 private:
96
  node::Environment* parent_env_;
97
  std::unique_ptr<NodeInspectorClient> client_;
98
  std::unique_ptr<InspectorIo> io_;
99
  v8::Platform* platform_;
100
  bool enabled_;
101
  std::string path_;
102
  DebugOptions debug_options_;
103
  int next_context_number_;
104
105
  v8::Persistent<v8::Function> enable_async_hook_function_;
106
  v8::Persistent<v8::Function> disable_async_hook_function_;
107
};
108
109
}  // namespace inspector
110
}  // namespace node
111
112
#endif  // SRC_INSPECTOR_AGENT_H_