mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
This change adds a new inspector domain for receiving Node tracing
data.
1. Node.js now can extend Inspector protocol with new domains with
the API defined in the src/inspector/node_protocol.pdl.
2. Plumbing code will be generated at the build time. /json/protocol
HTTP endpoint returns both V8 and Node.js inspector protocol.
3. "NodeTracing" domain was introduced. It is based on the Chrome
"Tracing" domain.
PR-URL: https://github.com/nodejs/node/pull/20608
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
80 lines
2.2 KiB
C++
80 lines
2.2 KiB
C++
// Bridges V8 Inspector generated code with the std::string used by the Node
|
|
// Compare to V8 counterpart - deps/v8/src/inspector/string-util.h
|
|
#ifndef SRC_INSPECTOR_NODE_STRING_H_
|
|
#define SRC_INSPECTOR_NODE_STRING_H_
|
|
|
|
#include "util.h"
|
|
#include "v8-inspector.h"
|
|
|
|
#include <cstring>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
namespace node {
|
|
namespace inspector {
|
|
namespace protocol {
|
|
|
|
class Value;
|
|
|
|
using String = std::string;
|
|
using StringBuilder = std::ostringstream;
|
|
|
|
namespace StringUtil {
|
|
// NOLINTNEXTLINE(runtime/references) This is V8 API...
|
|
inline void builderAppend(StringBuilder& builder, char c) {
|
|
builder.put(c);
|
|
}
|
|
|
|
// NOLINTNEXTLINE(runtime/references)
|
|
inline void builderAppend(StringBuilder& builder, const char* value,
|
|
size_t length) {
|
|
builder.write(value, length);
|
|
}
|
|
|
|
// NOLINTNEXTLINE(runtime/references)
|
|
inline void builderAppend(StringBuilder& builder, const char* value) {
|
|
builderAppend(builder, value, std::strlen(value));
|
|
}
|
|
|
|
// NOLINTNEXTLINE(runtime/references)
|
|
inline void builderAppend(StringBuilder& builder, const String& string) {
|
|
builder << string;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(runtime/references)
|
|
inline void builderReserve(StringBuilder& builder, size_t) {
|
|
// ostringstream does not have a counterpart
|
|
}
|
|
inline String substring(const String& string, size_t start, size_t count) {
|
|
return string.substr(start, count);
|
|
}
|
|
inline String fromInteger(int n) {
|
|
return std::to_string(n);
|
|
}
|
|
inline String builderToString(const StringBuilder& builder) {
|
|
return builder.str();
|
|
}
|
|
inline size_t find(const String& string, const char* substring) {
|
|
return string.find(substring);
|
|
}
|
|
String fromDouble(double d);
|
|
double toDouble(const char* buffer, size_t length, bool* ok);
|
|
|
|
String StringViewToUtf8(v8_inspector::StringView view);
|
|
|
|
// NOLINTNEXTLINE(runtime/references)
|
|
void builderAppendQuotedString(StringBuilder& builder, const String&);
|
|
std::unique_ptr<Value> parseJSON(const String&);
|
|
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);
|
|
|
|
extern size_t kNotFound;
|
|
} // namespace StringUtil
|
|
} // namespace protocol
|
|
} // namespace inspector
|
|
} // namespace node
|
|
|
|
#define DCHECK CHECK
|
|
#define DCHECK_LT CHECK_LT
|
|
|
|
#endif // SRC_INSPECTOR_NODE_STRING_H_
|