blob: acbabf5b03ee7e096a3647b9eb0a5944d16214b6 [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/components.gni")
import("//build/test.gni")
static_library("lib") {
sources = [
"align.cc",
"align.h",
"arch.h",
"automation_handler.cc",
"automation_handler.h",
"automation_instruction_executor.cc",
"automation_instruction_executor.h",
"binary_launcher.h",
"breakpoint.cc",
"breakpoint.h",
"component_manager.cc",
"component_manager.h",
"debug_agent.cc",
"debug_agent.h",
"debug_registers.h",
"debugged_process.cc",
"debugged_process.h",
"debugged_thread.cc",
"debugged_thread.h",
"elf_utils.cc",
"elf_utils.h",
"exception_handle.h",
"filter.cc",
"filter.h",
"general_registers.cc",
"general_registers.h",
"hardware_breakpoint.cc",
"hardware_breakpoint.h",
"job_exception_observer.h",
"job_handle.cc",
"job_handle.h",
"limbo_provider.h",
"module_list.cc",
"module_list.h",
"process_breakpoint.cc",
"process_breakpoint.h",
"process_handle.h",
"process_handle_observer.h",
"remote_api.h",
"remote_api_adapter.cc",
"remote_api_adapter.h",
"software_breakpoint.cc",
"software_breakpoint.h",
"stdio_handles.h",
"system_interface.cc",
"system_interface.h",
"thread_handle.h",
"time.h",
"unwind.cc",
"unwind.h",
"watchpoint.cc",
"watchpoint.h",
]
public_deps = [
"//sdk/lib/fit",
"//src/developer/debug/ipc",
"//src/developer/debug/shared",
"//src/lib/containers/cpp",
"//third_party/googletest:gtest_prod",
"//zircon/system/ulib/zx",
]
deps = [
"//src/lib/elflib",
"//src/lib/unwinder",
]
# OS-independent architecture specific files.
if (current_cpu == "x64") {
sources += [
"arch_x64.cc",
"debug_registers_x64.cc",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64.cc",
"debug_registers_arm64.cc",
]
} else if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42074048): Implement this
sources += [
# "arch_riscv64.cc",
# "debug_registers_riscv64.cc",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
if (is_fuchsia) {
sources += [
"debug_agent_server.cc",
"debug_agent_server.h",
"test_realm.cc",
"test_realm.h",
"zircon_arch.cc",
"zircon_arch.h",
"zircon_binary_launcher.cc",
"zircon_binary_launcher.h",
"zircon_component_manager.cc",
"zircon_component_manager.h",
"zircon_exception_handle.cc",
"zircon_exception_handle.h",
"zircon_job_handle.cc",
"zircon_job_handle.h",
"zircon_limbo_provider.cc",
"zircon_limbo_provider.h",
"zircon_process_handle.cc",
"zircon_process_handle.h",
"zircon_suspend_handle.cc",
"zircon_suspend_handle.h",
"zircon_system_interface.cc",
"zircon_system_interface.h",
"zircon_thread_handle.cc",
"zircon_thread_handle.h",
"zircon_utils.cc",
"zircon_utils.h",
]
public_deps += [
"//sdk/fidl/fuchsia.debugger:fuchsia.debugger_cpp",
"//sdk/fidl/fuchsia.exception:fuchsia.exception_cpp",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp",
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2_cpp",
"//sdk/fidl/fuchsia.test.manager:fuchsia.test.manager_cpp",
"//sdk/lib/component/outgoing/cpp",
"//sdk/lib/syslog/cpp",
"//src/lib/fxl",
"//src/lib/process",
"//third_party/crashpad/src/minidump",
"//third_party/crashpad/src/snapshot",
"//third_party/crashpad/src/util",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
deps += [
"//sdk/lib/component/incoming/cpp",
"//src/lib/diagnostics/accessor2logger",
]
# Fuchsia architecture-specific files.
if (current_cpu == "x64") {
sources += [ "zircon_arch_x64.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "zircon_arch_arm64.cc" ]
} else if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42074048): Implement this
sources += [
# "zircon_arch_riscv64.cc",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
} else if (is_linux) {
sources += [
"aligned_chunk.cc",
"aligned_chunk.h",
"linux_arch.h",
"linux_binary_launcher.cc",
"linux_binary_launcher.h",
"linux_component_manager.cc",
"linux_component_manager.h",
"linux_exception_handle.cc",
"linux_exception_handle.h",
"linux_job_handle.cc",
"linux_job_handle.h",
"linux_process_handle.cc",
"linux_process_handle.h",
"linux_suspend_handle.h",
"linux_system_interface.cc",
"linux_system_interface.h",
"linux_task.cc",
"linux_task.h",
"linux_task_observer.h",
"linux_thread_handle.cc",
"linux_thread_handle.h",
"linux_utils.cc",
"linux_utils.h",
"posix/dir_reader_linux.h",
"posix/eintr_wrapper.h",
"posix/file_descriptor_shuffle.cc",
"posix/file_descriptor_shuffle.h",
]
if (current_cpu == "x64") {
sources += [ "linux_arch_x64.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "linux_arch_arm64.cc" ]
} else if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42074048): Implement this:
# sources += [ "linux_arch_riscv64.cc" ]
}
}
# TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-conversion" ]
}
executable("bin") {
output_name = "debug_agent"
sources = [ "main.cc" ]
deps = [ ":lib" ]
# TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-conversion" ]
}
executable("launcher") {
output_name = "debug_agent_launcher"
sources = [
"launcher.cc",
"launcher.h",
"main_launcher.cc",
]
deps = [
"//sdk/fidl/fuchsia.component:fuchsia.component_cpp",
"//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_cpp",
"//sdk/fidl/fuchsia.debugger:fuchsia.debugger_cpp",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/component/outgoing/cpp",
"//sdk/lib/syslog/cpp",
"//zircon/system/ulib/async-default",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
fuchsia_component("debug_agent_component") {
component_name = "debug_agent"
manifest = "meta/debug_agent.cml"
deps = [ ":bin" ]
}
fuchsia_component("debug_agent_launcher_component") {
component_name = "debug_agent_launcher"
manifest = "meta/debug_agent_launcher.cml"
deps = [
":debug_agent_component",
":launcher",
]
}
executable("zxdb_test_app") {
sources = [ "zxdb_test_app.cc" ]
deps = [ "//zircon/system/ulib/zx" ]
# TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-conversion" ]
}
if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42074048): remove this empty group
group("debug_agent") {
}
} else {
fuchsia_package("debug_agent") {
deps = [
":debug_agent_component",
":debug_agent_launcher_component",
]
# Set manually to true to compile helper executables for manual debugger
# testing of various conditions. Use `ffx component explore /core/debug_agent`
# to run these executables.
include_helper_executables = false
if (include_helper_executables) {
# These executables are not used by tests or the agent, but are useful for
# replicating behaviour in development.
deps += [
":zxdb_test_app",
"test_data:helper_executables",
]
}
}
}
# Common functionality used by tests.
source_set("test_lib") {
testonly = true
sources = [
"local_stream_backend.cc",
"local_stream_backend.h",
"mock_component_manager.h",
"mock_debug_agent_harness.cc",
"mock_debug_agent_harness.h",
"mock_exception_handle.h",
"mock_job_handle.cc",
"mock_job_handle.h",
"mock_limbo_provider.cc",
"mock_limbo_provider.h",
"mock_process.cc",
"mock_process.h",
"mock_process_handle.cc",
"mock_process_handle.h",
"mock_stream_backend.h",
"mock_system_interface.cc",
"mock_system_interface.h",
"mock_thread.cc",
"mock_thread.h",
"mock_thread_handle.cc",
"mock_thread_handle.h",
]
public_deps = [
":lib",
"//sdk/lib/syslog/cpp",
"//src/developer/debug/shared:test_support",
]
# TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-conversion" ]
}
test("unit_tests") {
output_name = "debug_agent_unit_tests"
sources = [ "align_unittest.cc" ]
deps = [
":test_lib",
"//src/lib/elflib",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
if (is_fuchsia) {
sources += [
"automation_instruction_executor_unittest.cc",
"breakpoint_unittest.cc",
"debug_agent_unittest.cc",
"debugged_process_unittest.cc",
"debugged_thread_breakpoint_unittest.cc",
"debugged_thread_unittest.cc",
"elf_utils_unittest.cc",
"filter_unittest.cc",
"hardware_breakpoint_unittest.cc",
"software_breakpoint_unittest.cc",
"system_interface_unittest.cc",
"time_zircon_unittest.cc",
"unwind_unittest.cc",
"watchpoint_unittest.cc",
"zircon_limbo_provider_unittest.cc",
"zircon_system_interface_unittest.cc",
]
if (current_cpu == "x64") {
sources += [
"arch_x64_unittest.cc",
"debug_registers_x64_unittest.cc",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64_unittest.cc",
"debug_registers_arm64_unittest.cc",
]
} else if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42074048): Implement this.
sources += [
# "arch_riscv64_unittest.cc",
# "debug_registers_riscv64_unittest.cc",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
deps += [
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/component/outgoing/cpp",
# Only include these here in the Fuchsia build because on the host build they're included in
# the zxdb_unit_tests.
"//src/developer/debug/ipc:tests",
"//src/developer/debug/shared:tests",
]
} else if (is_linux) {
sources += [
"aligned_chunk_unittest.cc",
"linux_utils_unittest.cc",
"posix/file_descriptor_shuffle_unittest.cc",
]
}
# TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-conversion" ]
}
fuchsia_unittest_package("debug_agent_unit_tests") {
component_name = "debug_agent_unit_tests"
manifest = "meta/debug_agent_unit_tests.cml"
deps = [ ":unit_tests" ]
# required for accessing RootJob.
test_type = "system"
}
fuchsia_unittest_package("debug_agent_integration_tests") {
manifest = "meta/debug_agent_integration_tests.cml"
deps = [
"integration_tests",
"test_data:debug_agent_test_loadable_module",
# These are executables that integration tests will need in order to test
# actual behaviour against zircon.
"test_data:test_executables",
]
# required for accessing RootJob.
test_type = "system"
}
group("tests") {
testonly = true
deps = [
":debug_agent_integration_tests",
":debug_agent_unit_tests",
]
if (host_os == "linux") {
deps += [ ":unit_tests($host_toolchain)" ]
}
}