[d8] Fix --enable-tracing

This CL fixes an issue with --enable-tracing which was introduced
recently where the tracing file was closed too early. In addition it
adds a test for --enable-tracing to avoid such an issue in the future.

R=machenbach@chromium.org, rmcilroy@chromium.org

Change-Id: I1b3699a4dfbe27230ac1d21d5f6bc7b2ee9ed435
Reviewed-on: https://chromium-review.googlesource.com/796214
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49742}
This commit is contained in:
Andreas Haas 2017-11-29 12:52:22 +01:00 committed by Commit Bot
parent df659b17ed
commit 603d52f393
6 changed files with 26 additions and 1 deletions

1
.gitignore vendored
View File

@ -90,6 +90,7 @@ TAGS
bsuite
compile_commands.json
d8
!/test/mjsunit/d8
d8_g
gccauses
gcsuspects

View File

@ -2876,6 +2876,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--enable-tracing") == 0) {
options.trace_enabled = true;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--trace-path=", 13) == 0) {
options.trace_path = argv[i] + 13;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--trace-config=", 15) == 0) {
options.trace_config = argv[i] + 15;
argv[i] = nullptr;
@ -3306,7 +3309,8 @@ int Shell::Main(int argc, char* argv[]) {
std::unique_ptr<platform::tracing::TracingController> tracing;
if (options.trace_enabled && !i::FLAG_verify_predictable) {
tracing = base::make_unique<platform::tracing::TracingController>();
trace_file.open("v8_trace.json");
trace_file.open(options.trace_path ? options.trace_path : "v8_trace.json");
platform::tracing::TraceBuffer* trace_buffer =
platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer(
platform::tracing::TraceBuffer::kRingBufferChunks,
@ -3438,6 +3442,9 @@ int Shell::Main(int argc, char* argv[]) {
V8::Dispose();
V8::ShutdownPlatform();
// Delete the platform explicitly here to write the tracing output to the
// tracing file.
g_platform.reset();
return result;
}

View File

@ -301,6 +301,7 @@ class ShellOptions {
natives_blob(nullptr),
snapshot_blob(nullptr),
trace_enabled(false),
trace_path(nullptr),
trace_config(nullptr),
lcov_file(nullptr),
disable_in_process_stack_traces(false),
@ -334,6 +335,7 @@ class ShellOptions {
const char* natives_blob;
const char* snapshot_blob;
bool trace_enabled;
const char* trace_path;
const char* trace_config;
const char* lcov_file;
bool disable_in_process_stack_traces;

1
test/mjsunit/d8/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
v8_trace.json

View File

@ -0,0 +1,8 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --enable-tracing --trace-path=test/mjsunit/d8/v8_trace.json
// Just test that running d8 with --enable-tracing does not crash in a normal
// execution without exceptions or calls to natives.

View File

@ -113,6 +113,12 @@
'tools/tickprocessor': [PASS, NO_VARIANTS, ['arch == android_arm or arch == android_arm64 or arch == android_ia32', SKIP]],
'tools/dumpcpp': [PASS, NO_VARIANTS, ['arch == android_arm or arch == android_arm64 or arch == android_ia32', SKIP]],
##############################################################################
# This test generates a file in the test directory, so we cannot run several
# variants of the test simultaneously. Additionally the test should not be
# affected by variants.
'd8/enable-tracing': [PASS, NO_VARIANTS],
##############################################################################
# Long running test that reproduces memory leak and should be run manually.
'regress/regress-2073': [SKIP],