• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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
17package {
18    default_applicable_licenses: [
19        "Android-Apache-2.0",
20        "system_unwinding_libunwindstack_license",
21    ],
22}
23
24license {
25    name: "system_unwinding_libunwindstack_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-BSD",
29    ],
30    license_text: ["LICENSE_BSD"],
31}
32
33cc_defaults {
34    name: "libunwindstack_flags",
35
36    host_supported: true,
37
38    cflags: [
39        "-Wall",
40        "-Werror",
41        "-Wextra",
42    ],
43
44    target: {
45        darwin: {
46            enabled: false,
47        },
48        linux_bionic: {
49            enabled: true,
50        },
51    },
52}
53
54libunwindstack_common_src_files = [
55    "AndroidUnwinder.cpp",
56    "ArmExidx.cpp",
57    "DexFiles.cpp",
58    "DwarfCfa.cpp",
59    "DwarfEhFrameWithHdr.cpp",
60    "DwarfMemory.cpp",
61    "DwarfOp.cpp",
62    "DwarfSection.cpp",
63    "Elf.cpp",
64    "ElfInterface.cpp",
65    "ElfInterfaceArm.cpp",
66    "Global.cpp",
67    "JitDebug.cpp",
68    "MapInfo.cpp",
69    "Maps.cpp",
70    "Memory.cpp",
71    "MemoryMte.cpp",
72    "MemoryXz.cpp",
73    "Regs.cpp",
74    "RegsArm.cpp",
75    "RegsArm64.cpp",
76    "RegsX86.cpp",
77    "RegsX86_64.cpp",
78    "RegsMips.cpp",
79    "RegsMips64.cpp",
80    "Symbols.cpp",
81    "ThreadEntry.cpp",
82    "ThreadUnwinder.cpp",
83    "Unwinder.cpp",
84]
85
86cc_defaults {
87    name: "libunwindstack_defaults",
88    defaults: ["libunwindstack_flags"],
89    export_include_dirs: ["include"],
90
91    srcs: libunwindstack_common_src_files,
92
93    cflags: [
94        "-Wexit-time-destructors",
95        "-fno-c++-static-destructors",
96    ],
97
98    target: {
99        host: {
100            // Always disable optimizations for host to make it easier to debug.
101            cflags: [
102                "-O0",
103                "-g",
104            ],
105        },
106        bionic: {
107            header_libs: ["bionic_libc_platform_headers"],
108            static_libs: ["libasync_safe"],
109        },
110    },
111
112    arch: {
113        x86: {
114            srcs: ["AsmGetRegsX86.S"],
115        },
116        x86_64: {
117            srcs: ["AsmGetRegsX86_64.S"],
118        },
119    },
120
121    static_libs: [
122        "libprocinfo",
123    ],
124
125    shared_libs: [
126        "libbase",
127        "liblog",
128        "liblzma",
129    ],
130}
131
132cc_library {
133    name: "libunwindstack",
134    vendor_available: true,
135    product_available: true,
136    recovery_available: true,
137    vendor_ramdisk_available: true,
138    // TODO(b/153609531): remove when no longer needed.
139    native_bridge_supported: true,
140    vndk: {
141        enabled: true,
142        support_system_process: true,
143    },
144    defaults: ["libunwindstack_defaults"],
145    srcs: [
146        "DexFile.cpp",
147        "LogAndroid.cpp",
148    ],
149    cflags: ["-DDEXFILE_SUPPORT"],
150    static_libs: ["libdexfile_support"],
151    runtime_libs: ["libdexfile"], // libdexfile_support dependency
152
153    target: {
154        vendor: {
155            cflags: ["-UDEXFILE_SUPPORT"],
156            exclude_srcs: ["DexFile.cpp"],
157            exclude_static_libs: ["libdexfile_support"],
158            exclude_runtime_libs: ["libdexfile"],
159        },
160        product: {
161            cflags: ["-UDEXFILE_SUPPORT"],
162            exclude_srcs: ["DexFile.cpp"],
163            exclude_static_libs: ["libdexfile_support"],
164            exclude_runtime_libs: ["libdexfile"],
165        },
166        recovery: {
167            cflags: ["-UDEXFILE_SUPPORT"],
168            exclude_srcs: ["DexFile.cpp"],
169            exclude_static_libs: ["libdexfile_support"],
170            exclude_runtime_libs: ["libdexfile"],
171        },
172        vendor_ramdisk: {
173            cflags: ["-UDEXFILE_SUPPORT"],
174            exclude_srcs: ["DexFile.cpp"],
175            exclude_static_libs: ["libdexfile_support"],
176            exclude_runtime_libs: ["libdexfile"],
177        },
178        native_bridge: {
179            cflags: ["-UDEXFILE_SUPPORT"],
180            exclude_srcs: ["DexFile.cpp"],
181            exclude_static_libs: ["libdexfile_support"],
182            exclude_runtime_libs: ["libdexfile"],
183        },
184    },
185
186    apex_available: [
187        "//apex_available:platform",
188        "com.android.art",
189        "com.android.art.debug",
190    ],
191    min_sdk_version: "29",
192}
193
194// Make sure that the code can be compiled without Android Logging.
195cc_library {
196    name: "libunwindstack_stdout_log",
197    defaults: ["libunwindstack_defaults"],
198    srcs: [
199        "LogStdout.cpp",
200    ],
201}
202
203// Static library without DEX support to avoid dependencies on the ART APEX.
204cc_library_static {
205    name: "libunwindstack_no_dex",
206    ramdisk_available: true,
207    recovery_available: true,
208    vendor_ramdisk_available: true,
209    defaults: ["libunwindstack_defaults"],
210    srcs: ["LogAndroid.cpp"],
211
212    visibility: [
213        "//external/gwp_asan",
214        "//system/core/debuggerd",
215        "//system/core/init",
216        "//system/unwinding/libbacktrace",
217    ],
218    apex_available: [
219        "//apex_available:platform",
220        "com.android.runtime",
221    ],
222}
223
224//-------------------------------------------------------------------------
225// Utils
226//-------------------------------------------------------------------------
227cc_library {
228    name: "libunwindstack_utils",
229    defaults: ["libunwindstack_flags"],
230    export_include_dirs: ["utils"],
231    shared_libs: [
232        "libbase",
233        "libunwindstack",
234        "libprocinfo",
235    ],
236    whole_static_libs: [
237        "libc++fs",
238        "libz",
239    ],
240    srcs: [
241        "utils/MemoryFake.cpp",
242        "utils/OfflineUnwindUtils.cpp",
243        "utils/PidUtils.cpp",
244        "utils/ProcessTracer.cpp",
245    ],
246}
247
248//-------------------------------------------------------------------------
249// Unit Tests
250//-------------------------------------------------------------------------
251cc_library_shared {
252    name: "libunwindstack_local",
253    defaults: ["libunwindstack_flags"],
254    srcs: ["tests/TestLocal.cpp"],
255
256    cflags: [
257        "-O0",
258        "-g",
259    ],
260
261    shared_libs: [
262        "libunwindstack",
263    ],
264}
265
266cc_defaults {
267    name: "libunwindstack_testlib_flags",
268    defaults: ["libunwindstack_flags"],
269
270    srcs: [
271        "tests/AndroidUnwinderTest.cpp",
272        "tests/ArmExidxDecodeTest.cpp",
273        "tests/ArmExidxExtractTest.cpp",
274        "tests/DexFileTest.cpp",
275        "tests/DexFilesTest.cpp",
276        "tests/DwarfCfaLogTest.cpp",
277        "tests/DwarfCfaTest.cpp",
278        "tests/DwarfDebugFrameTest.cpp",
279        "tests/DwarfEhFrameTest.cpp",
280        "tests/DwarfEhFrameWithHdrTest.cpp",
281        "tests/DwarfMemoryTest.cpp",
282        "tests/DwarfOpLogTest.cpp",
283        "tests/DwarfOpTest.cpp",
284        "tests/DwarfSectionTest.cpp",
285        "tests/DwarfSectionImplTest.cpp",
286        "tests/ElfCacheTest.cpp",
287        "tests/ElfFake.cpp",
288        "tests/ElfInterfaceArmTest.cpp",
289        "tests/ElfInterfaceTest.cpp",
290        "tests/ElfTest.cpp",
291        "tests/ElfTestUtils.cpp",
292        "tests/GlobalDebugImplTest.cpp",
293        "tests/GlobalTest.cpp",
294        "tests/IsolatedSettings.cpp",
295        "tests/JitDebugTest.cpp",
296        "tests/LocalUpdatableMapsTest.cpp",
297        "tests/LogFake.cpp",
298        "tests/MapInfoCreateMemoryTest.cpp",
299        "tests/MapInfoGetBuildIDTest.cpp",
300        "tests/MapInfoGetElfTest.cpp",
301        "tests/MapInfoGetLoadBiasTest.cpp",
302        "tests/MapInfoTest.cpp",
303        "tests/MapsTest.cpp",
304        "tests/MemoryBufferTest.cpp",
305        "tests/MemoryCacheTest.cpp",
306        "tests/MemoryFileTest.cpp",
307        "tests/MemoryLocalTest.cpp",
308        "tests/MemoryOfflineBufferTest.cpp",
309        "tests/MemoryOfflineTest.cpp",
310        "tests/MemoryRangeTest.cpp",
311        "tests/MemoryRangesTest.cpp",
312        "tests/MemoryRemoteTest.cpp",
313        "tests/MemoryTest.cpp",
314        "tests/MemoryThreadCacheTest.cpp",
315        "tests/MemoryMteTest.cpp",
316        "tests/MemoryXzTest.cpp",
317        "tests/RegsInfoTest.cpp",
318        "tests/RegsIterateTest.cpp",
319        "tests/RegsRemoteTest.cpp",
320        "tests/RegsStepIfSignalHandlerTest.cpp",
321        "tests/RegsTest.cpp",
322        "tests/SymbolsTest.cpp",
323        "tests/TestUtils.cpp",
324        "tests/UnwindOfflineTest.cpp",
325        "tests/UnwindTest.cpp",
326        "tests/UnwinderTest.cpp",
327        "tests/VerifyBionicTerminationTest.cpp",
328        "utils/tests/ProcessTracerTest.cpp",
329    ],
330
331    cflags: [
332        "-O0",
333        "-g",
334    ],
335
336    shared_libs: [
337        "libbase",
338        "liblog",
339        "liblzma",
340        "libunwindstack",
341    ],
342
343    static_libs: [
344        "libdexfile_support",
345        "libgmock",
346        "libprocinfo",
347        "libunwindstack_utils",
348    ],
349
350    test_suites: ["device-tests"],
351    data: [
352        "tests/files/boot_arm.oat.gnu_debugdata",
353        "tests/files/boot_arm.oat.gnu_debugdata.xz",
354        "tests/files/boot_arm.oat.gnu_debugdata.xz.non-power",
355        "tests/files/boot_arm.oat.gnu_debugdata.xz.odd-sizes",
356        "tests/files/boot_arm.oat.gnu_debugdata.xz.one-block",
357        "tests/files/elf32.xz",
358        "tests/files/elf64.xz",
359        "offline_files/common/*",
360        "offline_files/apk_rorx_arm64/*",
361        "offline_files/apk_rorx_unreadable_arm64/*",
362        "offline_files/apk_rx_arm64/*",
363        "offline_files/apk_rx_unreadable_arm64/*",
364        "offline_files/apk_soname_at_end_arm64/*",
365        "offline_files/art_quick_osr_stub_arm/*",
366        "offline_files/bad_eh_frame_hdr_arm64/*",
367        "offline_files/debug_frame_first_x86/*",
368        "offline_files/debug_frame_load_bias_arm/*",
369        "offline_files/eh_frame_bias_x86/*",
370        "offline_files/eh_frame_hdr_begin_x86_64/*",
371        "offline_files/empty_arm64/*",
372        "offline_files/invalid_elf_offset_arm/*",
373        "offline_files/jit_debug_arm/*",
374        "offline_files/jit_map_arm/*",
375        "offline_files/gnu_debugdata_arm/*",
376        "offline_files/load_bias_different_section_bias_arm64/*",
377        "offline_files/load_bias_ro_rx_x86_64/*",
378        "offline_files/offset_arm/*",
379        "offline_files/pauth_pc_arm64/*",
380        "offline_files/shared_lib_in_apk_arm64/*",
381        "offline_files/shared_lib_in_apk_memory_only_arm64/*",
382        "offline_files/shared_lib_in_apk_single_map_arm64/*",
383        "offline_files/signal_load_bias_arm/*",
384        "offline_files/signal_fde_x86/*",
385        "offline_files/signal_fde_x86_64/*",
386        "offline_files/straddle_arm/*",
387        "offline_files/jit_debug_x86/*",
388        "offline_files/straddle_arm64/*",
389        "offline_files/bluetooth_arm64/pc_1/*",
390        "offline_files/bluetooth_arm64/pc_2/*",
391        "offline_files/bluetooth_arm64/pc_3/*",
392        "offline_files/bluetooth_arm64/pc_4/*",
393        "offline_files/photos_reset_arm64/*",
394        "offline_files/youtube_compiled_arm64/*",
395        "offline_files/yt_music_arm64/*",
396        "offline_files/maps_compiled_arm64/28613_main-thread/*",
397        "offline_files/maps_compiled_arm64/28644/*",
398        "offline_files/maps_compiled_arm64/28648/*",
399        "offline_files/maps_compiled_arm64/28656_oat_odex_jar/*",
400        "offline_files/maps_compiled_arm64/28667/*",
401    ],
402
403    target: {
404        android: {
405            header_libs: ["bionic_libc_platform_headers"],
406        },
407        linux_bionic: {
408            header_libs: ["bionic_libc_platform_headers"],
409        },
410    },
411}
412
413cc_test {
414    name: "libunwindstack_unit_test",
415    defaults: ["libunwindstack_testlib_flags"],
416    isolated: true,
417    data: [
418        ":libunwindstack_local",
419    ],
420}
421
422//-------------------------------------------------------------------------
423// Fuzzers
424//-------------------------------------------------------------------------
425cc_defaults {
426    name: "libunwindstack_fuzz_defaults",
427    host_supported: true,
428    defaults: ["libunwindstack_flags"],
429    cflags: [
430        "-Wexit-time-destructors",
431        "-fno-c++-static-destructors",
432        "-g",
433    ],
434    shared_libs: [
435        "libbase",
436        "liblog",
437        "liblzma",
438        "libunwindstack",
439    ],
440    static_libs: [
441        "libdexfile_support",
442        "libunwindstack_utils",
443    ],
444}
445
446cc_fuzz {
447    name: "libunwindstack_fuzz_unwinder",
448    defaults: ["libunwindstack_fuzz_defaults"],
449    srcs: [
450        "tests/ElfFake.cpp",
451        "tests/fuzz/UnwinderComponentCreator.cpp",
452        "tests/fuzz/UnwinderFuzz.cpp",
453    ],
454}
455
456//-------------------------------------------------------------------------
457// Tools
458//-------------------------------------------------------------------------
459cc_defaults {
460    name: "libunwindstack_tools",
461    defaults: ["libunwindstack_flags"],
462
463    shared_libs: [
464        "libunwindstack_stdout_log",
465        "libbase",
466        "liblzma",
467    ],
468    target: {
469        // Always disable optimizations for host to make it easier to debug.
470        host: {
471            cflags: [
472                "-O0",
473                "-g",
474            ],
475        },
476    },
477}
478
479cc_binary {
480    name: "unwind",
481    defaults: ["libunwindstack_tools"],
482
483    srcs: [
484        "tools/unwind.cpp",
485    ],
486}
487
488cc_binary {
489    name: "unwind_info",
490    defaults: ["libunwindstack_tools"],
491
492    srcs: [
493        "tools/unwind_info.cpp",
494    ],
495}
496
497cc_binary {
498    name: "unwind_symbols",
499    defaults: ["libunwindstack_tools"],
500
501    srcs: [
502        "tools/unwind_symbols.cpp",
503    ],
504}
505
506cc_binary {
507    name: "unwind_for_offline",
508    defaults: ["libunwindstack_tools"],
509    static_libs: [
510        "libunwindstack_utils",
511        "libc++fs",
512    ],
513
514    srcs: [
515        "tools/unwind_for_offline.cpp",
516    ],
517}
518
519cc_binary {
520    name: "unwind_reg_info",
521    defaults: ["libunwindstack_tools"],
522
523    srcs: [
524        "tools/unwind_reg_info.cpp",
525    ],
526}
527
528//-------------------------------------------------------------------------
529// Benchmarks
530//-------------------------------------------------------------------------
531cc_benchmark {
532    name: "unwind_benchmarks",
533    host_supported: true,
534    defaults: ["libunwindstack_flags"],
535
536    // Disable optimizations so that all of the calls are not optimized away.
537    cflags: [
538        "-O0",
539    ],
540
541    srcs: [
542        "benchmarks/ElfBenchmark.cpp",
543        "benchmarks/MapsBenchmark.cpp",
544        "benchmarks/SymbolBenchmark.cpp",
545        "benchmarks/Utils.cpp",
546        "benchmarks/local_unwind_benchmarks.cpp",
547        "benchmarks/main.cpp",
548        "benchmarks/remote_unwind_benchmarks.cpp",
549        "benchmarks/thread_unwind_benchmarks.cpp",
550        "benchmarks/OfflineUnwindBenchmarks.cpp",
551        "benchmarks/EvalBenchmark.cpp",
552    ],
553
554    data: [
555        "benchmarks/files/*",
556        "offline_files/common/*",
557        "offline_files/jit_debug_arm/*",
558        "offline_files/straddle_arm64/*",
559        "offline_files/bluetooth_arm64/pc_1/*",
560        "offline_files/bluetooth_arm64/pc_2/*",
561        "offline_files/bluetooth_arm64/pc_3/*",
562        "offline_files/bluetooth_arm64/pc_4/*",
563        "offline_files/photos_reset_arm64/*",
564        "offline_files/youtube_compiled_arm64/*",
565        "offline_files/yt_music_arm64/*",
566        "offline_files/maps_compiled_arm64/28613_main-thread/*",
567        "offline_files/maps_compiled_arm64/28644/*",
568        "offline_files/maps_compiled_arm64/28648/*",
569        "offline_files/maps_compiled_arm64/28656_oat_odex_jar/*",
570        "offline_files/maps_compiled_arm64/28667/*",
571    ],
572
573    shared_libs: [
574        "libbase",
575        "libunwindstack",
576    ],
577
578    static_libs: [
579        "libunwindstack_utils",
580        "libprocinfo",
581    ],
582
583    target: {
584        android: {
585            static_libs: [
586                "libmeminfo",
587            ],
588        },
589    },
590}
591
592// Generates the elf data for use in the tests for .gnu_debugdata frames.
593// Once these files are generated, use the xz command to compress the data.
594cc_binary_host {
595    name: "gen_gnudebugdata",
596    defaults: ["libunwindstack_flags"],
597
598    srcs: [
599        "tests/GenGnuDebugdata.cpp",
600    ],
601}
602