Florian Mayer | c9b8423 | 2018-08-02 11:17:03 +0100 | [diff] [blame] | 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 | |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 15 | import("../../../gn/fuzzer.gni") |
| 16 | import("../../../gn/perfetto.gni") |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 17 | import("../../../gn/test.gni") |
Florian Mayer | 8aba432 | 2018-08-06 09:45:38 +0100 | [diff] [blame] | 18 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 19 | assert(enable_perfetto_heapprofd) |
| 20 | |
| 21 | # The Android heap profiling daemon. |
| 22 | executable("heapprofd") { |
| 23 | deps = [ |
| 24 | "../../../gn:default_deps", |
| 25 | "../../../protos/perfetto/trace:zero", |
| 26 | "../../../src/base", |
| 27 | "../../../src/base:unix_socket", |
| 28 | "../../../src/profiling/memory:daemon", |
| 29 | "../../../src/profiling/memory:wire_protocol", |
| 30 | "../../../src/tracing:ipc", |
| 31 | ] |
| 32 | sources = [ |
| 33 | "main.cc", |
| 34 | ] |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 35 | } |
| 36 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 37 | # This library gets loaded into (and executes in) arbitrary android processes. |
| 38 | # Logging must be non-allocating. This is achieved by defining |
| 39 | # PERFETTO_ANDROID_ASYNC_SAFE_LOG, which needs to be set for all perfetto code |
| 40 | # being compiled for this library. When generating Android.bp, the |cflags| |
| 41 | # entry on this target is sufficient (as all sources are flattened into a |
| 42 | # single bp target). However this is not correctly reflected in the gn |
| 43 | # structure (which is a tree of targets) as the dependencies would not pick |
| 44 | # up the flag (and thus use the wrong logging macro). |
| 45 | # |
| 46 | # This builds only in the Android tree, when using the generated Android.bp. |
| 47 | if (perfetto_build_with_android) { |
| 48 | shared_library("heapprofd_client") { |
| 49 | configs -= [ "//gn/standalone:android_liblog" ] |
| 50 | cflags = [ "-DPERFETTO_ANDROID_ASYNC_SAFE_LOG" ] |
| 51 | deps = [ |
| 52 | ":malloc_hooks", |
| 53 | ] |
| 54 | } |
| 55 | |
| 56 | # This will export publicly visible symbols for the malloc_hooks. |
| 57 | source_set("malloc_hooks") { |
| 58 | deps = [ |
| 59 | ":client", |
| 60 | ":proc_utils", |
| 61 | ":scoped_spinlock", |
| 62 | ":wire_protocol", |
| 63 | "../../../gn:default_deps", |
| 64 | "../../base", |
| 65 | "../../base:unix_socket", |
| 66 | ] |
| 67 | cflags = [ |
| 68 | "-isystem", |
| 69 | rebase_path("../../../buildtools/bionic/libc", root_build_dir), |
| 70 | ] |
| 71 | sources = [ |
| 72 | "malloc_hooks.cc", |
| 73 | ] |
| 74 | } |
| 75 | } # if (perfetto_build_with_android) |
| 76 | |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 77 | source_set("wire_protocol") { |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 78 | public_deps = [ |
| 79 | "../../../gn:libunwindstack", |
| 80 | ] |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 81 | deps = [ |
Florian Mayer | 5195059 | 2019-03-06 20:05:15 +0000 | [diff] [blame] | 82 | ":ring_buffer", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 83 | "../../../gn:default_deps", |
| 84 | "../../base", |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 85 | "../../base:unix_socket", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 86 | ] |
| 87 | sources = [ |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 88 | "wire_protocol.cc", |
| 89 | "wire_protocol.h", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 90 | ] |
| 91 | } |
| 92 | |
Ryan Savitski | 10c19fb | 2019-01-22 14:44:15 +0000 | [diff] [blame] | 93 | source_set("proc_utils") { |
| 94 | deps = [ |
| 95 | "../../../gn:default_deps", |
Florian Mayer | cc7eab0 | 2019-09-25 11:52:23 +0100 | [diff] [blame] | 96 | "../../../include/perfetto/profiling:normalize", |
Ryan Savitski | 10c19fb | 2019-01-22 14:44:15 +0000 | [diff] [blame] | 97 | "../../base", |
| 98 | ] |
| 99 | sources = [ |
| 100 | "proc_utils.cc", |
| 101 | "proc_utils.h", |
| 102 | ] |
| 103 | } |
| 104 | |
Ryan Savitski | a502bde | 2019-02-26 21:34:03 +0000 | [diff] [blame] | 105 | source_set("scoped_spinlock") { |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 106 | deps = [ |
| 107 | "../../../gn:default_deps", |
| 108 | "../../base", |
| 109 | ] |
| 110 | sources = [ |
Ryan Savitski | a502bde | 2019-02-26 21:34:03 +0000 | [diff] [blame] | 111 | "scoped_spinlock.cc", |
| 112 | "scoped_spinlock.h", |
| 113 | ] |
| 114 | } |
| 115 | |
| 116 | source_set("ring_buffer") { |
| 117 | deps = [ |
| 118 | ":scoped_spinlock", |
| 119 | "../../../gn:default_deps", |
| 120 | "../../base", |
| 121 | ] |
| 122 | sources = [ |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 123 | "shared_ring_buffer.cc", |
Ryan Savitski | a502bde | 2019-02-26 21:34:03 +0000 | [diff] [blame] | 124 | "shared_ring_buffer.h", |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 125 | ] |
| 126 | } |
| 127 | |
| 128 | source_set("ring_buffer_unittests") { |
| 129 | testonly = true |
| 130 | deps = [ |
| 131 | ":ring_buffer", |
| 132 | "../../../gn:default_deps", |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 133 | "../../../gn:gtest_and_gmock", |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 134 | "../../base", |
| 135 | ] |
| 136 | sources = [ |
| 137 | "shared_ring_buffer_unittest.cc", |
| 138 | ] |
| 139 | } |
| 140 | |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 141 | source_set("daemon") { |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 142 | deps = [ |
Ryan Savitski | 10c19fb | 2019-01-22 14:44:15 +0000 | [diff] [blame] | 143 | ":proc_utils", |
Florian Mayer | 5195059 | 2019-03-06 20:05:15 +0000 | [diff] [blame] | 144 | ":ring_buffer", |
| 145 | ":scoped_spinlock", |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 146 | ":wire_protocol", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 147 | "../../../gn:default_deps", |
Primiano Tucci | 7043100 | 2019-08-22 17:13:10 +0200 | [diff] [blame] | 148 | "../../../protos/perfetto/config/profiling:lite", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 149 | "../../base", |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 150 | "../../base:unix_socket", |
Florian Mayer | e9f4686 | 2018-11-07 20:20:37 +0000 | [diff] [blame] | 151 | "../../tracing", |
| 152 | "../../tracing:ipc", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 153 | ] |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 154 | public_deps = [ |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 155 | "../../../gn:libunwindstack", |
Primiano Tucci | 57dd66b | 2019-10-15 23:09:04 +0100 | [diff] [blame^] | 156 | "../../../protos/perfetto/config/profiling:cpp", |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 157 | "../../../protos/perfetto/trace:zero", |
Florian Mayer | 5716fc1 | 2019-06-24 11:50:51 -0700 | [diff] [blame] | 158 | "../../../protos/perfetto/trace/interned_data:zero", |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 159 | "../../../protos/perfetto/trace/profiling:zero", |
| 160 | ] |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 161 | sources = [ |
Florian Mayer | 86feba6 | 2018-09-05 17:49:08 +0100 | [diff] [blame] | 162 | "bookkeeping.cc", |
| 163 | "bookkeeping.h", |
Florian Mayer | 7791fce | 2019-05-16 18:04:20 +0100 | [diff] [blame] | 164 | "bookkeeping_dump.cc", |
| 165 | "bookkeeping_dump.h", |
Florian Mayer | e9f4686 | 2018-11-07 20:20:37 +0000 | [diff] [blame] | 166 | "heapprofd_producer.cc", |
| 167 | "heapprofd_producer.h", |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 168 | "interner.h", |
Florian Mayer | 98965ba | 2019-09-13 15:32:36 +0100 | [diff] [blame] | 169 | "java_hprof_producer.cc", |
| 170 | "java_hprof_producer.h", |
Florian Mayer | 7142c7c | 2019-05-20 18:11:41 +0100 | [diff] [blame] | 171 | "page_idle_checker.cc", |
| 172 | "page_idle_checker.h", |
Florian Mayer | 78cb562 | 2018-11-27 17:17:10 +0000 | [diff] [blame] | 173 | "system_property.cc", |
| 174 | "system_property.h", |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 175 | "unwinding.cc", |
| 176 | "unwinding.h", |
Ryan Savitski | 549753e | 2019-03-15 15:52:37 +0000 | [diff] [blame] | 177 | "unwound_messages.h", |
Florian Mayer | 7142c7c | 2019-05-20 18:11:41 +0100 | [diff] [blame] | 178 | "utils.cc", |
| 179 | "utils.h", |
Florian Mayer | 86feba6 | 2018-09-05 17:49:08 +0100 | [diff] [blame] | 180 | ] |
| 181 | } |
| 182 | |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 183 | source_set("client") { |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 184 | deps = [ |
Ryan Savitski | 10c19fb | 2019-01-22 14:44:15 +0000 | [diff] [blame] | 185 | ":proc_utils", |
Florian Mayer | 5195059 | 2019-03-06 20:05:15 +0000 | [diff] [blame] | 186 | ":ring_buffer", |
Ryan Savitski | a502bde | 2019-02-26 21:34:03 +0000 | [diff] [blame] | 187 | ":scoped_spinlock", |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 188 | ":wire_protocol", |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 189 | "../../../gn:default_deps", |
| 190 | "../../base", |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 191 | "../../base:unix_socket", |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 192 | ] |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 193 | public_deps = [ |
| 194 | "../../../gn:libunwindstack", |
| 195 | ] |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 196 | sources = [ |
| 197 | "client.cc", |
| 198 | "client.h", |
Florian Mayer | c6be21f | 2018-10-02 11:33:59 +0100 | [diff] [blame] | 199 | "sampler.h", |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 200 | ] |
| 201 | } |
| 202 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 203 | perfetto_unittest_source_set("unittests") { |
Florian Mayer | c9b8423 | 2018-08-02 11:17:03 +0100 | [diff] [blame] | 204 | testonly = true |
| 205 | deps = [ |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 206 | ":client", |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 207 | ":daemon", |
Ryan Savitski | 10c19fb | 2019-01-22 14:44:15 +0000 | [diff] [blame] | 208 | ":proc_utils", |
Florian Mayer | b85a938 | 2018-09-27 13:59:01 +0100 | [diff] [blame] | 209 | ":wire_protocol", |
| 210 | "../../../gn:default_deps", |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 211 | "../../../gn:gtest_and_gmock", |
| 212 | "../../../gn:libunwindstack", |
Florian Mayer | cc7eab0 | 2019-09-25 11:52:23 +0100 | [diff] [blame] | 213 | "../../../include/perfetto/profiling:normalize", |
Florian Mayer | c9b8423 | 2018-08-02 11:17:03 +0100 | [diff] [blame] | 214 | "../../base", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 215 | "../../base:test_support", |
Florian Mayer | 86820d1 | 2019-04-08 19:19:46 +0100 | [diff] [blame] | 216 | "../../tracing", |
Florian Mayer | c9b8423 | 2018-08-02 11:17:03 +0100 | [diff] [blame] | 217 | ] |
| 218 | sources = [ |
Florian Mayer | 86feba6 | 2018-09-05 17:49:08 +0100 | [diff] [blame] | 219 | "bookkeeping_unittest.cc", |
Florian Mayer | 824274d | 2018-09-17 11:33:45 +0100 | [diff] [blame] | 220 | "client_unittest.cc", |
Florian Mayer | 096bbe3 | 2019-04-03 12:10:53 +0100 | [diff] [blame] | 221 | "heapprofd_producer_unittest.cc", |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 222 | "interner_unittest.cc", |
Florian Mayer | 7142c7c | 2019-05-20 18:11:41 +0100 | [diff] [blame] | 223 | "page_idle_checker_unittest.cc", |
Florian Mayer | f3e3dd3 | 2019-01-17 10:33:56 +0000 | [diff] [blame] | 224 | "proc_utils_unittest.cc", |
Florian Mayer | c6be21f | 2018-10-02 11:33:59 +0100 | [diff] [blame] | 225 | "sampler_unittest.cc", |
Florian Mayer | 78cb562 | 2018-11-27 17:17:10 +0000 | [diff] [blame] | 226 | "system_property_unittest.cc", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 227 | "unwinding_unittest.cc", |
Florian Mayer | 7ad1275 | 2018-10-02 16:48:44 +0100 | [diff] [blame] | 228 | "wire_protocol_unittest.cc", |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 229 | ] |
| 230 | } |
| 231 | |
Florian Mayer | 4280249 | 2018-12-13 11:00:16 +0000 | [diff] [blame] | 232 | source_set("end_to_end_tests") { |
Florian Mayer | 4280249 | 2018-12-13 11:00:16 +0000 | [diff] [blame] | 233 | testonly = true |
| 234 | deps = [ |
| 235 | ":client", |
| 236 | ":daemon", |
| 237 | ":wire_protocol", |
| 238 | "../../../gn:default_deps", |
Primiano Tucci | 13ae72f | 2019-06-06 10:53:02 +0100 | [diff] [blame] | 239 | "../../../gn:gtest_and_gmock", |
| 240 | "../../../gn:libunwindstack", |
Primiano Tucci | 0f2f3b4 | 2019-05-21 19:37:01 +0100 | [diff] [blame] | 241 | "../../../include/perfetto/protozero", |
Primiano Tucci | 7043100 | 2019-08-22 17:13:10 +0200 | [diff] [blame] | 242 | "../../../protos/perfetto/config/profiling:zero", |
Florian Mayer | 4280249 | 2018-12-13 11:00:16 +0000 | [diff] [blame] | 243 | "../../../test:test_helper", |
| 244 | "../../base", |
| 245 | "../../base:test_support", |
| 246 | ] |
| 247 | sources = [ |
| 248 | "heapprofd_end_to_end_test.cc", |
| 249 | ] |
| 250 | if (start_daemons_for_testing) { |
| 251 | defines = [ "PERFETTO_START_DAEMONS_FOR_TESTING" ] |
| 252 | } |
| 253 | } |
| 254 | |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 255 | perfetto_fuzzer_test("unwinding_fuzzer") { |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 256 | testonly = true |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 257 | sources = [ |
| 258 | "unwinding_fuzzer.cc", |
| 259 | ] |
| 260 | deps = [ |
| 261 | ":daemon", |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 262 | ":ring_buffer", |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 263 | ":wire_protocol", |
| 264 | "../../../gn:default_deps", |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 265 | "../../base", |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 266 | "../../tracing", |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 267 | ] |
| 268 | } |
Florian Mayer | 4a1ee94 | 2019-02-07 15:51:16 +0000 | [diff] [blame] | 269 | |
| 270 | perfetto_fuzzer_test("shared_ring_buffer_fuzzer") { |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 271 | testonly = true |
Florian Mayer | 4a1ee94 | 2019-02-07 15:51:16 +0000 | [diff] [blame] | 272 | sources = [ |
| 273 | "shared_ring_buffer_fuzzer.cc", |
| 274 | ] |
| 275 | deps = [ |
| 276 | ":ring_buffer", |
| 277 | "../../../gn:default_deps", |
Ryan Savitski | 7547604 | 2019-03-11 18:50:13 +0000 | [diff] [blame] | 278 | "../../base", |
Florian Mayer | 4a1ee94 | 2019-02-07 15:51:16 +0000 | [diff] [blame] | 279 | ] |
| 280 | } |
Florian Mayer | 0038918 | 2019-04-08 16:43:21 +0100 | [diff] [blame] | 281 | |
| 282 | perfetto_fuzzer_test("shared_ring_buffer_write_fuzzer") { |
| 283 | testonly = true |
| 284 | sources = [ |
| 285 | "shared_ring_buffer_write_fuzzer.cc", |
| 286 | ] |
| 287 | deps = [ |
| 288 | ":ring_buffer", |
| 289 | "../../../gn:default_deps", |
| 290 | "../../base", |
| 291 | ] |
| 292 | } |