Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2017 The Abseil Authors. |
| 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 | # https://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 | |
| 17 | load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") |
| 18 | load( |
| 19 | "//absl:copts/configure_copts.bzl", |
| 20 | "ABSL_DEFAULT_COPTS", |
| 21 | "ABSL_DEFAULT_LINKOPTS", |
| 22 | "ABSL_TEST_COPTS", |
| 23 | ) |
| 24 | |
| 25 | package( |
| 26 | default_visibility = ["//visibility:public"], |
| 27 | ) |
| 28 | |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 29 | licenses(["notice"]) |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 30 | |
| 31 | cc_library( |
| 32 | name = "stacktrace", |
| 33 | srcs = [ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 34 | "internal/stacktrace_aarch64-inl.inc", |
| 35 | "internal/stacktrace_arm-inl.inc", |
| 36 | "internal/stacktrace_config.h", |
| 37 | "internal/stacktrace_generic-inl.inc", |
| 38 | "internal/stacktrace_powerpc-inl.inc", |
| 39 | "internal/stacktrace_unimplemented-inl.inc", |
| 40 | "internal/stacktrace_win32-inl.inc", |
| 41 | "internal/stacktrace_x86-inl.inc", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 42 | "stacktrace.cc", |
| 43 | ], |
| 44 | hdrs = ["stacktrace.h"], |
| 45 | copts = ABSL_DEFAULT_COPTS, |
| 46 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 47 | deps = [ |
| 48 | ":debugging_internal", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 49 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 50 | "//absl/base:core_headers", |
| 51 | ], |
| 52 | ) |
| 53 | |
| 54 | cc_library( |
| 55 | name = "symbolize", |
| 56 | srcs = [ |
| 57 | "symbolize.cc", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 58 | "symbolize_darwin.inc", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 59 | "symbolize_elf.inc", |
| 60 | "symbolize_unimplemented.inc", |
| 61 | "symbolize_win32.inc", |
| 62 | ], |
| 63 | hdrs = [ |
| 64 | "internal/symbolize.h", |
| 65 | "symbolize.h", |
| 66 | ], |
| 67 | copts = ABSL_DEFAULT_COPTS, |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 68 | linkopts = ABSL_DEFAULT_LINKOPTS + select({ |
| 69 | "//absl:windows": ["-DEFAULTLIB:dbghelp.lib"], |
| 70 | "//conditions:default": [], |
| 71 | }), |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 72 | deps = [ |
| 73 | ":debugging_internal", |
| 74 | ":demangle_internal", |
| 75 | "//absl/base", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 76 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 77 | "//absl/base:core_headers", |
| 78 | "//absl/base:dynamic_annotations", |
| 79 | "//absl/base:malloc_internal", |
| 80 | "//absl/base:raw_logging_internal", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 81 | "//absl/strings", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 82 | ], |
| 83 | ) |
| 84 | |
| 85 | cc_test( |
| 86 | name = "symbolize_test", |
| 87 | srcs = ["symbolize_test.cc"], |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 88 | copts = ABSL_TEST_COPTS + select({ |
| 89 | "//absl:windows": ["/Z7"], |
| 90 | "//conditions:default": [], |
| 91 | }), |
| 92 | linkopts = ABSL_DEFAULT_LINKOPTS + select({ |
| 93 | "//absl:windows": ["/DEBUG"], |
| 94 | "//conditions:default": [], |
| 95 | }), |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 96 | deps = [ |
| 97 | ":stack_consumption", |
| 98 | ":symbolize", |
| 99 | "//absl/base", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 100 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 101 | "//absl/base:core_headers", |
| 102 | "//absl/base:raw_logging_internal", |
| 103 | "//absl/memory", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 104 | "//absl/strings", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 105 | "@com_google_googletest//:gtest", |
| 106 | ], |
| 107 | ) |
| 108 | |
| 109 | cc_library( |
| 110 | name = "examine_stack", |
| 111 | srcs = [ |
| 112 | "internal/examine_stack.cc", |
| 113 | ], |
| 114 | hdrs = [ |
| 115 | "internal/examine_stack.h", |
| 116 | ], |
| 117 | copts = ABSL_DEFAULT_COPTS, |
| 118 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 119 | visibility = ["//visibility:private"], |
| 120 | deps = [ |
| 121 | ":stacktrace", |
| 122 | ":symbolize", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 123 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 124 | "//absl/base:core_headers", |
| 125 | "//absl/base:raw_logging_internal", |
| 126 | ], |
| 127 | ) |
| 128 | |
| 129 | cc_library( |
| 130 | name = "failure_signal_handler", |
| 131 | srcs = ["failure_signal_handler.cc"], |
| 132 | hdrs = ["failure_signal_handler.h"], |
| 133 | copts = ABSL_DEFAULT_COPTS, |
| 134 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 135 | deps = [ |
| 136 | ":examine_stack", |
| 137 | ":stacktrace", |
| 138 | "//absl/base", |
| 139 | "//absl/base:config", |
| 140 | "//absl/base:core_headers", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 141 | "//absl/base:errno_saver", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 142 | "//absl/base:raw_logging_internal", |
| 143 | ], |
| 144 | ) |
| 145 | |
| 146 | cc_test( |
| 147 | name = "failure_signal_handler_test", |
| 148 | srcs = ["failure_signal_handler_test.cc"], |
| 149 | copts = ABSL_TEST_COPTS, |
| 150 | linkopts = select({ |
| 151 | "//absl:windows": [], |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 152 | "//absl:wasm": [], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 153 | "//conditions:default": ["-pthread"], |
| 154 | }) + ABSL_DEFAULT_LINKOPTS, |
| 155 | deps = [ |
| 156 | ":failure_signal_handler", |
| 157 | ":stacktrace", |
| 158 | ":symbolize", |
| 159 | "//absl/base:raw_logging_internal", |
| 160 | "//absl/strings", |
| 161 | "@com_google_googletest//:gtest", |
| 162 | ], |
| 163 | ) |
| 164 | |
| 165 | cc_library( |
| 166 | name = "debugging_internal", |
| 167 | srcs = [ |
| 168 | "internal/address_is_readable.cc", |
| 169 | "internal/elf_mem_image.cc", |
| 170 | "internal/vdso_support.cc", |
| 171 | ], |
| 172 | hdrs = [ |
| 173 | "internal/address_is_readable.h", |
| 174 | "internal/elf_mem_image.h", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 175 | "internal/vdso_support.h", |
| 176 | ], |
| 177 | copts = ABSL_DEFAULT_COPTS, |
| 178 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 179 | deps = [ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 180 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 181 | "//absl/base:core_headers", |
| 182 | "//absl/base:dynamic_annotations", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 183 | "//absl/base:errno_saver", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 184 | "//absl/base:raw_logging_internal", |
| 185 | ], |
| 186 | ) |
| 187 | |
| 188 | cc_library( |
| 189 | name = "demangle_internal", |
| 190 | srcs = ["internal/demangle.cc"], |
| 191 | hdrs = ["internal/demangle.h"], |
| 192 | copts = ABSL_DEFAULT_COPTS, |
| 193 | deps = [ |
| 194 | "//absl/base", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 195 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 196 | "//absl/base:core_headers", |
| 197 | ], |
| 198 | ) |
| 199 | |
| 200 | cc_test( |
| 201 | name = "demangle_test", |
| 202 | srcs = ["internal/demangle_test.cc"], |
| 203 | copts = ABSL_TEST_COPTS, |
| 204 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 205 | deps = [ |
| 206 | ":demangle_internal", |
| 207 | ":stack_consumption", |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 208 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 209 | "//absl/base:core_headers", |
| 210 | "//absl/base:raw_logging_internal", |
| 211 | "//absl/memory", |
| 212 | "@com_google_googletest//:gtest_main", |
| 213 | ], |
| 214 | ) |
| 215 | |
| 216 | cc_library( |
| 217 | name = "leak_check", |
| 218 | srcs = ["leak_check.cc"], |
| 219 | hdrs = ["leak_check.h"], |
| 220 | linkopts = ABSL_DEFAULT_LINKOPTS, |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 221 | deps = [ |
| 222 | "//absl/base:config", |
| 223 | "//absl/base:core_headers", |
| 224 | ], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 225 | ) |
| 226 | |
| 227 | # Adding a dependency to leak_check_disable will disable |
| 228 | # sanitizer leak checking (asan/lsan) in a test without |
| 229 | # the need to mess around with build features. |
| 230 | cc_library( |
| 231 | name = "leak_check_disable", |
| 232 | srcs = ["leak_check_disable.cc"], |
| 233 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 234 | linkstatic = 1, |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 235 | deps = ["//absl/base:config"], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 236 | alwayslink = 1, |
| 237 | ) |
| 238 | |
| 239 | # These targets exists for use in tests only, explicitly configuring the |
| 240 | # LEAK_SANITIZER macro. It must be linked with -fsanitize=leak for lsan. |
| 241 | ABSL_LSAN_LINKOPTS = select({ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 242 | "//absl:clang_compiler": ["-fsanitize=leak"], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 243 | "//conditions:default": [], |
| 244 | }) |
| 245 | |
| 246 | cc_library( |
| 247 | name = "leak_check_api_enabled_for_testing", |
| 248 | testonly = 1, |
| 249 | srcs = ["leak_check.cc"], |
| 250 | hdrs = ["leak_check.h"], |
| 251 | copts = select({ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 252 | "//absl:clang_compiler": ["-DLEAK_SANITIZER"], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 253 | "//conditions:default": [], |
| 254 | }), |
| 255 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 256 | visibility = ["//visibility:private"], |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 257 | deps = [ |
| 258 | "//absl/base:config", |
| 259 | ], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 260 | ) |
| 261 | |
| 262 | cc_library( |
| 263 | name = "leak_check_api_disabled_for_testing", |
| 264 | testonly = 1, |
| 265 | srcs = ["leak_check.cc"], |
| 266 | hdrs = ["leak_check.h"], |
| 267 | copts = ["-ULEAK_SANITIZER"], |
| 268 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 269 | visibility = ["//visibility:private"], |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 270 | deps = [ |
| 271 | "//absl/base:config", |
| 272 | ], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 273 | ) |
| 274 | |
| 275 | cc_test( |
| 276 | name = "leak_check_test", |
| 277 | srcs = ["leak_check_test.cc"], |
| 278 | copts = select({ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 279 | "//absl:clang_compiler": ["-DABSL_EXPECT_LEAK_SANITIZER"], |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 280 | "//conditions:default": [], |
| 281 | }), |
| 282 | linkopts = ABSL_LSAN_LINKOPTS + ABSL_DEFAULT_LINKOPTS, |
| 283 | tags = ["notsan"], |
| 284 | deps = [ |
| 285 | ":leak_check_api_enabled_for_testing", |
| 286 | "//absl/base", |
| 287 | "@com_google_googletest//:gtest_main", |
| 288 | ], |
| 289 | ) |
| 290 | |
| 291 | cc_test( |
| 292 | name = "leak_check_no_lsan_test", |
| 293 | srcs = ["leak_check_test.cc"], |
| 294 | copts = ["-UABSL_EXPECT_LEAK_SANITIZER"], |
| 295 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 296 | tags = ["noasan"], |
| 297 | deps = [ |
| 298 | ":leak_check_api_disabled_for_testing", |
| 299 | "//absl/base", # for raw_logging |
| 300 | "@com_google_googletest//:gtest_main", |
| 301 | ], |
| 302 | ) |
| 303 | |
| 304 | # Test that leak checking is skipped when lsan is enabled but |
| 305 | # ":leak_check_disable" is linked in. |
| 306 | # |
| 307 | # This test should fail in the absence of a dependency on ":leak_check_disable" |
| 308 | cc_test( |
| 309 | name = "disabled_leak_check_test", |
| 310 | srcs = ["leak_check_fail_test.cc"], |
| 311 | linkopts = ABSL_LSAN_LINKOPTS + ABSL_DEFAULT_LINKOPTS, |
| 312 | tags = ["notsan"], |
| 313 | deps = [ |
| 314 | ":leak_check_api_enabled_for_testing", |
| 315 | ":leak_check_disable", |
| 316 | "//absl/base", |
| 317 | "@com_google_googletest//:gtest_main", |
| 318 | ], |
| 319 | ) |
| 320 | |
| 321 | cc_library( |
| 322 | name = "stack_consumption", |
| 323 | testonly = 1, |
| 324 | srcs = ["internal/stack_consumption.cc"], |
| 325 | hdrs = ["internal/stack_consumption.h"], |
| 326 | copts = ABSL_DEFAULT_COPTS, |
| 327 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 328 | visibility = ["//visibility:private"], |
| 329 | deps = [ |
Austin Schuh | b4691e9 | 2020-12-31 12:37:18 -0800 | [diff] [blame] | 330 | "//absl/base:config", |
Austin Schuh | 36244a1 | 2019-09-21 17:52:38 -0700 | [diff] [blame] | 331 | "//absl/base:core_headers", |
| 332 | "//absl/base:raw_logging_internal", |
| 333 | ], |
| 334 | ) |
| 335 | |
| 336 | cc_test( |
| 337 | name = "stack_consumption_test", |
| 338 | srcs = ["internal/stack_consumption_test.cc"], |
| 339 | copts = ABSL_TEST_COPTS, |
| 340 | linkopts = ABSL_DEFAULT_LINKOPTS, |
| 341 | deps = [ |
| 342 | ":stack_consumption", |
| 343 | "//absl/base:core_headers", |
| 344 | "//absl/base:raw_logging_internal", |
| 345 | "@com_google_googletest//:gtest_main", |
| 346 | ], |
| 347 | ) |