Commit c302920a authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[tracing] Add missing support for flow events.

The JSONTraceWriter didn't write the "flow_in", "flow_out" and "bind_id"
fields, which are necessary to support TRACE_EVENT_WITH_FLOW and
friends. This just mirrors the logic from trace_event_impl.cc in Chrome.

Bug: v8:8991
Change-Id: I496db587fbb74d3c7205bbab4c23ec41c63fa715
Document: http://bit.ly/v8-tracing-signals
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1521108Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60218}
parent ff8011c8
......@@ -142,6 +142,17 @@ void JSONTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
<< "\",\"name\":\"" << trace_event->name()
<< "\",\"dur\":" << trace_event->duration()
<< ",\"tdur\":" << trace_event->cpu_duration();
if (trace_event->flags() &
(TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT)) {
stream_ << ",\"bind_id\":\"0x" << std::hex << trace_event->bind_id() << "\""
<< std::dec;
if (trace_event->flags() & TRACE_EVENT_FLAG_FLOW_IN) {
stream_ << ",\"flow_in\":true";
}
if (trace_event->flags() & TRACE_EVENT_FLAG_FLOW_OUT) {
stream_ << ",\"flow_out\":true";
}
}
if (trace_event->flags() & TRACE_EVENT_FLAG_HAS_ID) {
if (trace_event->scope() != nullptr) {
stream_ << ",\"scope\":\"" << trace_event->scope() << "\"";
......
......@@ -149,13 +149,14 @@ void PopulateJSONWriter(TraceWriter* writer) {
TraceObject trace_object;
trace_object.InitializeForTesting(
'X', tracing_controller->GetCategoryGroupEnabled("v8-cat"), "Test0",
v8::internal::tracing::kGlobalScope, 42, 123, 0, nullptr, nullptr,
v8::internal::tracing::kGlobalScope, 42, 0x1234, 0, nullptr, nullptr,
nullptr, nullptr, TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44);
writer->AppendTraceEvent(&trace_object);
trace_object.InitializeForTesting(
'Y', tracing_controller->GetCategoryGroupEnabled("v8-cat"), "Test1",
v8::internal::tracing::kGlobalScope, 43, 456, 0, nullptr, nullptr,
nullptr, nullptr, 0, 55, 66, 110, 55, 77, 88);
v8::internal::tracing::kGlobalScope, 43, 0x5678, 0, nullptr, nullptr,
nullptr, nullptr, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
55, 66, 110, 55, 77, 88);
writer->AppendTraceEvent(&trace_object);
tracing_controller->StopTracing();
i::V8::SetPlatformForTesting(old_platform);
......@@ -171,7 +172,8 @@ TEST(TestJSONTraceWriter) {
"\"ph\":\"X\",\"cat\":\"v8-cat\",\"name\":\"Test0\",\"dur\":33,"
"\"tdur\":44,\"id\":\"0x2a\",\"args\":{}},{\"pid\":55,\"tid\":66,"
"\"ts\":110,\"tts\":55,\"ph\":\"Y\",\"cat\":\"v8-cat\",\"name\":"
"\"Test1\",\"dur\":77,\"tdur\":88,\"args\":{}}]}";
"\"Test1\",\"dur\":77,\"tdur\":88,\"bind_id\":\"0x5678\","
"\"flow_in\":true,\"flow_out\":true,\"args\":{}}]}";
CHECK_EQ(expected_trace_str, trace_str);
}
......@@ -186,7 +188,8 @@ TEST(TestJSONTraceWriterWithCustomtag) {
"\"ph\":\"X\",\"cat\":\"v8-cat\",\"name\":\"Test0\",\"dur\":33,"
"\"tdur\":44,\"id\":\"0x2a\",\"args\":{}},{\"pid\":55,\"tid\":66,"
"\"ts\":110,\"tts\":55,\"ph\":\"Y\",\"cat\":\"v8-cat\",\"name\":"
"\"Test1\",\"dur\":77,\"tdur\":88,\"args\":{}}]}";
"\"Test1\",\"dur\":77,\"tdur\":88,\"bind_id\":\"0x5678\","
"\"flow_in\":true,\"flow_out\":true,\"args\":{}}]}";
CHECK_EQ(expected_trace_str, trace_str);
}
......
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