From d5ead4d70f0ba11eb2aa2fbeb76133b3136ddc22 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Fri, 17 Nov 2017 17:48:22 -0800 Subject: [PATCH] Upstream lightly modified Chromium BUILD.gn files Unreferenced, and not working at all in Crashpad-standalone. Copied from Chromium at 52a9831d81f2099ef9f50fcdaca5853019262c35 to have a point where a roll back into Chromium should be a no-op (with Chromium's build/secondary/third_party/crashpad/... removed). I'm not sure what we want to do about the various gni references into Chromium (e.g. //build/config/sanitizers/sanitizers.gni, //testing/test.gni, etc.) but I guess the sooner they live in Crashpad rather than in Chromium the sooner we can figure out the sort of knobs and dials we need. Bug: crashpad:79 Change-Id: Id99c29123bcd4174ee2bcc128c2be87e3c94fa3f Reviewed-on: https://chromium-review.googlesource.com/777819 Reviewed-by: Mark Mentovai Commit-Queue: Scott Graham --- BUILD.gn | 31 ++ client/BUILD.gn | 107 +++++++ compat/BUILD.gn | 82 +++++ handler/BUILD.gn | 164 ++++++++++ minidump/BUILD.gn | 169 +++++++++++ snapshot/BUILD.gn | 408 +++++++++++++++++++++++++ snapshot/test/BUILD.gn | 155 ++++++++++ test/BUILD.gn | 155 ++++++++++ third_party/apple_cctools/BUILD.gn | 25 ++ third_party/getopt/BUILD.gn | 20 ++ third_party/zlib/BUILD.gn | 24 ++ tools/BUILD.gn | 161 ++++++++++ util/BUILD.gn | 470 +++++++++++++++++++++++++++++ 13 files changed, 1971 insertions(+) create mode 100644 BUILD.gn create mode 100644 client/BUILD.gn create mode 100644 compat/BUILD.gn create mode 100644 handler/BUILD.gn create mode 100644 minidump/BUILD.gn create mode 100644 snapshot/BUILD.gn create mode 100644 snapshot/test/BUILD.gn create mode 100644 test/BUILD.gn create mode 100644 third_party/apple_cctools/BUILD.gn create mode 100644 third_party/getopt/BUILD.gn create mode 100644 third_party/zlib/BUILD.gn create mode 100644 tools/BUILD.gn create mode 100644 util/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 00000000..5c3918ef --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright 2017 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +config("crashpad_config") { + include_dirs = [ "//third_party/crashpad/crashpad" ] +} + +test("crashpad_tests") { + deps = [ + "client:client_test", + "handler:handler_test", + "minidump:minidump_test", + "snapshot:snapshot_test", + "test:gmock_main", + "test:test_test", + "util:util_test", + ] +} diff --git a/client/BUILD.gn b/client/BUILD.gn new file mode 100644 index 00000000..3e24d6dd --- /dev/null +++ b/client/BUILD.gn @@ -0,0 +1,107 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +static_library("client") { + sources = [ + "annotation.cc", + "annotation.h", + "annotation_list.cc", + "annotation_list.h", + "crash_report_database.cc", + "crash_report_database.h", + "crash_report_database_mac.mm", + "crash_report_database_win.cc", + "crashpad_client.h", + "crashpad_client_mac.cc", + "crashpad_client_win.cc", + "crashpad_info.cc", + "crashpad_info.h", + "prune_crash_reports.cc", + "prune_crash_reports.h", + "settings.cc", + "settings.h", + "simple_address_range_bag.h", + "simple_string_dictionary.h", + "simulate_crash.h", + "simulate_crash_mac.cc", + "simulate_crash_mac.h", + "simulate_crash_win.h", + ] + + if (is_mac) { + sources += [ + "capture_context_mac.S", + "capture_context_mac.h", + ] + } + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + libs = [ "rpcrt4.lib" ] + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} + +source_set("client_test") { + testonly = true + + sources = [ + "annotation_list_test.cc", + "annotation_test.cc", + "crash_report_database_test.cc", + "prune_crash_reports_test.cc", + "settings_test.cc", + "simple_address_range_bag_test.cc", + "simple_string_dictionary_test.cc", + ] + + if (is_mac) { + sources += [ + "capture_context_mac_test.cc", + "simulate_crash_mac_test.cc", + ] + } + + if (is_win) { + sources += [ "crashpad_client_win_test.cc" ] + } + + deps = [ + ":client", + "//base", + "//testing/gmock", + "//testing/gtest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/test", + "//third_party/crashpad/crashpad/util", + ] + + data_deps = [ + "//third_party/crashpad/crashpad/handler:crashpad_handler", + ] + + if (is_win) { + data_deps += + [ "//third_party/crashpad/crashpad/handler:crashpad_handler_console" ] + } +} diff --git a/compat/BUILD.gn b/compat/BUILD.gn new file mode 100644 index 00000000..ddeb53d7 --- /dev/null +++ b/compat/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("compat_config") { + include_dirs = [] + + if (is_win) { + include_dirs += [ "win" ] + } else { + include_dirs += [ "non_win" ] + } + + if (is_mac) { + include_dirs += [ "mac" ] + } +} + +static_library("compat") { + sources = [] + + if (is_mac) { + sources += [ + "mac/AvailabilityMacros.h", + "mac/kern/exc_resource.h", + "mac/mach-o/getsect.cc", + "mac/mach-o/getsect.h", + "mac/mach-o/loader.h", + "mac/mach/mach.h", + "mac/sys/resource.h", + ] + } else { + sources += [ "non_mac/mach/mach.h" ] + } + + if (is_win) { + sources += [ + "win/getopt.h", + "win/strings.cc", + "win/strings.h", + "win/sys/types.h", + "win/time.cc", + "win/time.h", + "win/winbase.h", + "win/winnt.h", + "win/winternl.h", + ] + } else { + sources += [ + "non_win/dbghelp.h", + "non_win/minwinbase.h", + "non_win/timezoneapi.h", + "non_win/verrsrc.h", + "non_win/windows.h", + "non_win/winnt.h", + ] + } + + public_configs = [ + ":compat_config", + "//third_party/crashpad/crashpad:crashpad_config", + ] + + deps = [] + + if (is_mac) { + deps += [ "//third_party/crashpad/crashpad/third_party/apple_cctools" ] + } + if (is_win) { + deps += [ "//third_party/crashpad/crashpad/third_party/getopt" ] + } +} diff --git a/handler/BUILD.gn b/handler/BUILD.gn new file mode 100644 index 00000000..2c17f3d9 --- /dev/null +++ b/handler/BUILD.gn @@ -0,0 +1,164 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +static_library("handler") { + sources = [ + "crash_report_upload_thread.cc", + "crash_report_upload_thread.h", + "handler_main.cc", + "handler_main.h", + "mac/crash_report_exception_handler.cc", + "mac/crash_report_exception_handler.h", + "mac/exception_handler_server.cc", + "mac/exception_handler_server.h", + "mac/file_limit_annotation.cc", + "mac/file_limit_annotation.h", + "minidump_to_upload_parameters.cc", + "minidump_to_upload_parameters.h", + "prune_crash_reports_thread.cc", + "prune_crash_reports_thread.h", + "user_stream_data_source.cc", + "user_stream_data_source.h", + "win/crash_report_exception_handler.cc", + "win/crash_report_exception_handler.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/minidump", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/tools:tool_support", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} + +source_set("handler_test") { + testonly = true + + sources = [ + "minidump_to_upload_parameters_test.cc", + ] + + deps = [ + ":handler", + "//base", + "//testing/gtest", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/test", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + sources += [ "crashpad_handler_test.cc" ] + + data_deps = [ + ":crashpad_handler_test_extended_handler", + ] + } +} + +executable("crashpad_handler") { + sources = [ + "main.cc", + ] + + deps = [ + ":handler", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/compat", + ] + + if (is_mac && is_component_build) { + ldflags = [ + # The handler is in + # Chromium.app/Contents/Versions/X/Chromium Framework.framework/Versions/A/Helpers/ + # so set rpath up to the base. + "-rpath", + "@loader_path/../../../../../../../..", + + # The handler is also in + # Content Shell.app/Contents/Frameworks/Content Shell Framework.framework/Helpers/ + # so set the rpath for that too. + "-rpath", + "@loader_path/../../../../..", + ] + } + + if (is_win) { + configs -= [ "//build/config/win:console" ] + configs += [ "//build/config/win:windowed" ] + } +} + +executable("crashpad_handler_test_extended_handler") { + testonly = true + + sources = [ + "crashpad_handler_test_extended_handler.cc", + ] + + deps = [ + ":handler", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/minidump:test_support", + "//third_party/crashpad/crashpad/tools:tool_support", + ] +} + +if (is_win) { + executable("crashpad_handler_com") { + sources = [ + "main.cc", + ] + + # Avoid .exp, .ilk, and .lib file collisions with crashpad_handler.exe by + # having this target produce crashpad_handler_com.com. Don’t use this target + # directly. Instead, use crashpad_handler_console. + output_extension = "com" + + deps = [ + ":handler", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/compat", + ] + } + + copy("crashpad_handler_console") { + deps = [ + ":crashpad_handler_com", + ] + sources = [ + "$root_out_dir/crashpad_handler_com.com", + ] + outputs = [ + "$root_out_dir/crashpad_handler.com", + ] + } +} diff --git a/minidump/BUILD.gn b/minidump/BUILD.gn new file mode 100644 index 00000000..42f8c3e1 --- /dev/null +++ b/minidump/BUILD.gn @@ -0,0 +1,169 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +static_library("minidump") { + sources = [ + "minidump_annotation_writer.cc", + "minidump_annotation_writer.h", + "minidump_byte_array_writer.cc", + "minidump_byte_array_writer.h", + "minidump_context.h", + "minidump_context_writer.cc", + "minidump_context_writer.h", + "minidump_crashpad_info_writer.cc", + "minidump_crashpad_info_writer.h", + "minidump_exception_writer.cc", + "minidump_exception_writer.h", + "minidump_extensions.cc", + "minidump_extensions.h", + "minidump_file_writer.cc", + "minidump_file_writer.h", + "minidump_handle_writer.cc", + "minidump_handle_writer.h", + "minidump_memory_info_writer.cc", + "minidump_memory_info_writer.h", + "minidump_memory_writer.cc", + "minidump_memory_writer.h", + "minidump_misc_info_writer.cc", + "minidump_misc_info_writer.h", + "minidump_module_crashpad_info_writer.cc", + "minidump_module_crashpad_info_writer.h", + "minidump_module_writer.cc", + "minidump_module_writer.h", + "minidump_rva_list_writer.cc", + "minidump_rva_list_writer.h", + "minidump_simple_string_dictionary_writer.cc", + "minidump_simple_string_dictionary_writer.h", + "minidump_stream_writer.cc", + "minidump_stream_writer.h", + "minidump_string_writer.cc", + "minidump_string_writer.h", + "minidump_system_info_writer.cc", + "minidump_system_info_writer.h", + "minidump_thread_id_map.cc", + "minidump_thread_id_map.h", + "minidump_thread_writer.cc", + "minidump_thread_writer.h", + "minidump_unloaded_module_writer.cc", + "minidump_unloaded_module_writer.h", + "minidump_user_extension_stream_data_source.cc", + "minidump_user_extension_stream_data_source.h", + "minidump_user_stream_writer.cc", + "minidump_user_stream_writer.h", + "minidump_writable.cc", + "minidump_writable.h", + "minidump_writer_util.cc", + "minidump_writer_util.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + public_deps = [ + "//third_party/crashpad/crashpad/compat", + ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + cflags = [ + "/wd4201", # nonstandard extension used : nameless struct/union + "/wd4324", # 'struct' : structure was padded due to __declspec(align()) + ] + } +} + +static_library("test_support") { + testonly = true + + sources = [ + "test/minidump_byte_array_writer_test_util.cc", + "test/minidump_byte_array_writer_test_util.h", + "test/minidump_context_test_util.cc", + "test/minidump_context_test_util.h", + "test/minidump_file_writer_test_util.cc", + "test/minidump_file_writer_test_util.h", + "test/minidump_memory_writer_test_util.cc", + "test/minidump_memory_writer_test_util.h", + "test/minidump_rva_list_test_util.cc", + "test/minidump_rva_list_test_util.h", + "test/minidump_string_writer_test_util.cc", + "test/minidump_string_writer_test_util.h", + "test/minidump_user_extension_stream_util.cc", + "test/minidump_user_extension_stream_util.h", + "test/minidump_writable_test_util.cc", + "test/minidump_writable_test_util.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + public_deps = [ + ":minidump", + ] + + deps = [ + "//base", + "//testing/gtest", + ] + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} + +source_set("minidump_test") { + testonly = true + + sources = [ + "minidump_annotation_writer_test.cc", + "minidump_byte_array_writer_test.cc", + "minidump_context_writer_test.cc", + "minidump_crashpad_info_writer_test.cc", + "minidump_exception_writer_test.cc", + "minidump_file_writer_test.cc", + "minidump_handle_writer_test.cc", + "minidump_memory_info_writer_test.cc", + "minidump_memory_writer_test.cc", + "minidump_misc_info_writer_test.cc", + "minidump_module_crashpad_info_writer_test.cc", + "minidump_module_writer_test.cc", + "minidump_rva_list_writer_test.cc", + "minidump_simple_string_dictionary_writer_test.cc", + "minidump_string_writer_test.cc", + "minidump_system_info_writer_test.cc", + "minidump_thread_id_map_test.cc", + "minidump_thread_writer_test.cc", + "minidump_unloaded_module_writer_test.cc", + "minidump_user_stream_writer_test.cc", + "minidump_writable_test.cc", + ] + + deps = [ + ":test_support", + "//base", + "//testing/gtest", + "//third_party/crashpad/crashpad/snapshot:test_support", + "//third_party/crashpad/crashpad/test", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn new file mode 100644 index 00000000..49402fe9 --- /dev/null +++ b/snapshot/BUILD.gn @@ -0,0 +1,408 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/compiler/compiler.gni") +import("//testing/test.gni") + +static_library("snapshot") { + sources = [ + "annotation_snapshot.cc", + "annotation_snapshot.h", + "capture_memory.cc", + "capture_memory.h", + "cpu_architecture.h", + "cpu_context.cc", + "cpu_context.h", + "crashpad_info_client_options.cc", + "crashpad_info_client_options.h", + "exception_snapshot.h", + "handle_snapshot.cc", + "handle_snapshot.h", + "mac/cpu_context_mac.cc", + "mac/cpu_context_mac.h", + "mac/exception_snapshot_mac.cc", + "mac/exception_snapshot_mac.h", + "mac/mach_o_image_annotations_reader.cc", + "mac/mach_o_image_annotations_reader.h", + "mac/mach_o_image_reader.cc", + "mac/mach_o_image_reader.h", + "mac/mach_o_image_segment_reader.cc", + "mac/mach_o_image_segment_reader.h", + "mac/mach_o_image_symbol_table_reader.cc", + "mac/mach_o_image_symbol_table_reader.h", + "mac/memory_snapshot_mac.cc", + "mac/memory_snapshot_mac.h", + "mac/module_snapshot_mac.cc", + "mac/module_snapshot_mac.h", + "mac/process_reader.cc", + "mac/process_reader.h", + "mac/process_snapshot_mac.cc", + "mac/process_snapshot_mac.h", + "mac/process_types.cc", + "mac/process_types.h", + "mac/process_types/all.proctype", + "mac/process_types/annotation.proctype", + "mac/process_types/crashpad_info.proctype", + "mac/process_types/crashreporterclient.proctype", + "mac/process_types/custom.cc", + "mac/process_types/dyld_images.proctype", + "mac/process_types/flavors.h", + "mac/process_types/internal.h", + "mac/process_types/loader.proctype", + "mac/process_types/nlist.proctype", + "mac/process_types/traits.h", + "mac/system_snapshot_mac.cc", + "mac/system_snapshot_mac.h", + "mac/thread_snapshot_mac.cc", + "mac/thread_snapshot_mac.h", + "memory_snapshot.h", + "minidump/minidump_annotation_reader.cc", + "minidump/minidump_annotation_reader.h", + "minidump/minidump_simple_string_dictionary_reader.cc", + "minidump/minidump_simple_string_dictionary_reader.h", + "minidump/minidump_string_list_reader.cc", + "minidump/minidump_string_list_reader.h", + "minidump/minidump_string_reader.cc", + "minidump/minidump_string_reader.h", + "minidump/module_snapshot_minidump.cc", + "minidump/module_snapshot_minidump.h", + "minidump/process_snapshot_minidump.cc", + "minidump/process_snapshot_minidump.h", + "module_snapshot.h", + "posix/timezone.cc", + "posix/timezone.h", + "process_snapshot.h", + "snapshot_constants.h", + "system_snapshot.h", + "thread_snapshot.h", + "unloaded_module_snapshot.cc", + "unloaded_module_snapshot.h", + "win/capture_memory_delegate_win.cc", + "win/capture_memory_delegate_win.h", + "win/cpu_context_win.cc", + "win/cpu_context_win.h", + "win/exception_snapshot_win.cc", + "win/exception_snapshot_win.h", + "win/memory_map_region_snapshot_win.cc", + "win/memory_map_region_snapshot_win.h", + "win/memory_snapshot_win.cc", + "win/memory_snapshot_win.h", + "win/module_snapshot_win.cc", + "win/module_snapshot_win.h", + "win/pe_image_annotations_reader.cc", + "win/pe_image_annotations_reader.h", + "win/pe_image_reader.cc", + "win/pe_image_reader.h", + "win/pe_image_resource_reader.cc", + "win/pe_image_resource_reader.h", + "win/process_reader_win.cc", + "win/process_reader_win.h", + "win/process_snapshot_win.cc", + "win/process_snapshot_win.h", + "win/process_subrange_reader.cc", + "win/process_subrange_reader.h", + "win/system_snapshot_win.cc", + "win/system_snapshot_win.h", + "win/thread_snapshot_win.cc", + "win/thread_snapshot_win.h", + ] + + if (target_cpu == "x86" || target_cpu == "x64") { + sources += [ + "x86/cpuid_reader.cc", + "x86/cpuid_reader.h", + ] + } + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + libs = [ "powrprof.lib" ] + } +} + +if (is_win) { + static_library("snapshot_api") { + sources = [ + "api/module_annotations_win.cc", + "api/module_annotations_win.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + cflags = [ "/wd4201" ] + + deps = [ + ":snapshot", + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } +} else { + group("snapshot_api") { + } +} + +static_library("test_support") { + testonly = true + + sources = [ + "test/test_cpu_context.cc", + "test/test_cpu_context.h", + "test/test_exception_snapshot.cc", + "test/test_exception_snapshot.h", + "test/test_memory_map_region_snapshot.cc", + "test/test_memory_map_region_snapshot.h", + "test/test_memory_snapshot.cc", + "test/test_memory_snapshot.h", + "test/test_module_snapshot.cc", + "test/test_module_snapshot.h", + "test/test_process_snapshot.cc", + "test/test_process_snapshot.h", + "test/test_system_snapshot.cc", + "test/test_system_snapshot.h", + "test/test_thread_snapshot.cc", + "test/test_thread_snapshot.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + public_deps = [ + ":snapshot", + ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} + +source_set("snapshot_test") { + testonly = true + + sources = [ + "cpu_context_test.cc", + "crashpad_info_client_options_test.cc", + "mac/cpu_context_mac_test.cc", + "mac/mach_o_image_annotations_reader_test.cc", + "mac/mach_o_image_reader_test.cc", + "mac/mach_o_image_segment_reader_test.cc", + "mac/process_reader_test.cc", + "mac/process_types_test.cc", + "mac/system_snapshot_mac_test.cc", + "minidump/process_snapshot_minidump_test.cc", + "win/cpu_context_win_test.cc", + "win/exception_snapshot_win_test.cc", + "win/extra_memory_ranges_test.cc", + "win/pe_image_annotations_reader_test.cc", + "win/pe_image_reader_test.cc", + "win/process_reader_win_test.cc", + "win/process_snapshot_win_test.cc", + "win/system_snapshot_win_test.cc", + ] + + if (is_win) { + sources += [ "api/module_annotations_win_test.cc" ] + } else { + sources += [ "posix/timezone_test.cc" ] + } + + deps = [ + ":snapshot_api", + ":test_support", + "//base", + "//testing/gtest", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/test", + "//third_party/crashpad/crashpad/util", + ] + + data_deps = [ + ":crashpad_snapshot_test_module", + ":crashpad_snapshot_test_module_large", + ":crashpad_snapshot_test_module_small", + ] + + if (is_mac) { + libs = [ "OpenCL.framework" ] + + data_deps += [ + ":crashpad_snapshot_test_module_crashy_initializer", + ":crashpad_snapshot_test_no_op", + ] + } + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + + data_deps += [ + ":crashpad_snapshot_test_annotations", + ":crashpad_snapshot_test_crashing_child", + ":crashpad_snapshot_test_dump_without_crashing", + ":crashpad_snapshot_test_extra_memory_ranges", + ":crashpad_snapshot_test_image_reader", + ":crashpad_snapshot_test_image_reader_module", + ] + } +} + +loadable_module("crashpad_snapshot_test_module") { + testonly = true + sources = [ + "crashpad_info_client_options_test_module.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + ] +} + +loadable_module("crashpad_snapshot_test_module_large") { + testonly = true + sources = [ + "crashpad_info_size_test_module.cc", + ] + defines = [ "CRASHPAD_INFO_SIZE_TEST_MODULE_LARGE" ] + deps = [ + "//base", + ] +} + +loadable_module("crashpad_snapshot_test_module_small") { + testonly = true + sources = [ + "crashpad_info_size_test_module.cc", + ] + defines = [ "CRASHPAD_INFO_SIZE_TEST_MODULE_SMALL" ] + deps = [ + "//base", + ] +} + +if (is_mac) { + loadable_module("crashpad_snapshot_test_module_crashy_initializer") { + testonly = true + sources = [ + "mac/mach_o_image_annotations_reader_test_module_crashy_initializer.cc", + ] + } + + executable("crashpad_snapshot_test_no_op") { + testonly = true + sources = [ + "mac/mach_o_image_annotations_reader_test_no_op.cc", + ] + } +} + +if (is_win) { + executable("crashpad_snapshot_test_annotations") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_annotations.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + ] + } + + executable("crashpad_snapshot_test_crashing_child") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_crashing_child.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } + + executable("crashpad_snapshot_test_dump_without_crashing") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_dump_without_crashing.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } + + executable("crashpad_snapshot_test_extra_memory_ranges") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_extra_memory_ranges.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + ] + } + + executable("crashpad_snapshot_test_image_reader") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_image_reader.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + if (symbol_level == 0) { + # The tests that use this executable rely on at least minimal debug info. + configs -= [ "//build/config/compiler:default_symbols" ] + configs += [ "//build/config/compiler:minimal_symbols" ] + } + } + + loadable_module("crashpad_snapshot_test_image_reader_module") { + testonly = true + sources = [ + "win/crashpad_snapshot_test_image_reader_module.cc", + ] + deps = [ + "//base", + "//third_party/crashpad/crashpad/client", + ] + if (symbol_level == 0) { + # The tests that use this module rely on at least minimal debug info. + configs -= [ "//build/config/compiler:default_symbols" ] + configs += [ "//build/config/compiler:minimal_symbols" ] + } + } +} diff --git a/snapshot/test/BUILD.gn b/snapshot/test/BUILD.gn new file mode 100644 index 00000000..5b9b745f --- /dev/null +++ b/snapshot/test/BUILD.gn @@ -0,0 +1,155 @@ +# Copyright 2017 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +static_library("test") { + testonly = true + + sources = [ + "errors.cc", + "errors.h", + "file.cc", + "file.h", + "filesystem.cc", + "filesystem.h", + "gtest_death_check.h", + "gtest_disabled.cc", + "gtest_disabled.h", + "hex_string.cc", + "hex_string.h", + "mac/dyld.cc", + "mac/dyld.h", + "mac/mach_errors.cc", + "mac/mach_errors.h", + "mac/mach_multiprocess.cc", + "mac/mach_multiprocess.h", + "main_arguments.cc", + "main_arguments.h", + "multiprocess.h", + "multiprocess_exec.h", + "multiprocess_exec_posix.cc", + "multiprocess_exec_win.cc", + "multiprocess_posix.cc", + "scoped_module_handle.cc", + "scoped_module_handle.h", + "scoped_temp_dir.cc", + "scoped_temp_dir.h", + "scoped_temp_dir_posix.cc", + "scoped_temp_dir_win.cc", + "test_paths.cc", + "test_paths.h", + "win/child_launcher.cc", + "win/child_launcher.h", + "win/win_child_process.cc", + "win/win_child_process.h", + "win/win_multiprocess.cc", + "win/win_multiprocess.h", + "win/win_multiprocess_with_temp_dir.cc", + "win/win_multiprocess_with_temp_dir.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + defines = [ "CRASHPAD_IN_CHROMIUM" ] + + data = [ + "test_paths_test_data_root.txt", + ] + + deps = [ + "//base", + "//testing/gtest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/util", + ] + + if (is_mac) { + libs = [ "bsm" ] + } +} + +source_set("test_test") { + testonly = true + + sources = [ + "hex_string_test.cc", + "mac/mach_multiprocess_test.cc", + "main_arguments_test.cc", + "multiprocess_exec_test.cc", + "scoped_temp_dir_test.cc", + "test_paths_test.cc", + "win/win_child_process_test.cc", + "win/win_multiprocess_test.cc", + ] + + if (!is_win) { + sources += [ "multiprocess_posix_test.cc" ] + } + + deps = [ + ":test", + "//base", + "//testing/gmock", + "//testing/gtest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + + data_deps = [ + ":crashpad_test_test_multiprocess_exec_test_child", + ] +} + +executable("crashpad_test_test_multiprocess_exec_test_child") { + sources = [ + "multiprocess_exec_test_child.cc", + ] +} + +static_library("gmock_main") { + testonly = true + sources = [ + "gtest_main.cc", + ] + defines = [ + "CRASHPAD_IN_CHROMIUM", + "CRASHPAD_TEST_LAUNCHER_GMOCK", + ] + deps = [ + ":test", + "//base", + "//base/test:test_support", + "//testing/gmock", + "//testing/gtest", + ] +} + +static_library("gtest_main") { + testonly = true + sources = [ + "gtest_main.cc", + ] + defines = [ + "CRASHPAD_IN_CHROMIUM", + "CRASHPAD_TEST_LAUNCHER_GTEST", + ] + deps = [ + ":test", + "//base", + "//base/test:test_support", + "//testing/gtest", + ] +} diff --git a/test/BUILD.gn b/test/BUILD.gn new file mode 100644 index 00000000..5b9b745f --- /dev/null +++ b/test/BUILD.gn @@ -0,0 +1,155 @@ +# Copyright 2017 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//testing/test.gni") + +static_library("test") { + testonly = true + + sources = [ + "errors.cc", + "errors.h", + "file.cc", + "file.h", + "filesystem.cc", + "filesystem.h", + "gtest_death_check.h", + "gtest_disabled.cc", + "gtest_disabled.h", + "hex_string.cc", + "hex_string.h", + "mac/dyld.cc", + "mac/dyld.h", + "mac/mach_errors.cc", + "mac/mach_errors.h", + "mac/mach_multiprocess.cc", + "mac/mach_multiprocess.h", + "main_arguments.cc", + "main_arguments.h", + "multiprocess.h", + "multiprocess_exec.h", + "multiprocess_exec_posix.cc", + "multiprocess_exec_win.cc", + "multiprocess_posix.cc", + "scoped_module_handle.cc", + "scoped_module_handle.h", + "scoped_temp_dir.cc", + "scoped_temp_dir.h", + "scoped_temp_dir_posix.cc", + "scoped_temp_dir_win.cc", + "test_paths.cc", + "test_paths.h", + "win/child_launcher.cc", + "win/child_launcher.h", + "win/win_child_process.cc", + "win/win_child_process.h", + "win/win_multiprocess.cc", + "win/win_multiprocess.h", + "win/win_multiprocess_with_temp_dir.cc", + "win/win_multiprocess_with_temp_dir.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + defines = [ "CRASHPAD_IN_CHROMIUM" ] + + data = [ + "test_paths_test_data_root.txt", + ] + + deps = [ + "//base", + "//testing/gtest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/util", + ] + + if (is_mac) { + libs = [ "bsm" ] + } +} + +source_set("test_test") { + testonly = true + + sources = [ + "hex_string_test.cc", + "mac/mach_multiprocess_test.cc", + "main_arguments_test.cc", + "multiprocess_exec_test.cc", + "scoped_temp_dir_test.cc", + "test_paths_test.cc", + "win/win_child_process_test.cc", + "win/win_multiprocess_test.cc", + ] + + if (!is_win) { + sources += [ "multiprocess_posix_test.cc" ] + } + + deps = [ + ":test", + "//base", + "//testing/gmock", + "//testing/gtest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + + data_deps = [ + ":crashpad_test_test_multiprocess_exec_test_child", + ] +} + +executable("crashpad_test_test_multiprocess_exec_test_child") { + sources = [ + "multiprocess_exec_test_child.cc", + ] +} + +static_library("gmock_main") { + testonly = true + sources = [ + "gtest_main.cc", + ] + defines = [ + "CRASHPAD_IN_CHROMIUM", + "CRASHPAD_TEST_LAUNCHER_GMOCK", + ] + deps = [ + ":test", + "//base", + "//base/test:test_support", + "//testing/gmock", + "//testing/gtest", + ] +} + +static_library("gtest_main") { + testonly = true + sources = [ + "gtest_main.cc", + ] + defines = [ + "CRASHPAD_IN_CHROMIUM", + "CRASHPAD_TEST_LAUNCHER_GTEST", + ] + deps = [ + ":test", + "//base", + "//base/test:test_support", + "//testing/gtest", + ] +} diff --git a/third_party/apple_cctools/BUILD.gn b/third_party/apple_cctools/BUILD.gn new file mode 100644 index 00000000..c6277281 --- /dev/null +++ b/third_party/apple_cctools/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("apple_cctools_config") { + include_dirs = [ "../.." ] +} + +source_set("apple_cctools") { + sources = [ + "cctools/include/mach-o/getsect.h", + "cctools/libmacho/getsecbyname.c", + ] + public_configs = [ ":apple_cctools_config" ] +} diff --git a/third_party/getopt/BUILD.gn b/third_party/getopt/BUILD.gn new file mode 100644 index 00000000..573d844b --- /dev/null +++ b/third_party/getopt/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright 2014 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("getopt") { + sources = [ + "getopt.cc", + "getopt.h", + ] +} diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn new file mode 100644 index 00000000..db158c7d --- /dev/null +++ b/third_party/zlib/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright 2017 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("zlib_config") { + defines = [ "CRASHPAD_ZLIB_SOURCE_CHROMIUM" ] +} + +group("zlib") { + public_configs = [ ":zlib_config" ] + public_deps = [ + "//third_party/zlib:zlib", + ] +} diff --git a/tools/BUILD.gn b/tools/BUILD.gn new file mode 100644 index 00000000..e2a82d39 --- /dev/null +++ b/tools/BUILD.gn @@ -0,0 +1,161 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("tool_support") { + sources = [ + "tool_support.cc", + "tool_support.h", + ] + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + deps = [ + "//base", + ] +} + +executable("crashpad_database_util") { + sources = [ + "crashpad_database_util.cc", + ] + + deps = [ + ":tool_support", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] +} + +executable("crashpad_http_upload") { + sources = [ + "crashpad_http_upload.cc", + ] + + deps = [ + ":tool_support", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] +} + +executable("generate_dump") { + sources = [ + "generate_dump.cc", + ] + + deps = [ + ":tool_support", + "//base", + "//build/win:default_exe_manifest", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/minidump", + "//third_party/crashpad/crashpad/snapshot", + "//third_party/crashpad/crashpad/util", + ] + + if (is_mac) { + # This would be better as a config so that it could be shared with + # exception_port_tool, but configs can’t alter “inputs”. + inputs = [ + rebase_path("mac/sectaskaccess_info.plist"), + ] + ldflags = [ + "-sectcreate", + "__TEXT", + "__info_plist", + inputs[0], + ] + } + + if (is_win) { + cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union + } +} + +if (is_mac) { + executable("catch_exception_tool") { + sources = [ + "mac/catch_exception_tool.cc", + ] + + deps = [ + ":tool_support", + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } + + executable("exception_port_tool") { + sources = [ + "mac/exception_port_tool.cc", + ] + + # This would be better as a config so that it could be shared with + # generate_dump, but configs can’t alter “inputs”. + inputs = [ + rebase_path("mac/sectaskaccess_info.plist"), + ] + ldflags = [ + "-sectcreate", + "__TEXT", + "__info_plist", + inputs[0], + ] + + deps = [ + ":tool_support", + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } + + executable("on_demand_service_tool") { + sources = [ + "mac/on_demand_service_tool.mm", + ] + + libs = [ + "CoreFoundation.framework", + "Foundation.framework", + ] + + deps = [ + ":tool_support", + "//base", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } + + executable("run_with_crashpad") { + sources = [ + "mac/run_with_crashpad.cc", + ] + + deps = [ + ":tool_support", + "//base", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/util", + ] + } +} diff --git a/util/BUILD.gn b/util/BUILD.gn new file mode 100644 index 00000000..b61a76e3 --- /dev/null +++ b/util/BUILD.gn @@ -0,0 +1,470 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/sanitizers/sanitizers.gni") +import("//build/toolchain/toolchain.gni") +import("//testing/test.gni") + +if (is_mac) { + import("//build/config/sysroot.gni") +} + +if (is_mac) { + action_foreach("mig") { + script = "mach/mig.py" + + sources = [ + "$sysroot/usr/include/mach/exc.defs", + "$sysroot/usr/include/mach/mach_exc.defs", + "$sysroot/usr/include/mach/notify.defs", + "mach/child_port.defs", + ] + + outputs = [ + "$target_gen_dir/mach/{{source_name_part}}User.c", + "$target_gen_dir/mach/{{source_name_part}}Server.c", + "$target_gen_dir/mach/{{source_name_part}}.h", + "$target_gen_dir/mach/{{source_name_part}}Server.h", + ] + + args = [ "{{source}}" ] + args += rebase_path(outputs, root_build_dir) + if (!use_system_xcode) { + args += [ + "--developer-dir", + hermetic_xcode_path, + ] + } + args += [ + "--sdk", + mac_sdk_path, + "--include", + rebase_path("../compat/mac", root_build_dir), + ] + } +} + +static_library("util") { + sources = [ + "file/delimited_file_reader.cc", + "file/delimited_file_reader.h", + "file/directory_reader.h", + "file/directory_reader_posix.cc", + "file/directory_reader_win.cc", + "file/file_io.cc", + "file/file_io.h", + "file/file_io_posix.cc", + "file/file_io_win.cc", + "file/file_reader.cc", + "file/file_reader.h", + "file/file_seeker.cc", + "file/file_seeker.h", + "file/file_writer.cc", + "file/file_writer.h", + "file/filesystem.h", + "file/filesystem_posix.cc", + "file/filesystem_win.cc", + "file/scoped_remove_file.cc", + "file/scoped_remove_file.h", + "file/string_file.cc", + "file/string_file.h", + "mac/checked_mach_address_range.h", + "mac/launchd.h", + "mac/launchd.mm", + "mac/mac_util.cc", + "mac/mac_util.h", + "mac/service_management.cc", + "mac/service_management.h", + "mac/xattr.cc", + "mac/xattr.h", + "misc/address_sanitizer.h", + "misc/address_types.h", + "misc/arraysize_unsafe.h", + "misc/as_underlying_type.h", + "misc/clock.h", + "misc/clock_mac.cc", + "misc/clock_posix.cc", + "misc/clock_win.cc", + "misc/from_pointer_cast.h", + "misc/implicit_cast.h", + "misc/initialization_state.h", + "misc/initialization_state_dcheck.cc", + "misc/initialization_state_dcheck.h", + "misc/lexing.cc", + "misc/lexing.h", + "misc/metrics.cc", + "misc/metrics.h", + "misc/paths.h", + "misc/paths_mac.cc", + "misc/paths_win.cc", + "misc/pdb_structures.cc", + "misc/pdb_structures.h", + "misc/random_string.cc", + "misc/random_string.h", + "misc/reinterpret_bytes.cc", + "misc/reinterpret_bytes.h", + "misc/scoped_forbid_return.cc", + "misc/scoped_forbid_return.h", + "misc/symbolic_constants_common.h", + "misc/time.cc", + "misc/time.h", + "misc/time_win.cc", + "misc/tri_state.h", + "misc/uuid.cc", + "misc/uuid.h", + "misc/zlib.cc", + "misc/zlib.h", + "net/http_body.cc", + "net/http_body.h", + "net/http_body_gzip.cc", + "net/http_body_gzip.h", + "net/http_headers.h", + "net/http_multipart_builder.cc", + "net/http_multipart_builder.h", + "net/http_transport.cc", + "net/http_transport.h", + "net/http_transport_mac.mm", + "net/http_transport_win.cc", + "net/url.cc", + "net/url.h", + "numeric/checked_address_range.cc", + "numeric/checked_address_range.h", + "numeric/checked_range.h", + "numeric/checked_vm_address_range.h", + "numeric/in_range_cast.h", + "numeric/int128.h", + "numeric/safe_assignment.h", + "posix/close_multiple.cc", + "posix/close_multiple.h", + "posix/close_stdio.cc", + "posix/close_stdio.h", + "posix/drop_privileges.cc", + "posix/drop_privileges.h", + "posix/process_info.h", + "posix/process_info_mac.cc", + "posix/scoped_dir.cc", + "posix/scoped_dir.h", + "posix/scoped_mmap.cc", + "posix/scoped_mmap.h", + "posix/signals.cc", + "posix/signals.h", + "posix/symbolic_constants_posix.cc", + "posix/symbolic_constants_posix.h", + "stdlib/aligned_allocator.cc", + "stdlib/aligned_allocator.h", + "stdlib/map_insert.h", + "stdlib/objc.h", + "stdlib/string_number_conversion.cc", + "stdlib/string_number_conversion.h", + "stdlib/strlcpy.cc", + "stdlib/strlcpy.h", + "stdlib/strnlen.cc", + "stdlib/strnlen.h", + "stdlib/thread_safe_vector.h", + "string/split_string.cc", + "string/split_string.h", + "synchronization/semaphore.h", + "synchronization/semaphore_mac.cc", + "synchronization/semaphore_posix.cc", + "synchronization/semaphore_win.cc", + "thread/thread.cc", + "thread/thread.h", + "thread/thread_log_messages.cc", + "thread/thread_log_messages.h", + "thread/thread_posix.cc", + "thread/thread_win.cc", + "thread/worker_thread.cc", + "thread/worker_thread.h", + "win/address_types.h", + "win/capture_context.h", + "win/checked_win_address_range.h", + "win/command_line.cc", + "win/command_line.h", + "win/critical_section_with_debug_info.cc", + "win/critical_section_with_debug_info.h", + "win/exception_handler_server.cc", + "win/exception_handler_server.h", + "win/get_function.cc", + "win/get_function.h", + "win/get_module_information.cc", + "win/get_module_information.h", + "win/handle.cc", + "win/handle.h", + "win/initial_client_data.cc", + "win/initial_client_data.h", + "win/module_version.cc", + "win/module_version.h", + "win/nt_internals.cc", + "win/nt_internals.h", + "win/ntstatus_logging.cc", + "win/ntstatus_logging.h", + "win/process_info.cc", + "win/process_info.h", + "win/process_structs.h", + "win/registration_protocol_win.cc", + "win/registration_protocol_win.h", + "win/safe_terminate_process.h", + "win/scoped_handle.cc", + "win/scoped_handle.h", + "win/scoped_local_alloc.cc", + "win/scoped_local_alloc.h", + "win/scoped_process_suspend.cc", + "win/scoped_process_suspend.h", + "win/scoped_set_event.cc", + "win/scoped_set_event.h", + "win/session_end_watcher.cc", + "win/session_end_watcher.h", + "win/termination_codes.h", + "win/xp_compat.h", + ] + + if (is_mac) { + # mach/ are not globally filtered. + sources += [ + "mach/child_port_handshake.cc", + "mach/child_port_handshake.h", + "mach/child_port_server.cc", + "mach/child_port_server.h", + "mach/child_port_types.h", + "mach/composite_mach_message_server.cc", + "mach/composite_mach_message_server.h", + "mach/exc_client_variants.cc", + "mach/exc_client_variants.h", + "mach/exc_server_variants.cc", + "mach/exc_server_variants.h", + "mach/exception_behaviors.cc", + "mach/exception_behaviors.h", + "mach/exception_ports.cc", + "mach/exception_ports.h", + "mach/exception_types.cc", + "mach/exception_types.h", + "mach/mach_extensions.cc", + "mach/mach_extensions.h", + "mach/mach_message.cc", + "mach/mach_message.h", + "mach/mach_message_server.cc", + "mach/mach_message_server.h", + "mach/notify_server.cc", + "mach/notify_server.h", + "mach/scoped_task_suspend.cc", + "mach/scoped_task_suspend.h", + "mach/symbolic_constants_mach.cc", + "mach/symbolic_constants_mach.h", + "mach/task_for_pid.cc", + "mach/task_for_pid.h", + "mach/task_memory.cc", + "mach/task_memory.h", + ] + } + + if (is_mac) { + sources += get_target_outputs(":mig") + } + + if (is_win) { + # There's no ml.exe yet in cross builds, so provide broken-but-not-asm + # versions of the functions defined in .asm files. + # CaptureContext() in capture_context_broken.cc just calls CHECK(false). + # SafeTerminateProcess() in safe_terminate_process.cc just calls regular + # TerminateProcess() without the protection against broken third-party + # patching of TerminateProcess(). + # TODO(thakis): Use the .asm file in cross builds somehow, crbug.com/762167 + if (host_os == "win") { + sources += [ + "win/capture_context.asm", + "win/safe_terminate_process.asm", + ] + } else { + sources += [ + "win/capture_context_broken.cc", + "win/safe_terminate_process_broken.cc", + ] + } + } + + public_configs = [ "//third_party/crashpad/crashpad:crashpad_config" ] + + # Include files from here and generated files starting with "util". + include_dirs = [ "$root_gen_dir/third_party/crashpad/crashpad" ] + + public_deps = [ + "//third_party/crashpad/crashpad/compat", + ] + + deps = [ + "//base", + "//third_party/crashpad/crashpad/third_party/zlib", + ] + + if (is_mac) { + libs = [ + "bsm", + "CoreFoundation.framework", + "Foundation.framework", + "IOKit.framework", + ] + deps += [ ":mig" ] + } + + if (is_win) { + cflags = [ + "/wd4201", # nonstandard extension used : nameless struct/union. + "/wd4577", # 'noexcept' used with no exception handling mode specified. + ] + libs = [ "winhttp.lib" ] + + if (current_cpu == "x86") { + asmflags = [ "/safeseh" ] + } + } +} + +source_set("util_test") { + testonly = true + + sources = [ + "file/delimited_file_reader_test.cc", + "file/directory_reader_test.cc", + "file/file_io_test.cc", + "file/file_reader_test.cc", + "file/filesystem_test.cc", + "file/string_file_test.cc", + "mac/launchd_test.mm", + "mac/mac_util_test.mm", + "mac/service_management_test.mm", + "mac/xattr_test.cc", + "misc/arraysize_unsafe_test.cc", + "misc/clock_test.cc", + "misc/from_pointer_cast_test.cc", + "misc/initialization_state_dcheck_test.cc", + "misc/initialization_state_test.cc", + "misc/paths_test.cc", + "misc/random_string_test.cc", + "misc/reinterpret_bytes_test.cc", + "misc/scoped_forbid_return_test.cc", + "misc/time_test.cc", + "misc/uuid_test.cc", + "net/http_body_gzip_test.cc", + "net/http_body_test.cc", + "net/http_body_test_util.cc", + "net/http_body_test_util.h", + "net/http_multipart_builder_test.cc", + "net/http_transport_test.cc", + "net/url_test.cc", + "numeric/checked_address_range_test.cc", + "numeric/checked_range_test.cc", + "numeric/in_range_cast_test.cc", + "numeric/int128_test.cc", + "posix/process_info_test.cc", + "posix/scoped_mmap_test.cc", + "posix/signals_test.cc", + "posix/symbolic_constants_posix_test.cc", + "stdlib/aligned_allocator_test.cc", + "stdlib/map_insert_test.cc", + "stdlib/string_number_conversion_test.cc", + "stdlib/strlcpy_test.cc", + "stdlib/strnlen_test.cc", + "stdlib/thread_safe_vector_test.cc", + "string/split_string_test.cc", + "synchronization/semaphore_test.cc", + "thread/thread_log_messages_test.cc", + "thread/thread_test.cc", + "thread/worker_thread_test.cc", + "win/capture_context_test.cc", + "win/command_line_test.cc", + "win/critical_section_with_debug_info_test.cc", + "win/exception_handler_server_test.cc", + "win/get_function_test.cc", + "win/handle_test.cc", + "win/initial_client_data_test.cc", + "win/process_info_test.cc", + "win/registration_protocol_win_test.cc", + "win/safe_terminate_process_test.cc", + "win/scoped_process_suspend_test.cc", + "win/session_end_watcher_test.cc", + ] + + if (is_mac) { + # mach/ are not globally filtered. + sources += [ + "mach/child_port_handshake_test.cc", + "mach/child_port_server_test.cc", + "mach/composite_mach_message_server_test.cc", + "mach/exc_client_variants_test.cc", + "mach/exc_server_variants_test.cc", + "mach/exception_behaviors_test.cc", + "mach/exception_ports_test.cc", + "mach/exception_types_test.cc", + "mach/mach_extensions_test.cc", + "mach/mach_message_server_test.cc", + "mach/mach_message_test.cc", + "mach/notify_server_test.cc", + "mach/scoped_task_suspend_test.cc", + "mach/symbolic_constants_mach_test.cc", + "mach/task_memory_test.cc", + ] + } + + data = [ + "net/http_transport_test_server.py", + "net/testdata/", + ] + + deps = [ + ":util", + "//base", + "//testing/gmock", + "//testing/gtest", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/compat", + "//third_party/crashpad/crashpad/test", + "//third_party/crashpad/crashpad/third_party/zlib", + ] + + if (is_mac) { + libs = [ "Foundation.framework" ] + } + + if (is_win) { + libs = [ "rpcrt4.lib" ] + data_deps = [ + ":crashpad_util_test_process_info_test_child", + ":crashpad_util_test_safe_terminate_process_test_child", + ] + } +} + +if (is_win) { + executable("crashpad_util_test_process_info_test_child") { + testonly = true + sources = [ + "win/process_info_test_child.cc", + ] + + # Set an unusually high load address to make sure that the main executable + # still appears as the first element in ProcessInfo::Modules(). + ldflags = [ + "/BASE:0x78000000", + "/DYNAMICBASE:NO", + "/FIXED", + ] + } + + executable("crashpad_util_test_safe_terminate_process_test_child") { + testonly = true + sources = [ + "win/safe_terminate_process_test_child.cc", + ] + } +}