Commit 3e8407ce authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

Add --perf-prof-delete-file flag

Tests which set the --perf-prof flag leave behind a file in the current
working directory every time they execute.
In order to avoid this, this CL introduces a --perf-prof-delete-file
flag, which removes this file right after creating it. This still allows
the process to write to it via the open handle, but the file will be
gone afterwards, even if the process crashes or gets killed while
executing.

R=ahaas@chromium.org

Bug: v8:10121
Change-Id: I99b159bb6d94255f77095ac78d98ba55106e94fc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2000738Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65759}
parent 83c84c44
......@@ -129,6 +129,11 @@ void PerfJitLogger::OpenJitDumpFile() {
int fd = open(perf_dump_name.begin(), O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd == -1) return;
// If --perf-prof-delete-file is given, unlink the file right after opening
// it. This keeps the file handle to the file valid. This only works on Linux,
// which is the only platform supported for --perf-prof anyway.
if (FLAG_perf_prof_delete_file) CHECK_EQ(0, unlink(perf_dump_name.begin()));
marker_address_ = OpenMarkerFile(fd);
if (marker_address_ == nullptr) return;
......
......@@ -1519,6 +1519,9 @@ DEFINE_PERF_PROF_BOOL(
perf_prof_annotate_wasm,
"Used with --perf-prof, load wasm source map and provide annotate "
"support (experimental).")
DEFINE_PERF_PROF_BOOL(
perf_prof_delete_file,
"Remove the perf file right after creating it (for testing only).")
DEFINE_NEG_IMPLICATION(perf_prof, compact_code_space)
// TODO(v8:8462) Remove implication once perf supports remapping.
DEFINE_NEG_IMPLICATION(perf_prof, write_protect_code_memory)
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --perf-prof
// Flags: --perf-prof --perf-prof-delete-file
load('test/mjsunit/wasm/wasm-module-builder.js');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment