GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_report.h Lines: 0 68 0.0 %
Date: 2019-02-01 22:03:38 Branches: 0 78 0.0 %

Line Branch Exec Source
1
#ifndef SRC_NODE_REPORT_H_
2
#define SRC_NODE_REPORT_H_
3
4
#include <node.h>
5
#include <node_buffer.h>
6
#include <uv.h>
7
#include <algorithm>
8
#include <climits>
9
#include <cstdlib>
10
#include <cstring>
11
#include <queue>
12
#include <string>
13
#include <utility>
14
#include <vector>
15
#include "v8.h"
16
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <iomanip>
20
#include <iostream>
21
#include <sstream>
22
#include <limits>
23
24
#ifdef _WIN32
25
#include <time.h>
26
#else
27
#include <sys/time.h>
28
#include <sys/types.h>
29
#include <unistd.h>
30
#endif
31
32
namespace report {
33
34
#ifdef _WIN32
35
typedef SYSTEMTIME TIME_TYPE;
36
#define PATHSEP "\\"
37
#else  // UNIX, OSX
38
typedef struct tm TIME_TYPE;
39
#define PATHSEP "/"
40
#endif
41
42
// Function declarations - functions in src/node_report.cc
43
std::string TriggerNodeReport(v8::Isolate* isolate,
44
                              node::Environment* env,
45
                              const char* message,
46
                              const char* location,
47
                              std::string name,
48
                              v8::Local<v8::String> stackstr);
49
void GetNodeReport(v8::Isolate* isolate,
50
                   node::Environment* env,
51
                   const char* message,
52
                   const char* location,
53
                   v8::Local<v8::String> stackstr,
54
                   std::ostream& out);
55
56
// Function declarations - utility functions in src/utilities.cc
57
void ReportEndpoints(uv_handle_t* h, std::ostringstream& out);
58
void WalkHandle(uv_handle_t* h, void* arg);
59
std::string EscapeJsonChars(const std::string& str);
60
61
// Function declarations - export functions in src/node_report_module.cc
62
void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info);
63
void GetReport(const v8::FunctionCallbackInfo<v8::Value>& info);
64
65
// Node.js boot time - defined in src/node.cc
66
extern double prog_start_time;
67
68
// JSON compiler definitions.
69
class JSONWriter {
70
 public:
71
  explicit JSONWriter(std::ostream& out) : out_(out) {}
72
73
  inline void indent() { indent_ += 2; }
74
  inline void deindent() { indent_ -= 2; }
75
  inline void advance() {
76
    for (int i = 0; i < indent_; i++) out_ << ' ';
77
  }
78
79
  inline void json_start() {
80
    if (state_ == kAfterValue) out_ << ',';
81
    out_ << '\n';
82
    advance();
83
    out_ << '{';
84
    indent();
85
    state_ = kObjectStart;
86
  }
87
88
  inline void json_end() {
89
    out_ << '\n';
90
    deindent();
91
    advance();
92
    out_ << '}';
93
    state_ = kAfterValue;
94
  }
95
  template <typename T>
96
  inline void json_objectstart(T key) {
97
    if (state_ == kAfterValue) out_ << ',';
98
    out_ << '\n';
99
    advance();
100
    write_string(key);
101
    out_ << ": {";
102
    indent();
103
    state_ = kObjectStart;
104
  }
105
106
  template <typename T>
107
  inline void json_arraystart(T key) {
108
    if (state_ == kAfterValue) out_ << ',';
109
    out_ << '\n';
110
    advance();
111
    write_string(key);
112
    out_ << ": [";
113
    indent();
114
    state_ = kObjectStart;
115
  }
116
  inline void json_objectend() {
117
    out_ << '\n';
118
    deindent();
119
    advance();
120
    out_ << '}';
121
    state_ = kAfterValue;
122
  }
123
124
  inline void json_arrayend() {
125
    out_ << '\n';
126
    deindent();
127
    advance();
128
    out_ << ']';
129
    state_ = kAfterValue;
130
  }
131
  template <typename T, typename U>
132
  inline void json_keyvalue(const T& key, const U& value) {
133
    if (state_ == kAfterValue) out_ << ',';
134
    out_ << '\n';
135
    advance();
136
    write_string(key);
137
    out_ << ": ";
138
    write_value(value);
139
    state_ = kAfterValue;
140
  }
141
142
  template <typename U>
143
  inline void json_element(const U& value) {
144
    if (state_ == kAfterValue) out_ << ',';
145
    out_ << '\n';
146
    advance();
147
    write_value(value);
148
    state_ = kAfterValue;
149
  }
150
151
 private:
152
  template <typename T,
153
            typename test_for_number = typename std::
154
                enable_if<std::numeric_limits<T>::is_specialized, bool>::type>
155
  inline void write_value(T number) {
156
    if (std::is_same<T, bool>::value)
157
      out_ << (number ? "true" : "false");
158
    else
159
      out_ << number;
160
  }
161
162
  inline void write_value(const char* str) { write_string(str); }
163
  inline void write_value(const std::string& str) { write_string(str); }
164
165
  inline void write_string(const std::string& str) {
166
    out_ << '"' << EscapeJsonChars(str) << '"';
167
  }
168
  inline void write_string(const char* str) { write_string(std::string(str)); }
169
170
  enum JSONState { kObjectStart, kAfterValue };
171
  std::ostream& out_;
172
  int indent_ = 0;
173
  int state_ = kObjectStart;
174
};
175
176
}  // namespace report
177
178
#endif  // SRC_NODE_REPORT_H_