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>2019-04-19 12:15:04 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-22 20:48:46 +0300
commit49d3d11ba7975b2c6df4ecab55b4619da46fcb95 (patch)
tree90a6011d693065805b725fed7a475b1bf1e2f7ef /src/inspector_profiler.cc
parenta3d1922958a18851afaae7238cfbd8079070f272 (diff)
inspector: split --cpu-prof-path to --cpu-prof-dir and --cpu-prof-name
To improve the integration of `--cpu-prof` with workers, this patch splits `--cpu-prof-path` into `--cpu-prof-dir` and `--cpu-prof-name`, so when a worker is launched from a thread that enables `--cpu-prof`, if the parent thread sets `--cpu-prof-dir`, then the profile of both thread would be generated to the specified directory. If they end up specifying the same `--cpu-prof-name` the behavior is undefined the last profile will overwritten the first one. PR-URL: https://github.com/nodejs/node/pull/27306 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/inspector_profiler.cc')
-rw-r--r--src/inspector_profiler.cc16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc
index 46d4c4fec8d..3507ae4ef2f 100644
--- a/src/inspector_profiler.cc
+++ b/src/inspector_profiler.cc
@@ -318,19 +318,13 @@ void StartCoverageCollection(Environment* env) {
env->coverage_connection()->Start();
}
-void StartCpuProfiling(Environment* env, const std::string& profile_path) {
- std::string path;
- if (profile_path.empty()) {
- char cwd[CWD_BUFSIZE];
- size_t size = CWD_BUFSIZE;
- int err = uv_cwd(cwd, &size);
- // TODO(joyeecheung): fallback to exec path / argv[0]
- CHECK_EQ(err, 0);
- CHECK_GT(size, 0);
+void StartCpuProfiling(Environment* env, const std::string& profile_name) {
+ std::string path = env->cpu_prof_dir() + std::string(kPathSeparator);
+ if (profile_name.empty()) {
DiagnosticFilename filename(env, "CPU", "cpuprofile");
- path = cwd + std::string(kPathSeparator) + (*filename);
+ path += *filename;
} else {
- path = profile_path;
+ path += profile_name;
}
env->set_cpu_profile_path(std::move(path));
env->set_cpu_profiler_connection(