1# Copyright (C) 2018 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("../../../gn/perfetto.gni") 16import("../../../gn/fuzzer.gni") 17import("//build_overrides/build.gni") 18 19# For use_libfuzzer. 20if (!build_with_chromium) { 21 import("//gn/standalone/sanitizers/vars.gni") 22} else { 23 import("//build/config/sanitizers/sanitizers.gni") 24} 25 26source_set("wire_protocol") { 27 public_configs = [ "../../../buildtools:libunwindstack_config" ] 28 deps = [ 29 ":ring_buffer", 30 "../../../buildtools:libunwindstack", 31 "../../../gn:default_deps", 32 "../../base", 33 "../../base:unix_socket", 34 ] 35 sources = [ 36 "wire_protocol.cc", 37 "wire_protocol.h", 38 ] 39} 40 41source_set("proc_utils") { 42 deps = [ 43 "../../../gn:default_deps", 44 "../../base", 45 ] 46 sources = [ 47 "proc_utils.cc", 48 "proc_utils.h", 49 ] 50} 51 52source_set("scoped_spinlock") { 53 deps = [ 54 "../../../gn:default_deps", 55 "../../base", 56 ] 57 sources = [ 58 "scoped_spinlock.cc", 59 "scoped_spinlock.h", 60 ] 61} 62 63source_set("ring_buffer") { 64 deps = [ 65 ":scoped_spinlock", 66 "../../../gn:default_deps", 67 "../../base", 68 ] 69 sources = [ 70 "shared_ring_buffer.cc", 71 "shared_ring_buffer.h", 72 ] 73} 74 75source_set("ring_buffer_unittests") { 76 testonly = true 77 deps = [ 78 ":ring_buffer", 79 "../../../gn:default_deps", 80 "../../../gn:gtest_deps", 81 "../../base", 82 ] 83 sources = [ 84 "shared_ring_buffer_unittest.cc", 85 ] 86} 87 88source_set("daemon") { 89 public_configs = [ "../../../buildtools:libunwindstack_config" ] 90 deps = [ 91 ":proc_utils", 92 ":ring_buffer", 93 ":scoped_spinlock", 94 ":wire_protocol", 95 "../../../buildtools:libunwindstack", 96 "../../../gn:default_deps", 97 "../../base", 98 "../../base:unix_socket", 99 "../../tracing", 100 "../../tracing:ipc", 101 ] 102 public_deps = [ 103 "../../../protos/perfetto/trace:zero", 104 "../../../protos/perfetto/trace/profiling:zero", 105 ] 106 sources = [ 107 "bookkeeping.cc", 108 "bookkeeping.h", 109 "heapprofd_producer.cc", 110 "heapprofd_producer.h", 111 "interner.h", 112 "system_property.cc", 113 "system_property.h", 114 "unwinding.cc", 115 "unwinding.h", 116 "unwound_messages.h", 117 ] 118} 119 120source_set("client") { 121 public_configs = [ "../../../buildtools:libunwindstack_config" ] 122 deps = [ 123 ":proc_utils", 124 ":ring_buffer", 125 ":scoped_spinlock", 126 ":wire_protocol", 127 "../../../buildtools:libunwindstack", 128 "../../../gn:default_deps", 129 "../../base", 130 "../../base:unix_socket", 131 ] 132 sources = [ 133 "client.cc", 134 "client.h", 135 "sampler.h", 136 ] 137} 138 139source_set("unittests") { 140 public_configs = [ "../../../buildtools:libunwindstack_config" ] 141 testonly = true 142 deps = [ 143 ":client", 144 ":daemon", 145 ":proc_utils", 146 ":wire_protocol", 147 "../../../gn:default_deps", 148 "../../../gn:gtest_deps", 149 "../../base", 150 "../../base:test_support", 151 "../../tracing", 152 ] 153 sources = [ 154 "bookkeeping_unittest.cc", 155 "client_unittest.cc", 156 "heapprofd_producer_unittest.cc", 157 "interner_unittest.cc", 158 "proc_utils_unittest.cc", 159 "sampler_unittest.cc", 160 "system_property_unittest.cc", 161 "unwinding_unittest.cc", 162 "wire_protocol_unittest.cc", 163 ] 164} 165 166source_set("end_to_end_tests") { 167 public_configs = [ "../../../buildtools:libunwindstack_config" ] 168 testonly = true 169 deps = [ 170 ":client", 171 ":daemon", 172 ":wire_protocol", 173 "../../../gn:default_deps", 174 "../../../gn:gtest_deps", 175 "../../../test:test_helper", 176 "../../base", 177 "../../base:test_support", 178 ] 179 sources = [ 180 "heapprofd_end_to_end_test.cc", 181 ] 182 if (start_daemons_for_testing) { 183 defines = [ "PERFETTO_START_DAEMONS_FOR_TESTING" ] 184 } 185} 186 187# This will export publicly visibile symbols for the malloc_hooks. 188source_set("malloc_hooks") { 189 deps = [ 190 ":client", 191 ":proc_utils", 192 ":scoped_spinlock", 193 ":wire_protocol", 194 "../../../gn:default_deps", 195 "../../base", 196 "../../base:unix_socket", 197 ] 198 cflags = [ 199 "-isystem", 200 rebase_path("../../../buildtools/bionic/libc", root_build_dir), 201 ] 202 sources = [ 203 "malloc_hooks.cc", 204 ] 205} 206 207perfetto_fuzzer_test("unwinding_fuzzer") { 208 testonly = true 209 sources = [ 210 "unwinding_fuzzer.cc", 211 ] 212 deps = [ 213 ":daemon", 214 ":ring_buffer", 215 ":wire_protocol", 216 "../../../gn:default_deps", 217 "../../base", 218 "../../tracing", 219 ] 220} 221 222perfetto_fuzzer_test("shared_ring_buffer_fuzzer") { 223 testonly = true 224 sources = [ 225 "shared_ring_buffer_fuzzer.cc", 226 ] 227 deps = [ 228 ":ring_buffer", 229 "../../../gn:default_deps", 230 "../../base", 231 ] 232} 233 234perfetto_fuzzer_test("shared_ring_buffer_write_fuzzer") { 235 testonly = true 236 sources = [ 237 "shared_ring_buffer_write_fuzzer.cc", 238 ] 239 deps = [ 240 ":ring_buffer", 241 "../../../gn:default_deps", 242 "../../base", 243 ] 244} 245