Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-06-09 16:18:25 +0300
committergengjiawen <technicalcute@gmail.com>2020-10-22 13:53:36 +0300
commit7945a2cdc34623234037dfaccef56c257da68d13 (patch)
tree8030f573c3e83f0da49e0a00e36763c1f7aa2d18 /src/inspector_profiler.cc
parentfc5636e1eb45949e764f3b1ffbd63e39b2ca30a9 (diff)
v8: implement v8.stopCoverage()
Add a v8.stopCoverage() API to stop the coverage collection started by NODE_V8_COVERAGE - this would be useful in conjunction with v8.takeCoverage() if the user don't want to emit the coverage at the process exit but still want to collect it on demand at some point. PR-URL: https://github.com/nodejs/node/pull/33807 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
Diffstat (limited to 'src/inspector_profiler.cc')
-rw-r--r--src/inspector_profiler.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc
index 3444a9b9895..092b263ada2 100644
--- a/src/inspector_profiler.cc
+++ b/src/inspector_profiler.cc
@@ -295,6 +295,10 @@ void V8CoverageConnection::TakeCoverage() {
DispatchMessage("Profiler.takePreciseCoverage", nullptr, true);
}
+void V8CoverageConnection::StopCoverage() {
+ DispatchMessage("Profiler.stopPreciseCoverage");
+}
+
void V8CoverageConnection::End() {
Debug(env_,
DebugCategory::INSPECTOR_PROFILER,
@@ -489,6 +493,21 @@ static void TakeCoverage(const FunctionCallbackInfo<Value>& args) {
}
}
+static void StopCoverage(const FunctionCallbackInfo<Value>& args) {
+ Environment* env = Environment::GetCurrent(args);
+ V8CoverageConnection* connection = env->coverage_connection();
+
+ Debug(env,
+ DebugCategory::INSPECTOR_PROFILER,
+ "StopCoverage, connection %s nullptr\n",
+ connection == nullptr ? "==" : "!=");
+
+ if (connection != nullptr) {
+ Debug(env, DebugCategory::INSPECTOR_PROFILER, "Stopping coverage\n");
+ connection->StopCoverage();
+ }
+}
+
static void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context,
@@ -497,6 +516,7 @@ static void Initialize(Local<Object> target,
env->SetMethod(target, "setCoverageDirectory", SetCoverageDirectory);
env->SetMethod(target, "setSourceMapCacheGetter", SetSourceMapCacheGetter);
env->SetMethod(target, "takeCoverage", TakeCoverage);
+ env->SetMethod(target, "stopCoverage", StopCoverage);
}
} // namespace profiler