1// 2// Copyright (C) 2014 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: ["Android-Apache-2.0"], 19} 20 21cc_defaults { 22 name: "libbacktrace_common", 23 24 cflags: [ 25 "-Wall", 26 "-Werror", 27 ], 28 29 target: { 30 darwin: { 31 enabled: false, 32 }, 33 }, 34} 35 36libbacktrace_sources = [ 37 "Backtrace.cpp", 38 "BacktraceCurrent.cpp", 39 "BacktracePtrace.cpp", 40 "ThreadEntry.cpp", 41 "UnwindStack.cpp", 42 "UnwindStackMap.cpp", 43] 44 45cc_library_headers { 46 name: "libbacktrace_headers", 47 vendor_available: true, 48 product_available: true, 49 host_supported: true, 50 recovery_available: true, 51 vendor_ramdisk_available: true, 52 native_bridge_supported: true, 53 export_include_dirs: ["include"], 54 apex_available: [ 55 "//apex_available:platform", 56 "//apex_available:anyapex", 57 ], 58 target: { 59 linux_bionic: { 60 enabled: true, 61 }, 62 }, 63 min_sdk_version: "apex_inherit", 64} 65 66cc_defaults { 67 name: "libbacktrace_defaults", 68 defaults: ["libbacktrace_common"], 69 70 cflags: [ 71 "-Wexit-time-destructors", 72 ], 73 74 srcs: [ 75 "BacktraceMap.cpp", 76 ], 77 78 export_include_dirs: ["include"], 79 80 target: { 81 darwin: { 82 enabled: true, 83 shared_libs: [ 84 "libbase", 85 ], 86 }, 87 linux: { 88 srcs: libbacktrace_sources, 89 90 shared_libs: [ 91 "libbase", 92 "liblog", 93 ], 94 95 static_libs: [ 96 "libprocinfo", 97 ], 98 }, 99 android: { 100 static_libs: ["libasync_safe"], 101 static: { 102 whole_static_libs: ["libasync_safe"], 103 }, 104 }, 105 }, 106} 107 108cc_library { 109 name: "libbacktrace", 110 vendor_available: true, 111 product_available: true, 112 // TODO(b/153609531): remove when no longer needed. 113 native_bridge_supported: true, 114 recovery_available: true, 115 apex_available: [ 116 "//apex_available:platform", 117 "//apex_available:anyapex", 118 ], 119 // This library is being deprecated in favor of libunwindstack. 120 // Therefore, only allow the current set of users, and block anyone 121 // else. 122 visibility: [ 123 "//art:__subpackages__", 124 "//bionic/libc/malloc_debug", 125 "//frameworks/native/opengl/libs", 126 "//packages/modules/vndk/apex", 127 "//packages/modules/Bluetooth/tools/rootcanal", 128 "//packages/modules/Bluetooth/system/gd", 129 "//system/core/init", 130 "//system/core/libutils", 131 ], 132 min_sdk_version: "apex_inherit", 133 vndk: { 134 enabled: true, 135 support_system_process: true, 136 private: true, 137 }, 138 host_supported: true, 139 defaults: ["libbacktrace_defaults"], 140 141 target: { 142 linux: { 143 shared_libs: [ 144 "libunwindstack", 145 ], 146 }, 147 vendor: { 148 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 149 }, 150 product: { 151 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 152 }, 153 recovery: { 154 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 155 }, 156 native_bridge: { 157 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 158 }, 159 }, 160} 161 162// Static library without DEX support to avoid dependencies on the ART APEX. 163cc_library_static { 164 name: "libbacktrace_no_dex", 165 ramdisk_available: true, 166 visibility: [ 167 "//system/core/debuggerd", 168 "//system/core/init", 169 ], 170 defaults: ["libbacktrace_defaults"], 171 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 172 target: { 173 linux: { 174 static_libs: [ 175 "libunwindstack_no_dex", 176 ], 177 }, 178 }, 179} 180 181cc_test_library { 182 name: "libbacktrace_test", 183 defaults: ["libbacktrace_common"], 184 host_supported: true, 185 strip: { 186 none: true, 187 }, 188 cflags: ["-O0"], 189 srcs: ["backtrace_testlib.cpp"], 190 191 shared_libs: [ 192 "libunwindstack", 193 ], 194 195 target: { 196 host_linux: { 197 // This forces the creation of eh_frame with unwind information 198 // for host. 199 cflags: [ 200 "-fcxx-exceptions" 201 ], 202 }, 203 }, 204} 205 206//------------------------------------------------------------------------- 207// The backtrace_test executable. 208//------------------------------------------------------------------------- 209cc_test { 210 name: "backtrace_test", 211 isolated: true, 212 defaults: ["libbacktrace_common"], 213 host_supported: true, 214 test_options: { 215 unit_test: true, 216 }, 217 srcs: [ 218 "backtrace_test.cpp", 219 ], 220 221 cflags: [ 222 "-fno-builtin", 223 "-O0", 224 "-g", 225 ], 226 227 shared_libs: [ 228 "libbacktrace", 229 "libbase", 230 "liblog", 231 "libunwindstack", 232 ], 233 234 target: { 235 android: { 236 // So that the dlopen can find the libbacktrace_test.so. 237 ldflags: [ 238 "-Wl,--rpath,${ORIGIN}", 239 ], 240 }, 241 }, 242 243 test_suites: ["device-tests"], 244 data: [ 245 ":libbacktrace_test", 246 "testdata/arm/*", 247 "testdata/arm64/*", 248 "testdata/x86/*", 249 "testdata/x86_64/*", 250 ], 251} 252 253cc_benchmark { 254 name: "backtrace_benchmarks", 255 defaults: ["libbacktrace_common"], 256 257 srcs: [ 258 "backtrace_benchmarks.cpp", 259 "backtrace_read_benchmarks.cpp", 260 ], 261 262 shared_libs: [ 263 "libbacktrace", 264 "libbase", 265 "libunwindstack", 266 ], 267} 268