Commit a63ce7f5 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[tracing] OPTIONAL_TRACE_EVENT

Add OPTIONAL_TRACE_EVENT{0,1,2} macros. They are equivalent to regular
TRACE_EVENTs, but they are disabled by default on the platforms where
binary size is a significant factor.

R=eseckler@chromium.org
BUG=1043616

Change-Id: Ifb4265856826423c5079c5d412fc1234db19e820
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359132
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800770}
parent c37fddb5
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# huge sequence of random-looking conditionals. # huge sequence of random-looking conditionals.
import("//base/allocator/allocator.gni") import("//base/allocator/allocator.gni")
import("//base/trace_event/tracing.gni")
import("//build/buildflag_header.gni") import("//build/buildflag_header.gni")
import("//build/config/allocator.gni") import("//build/config/allocator.gni")
import("//build/config/arm.gni") import("//build/config/arm.gni")
...@@ -2106,6 +2107,7 @@ component("base") { ...@@ -2106,6 +2107,7 @@ component("base") {
"trace_event/memory_infra_background_allowlist.h", "trace_event/memory_infra_background_allowlist.h",
"trace_event/memory_usage_estimator.cc", "trace_event/memory_usage_estimator.cc",
"trace_event/memory_usage_estimator.h", "trace_event/memory_usage_estimator.h",
"trace_event/optional_trace_event.h",
"trace_event/process_memory_dump.cc", "trace_event/process_memory_dump.cc",
"trace_event/process_memory_dump.h", "trace_event/process_memory_dump.h",
"trace_event/thread_instruction_count.cc", "trace_event/thread_instruction_count.cc",
...@@ -2298,6 +2300,7 @@ buildflag_header("tracing_buildflags") { ...@@ -2298,6 +2300,7 @@ buildflag_header("tracing_buildflags") {
flags = [ flags = [
"ENABLE_BASE_TRACING=$enable_base_tracing", "ENABLE_BASE_TRACING=$enable_base_tracing",
"USE_PERFETTO_CLIENT_LIBRARY=$use_perfetto_client_library", "USE_PERFETTO_CLIENT_LIBRARY=$use_perfetto_client_library",
"OPTIONAL_TRACE_EVENTS_ENABLED=$optional_trace_events_enabled",
] ]
} }
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
#define BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
#include "base/trace_event/trace_event.h"
#include "base/tracing_buildflags.h"
#include "build/buildflag.h"
// These macros are functionally equivalent to TRACE_EVENTX macros,
// but they are disabled if optional_trace_events_enabled gn flag
// defined in tracing.gni is false.
#if BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
#define OPTIONAL_TRACE_EVENT0(...) TRACE_EVENT0(__VA_ARGS__)
#define OPTIONAL_TRACE_EVENT1(...) TRACE_EVENT1(__VA_ARGS__)
#define OPTIONAL_TRACE_EVENT2(...) TRACE_EVENT2(__VA_ARGS__)
#else // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
#define OPTIONAL_TRACE_EVENT0(category, name)
#define OPTIONAL_TRACE_EVENT1(category, name, arg1_name, arg1_val)
#define OPTIONAL_TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val)
#endif // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
#endif // BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chrome_build.gni")
declare_args() {
# Enable more trace events. Disabled by default due to binary size impact,
# but highly recommended for local development.
extended_tracing_enabled = false
}
# Separate block so that we can refer to extended_tracing_enabled's value.
declare_args() {
# Whether OPTIONAL_TRACE_EVENT macros are included in the build or not.
# Disabled by default on Android and ChromeOS due to binary size impact,
# enabled everywhere else.
optional_trace_events_enabled =
(!is_android && !is_chromeos) || extended_tracing_enabled
}
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