crashpad/util/util.gyp

394 lines
13 KiB
Plaintext
Raw Normal View History

# 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.
{
'includes': [
'../build/crashpad.gypi',
],
'targets': [
{
'target_name': 'crashpad_util',
'type': 'static_library',
'dependencies': [
'../compat/compat.gyp:crashpad_compat',
'../third_party/mini_chromium/mini_chromium.gyp:base',
'../third_party/zlib/zlib.gyp:zlib',
],
'include_dirs': [
'..',
'<(INTERMEDIATE_DIR)',
],
'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/filesystem.h',
'file/filesystem_posix.cc',
'file/filesystem_win.cc',
'file/file_writer.cc',
'file/file_writer.h',
'file/scoped_remove_file.cc',
'file/scoped_remove_file.h',
'file/string_file.cc',
'file/string_file.h',
'linux/address_types.h',
'linux/auxiliary_vector.cc',
'linux/auxiliary_vector.h',
'linux/checked_address_range.h',
'linux/direct_ptrace_connection.cc',
'linux/direct_ptrace_connection.h',
'linux/memory_map.cc',
'linux/memory_map.h',
'linux/proc_stat_reader.cc',
'linux/proc_stat_reader.h',
'linux/ptrace_connection.h',
'linux/ptracer.cc',
'linux/ptracer.h',
'linux/exception_information.h',
'linux/scoped_ptrace_attach.cc',
'linux/scoped_ptrace_attach.h',
'linux/thread_info.cc',
'linux/thread_info.h',
'linux/traits.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',
'mach/child_port.defs',
'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',
'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_linux.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_libcurl.cc',
'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_linux.cc',
'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',
'process/process_memory.h',
'process/process_memory_linux.cc',
'process/process_memory_linux.h',
'process/process_memory_range.cc',
'process/process_memory_range.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_mac.cc',
'synchronization/semaphore_posix.cc',
'synchronization/semaphore_win.cc',
'synchronization/semaphore.h',
'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.asm',
'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: Crash handler server This replaces the registration server, and adds dispatch to a delegate on crash requests. (As you are already aware) we went around in circles on trying to come up with a slightly-too-fancy threading design. All of them seemed to have problems when it comes to out of order events, and orderly shutdown, so I've gone back to something not-too-fancy. Two named pipe instances (that clients connect to) are created. These are used only for registration (which should take <1ms), so 2 should be sufficient to avoid any waits. When a client registers, we duplicate an event to it, which is used to signal when it wants a dump taken. The server registers threadpool waits on that event, and also on the process handle (which will be signalled when the client process exits). These requests (in particular the taking of the dump) are serviced on the threadpool, which avoids us needing to manage those threads, but still allows parallelism in taking dumps. On process termination, we use an IO Completion Port to post a message back to the main thread to request cleanup. This complexity is necessary so that we can unregister the threadpool waits without being on the threadpool, which we need to do synchronously so that we can be sure that no further callbacks will execute (and expect to have the client data around still). In a followup, I will readd support for DumpWithoutCrashing -- I don't think it will be too difficult now that we have an orderly way to clean up client records in the server. R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org BUG=crashpad:1,crashpad:45 Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
'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: Crash handler server This replaces the registration server, and adds dispatch to a delegate on crash requests. (As you are already aware) we went around in circles on trying to come up with a slightly-too-fancy threading design. All of them seemed to have problems when it comes to out of order events, and orderly shutdown, so I've gone back to something not-too-fancy. Two named pipe instances (that clients connect to) are created. These are used only for registration (which should take <1ms), so 2 should be sufficient to avoid any waits. When a client registers, we duplicate an event to it, which is used to signal when it wants a dump taken. The server registers threadpool waits on that event, and also on the process handle (which will be signalled when the client process exits). These requests (in particular the taking of the dump) are serviced on the threadpool, which avoids us needing to manage those threads, but still allows parallelism in taking dumps. On process termination, we use an IO Completion Port to post a message back to the main thread to request cleanup. This complexity is necessary so that we can unregister the threadpool waits without being on the threadpool, which we need to do synchronously so that we can be sure that no further callbacks will execute (and expect to have the client data around still). In a followup, I will readd support for DumpWithoutCrashing -- I don't think it will be too difficult now that we have an orderly way to clean up client records in the server. R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org BUG=crashpad:1,crashpad:45 Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
'win/registration_protocol_win.cc',
'win/registration_protocol_win.h',
'win/safe_terminate_process.asm',
win: Wrap TerminateProcess() to accept cdecl patches on x86 TerminateProcess(), like most of the Windows API, is declared WINAPI, which is __stdcall on 32-bit x86. That means that the callee, TerminateProcess() itself, is responsible for cleaning up parameters on the stack on return. In https://crashpad.chromium.org/bug/179, crashes in ExceptionHandlerServer::OnNonCrashDumpEvent() were observed in ways that make it evident that TerminateProcess() has been patched with a __cdecl routine. The crucial difference between __stdcall and __cdecl is that the caller is responsible for stack parameter cleanup in __cdecl. The mismatch means that nobody cleans parameters from the stack, and the stack pointer has an unexpected value, which in the case of the Crashpad handler crash, results in TerminateProcess()’s second argument erroneously being used as the lock address in the call to ReleaseSRWLockExclusive() or LeaveCriticalSection(). As a workaround, on 32-bit x86, call through SafeTerminateProcess(), a custom assembly routine that’s compatible with either __stdcall or __cdecl implementations of TerminateProcess() by not trusting the value of the stack pointer on return from that function. Instead, the stack pointer is restored directly from the frame pointer. Bug: crashpad:179 Test: crashpad_util_test SafeTerminateProcess.*, others Change-Id: If9508f4eb7631020ea69ddbbe4a22eb335cdb325 Reviewed-on: https://chromium-review.googlesource.com/481180 Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-19 13:22:08 -04:00
'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/session_end_watcher.cc',
'win/session_end_watcher.h',
'win/termination_codes.h',
'win/xp_compat.h',
],
'conditions': [
['OS=="mac"', {
'conditions': [
['GENERATOR=="ninja"', {
# ninjas rules cant deal with sources that have paths relative
# to environment variables like SDKROOT. Copy the .defs files out
# of SDKROOT and into a place they can be referenced without any
# environment variables.
'copies': [
{
'destination': '<(INTERMEDIATE_DIR)/util/mach',
'files': [
'$(SDKROOT)/usr/include/mach/exc.defs',
'$(SDKROOT)/usr/include/mach/mach_exc.defs',
'$(SDKROOT)/usr/include/mach/notify.defs',
],
},
],
'sources': [
'<(INTERMEDIATE_DIR)/util/mach/exc.defs',
'<(INTERMEDIATE_DIR)/util/mach/mach_exc.defs',
'<(INTERMEDIATE_DIR)/util/mach/notify.defs',
],
}, { # else: GENERATOR!="ninja"
# The Xcode generator does copies after rules, so the above trick
# wont work, but its rules tolerate sources with SDKROOT-relative
# paths.
'sources': [
'$(SDKROOT)/usr/include/mach/exc.defs',
'$(SDKROOT)/usr/include/mach/mach_exc.defs',
'$(SDKROOT)/usr/include/mach/notify.defs',
],
}],
],
'rules': [
{
'rule_name': 'mig',
'extension': 'defs',
'inputs': [
'mach/mig.py',
],
'outputs': [
'<(INTERMEDIATE_DIR)/util/mach/<(RULE_INPUT_ROOT)User.c',
'<(INTERMEDIATE_DIR)/util/mach/<(RULE_INPUT_ROOT)Server.c',
'<(INTERMEDIATE_DIR)/util/mach/<(RULE_INPUT_ROOT).h',
'<(INTERMEDIATE_DIR)/util/mach/<(RULE_INPUT_ROOT)Server.h',
],
'action': [
'python',
'<@(_inputs)',
'<(RULE_INPUT_PATH)',
'<@(_outputs)',
'--include=../compat/mac'
],
'process_outputs_as_sources': 1,
},
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
'$(SDKROOT)/System/Library/Frameworks/IOKit.framework',
'$(SDKROOT)/usr/lib/libbsm.dylib',
],
},
}],
['OS=="win"', {
'link_settings': {
'libraries': [
'-luser32.lib',
'-lversion.lib',
'-lwinhttp.lib',
],
},
'msvs_disabled_warnings': [
4201, # nonstandard extension used : nameless struct/union.
4577, # 'noexcept' used with no exception handling mode specified
],
'direct_dependent_settings': {
'msvs_disabled_warnings': [
4577, # 'noexcept' used with no exception handling mode specified
],
},
'conditions': [
['target_arch=="ia32"', {
'msvs_settings': {
'MASM': {
'UseSafeExceptionHandlers': 'true',
},
},
}],
],
}, { # else: OS!="win"
'sources!': [
'win/capture_context.asm',
'win/safe_terminate_process.asm',
],
}],
['OS=="linux"', {
'link_settings': {
'libraries': [
'-lcurl',
],
},
}, { # else: OS!="linux"
'sources!': [
'net/http_transport_libcurl.cc',
],
}],
['OS!="linux" and OS!="android"', {
'sources/': [
['exclude', '^process/'],
],
}],
],
'target_conditions': [
['OS=="android"', {
'sources/': [
['include', '^linux/'],
['include', '^misc/paths_linux\\.cc$'],
['include', '^posix/process_info_linux\\.cc$'],
['include', '^process/process_memory_linux\\.cc$'],
['include', '^process/process_memory_linux\\.h$'],
],
}],
],
},
],
}