blob: c2c70926b5752d1ced294e7397c67a133ee26654 [file] [log] [blame]
# Copyright 2017 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/package.gni")
# Set manually to true to compile the zxdb_test_app.cc file for manual debugger
# testing of various conditions.
include_test_app = false
static_library("lib") {
sources = [
"arch.cc",
"arch.h",
"breakpoint.cc",
"breakpoint.h",
"debug_agent.cc",
"debug_agent.h",
"debugged_job.cc",
"debugged_job.h",
"debugged_process.cc",
"debugged_process.h",
"debugged_thread.cc",
"debugged_thread.h",
"launcher.cc",
"launcher.h",
"object_util.cc",
"object_util.h",
"process_breakpoint.cc",
"process_breakpoint.h",
"process_info.cc",
"process_info.h",
"process_memory_accessor.h",
"process_watchpoint.cc",
"process_watchpoint.h",
"remote_api.h",
"remote_api_adapter.cc",
"remote_api_adapter.h",
"system_info.cc",
"system_info.h",
"unwind.cc",
"unwind.h",
"watchpoint.cc",
"watchpoint.h",
]
if (current_cpu == "x64") {
sources += [
"arch_x64.cc",
"arch_x64.h",
"arch_x64_helpers.cc",
"arch_x64_helpers.h",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64.cc",
"arch_arm64.h",
"arch_arm64_helpers.cc",
"arch_arm64_helpers.h",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
public_deps = [
"//garnet/lib/debug_ipc:agent",
"//garnet/lib/debug_ipc/helper",
"//garnet/lib/elflib",
"//garnet/lib/process",
"//garnet/public/lib/fxl",
"//garnet/public/lib/svc/cpp",
"//garnet/third_party/libunwindstack",
"//zircon/public/fidl/fuchsia-sysinfo:fuchsia-sysinfo_c",
"//zircon/public/lib/ngunwind",
]
}
if (include_test_app) {
executable("zxdb_test_app") {
if (is_debug) {
# Force no optimization in debug builds.
configs -= [ "//build/config:debug" ]
cflags = [ "-O0" ]
}
sources = [
"zxdb_test_app.cc",
]
deps = [
"//zircon/public/lib/zx",
]
}
}
executable("bin") {
output_name = "debug_agent"
sources = [
"main.cc",
]
deps = [
":lib",
"//garnet/public/lib/component/cpp:environment_services",
]
}
package("debug_agent") {
deps = [
":bin",
]
meta = [
{
path = rebase_path("meta/debug_agent.cmx")
dest = "debug_agent.cmx"
},
]
binary = "debug_agent"
}
executable("unit_tests") {
testonly = true
output_name = "debug_agent_unit_tests"
sources = [
"breakpoint_unittest.cc",
"debugged_job_unittest.cc",
"debugged_thread_unittest.cc",
"mock_arch_provider.cc",
"mock_arch_provider.h",
"mock_process.cc",
"mock_process.h",
"process_breakpoint_unittest.cc",
"process_info_unittests.cc",
"process_watchpoint_unittest.cc",
"system_info_unittests.cc",
]
if (current_cpu == "x64") {
sources += [ "arch_x64_helpers_unittest.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "arch_arm64_helpers_unittest.cc" ]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
deps = [
":lib",
"//garnet/lib/debug_ipc:tests",
"//garnet/public/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
}
package("debug_agent_tests") {
testonly = true
package_name = "debug_agent_tests"
# TODO(DX-909): Some HW capabilities (like HW breakpoints) are not well
# emulated by QEMU without KVM. This will sometimes make tests
# fail or even crash QEMU.
# The tests will be re-enabled when there is way to express
# that these test must not run on QEMU.
add_integration_tests = false
deps = [
":unit_tests",
"//garnet/bin/debug_agent/test_data:breakpoint_test_exe",
"//garnet/bin/debug_agent/test_data:debug_agent_test_loadable_module",
"//garnet/bin/debug_agent/test_data:process_loop",
"//garnet/bin/debug_agent/test_data:process_spawner",
]
if (add_integration_tests) {
deps += [
"//garnet/bin/debug_agent/integration_tests",
]
}
tests = [{
name = "debug_agent_unit_tests"
}]
if (add_integration_tests) {
tests += [{
name = "debug_agent_integration_tests"
}]
}
# Test binaries
binaries = [{
shell = true
name = "breakpoint_test_exe"
}, {
name = "process_loop"
}, {
name = "process_spawner"
}]
# Add the platform specific test binaries
if (current_cpu == "x64") {
deps += [ "//garnet/bin/debug_agent/test_data:write_register_test_exe" ]
binaries += [{
shell = true
name = "write_register_test_exe"
}]
}
loadable_modules = [{
name = "debug_agent_test_so.so"
}]
meta = [{
path = "meta/debug_agent_unit_tests.cmx"
dest = "debug_agent_unit_tests.cmx"
}]
if (add_integration_tests) {
meta+= [{
path = "meta/debug_agent_integration_tests.cmx"
dest = "debug_agent_integration_tests.cmx"
}]
}
if (include_test_app) {
deps += [ ":zxdb_test_app" ]
binaries += [{
name = "zxdb_test_app"
}]
}
}