blob: d80d3779643f0121332303401b85fc81da8faa2e [file] [log] [blame]
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/components.gni")
import("//build/test.gni")
static_library("unwinder") {
public = [
"cfi_module.h",
"cfi_parser.h",
"dwarf_expr.h",
"error.h",
"fp_unwinder.h", # Used by
# //src/performance/experimental/profiler/sampler.cc.
"memory.h",
"module.h",
"platform.h",
"registers.h",
"unwind.h",
]
sources = [
"arm_ehabi_module.cc",
"arm_ehabi_module.h",
"arm_ehabi_parser.cc",
"arm_ehabi_parser.h",
"arm_ehabi_unwinder.cc",
"arm_ehabi_unwinder.h",
"cfi_module.cc",
"cfi_parser.cc",
"cfi_unwinder.cc",
"cfi_unwinder.h",
"dwarf_expr.cc",
"elf_utils.h",
"error.cc",
"fp_unwinder.cc",
"frame.h",
"memory.cc",
"module.cc",
"plt_unwinder.cc",
"plt_unwinder.h",
"registers.cc",
"scs_unwinder.cc",
"scs_unwinder.h",
"sigreturn_unwinder.cc",
"sigreturn_unwinder.h",
"unwind.cc",
"unwinder_base.h",
]
deps = [
"//sdk/lib/fit",
"//third_party/googletest:gtest_prod",
]
friend = [ ":*" ]
# UnwindLocal() is only available on ELF systems.
public += [
"third_party/libunwindstack/context.h",
"unwind_local.h",
]
sources += [ "unwind_local.cc" ]
if (current_cpu == "x64") {
sources += [ "third_party/libunwindstack/context_x86_64.S" ]
}
if (is_fuchsia) {
public += [ "fuchsia.h" ]
sources += [ "fuchsia.cc" ]
} else if (is_linux) {
public += [ "linux.h" ]
sources += [ "linux.cc" ]
}
}
# This test binary is always built in the linux_arm-shared toolchain. linux_arm is the only
# toolchain that will produce 32 bit binaries with the ARM Exception Handling unwinding ABI.
if (is_host) {
host_test_data("test_so") {
sources = [ "test_data/libunwind_info_test_data.targetso" ]
outputs =
[ "$root_out_dir/test_data/unwinder/{{source_name_part}}.targetso" ]
}
} else {
resource("test_so") {
sources = [ "test_data/libunwind_info_test_data.targetso" ]
outputs = [ "testdata/{{source_name_part}}.targetso" ]
}
}
test("unwinder_tests_bin") {
output_name = "unwinder_tests"
sources = [
"arm_ehabi_module_unittest.cc",
"arm_ehabi_parser_unittest.cc",
"dwarf_expr_unittest.cc",
"memory_unittest.cc",
]
deps = [
":unwinder",
"tests",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gtest",
]
if (is_host) {
data_deps = [ ":test_so" ]
}
ldflags = [ "-Wl,-z,stack-size=0x1000000" ]
}
fuchsia_unittest_package("unwinder_tests") {
deps = [ ":unwinder_tests_bin" ]
# This is a prebuilt test binary that we control ourselves. There won't be a corresponding
# unstripped binary for it.
disable_elf_binaries_checks = true
data_deps = [ ":test_so" ]
}
group("tests") {
testonly = true
deps = [
":unwinder_tests",
":unwinder_tests_bin($host_toolchain)",
]
}