blob: 57c4c2efe4c3973bc54efd91f698adaddb1e9fe1 [file] [log] [blame]
Christopher Ferris723cf9b2017-01-19 20:08:48 -08001//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "libunwindstack_flags",
19
20 host_supported: true,
21
22 cflags: [
23 "-Wall",
24 "-Werror",
25 "-Wextra",
26 ],
Christopher Ferris01d50372017-01-30 13:45:16 -080027
28 target: {
29 darwin: {
30 enabled: false,
31 },
Dan Willemsen0f048672017-09-19 17:53:12 -070032 linux_bionic: {
33 enabled: true,
34 },
Christopher Ferris01d50372017-01-30 13:45:16 -080035 },
Christopher Ferris723cf9b2017-01-19 20:08:48 -080036}
37
Martin Stjernholma2cc8932019-10-23 21:32:43 +010038cc_defaults {
39 name: "libunwindstack_defaults",
Christopher Ferris723cf9b2017-01-19 20:08:48 -080040 defaults: ["libunwindstack_flags"],
Christopher Ferrisd226a512017-07-14 10:37:19 -070041 export_include_dirs: ["include"],
Christopher Ferris723cf9b2017-01-19 20:08:48 -080042
43 srcs: [
44 "ArmExidx.cpp",
David Srbeckyb9cc4fb2019-04-05 18:23:32 +000045 "DexFiles.cpp",
Christopher Ferris8642fcb2017-04-24 11:14:39 -070046 "DwarfCfa.cpp",
Christopher Ferrisc9dee842017-11-03 14:50:27 -070047 "DwarfEhFrameWithHdr.cpp",
Christopher Ferris72a6fa62017-03-21 12:41:17 -070048 "DwarfMemory.cpp",
Christopher Ferris55d22ef2017-04-04 10:41:31 -070049 "DwarfOp.cpp",
Christopher Ferris53a3c9b2017-05-10 18:34:15 -070050 "DwarfSection.cpp",
Christopher Ferris3958f802017-02-01 15:44:40 -080051 "Elf.cpp",
52 "ElfInterface.cpp",
53 "ElfInterfaceArm.cpp",
Christopher Ferris56d0e072018-10-17 10:57:53 -070054 "Global.cpp",
Christopher Ferris150db122017-12-20 18:49:01 -080055 "JitDebug.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -080056 "Log.cpp",
Christopher Ferris0d7cf3e2017-04-19 15:42:19 -070057 "MapInfo.cpp",
Christopher Ferris09385e72017-04-05 13:25:04 -070058 "Maps.cpp",
Christopher Ferris3958f802017-02-01 15:44:40 -080059 "Memory.cpp",
Peter Collingbournec71e0a62020-04-07 14:04:46 -070060 "MemoryMte.cpp",
Christopher Ferrisca9a54b2018-04-05 11:15:00 -070061 "LocalUnwinder.cpp",
Christopher Ferrisbae69f12017-06-28 14:51:54 -070062 "Regs.cpp",
Christopher Ferrisd06001d2017-11-30 18:56:01 -080063 "RegsArm.cpp",
64 "RegsArm64.cpp",
65 "RegsX86.cpp",
66 "RegsX86_64.cpp",
Douglas Leung61b1a1a2017-11-08 10:53:53 +010067 "RegsMips.cpp",
68 "RegsMips64.cpp",
Christopher Ferrisb9de87f2017-09-20 13:37:24 -070069 "Unwinder.cpp",
Christopher Ferrise7ba4cc2017-04-04 14:06:58 -070070 "Symbols.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -080071 ],
72
Josh Gaoe22701e2017-10-23 14:25:08 -070073 cflags: [
74 "-Wexit-time-destructors",
75 ],
76
Christopher Ferris5f118512017-09-01 11:17:16 -070077 target: {
78 // Always disable optimizations for host to make it easier to debug.
Dan Willemsencd580882017-10-02 10:29:02 -070079 host: {
Elliott Hughesdc699a22018-02-16 17:58:14 -080080 cflags: [
81 "-O0",
82 "-g",
83 ],
Christopher Ferris5f118512017-09-01 11:17:16 -070084 },
85 },
86
Christopher Ferris2a25c4a2017-07-07 16:35:48 -070087 arch: {
88 x86: {
89 srcs: ["AsmGetRegsX86.S"],
90 },
91 x86_64: {
92 srcs: ["AsmGetRegsX86_64.S"],
93 },
94 },
95
Yabin Cui3841acc2018-05-10 17:19:12 -070096 static_libs: [
97 "libprocinfo",
98 ],
99
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800100 shared_libs: [
101 "libbase",
102 "liblog",
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700103 "liblzma",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800104 ],
Peter Collingbournec71e0a62020-04-07 14:04:46 -0700105
106 header_libs: [
107 "bionic_libc_platform_headers",
108 ],
109
110 product_variables: {
111 experimental_mte: {
112 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
113 },
114 },
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800115}
116
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100117cc_library {
118 name: "libunwindstack",
119 vendor_available: true,
120 recovery_available: true,
121 vndk: {
122 enabled: true,
123 support_system_process: true,
124 },
125 defaults: ["libunwindstack_defaults"],
126
127 srcs: ["DexFile.cpp"],
128 cflags: ["-DDEXFILE_SUPPORT"],
129 shared_libs: ["libdexfile_support"],
130
131 target: {
132 vendor: {
133 cflags: ["-UDEXFILE_SUPPORT"],
134 exclude_srcs: ["DexFile.cpp"],
135 exclude_shared_libs: ["libdexfile_support"],
136 },
137 recovery: {
138 cflags: ["-UDEXFILE_SUPPORT"],
139 exclude_srcs: ["DexFile.cpp"],
140 exclude_shared_libs: ["libdexfile_support"],
141 },
142 },
143}
144
145// Static library without DEX support to avoid dependencies on the ART APEX.
146cc_library_static {
147 name: "libunwindstack_no_dex",
148 recovery_available: true,
149 defaults: ["libunwindstack_defaults"],
150
151 visibility: [
152 "//system/core/debuggerd",
153 "//system/core/init",
154 "//system/core/libbacktrace",
155 ],
156 apex_available: [
157 "//apex_available:platform",
158 "com.android.runtime",
159 ],
160}
161
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800162//-------------------------------------------------------------------------
163// Unit Tests
164//-------------------------------------------------------------------------
Christopher Ferrisca9a54b2018-04-05 11:15:00 -0700165cc_test_library {
166 name: "libunwindstack_local",
167 defaults: ["libunwindstack_flags"],
168 srcs: ["tests/TestLocal.cpp"],
169
170 cflags: [
171 "-O0",
172 "-g",
173 ],
174
175 shared_libs: [
176 "libunwindstack",
177 ],
Christopher Ferris7aba5142019-09-03 10:18:42 -0700178 relative_install_path: "libunwindstack_test",
Christopher Ferrisca9a54b2018-04-05 11:15:00 -0700179}
180
Christopher Ferris7aba5142019-09-03 10:18:42 -0700181cc_defaults {
182 name: "libunwindstack_testlib_flags",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800183 defaults: ["libunwindstack_flags"],
184
185 srcs: [
186 "tests/ArmExidxDecodeTest.cpp",
187 "tests/ArmExidxExtractTest.cpp",
David Srbecky18121dc2018-03-12 19:54:22 +0000188 "tests/DexFileTest.cpp",
189 "tests/DexFilesTest.cpp",
Christopher Ferris8642fcb2017-04-24 11:14:39 -0700190 "tests/DwarfCfaLogTest.cpp",
191 "tests/DwarfCfaTest.cpp",
Christopher Ferris61d40972017-06-12 19:14:20 -0700192 "tests/DwarfDebugFrameTest.cpp",
193 "tests/DwarfEhFrameTest.cpp",
Christopher Ferrisc9dee842017-11-03 14:50:27 -0700194 "tests/DwarfEhFrameWithHdrTest.cpp",
Christopher Ferris72a6fa62017-03-21 12:41:17 -0700195 "tests/DwarfMemoryTest.cpp",
Christopher Ferris55d22ef2017-04-04 10:41:31 -0700196 "tests/DwarfOpLogTest.cpp",
197 "tests/DwarfOpTest.cpp",
Christopher Ferris53a3c9b2017-05-10 18:34:15 -0700198 "tests/DwarfSectionTest.cpp",
199 "tests/DwarfSectionImplTest.cpp",
Christopher Ferris0b79ae12018-01-25 12:15:56 -0800200 "tests/ElfCacheTest.cpp",
Christopher Ferrisf6f691b2017-09-25 19:23:07 -0700201 "tests/ElfFake.cpp",
Christopher Ferris3958f802017-02-01 15:44:40 -0800202 "tests/ElfInterfaceArmTest.cpp",
203 "tests/ElfInterfaceTest.cpp",
204 "tests/ElfTest.cpp",
Christopher Ferris570b76f2017-06-30 17:18:16 -0700205 "tests/ElfTestUtils.cpp",
Christopher Ferrisea8e7d12019-07-17 15:47:32 -0700206 "tests/IsolatedSettings.cpp",
Christopher Ferris150db122017-12-20 18:49:01 -0800207 "tests/JitDebugTest.cpp",
David Srbeckyf1932fd2019-09-16 22:36:55 +0100208 "tests/LocalUpdatableMapsTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800209 "tests/LogFake.cpp",
Christopher Ferris9d5712c2018-10-01 21:01:09 -0700210 "tests/MapInfoCreateMemoryTest.cpp",
Christopher Ferrisbf373ed2019-01-16 17:23:39 -0800211 "tests/MapInfoGetBuildIDTest.cpp",
Christopher Ferris570b76f2017-06-30 17:18:16 -0700212 "tests/MapInfoGetElfTest.cpp",
Christopher Ferrisb7de5f52017-12-01 21:37:37 -0800213 "tests/MapInfoGetLoadBiasTest.cpp",
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800214 "tests/MapInfoTest.cpp",
Christopher Ferris09385e72017-04-05 13:25:04 -0700215 "tests/MapsTest.cpp",
Christopher Ferrisf6d54312017-07-11 15:29:32 -0700216 "tests/MemoryBufferTest.cpp",
Christopher Ferrisef640102018-11-14 15:36:45 -0800217 "tests/MemoryCacheTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800218 "tests/MemoryFake.cpp",
219 "tests/MemoryFileTest.cpp",
220 "tests/MemoryLocalTest.cpp",
Christopher Ferris6633b0c2018-04-03 16:03:28 -0700221 "tests/MemoryOfflineBufferTest.cpp",
Josh Gaof4a94c42017-11-13 16:16:27 -0800222 "tests/MemoryOfflineTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800223 "tests/MemoryRangeTest.cpp",
Christopher Ferris9d5712c2018-10-01 21:01:09 -0700224 "tests/MemoryRangesTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800225 "tests/MemoryRemoteTest.cpp",
Christopher Ferris9744fb22017-07-07 12:18:16 -0700226 "tests/MemoryTest.cpp",
Peter Collingbournec71e0a62020-04-07 14:04:46 -0700227 "tests/MemoryMteTest.cpp",
Christopher Ferris27866082018-08-02 15:21:37 -0700228 "tests/RegsInfoTest.cpp",
Josh Gao6f580d82017-09-22 12:57:15 -0700229 "tests/RegsIterateTest.cpp",
Christopher Ferriseb4a6db2017-07-19 12:37:45 -0700230 "tests/RegsStepIfSignalHandlerTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800231 "tests/RegsTest.cpp",
Christopher Ferrise7ba4cc2017-04-04 14:06:58 -0700232 "tests/SymbolsTest.cpp",
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800233 "tests/TestUtils.cpp",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800234 "tests/UnwindOfflineTest.cpp",
Christopher Ferris2a25c4a2017-07-07 16:35:48 -0700235 "tests/UnwindTest.cpp",
Christopher Ferrisf6f691b2017-09-25 19:23:07 -0700236 "tests/UnwinderTest.cpp",
Christopher Ferris71382322019-08-30 14:02:19 -0700237 "tests/VerifyBionicTerminationTest.cpp",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800238 ],
239
240 cflags: [
241 "-O0",
242 "-g",
243 ],
244
245 shared_libs: [
246 "libbase",
247 "liblog",
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700248 "liblzma",
Christopher Ferrisf6d54312017-07-11 15:29:32 -0700249 "libunwindstack",
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000250 "libdexfile_support",
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800251 ],
252
Christopher Ferris53a3c9b2017-05-10 18:34:15 -0700253 static_libs: [
254 "libgmock",
255 ],
256
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700257 test_suites: ["device-tests"],
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700258 data: [
Christopher Ferris570b76f2017-06-30 17:18:16 -0700259 "tests/files/elf32.xz",
260 "tests/files/elf64.xz",
Yabin Cui11e96fe2018-03-14 18:16:22 -0700261 "tests/files/offline/art_quick_osr_stub_arm/*",
Christopher Ferris1a141a02018-01-24 08:52:47 -0800262 "tests/files/offline/bad_eh_frame_hdr_arm64/*",
263 "tests/files/offline/debug_frame_first_x86/*",
Christopher Ferris4cc36d22018-06-06 14:47:31 -0700264 "tests/files/offline/debug_frame_load_bias_arm/*",
Christopher Ferris5838e532019-10-21 18:59:42 -0700265 "tests/files/offline/eh_frame_bias_x86/*",
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800266 "tests/files/offline/eh_frame_hdr_begin_x86_64/*",
Christopher Ferris0f40a052020-01-22 12:17:06 -0800267 "tests/files/offline/empty_arm64/*",
Christopher Ferrisd49499d2019-06-10 18:37:32 -0700268 "tests/files/offline/invalid_elf_offset_arm/*",
Christopher Ferris5f5cb232018-02-05 13:07:06 -0800269 "tests/files/offline/jit_debug_arm/*",
270 "tests/files/offline/jit_debug_x86/*",
Yabin Cuid5b22c52018-02-22 17:11:31 -0800271 "tests/files/offline/jit_map_arm/*",
Christopher Ferris5f5cb232018-02-05 13:07:06 -0800272 "tests/files/offline/gnu_debugdata_arm/*",
Christopher Ferris819f1312019-10-03 13:35:48 -0700273 "tests/files/offline/load_bias_different_section_bias_arm64/*",
Florian Mayer249c90f2019-07-05 16:48:04 +0100274 "tests/files/offline/load_bias_ro_rx_x86_64/*",
Christopher Ferris239425b2018-05-17 18:37:38 -0700275 "tests/files/offline/offset_arm/*",
Christopher Ferris01040b12018-12-10 11:13:23 -0800276 "tests/files/offline/shared_lib_in_apk_arm64/*",
277 "tests/files/offline/shared_lib_in_apk_memory_only_arm64/*",
Christopher Ferris86f2d9d2019-03-12 15:17:36 -0700278 "tests/files/offline/shared_lib_in_apk_single_map_arm64/*",
Christopher Ferrisf0c82e72019-12-04 13:37:11 -0800279 "tests/files/offline/signal_load_bias_arm/*",
Christopher Ferris5f5cb232018-02-05 13:07:06 -0800280 "tests/files/offline/straddle_arm/*",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800281 "tests/files/offline/straddle_arm64/*",
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700282 ],
Peter Collingbournec71e0a62020-04-07 14:04:46 -0700283
284 header_libs: [
285 "bionic_libc_platform_headers",
286 ],
287
288 product_variables: {
289 experimental_mte: {
290 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
291 },
292 },
Christopher Ferris7aba5142019-09-03 10:18:42 -0700293}
294
295cc_test {
296 name: "libunwindstack_test",
297 defaults: ["libunwindstack_testlib_flags"],
298 isolated: true,
299
300 srcs: [
301 "tests/LocalUnwinderTest.cpp",
302 ],
Elliott Hughesf6d75942018-06-06 10:48:41 -0700303 required: [
304 "libunwindstack_local",
305 ],
Christopher Ferris723cf9b2017-01-19 20:08:48 -0800306}
307
Christopher Ferris7aba5142019-09-03 10:18:42 -0700308// Skip LocalUnwinderTest until atest understands required properly.
309cc_test {
310 name: "libunwindstack_unit_test",
311 defaults: ["libunwindstack_testlib_flags"],
312 isolated: true,
313}
314
Christopher Ferris3958f802017-02-01 15:44:40 -0800315//-------------------------------------------------------------------------
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700316// Tools
Christopher Ferris3958f802017-02-01 15:44:40 -0800317//-------------------------------------------------------------------------
318cc_defaults {
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700319 name: "libunwindstack_tools",
Christopher Ferris3958f802017-02-01 15:44:40 -0800320 defaults: ["libunwindstack_flags"],
321
322 shared_libs: [
323 "libunwindstack",
324 "libbase",
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700325 "liblzma",
Christopher Ferris3958f802017-02-01 15:44:40 -0800326 ],
Andreas Gampe8ccbe422018-05-21 08:24:20 -0700327 target: {
328 // Always disable optimizations for host to make it easier to debug.
329 host: {
330 cflags: [
331 "-O0",
332 "-g",
333 ],
334 },
335 },
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700336}
Christopher Ferris3958f802017-02-01 15:44:40 -0800337
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700338cc_binary {
339 name: "unwind",
340 defaults: ["libunwindstack_tools"],
341
342 srcs: [
343 "tools/unwind.cpp",
Christopher Ferris3958f802017-02-01 15:44:40 -0800344 ],
Christopher Ferris3958f802017-02-01 15:44:40 -0800345}
346
347cc_binary {
348 name: "unwind_info",
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700349 defaults: ["libunwindstack_tools"],
Christopher Ferris3958f802017-02-01 15:44:40 -0800350
351 srcs: [
Christopher Ferrisb5d7a872017-07-12 15:40:52 -0700352 "tools/unwind_info.cpp",
353 ],
354}
355
356cc_binary {
357 name: "unwind_symbols",
358 defaults: ["libunwindstack_tools"],
359
360 srcs: [
361 "tools/unwind_symbols.cpp",
Christopher Ferris3958f802017-02-01 15:44:40 -0800362 ],
363}
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700364
Christopher Ferris3dfd2ae2017-12-15 20:00:59 -0800365cc_binary {
366 name: "unwind_for_offline",
367 defaults: ["libunwindstack_tools"],
368
369 srcs: [
370 "tools/unwind_for_offline.cpp",
371 ],
372}
373
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800374cc_binary {
375 name: "unwind_reg_info",
376 defaults: ["libunwindstack_tools"],
377
378 srcs: [
379 "tools/unwind_reg_info.cpp",
380 ],
381}
382
Christopher Ferrisef640102018-11-14 15:36:45 -0800383//-------------------------------------------------------------------------
384// Benchmarks
385//-------------------------------------------------------------------------
386cc_benchmark {
387 name: "unwind_benchmarks",
388 host_supported: true,
389 defaults: ["libunwindstack_flags"],
390
391 // Disable optimizations so that all of the calls are not optimized away.
392 cflags: [
393 "-O0",
394 ],
395
396 srcs: [
397 "benchmarks/unwind_benchmarks.cpp",
Christopher Ferrisa9e19092020-04-14 11:59:15 -0700398 "benchmarks/SymbolBenchmark.cpp",
399 ],
400
401 data: [
402 "benchmarks/files/*",
Christopher Ferrisef640102018-11-14 15:36:45 -0800403 ],
404
405 shared_libs: [
Christopher Ferrisbf373ed2019-01-16 17:23:39 -0800406 "libbase",
Christopher Ferrisef640102018-11-14 15:36:45 -0800407 "libunwindstack",
408 ],
Christopher Ferrisa9e19092020-04-14 11:59:15 -0700409
410 target: {
411 android: {
412 static_libs: [
413 "libmeminfo",
414 "libprocinfo",
415 ],
416 },
417 },
Christopher Ferrisef640102018-11-14 15:36:45 -0800418}
419
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700420// Generates the elf data for use in the tests for .gnu_debugdata frames.
421// Once these files are generated, use the xz command to compress the data.
422cc_binary_host {
423 name: "gen_gnudebugdata",
Christopher Ferrisf6d54312017-07-11 15:29:32 -0700424 defaults: ["libunwindstack_flags"],
Christopher Ferrisbae69f12017-06-28 14:51:54 -0700425
426 srcs: [
427 "tests/GenGnuDebugdata.cpp",
428 ],
429}