xref: /aosp_15_r20/external/cronet/base/debug/debug.gni (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker# Copyright 2023 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker
5*6777b538SAndroid Build Coastguard Workerimport("//build/config/compiler/compiler.gni")
6*6777b538SAndroid Build Coastguard Worker
7*6777b538SAndroid Build Coastguard Workerdeclare_args() {
8*6777b538SAndroid Build Coastguard Worker  # Whether to compile support for Allocation Stack Trace Recorder.
9*6777b538SAndroid Build Coastguard Worker  #
10*6777b538SAndroid Build Coastguard Worker  # The recorder is initially intended as a support tool for Arm's
11*6777b538SAndroid Build Coastguard Worker  # Memory Tagging Extensions. A history of the most recent allocations and
12*6777b538SAndroid Build Coastguard Worker  # frees is included in the crashpad report and gives developers information
13*6777b538SAndroid Build Coastguard Worker  # where the memory which was invalidly accessed was allocated or freed.
14*6777b538SAndroid Build Coastguard Worker  #
15*6777b538SAndroid Build Coastguard Worker  # Although it should work on other platforms as well, for the above reasons,
16*6777b538SAndroid Build Coastguard Worker  # we currently enable it only for Android when compiling for Arm64.
17*6777b538SAndroid Build Coastguard Worker  build_allocation_stack_trace_recorder =
18*6777b538SAndroid Build Coastguard Worker      !is_official_build && current_cpu == "arm64" && is_android
19*6777b538SAndroid Build Coastguard Worker}
20*6777b538SAndroid Build Coastguard Worker
21*6777b538SAndroid Build Coastguard Workerdeclare_args() {
22*6777b538SAndroid Build Coastguard Worker  # If enabled, the recorder gathers some additional information, i.e. number of
23*6777b538SAndroid Build Coastguard Worker  # collisions of slots, and prints these periodically.
24*6777b538SAndroid Build Coastguard Worker  #
25*6777b538SAndroid Build Coastguard Worker  # Since this might impact performance negatively, it's disabled by default.
26*6777b538SAndroid Build Coastguard Worker  # Even if it's disabled we still collect some data, i.e. total number of
27*6777b538SAndroid Build Coastguard Worker  # allocations. All other data will be set to a default value.
28*6777b538SAndroid Build Coastguard Worker  build_allocation_trace_recorder_full_reporting = false
29*6777b538SAndroid Build Coastguard Worker}
30*6777b538SAndroid Build Coastguard Worker
31*6777b538SAndroid Build Coastguard Workerassert(!(build_allocation_stack_trace_recorder && is_fuchsia),
32*6777b538SAndroid Build Coastguard Worker       "Stack trace recording is not supported on Fuchsia due to missing" +
33*6777b538SAndroid Build Coastguard Worker           " Crashpad!")
34*6777b538SAndroid Build Coastguard Worker
35*6777b538SAndroid Build Coastguard Workerassert(!(build_allocation_stack_trace_recorder && is_linux),
36*6777b538SAndroid Build Coastguard Worker       "WARNING: Stack trace recording is not supported on Linux due to" +
37*6777b538SAndroid Build Coastguard Worker           " performance issues computing stack trace!")
38*6777b538SAndroid Build Coastguard Worker
39*6777b538SAndroid Build Coastguard Workerassert(
40*6777b538SAndroid Build Coastguard Worker    build_allocation_stack_trace_recorder ||
41*6777b538SAndroid Build Coastguard Worker        !build_allocation_trace_recorder_full_reporting,
42*6777b538SAndroid Build Coastguard Worker    "Report for stack trace recorder is enabled, but the recorder is disabled!")
43