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 17cc_defaults { 18 name: "libunwindstack_flags", 19 20 host_supported: true, 21 22 cflags: [ 23 "-Wall", 24 "-Werror", 25 "-Wextra", 26 ], 27 28 target: { 29 darwin: { 30 enabled: false, 31 }, 32 linux_bionic: { 33 enabled: true, 34 }, 35 }, 36} 37 38cc_library { 39 name: "libunwindstack", 40 vendor_available: true, 41 vndk: { 42 enabled: true, 43 support_system_process: true, 44 }, 45 defaults: ["libunwindstack_flags"], 46 export_include_dirs: ["include"], 47 48 srcs: [ 49 "ArmExidx.cpp", 50 "DwarfCfa.cpp", 51 "DwarfEhFrameWithHdr.cpp", 52 "DwarfMemory.cpp", 53 "DwarfOp.cpp", 54 "DwarfSection.cpp", 55 "Elf.cpp", 56 "ElfInterface.cpp", 57 "ElfInterfaceArm.cpp", 58 "JitDebug.cpp", 59 "Log.cpp", 60 "MapInfo.cpp", 61 "Maps.cpp", 62 "Memory.cpp", 63 "Regs.cpp", 64 "RegsArm.cpp", 65 "RegsArm64.cpp", 66 "RegsX86.cpp", 67 "RegsX86_64.cpp", 68 "RegsMips.cpp", 69 "RegsMips64.cpp", 70 "Unwinder.cpp", 71 "Symbols.cpp", 72 ], 73 74 cflags: [ 75 "-Wexit-time-destructors", 76 ], 77 78 target: { 79 // Always disable optimizations for host to make it easier to debug. 80 host: { 81 cflags: [ 82 "-O0", 83 "-g", 84 ], 85 }, 86 vendor: { 87 cflags: ["-DNO_LIBDEXFILE_SUPPORT"], 88 exclude_static_libs: ["libunwindstack_dex"], 89 exclude_shared_libs: ["libdexfile"], 90 }, 91 }, 92 whole_static_libs: ["libunwindstack_dex"], 93 94 arch: { 95 x86: { 96 srcs: ["AsmGetRegsX86.S"], 97 }, 98 x86_64: { 99 srcs: ["AsmGetRegsX86_64.S"], 100 }, 101 mips: { 102 srcs: ["AsmGetRegsMips.S"], 103 }, 104 mips64: { 105 srcs: ["AsmGetRegsMips64.S"], 106 }, 107 }, 108 109 shared_libs: [ 110 "libbase", 111 "libdexfile", 112 "liblog", 113 "liblzma", 114 ], 115} 116 117// Isolate the dex file processing into a separate library. Currently, 118// it is necessary to add art include directories directly, which also 119// adds the art elf.h file in the include path, overriding the system one. 120// Work to isolate libdexfile is b/72216369. 121cc_library_static { 122 name: "libunwindstack_dex", 123 vendor_available: false, 124 defaults: ["libunwindstack_flags"], 125 126 cflags: [ 127 "-Wexit-time-destructors", 128 ], 129 130 srcs: [ 131 "DexFile.cpp", 132 "DexFiles.cpp", 133 ], 134 target: { 135 // Always disable optimizations for host to make it easier to debug. 136 host: { 137 cflags: [ 138 "-O0", 139 "-g", 140 ], 141 }, 142 }, 143 144 shared_libs: [ 145 "libbase", 146 "libdexfile", 147 ], 148 local_include_dirs: ["include"], 149 allow_undefined_symbols: true, 150 151 // libdexfile will eventually properly export headers, for now include 152 // these directly. 153 include_dirs: [ 154 "art/runtime", 155 ], 156} 157 158//------------------------------------------------------------------------- 159// Unit Tests 160//------------------------------------------------------------------------- 161cc_test_library { 162 name: "libunwindstack_dex_test", 163 vendor_available: false, 164 defaults: ["libunwindstack_flags"], 165 166 shared: { 167 enabled: false, 168 }, 169 170 srcs: [ 171 "tests/DexFileTest.cpp", 172 "tests/DexFilesTest.cpp", 173 ], 174 local_include_dirs: ["include"], 175 allow_undefined_symbols: true, 176 177 shared_libs: [ 178 "libbase", 179 "libunwindstack", 180 "libdexfile", 181 ], 182 183 // libdexfile will eventually properly export headers, for now include 184 // these directly. 185 include_dirs: [ 186 "art/runtime", 187 ], 188} 189 190cc_test { 191 name: "libunwindstack_test", 192 defaults: ["libunwindstack_flags"], 193 194 srcs: [ 195 "tests/ArmExidxDecodeTest.cpp", 196 "tests/ArmExidxExtractTest.cpp", 197 "tests/DwarfCfaLogTest.cpp", 198 "tests/DwarfCfaTest.cpp", 199 "tests/DwarfDebugFrameTest.cpp", 200 "tests/DwarfEhFrameTest.cpp", 201 "tests/DwarfEhFrameWithHdrTest.cpp", 202 "tests/DwarfMemoryTest.cpp", 203 "tests/DwarfOpLogTest.cpp", 204 "tests/DwarfOpTest.cpp", 205 "tests/DwarfSectionTest.cpp", 206 "tests/DwarfSectionImplTest.cpp", 207 "tests/ElfCacheTest.cpp", 208 "tests/ElfFake.cpp", 209 "tests/ElfInterfaceArmTest.cpp", 210 "tests/ElfInterfaceTest.cpp", 211 "tests/ElfTest.cpp", 212 "tests/ElfTestUtils.cpp", 213 "tests/JitDebugTest.cpp", 214 "tests/LogFake.cpp", 215 "tests/MapInfoGetElfTest.cpp", 216 "tests/MapInfoGetLoadBiasTest.cpp", 217 "tests/MapsTest.cpp", 218 "tests/MemoryBufferTest.cpp", 219 "tests/MemoryFake.cpp", 220 "tests/MemoryFileTest.cpp", 221 "tests/MemoryLocalTest.cpp", 222 "tests/MemoryOfflineBufferTest.cpp", 223 "tests/MemoryOfflineTest.cpp", 224 "tests/MemoryRangeTest.cpp", 225 "tests/MemoryRemoteTest.cpp", 226 "tests/MemoryTest.cpp", 227 "tests/RegsIterateTest.cpp", 228 "tests/RegsStepIfSignalHandlerTest.cpp", 229 "tests/RegsTest.cpp", 230 "tests/SymbolsTest.cpp", 231 "tests/UnwindOfflineTest.cpp", 232 "tests/UnwindTest.cpp", 233 "tests/UnwinderTest.cpp", 234 ], 235 236 cflags: [ 237 "-O0", 238 "-g", 239 ], 240 241 shared_libs: [ 242 "libbase", 243 "liblog", 244 "liblzma", 245 "libunwindstack", 246 ], 247 248 static_libs: [ 249 "libgmock", 250 ], 251 252 whole_static_libs: ["libunwindstack_dex_test"], 253 254 data: [ 255 "tests/files/elf32.xz", 256 "tests/files/elf64.xz", 257 "tests/files/offline/art_quick_osr_stub_arm/*", 258 "tests/files/offline/bad_eh_frame_hdr_arm64/*", 259 "tests/files/offline/debug_frame_first_x86/*", 260 "tests/files/offline/eh_frame_hdr_begin_x86_64/*", 261 "tests/files/offline/jit_debug_arm/*", 262 "tests/files/offline/jit_debug_x86/*", 263 "tests/files/offline/gnu_debugdata_arm/*", 264 "tests/files/offline/offset_arm/*", 265 "tests/files/offline/straddle_arm/*", 266 "tests/files/offline/straddle_arm64/*", 267 ], 268} 269 270//------------------------------------------------------------------------- 271// Tools 272//------------------------------------------------------------------------- 273cc_defaults { 274 name: "libunwindstack_tools", 275 defaults: ["libunwindstack_flags"], 276 277 shared_libs: [ 278 "libunwindstack", 279 "libbase", 280 "liblzma", 281 ], 282} 283 284cc_binary { 285 name: "unwind", 286 defaults: ["libunwindstack_tools"], 287 288 srcs: [ 289 "tools/unwind.cpp", 290 ], 291} 292 293cc_binary { 294 name: "unwind_info", 295 defaults: ["libunwindstack_tools"], 296 297 srcs: [ 298 "tools/unwind_info.cpp", 299 ], 300} 301 302cc_binary { 303 name: "unwind_symbols", 304 defaults: ["libunwindstack_tools"], 305 306 srcs: [ 307 "tools/unwind_symbols.cpp", 308 ], 309} 310 311cc_binary { 312 name: "unwind_for_offline", 313 defaults: ["libunwindstack_tools"], 314 315 srcs: [ 316 "tools/unwind_for_offline.cpp", 317 ], 318} 319 320cc_binary { 321 name: "unwind_reg_info", 322 defaults: ["libunwindstack_tools"], 323 324 srcs: [ 325 "tools/unwind_reg_info.cpp", 326 ], 327} 328 329// Generates the elf data for use in the tests for .gnu_debugdata frames. 330// Once these files are generated, use the xz command to compress the data. 331cc_binary_host { 332 name: "gen_gnudebugdata", 333 defaults: ["libunwindstack_flags"], 334 335 srcs: [ 336 "tests/GenGnuDebugdata.cpp", 337 ], 338} 339