From 1aa478d161fd0d99bee03cc26e03222f86428d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Mon, 20 Sep 2021 12:55:12 -0700 Subject: [PATCH 01/69] Remove DISALLOW_* macros in crashpad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change was partially scripted and partially done manually with vim regex + manually placing the deleted constructors. The script change looked for destructors in the public: section of a class, if that existed the deleted constructors would go before the destructor. For manual placement I looked for any constructor in the public: section of the corresponding class. If there wasn't one, then it would ideally have gone as the first entry except below enums, classes and typedefs. This may not have been perfect, but is hopefully good enough. Fingers crossed. #include "base/macros.h" is removed from files that don't use ignore_result, which is the only other thing defined in base/macros.h. Bug: chromium:1010217 Change-Id: I099526255a40b1ac1264904b4ece2f3f503c9418 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3171034 Reviewed-by: Mark Mentovai Commit-Queue: Peter Boström --- client/annotation.h | 11 ++-- client/annotation_list.h | 7 ++- client/crash_report_database.h | 18 +++--- client/crash_report_database_generic.cc | 14 +++-- client/crash_report_database_mac.mm | 7 ++- client/crash_report_database_test.cc | 5 +- client/crash_report_database_win.cc | 12 ++-- client/crashpad_client.h | 7 ++- client/crashpad_client_ios.cc | 5 +- client/crashpad_client_linux.cc | 15 +++-- client/crashpad_client_linux_test.cc | 41 ++++++++----- client/crashpad_client_mac.cc | 11 ++-- client/crashpad_client_win.cc | 8 ++- client/crashpad_info.h | 6 +- .../in_process_intermediate_dump_handler.cc | 5 +- .../in_process_intermediate_dump_handler.h | 8 ++- client/prune_crash_reports.h | 20 ++++--- client/prune_crash_reports_test.cc | 6 +- client/settings.h | 13 ++-- client/settings_test.cc | 5 +- client/simple_address_range_bag.h | 6 +- client/simple_string_dictionary.h | 6 +- client/simulate_crash_mac_test.cc | 6 +- handler/crash_report_upload_thread.h | 7 ++- .../crashpad_handler_test_extended_handler.cc | 7 +-- handler/handler_main.cc | 19 +++--- .../linux/crash_report_exception_handler.cc | 7 ++- .../linux/crash_report_exception_handler.h | 7 ++- .../cros_crash_report_exception_handler.h | 8 ++- handler/linux/exception_handler_server.h | 7 ++- .../linux/exception_handler_server_test.cc | 33 ++++++---- handler/mac/crash_report_exception_handler.h | 7 ++- handler/mac/exception_handler_server.cc | 6 +- handler/mac/exception_handler_server.h | 7 ++- handler/prune_crash_reports_thread.h | 7 ++- handler/win/crash_report_exception_handler.h | 7 ++- minidump/minidump_annotation_writer.h | 13 ++-- minidump/minidump_byte_array_writer.h | 7 ++- minidump/minidump_context_writer.h | 47 ++++++++++----- minidump/minidump_crashpad_info_writer.h | 8 ++- minidump/minidump_exception_writer.h | 7 ++- minidump/minidump_file_writer.h | 7 ++- minidump/minidump_file_writer_test.cc | 11 ++-- minidump/minidump_handle_writer.h | 6 +- minidump/minidump_memory_info_writer.h | 8 ++- minidump/minidump_memory_writer.h | 14 +++-- minidump/minidump_memory_writer_test.cc | 5 +- minidump/minidump_misc_info_writer.h | 7 ++- .../minidump_module_crashpad_info_writer.h | 17 ++++-- minidump/minidump_module_writer.h | 60 ++++++++++++------- minidump/minidump_rva_list_writer.h | 7 ++- minidump/minidump_rva_list_writer_test.cc | 8 ++- ...minidump_simple_string_dictionary_writer.h | 17 ++++-- minidump/minidump_stream_writer.h | 6 +- minidump/minidump_string_writer.h | 29 +++++---- minidump/minidump_system_info_writer.h | 7 ++- minidump/minidump_thread_id_map_test.cc | 6 +- minidump/minidump_thread_writer.h | 13 ++-- minidump/minidump_unloaded_module_writer.h | 16 +++-- ...nidump_user_extension_stream_data_source.h | 9 ++- minidump/minidump_user_stream_writer.cc | 11 ++-- minidump/minidump_user_stream_writer.h | 7 ++- minidump/minidump_writable.h | 6 +- minidump/minidump_writable_test.cc | 24 +++++--- minidump/minidump_writer_util.h | 8 +-- .../test/minidump_memory_writer_test_util.h | 7 ++- .../minidump_user_extension_stream_util.h | 7 ++- minidump/test/minidump_writable_test_util.h | 7 ++- snapshot/capture_memory.h | 8 +-- snapshot/crashpad_info_client_options_test.cc | 8 ++- .../crashpad_types/crashpad_info_reader.h | 7 ++- .../crashpad_info_reader_test.cc | 16 +++-- .../crashpad_types/image_annotation_reader.h | 6 +- .../image_annotation_reader_test.cc | 5 +- snapshot/elf/elf_dynamic_array_reader.h | 7 ++- snapshot/elf/elf_image_reader.cc | 8 ++- snapshot/elf/elf_image_reader.h | 12 ++-- snapshot/elf/elf_symbol_table_reader.h | 7 ++- snapshot/elf/module_snapshot_elf.h | 7 ++- snapshot/fuchsia/exception_snapshot_fuchsia.h | 6 +- snapshot/fuchsia/memory_map_fuchsia.h | 6 +- snapshot/fuchsia/process_reader_fuchsia.h | 7 ++- .../fuchsia/process_reader_fuchsia_test.cc | 12 ++-- snapshot/fuchsia/process_snapshot_fuchsia.h | 7 ++- .../fuchsia/process_snapshot_fuchsia_test.cc | 12 ++-- snapshot/fuchsia/system_snapshot_fuchsia.h | 7 ++- snapshot/fuchsia/thread_snapshot_fuchsia.h | 7 ++- ...exception_snapshot_ios_intermediate_dump.h | 9 ++- .../memory_snapshot_ios_intermediate_dump.h | 9 ++- .../module_snapshot_ios_intermediate_dump.h | 9 ++- .../process_snapshot_ios_intermediate_dump.h | 7 ++- .../system_snapshot_ios_intermediate_dump.h | 9 ++- .../thread_snapshot_ios_intermediate_dump.h | 9 ++- snapshot/linux/debug_rendezvous.h | 7 ++- snapshot/linux/debug_rendezvous_test.cc | 6 +- snapshot/linux/exception_snapshot_linux.h | 7 ++- .../linux/exception_snapshot_linux_test.cc | 18 +++--- snapshot/linux/process_reader_linux.h | 7 ++- snapshot/linux/process_reader_linux_test.cc | 29 +++++---- snapshot/linux/process_snapshot_linux.h | 7 ++- snapshot/linux/system_snapshot_linux.h | 7 ++- snapshot/linux/thread_snapshot_linux.h | 7 ++- snapshot/mac/exception_snapshot_mac.h | 7 ++- .../mac/mach_o_image_annotations_reader.h | 7 ++- .../mach_o_image_annotations_reader_test.cc | 8 ++- snapshot/mac/mach_o_image_reader.h | 7 ++- snapshot/mac/mach_o_image_segment_reader.h | 7 ++- .../mac/mach_o_image_symbol_table_reader.cc | 7 ++- .../mac/mach_o_image_symbol_table_reader.h | 8 ++- snapshot/mac/module_snapshot_mac.h | 7 ++- snapshot/mac/process_reader_mac.h | 7 ++- snapshot/mac/process_reader_mac_test.cc | 27 +++++---- snapshot/mac/process_snapshot_mac.h | 7 ++- snapshot/mac/system_snapshot_mac.h | 7 ++- snapshot/mac/system_snapshot_mac_test.cc | 5 +- snapshot/mac/thread_snapshot_mac.h | 7 ++- snapshot/memory_snapshot_generic.h | 7 ++- snapshot/memory_snapshot_test.cc | 1 - .../minidump/exception_snapshot_minidump.h | 7 ++- snapshot/minidump/memory_snapshot_minidump.h | 7 ++- snapshot/minidump/minidump_stream.h | 6 +- snapshot/minidump/module_snapshot_minidump.h | 7 ++- snapshot/minidump/process_snapshot_minidump.h | 7 ++- snapshot/minidump/system_snapshot_minidump.h | 7 ++- snapshot/minidump/thread_snapshot_minidump.h | 6 +- snapshot/module_snapshot.h | 5 +- snapshot/posix/timezone_test.cc | 6 +- .../sanitized/memory_snapshot_sanitized.cc | 5 +- .../sanitized/memory_snapshot_sanitized.h | 5 +- .../sanitized/module_snapshot_sanitized.h | 7 ++- .../sanitized/process_snapshot_sanitized.h | 7 ++- .../process_snapshot_sanitized_test.cc | 11 ++-- .../sanitized/thread_snapshot_sanitized.h | 5 +- snapshot/test/test_exception_snapshot.h | 7 ++- .../test/test_memory_map_region_snapshot.h | 8 ++- snapshot/test/test_memory_snapshot.h | 7 ++- snapshot/test/test_module_snapshot.h | 7 ++- snapshot/test/test_process_snapshot.h | 7 ++- snapshot/test/test_system_snapshot.h | 7 ++- snapshot/test/test_thread_snapshot.h | 7 ++- snapshot/win/exception_snapshot_win.h | 7 ++- snapshot/win/exception_snapshot_win_test.cc | 24 +++++--- snapshot/win/module_snapshot_win.h | 7 ++- snapshot/win/pe_image_annotations_reader.h | 7 ++- snapshot/win/pe_image_reader.h | 7 ++- snapshot/win/pe_image_resource_reader.h | 7 ++- snapshot/win/process_reader_win.h | 7 ++- snapshot/win/process_reader_win_test.cc | 14 +++-- snapshot/win/process_snapshot_win.h | 7 ++- snapshot/win/process_subrange_reader.h | 7 ++- snapshot/win/system_snapshot_win.h | 7 ++- snapshot/win/system_snapshot_win_test.cc | 5 +- snapshot/win/thread_snapshot_win.h | 7 ++- test/linux/fake_ptrace_connection.h | 7 ++- test/mac/exception_swallower.cc | 5 +- test/mac/exception_swallower.h | 7 ++- test/mac/mach_multiprocess.cc | 1 + test/mac/mach_multiprocess.h | 6 +- test/mac/mach_multiprocess_test.cc | 6 +- test/multiprocess.h | 6 +- test/multiprocess_exec.h | 6 +- test/multiprocess_exec_test.cc | 19 +++--- test/multiprocess_posix_test.cc | 17 +++--- test/scoped_guarded_page.h | 6 +- test/scoped_module_handle.h | 14 +++-- test/scoped_temp_dir.h | 7 ++- test/test_paths.h | 7 ++- test/win/win_child_process.h | 7 ++- test/win/win_child_process_test.cc | 6 +- test/win/win_multiprocess.h | 19 +++--- test/win/win_multiprocess_test.cc | 20 ++++--- test/win/win_multiprocess_with_temp_dir.h | 14 +++-- tools/mac/exception_port_tool.cc | 6 +- tools/tool_support.h | 8 +-- util/file/delimited_file_reader.h | 7 ++- util/file/directory_reader.h | 7 ++- util/file/file_io.cc | 13 ++-- util/file/file_io.h | 10 ++-- util/file/file_io_test.cc | 20 ++++--- util/file/file_reader.cc | 6 +- util/file/file_reader.h | 13 ++-- util/file/file_reader_test.cc | 7 ++- util/file/file_writer.h | 13 ++-- util/file/output_stream_file_writer.h | 7 ++- util/file/string_file.h | 7 ++- util/fuchsia/scoped_task_suspend.h | 7 ++- util/ios/ios_intermediate_dump_data.h | 7 ++- util/ios/ios_intermediate_dump_list.h | 7 ++- util/ios/ios_intermediate_dump_map.h | 7 ++- util/ios/ios_intermediate_dump_object.h | 8 ++- util/ios/ios_intermediate_dump_reader.h | 7 ++- util/ios/ios_intermediate_dump_writer.h | 27 ++++++--- util/ios/scoped_vm_read.h | 12 ++-- util/linux/auxiliary_vector.h | 7 ++- util/linux/auxiliary_vector_test.cc | 7 ++- util/linux/direct_ptrace_connection.h | 7 ++- util/linux/exception_handler_client.cc | 5 +- util/linux/exception_handler_client.h | 6 +- util/linux/exception_handler_protocol.h | 7 ++- util/linux/memory_map.cc | 10 ++-- util/linux/memory_map_test.cc | 12 ++-- util/linux/proc_stat_reader.h | 7 ++- util/linux/proc_task_reader_test.cc | 6 +- util/linux/ptrace_broker.cc | 5 +- util/linux/ptrace_broker.h | 6 +- util/linux/ptrace_broker_test.cc | 22 ++++--- util/linux/ptrace_client.h | 7 ++- util/linux/ptracer.h | 6 +- util/linux/ptracer_test.cc | 6 +- util/linux/scoped_pr_set_dumpable.h | 6 +- util/linux/scoped_pr_set_ptracer.h | 6 +- util/linux/scoped_ptrace_attach.h | 7 ++- util/linux/scoped_ptrace_attach_test.cc | 26 +++++--- util/linux/socket.h | 8 +-- util/linux/socket_test.cc | 1 - util/mach/child_port_handshake.cc | 6 +- util/mach/child_port_handshake.h | 6 +- util/mach/child_port_handshake_test.cc | 5 +- util/mach/child_port_server.h | 6 +- util/mach/composite_mach_message_server.h | 8 ++- .../composite_mach_message_server_test.cc | 5 +- util/mach/exc_client_variants_test.cc | 6 +- util/mach/exc_server_variants.cc | 16 +++-- util/mach/exc_server_variants.h | 6 +- util/mach/exc_server_variants_test.cc | 5 +- util/mach/exception_ports.h | 12 ++-- util/mach/exception_ports_test.cc | 11 ++-- util/mach/mach_message_server.cc | 5 +- util/mach/mach_message_server.h | 8 +-- util/mach/mach_message_server_test.cc | 6 +- util/mach/notify_server.h | 12 ++-- util/mach/notify_server_test.cc | 5 +- util/mach/scoped_task_suspend.h | 7 ++- util/mach/scoped_task_suspend_test.cc | 6 +- util/misc/initialization_state.h | 7 ++- util/misc/initialization_state_dcheck.h | 8 +-- util/misc/metrics.h | 8 +-- util/misc/paths.h | 7 ++- util/misc/range_set.h | 7 ++- util/misc/scoped_forbid_return.h | 7 ++- util/net/http_body.h | 16 ++--- util/net/http_body_gzip.h | 6 +- util/net/http_body_gzip_test.cc | 6 +- util/net/http_multipart_builder.h | 7 ++- util/net/http_transport.h | 6 +- util/net/http_transport_libcurl.cc | 22 ++++--- util/net/http_transport_mac.mm | 13 ++-- util/net/http_transport_socket.cc | 23 +++---- util/net/http_transport_win.cc | 7 ++- util/numeric/checked_address_range.h | 1 - util/posix/process_info.h | 7 ++- util/posix/process_info_test.cc | 7 ++- util/posix/scoped_mmap.h | 7 ++- util/posix/scoped_mmap_test.cc | 5 +- util/posix/signals.h | 13 ++-- util/posix/signals_test.cc | 6 +- util/process/process_memory_fuchsia.h | 7 ++- util/process/process_memory_linux.h | 7 ++- util/process/process_memory_mac.h | 12 ++-- util/process/process_memory_range.h | 7 ++- util/process/process_memory_sanitized.h | 7 ++- util/process/process_memory_test.cc | 20 ++++--- util/process/process_memory_win.h | 7 ++- util/stdlib/thread_safe_vector.h | 7 ++- util/stdlib/thread_safe_vector_test.cc | 7 ++- util/stream/base94_output_stream.h | 7 ++- util/stream/base94_output_stream_test.cc | 6 +- util/stream/file_encoder.h | 7 ++- util/stream/file_encoder_test.cc | 1 - util/stream/file_output_stream.h | 7 ++- util/stream/log_output_stream.h | 7 ++- util/stream/log_output_stream_test.cc | 6 +- util/stream/test_output_stream.h | 7 ++- util/stream/zlib_output_stream.h | 7 ++- util/stream/zlib_output_stream_test.cc | 5 +- util/thread/stoppable.h | 1 - util/thread/thread.h | 7 ++- util/thread/thread_log_messages.cc | 5 +- util/thread/thread_log_messages.h | 7 ++- util/thread/thread_log_messages_test.cc | 6 +- util/thread/thread_test.cc | 18 ++++-- util/thread/worker_thread.h | 7 ++- util/thread/worker_thread_test.cc | 6 +- util/win/exception_handler_server.cc | 10 ++-- util/win/exception_handler_server.h | 6 +- util/win/exception_handler_server_test.cc | 30 ++++++---- util/win/initial_client_data.h | 6 +- util/win/ntstatus_logging.h | 7 ++- util/win/process_info.h | 7 ++- util/win/safe_terminate_process_test.cc | 11 ++-- util/win/scoped_process_suspend.h | 7 ++- util/win/scoped_process_suspend_test.cc | 6 +- util/win/scoped_set_event.h | 7 ++- util/win/session_end_watcher.h | 6 +- util/win/session_end_watcher_test.cc | 5 +- 295 files changed, 1615 insertions(+), 1066 deletions(-) diff --git a/client/annotation.h b/client/annotation.h index edb963c297..8e7a3cbdc1 100644 --- a/client/annotation.h +++ b/client/annotation.h @@ -23,7 +23,6 @@ #include #include "base/check.h" -#include "base/macros.h" #include "base/numerics/safe_conversions.h" #include "base/strings/string_piece.h" #include "build/build_config.h" @@ -139,6 +138,9 @@ class Annotation { size_(0), type_(type) {} + Annotation(const Annotation&) = delete; + Annotation& operator=(const Annotation&) = delete; + //! \brief Specifies the number of bytes in \a value_ptr_ to include when //! generating a crash report. //! @@ -189,8 +191,6 @@ class Annotation { void* const value_ptr_; ValueSizeType size_; const Type type_; - - DISALLOW_COPY_AND_ASSIGN(Annotation); }; //! \brief An \sa Annotation that stores a `NUL`-terminated C-string value. @@ -214,6 +214,9 @@ class StringAnnotation : public Annotation { constexpr explicit StringAnnotation(const char name[]) : Annotation(Type::kString, name, value_), value_() {} + StringAnnotation(const StringAnnotation&) = delete; + StringAnnotation& operator=(const StringAnnotation&) = delete; + //! \brief Constructs a new StringAnnotation with the given \a name. //! //! This constructor takes the ArrayInitializerTag for use when @@ -262,8 +265,6 @@ class StringAnnotation : public Annotation { // This value is not `NUL`-terminated, since the size is stored by the base // annotation. char value_[MaxSize]; - - DISALLOW_COPY_AND_ASSIGN(StringAnnotation); }; } // namespace crashpad diff --git a/client/annotation_list.h b/client/annotation_list.h index 0b80768862..02389530c8 100644 --- a/client/annotation_list.h +++ b/client/annotation_list.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_CLIENT_ANNOTATION_LIST_H_ #define CRASHPAD_CLIENT_ANNOTATION_LIST_H_ -#include "base/macros.h" #include "build/build_config.h" #include "client/annotation.h" @@ -35,6 +34,10 @@ class InProcessIntermediateDumpHandler; class AnnotationList { public: AnnotationList(); + + AnnotationList(const AnnotationList&) = delete; + AnnotationList& operator=(const AnnotationList&) = delete; + ~AnnotationList(); //! \brief Returns the instance of the list that has been registered on the @@ -102,8 +105,6 @@ class AnnotationList { // Dummy linked-list head and tail elements of \a Annotation::Type::kInvalid. Annotation head_; Annotation tail_; - - DISALLOW_COPY_AND_ASSIGN(AnnotationList); }; } // namespace crashpad diff --git a/client/crash_report_database.h b/client/crash_report_database.h index 2cec7260fc..19f1bf74db 100644 --- a/client/crash_report_database.h +++ b/client/crash_report_database.h @@ -24,7 +24,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "util/file/file_io.h" #include "util/file/file_reader.h" #include "util/file/file_writer.h" @@ -111,6 +110,10 @@ class CrashReportDatabase { class NewReport { public: NewReport(); + + NewReport(const NewReport&) = delete; + NewReport& operator=(const NewReport&) = delete; + ~NewReport(); //! \brief An open FileWriter with which to write the report. @@ -152,8 +155,6 @@ class CrashReportDatabase { std::vector attachment_removers_; UUID uuid_; CrashReportDatabase* database_; - - DISALLOW_COPY_AND_ASSIGN(NewReport); }; //! \brief A crash report that is in the process of being uploaded. @@ -162,6 +163,10 @@ class CrashReportDatabase { class UploadReport : public Report { public: UploadReport(); + + UploadReport(const UploadReport&) = delete; + UploadReport& operator=(const UploadReport&) = delete; + virtual ~UploadReport(); //! \brief An open FileReader with which to read the report. @@ -189,8 +194,6 @@ class CrashReportDatabase { std::vector> attachment_readers_; std::map attachment_map_; bool report_metrics_; - - DISALLOW_COPY_AND_ASSIGN(UploadReport); }; //! \brief The result code for operations performed on a database. @@ -233,6 +236,9 @@ class CrashReportDatabase { kCannotRequestUpload, }; + CrashReportDatabase(const CrashReportDatabase&) = delete; + CrashReportDatabase& operator=(const CrashReportDatabase&) = delete; + virtual ~CrashReportDatabase() {} //! \brief Opens a database of crash reports, possibly creating it. @@ -422,8 +428,6 @@ class CrashReportDatabase { virtual OperationStatus RecordUploadAttempt(UploadReport* report, bool successful, const std::string& id) = 0; - - DISALLOW_COPY_AND_ASSIGN(CrashReportDatabase); }; } // namespace crashpad diff --git a/client/crash_report_database_generic.cc b/client/crash_report_database_generic.cc index aeaf2af43f..a433a905dc 100644 --- a/client/crash_report_database_generic.cc +++ b/client/crash_report_database_generic.cc @@ -21,6 +21,7 @@ #include #include "base/logging.h" +#include "base/macros.h" #include "build/build_config.h" #include "client/settings.h" #include "util/file/directory_reader.h" @@ -100,6 +101,10 @@ struct ReportMetadata { class ScopedLockFile { public: ScopedLockFile() = default; + + ScopedLockFile(const ScopedLockFile&) = delete; + ScopedLockFile& operator=(const ScopedLockFile&) = delete; + ~ScopedLockFile() = default; ScopedLockFile& operator=(ScopedLockFile&& other) { @@ -158,8 +163,6 @@ class ScopedLockFile { private: ScopedRemoveFile lock_file_; - - DISALLOW_COPY_AND_ASSIGN(ScopedLockFile); }; off_t GetFileSize(const base::FilePath& filepath) { @@ -195,6 +198,11 @@ void AddAttachmentSize(const base::FilePath& attachments_dir, uint64_t* size) { class CrashReportDatabaseGeneric : public CrashReportDatabase { public: CrashReportDatabaseGeneric(); + + CrashReportDatabaseGeneric(const CrashReportDatabaseGeneric&) = delete; + CrashReportDatabaseGeneric& operator=(const CrashReportDatabaseGeneric&) = + delete; + ~CrashReportDatabaseGeneric() override; bool Initialize(const base::FilePath& path, bool may_create); @@ -297,8 +305,6 @@ class CrashReportDatabaseGeneric : public CrashReportDatabase { base::FilePath base_dir_; Settings settings_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseGeneric); }; FileWriter* CrashReportDatabase::NewReport::AddAttachment( diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm index 485d05f360..839cfc8f30 100644 --- a/client/crash_report_database_mac.mm +++ b/client/crash_report_database_mac.mm @@ -28,6 +28,7 @@ #include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" +#include "base/macros.h" #include "base/posix/eintr_wrapper.h" #include "base/scoped_generic.h" #include "base/strings/string_piece.h" @@ -127,6 +128,10 @@ bool CreateOrEnsureDirectoryExists(const base::FilePath& path) { class CrashReportDatabaseMac : public CrashReportDatabase { public: explicit CrashReportDatabaseMac(const base::FilePath& path); + + CrashReportDatabaseMac(const CrashReportDatabaseMac&) = delete; + CrashReportDatabaseMac& operator=(const CrashReportDatabaseMac&) = delete; + virtual ~CrashReportDatabaseMac(); bool Initialize(bool may_create); @@ -243,8 +248,6 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, Settings settings_; bool xattr_new_names_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseMac); }; FileWriter* CrashReportDatabase::NewReport::AddAttachment( diff --git a/client/crash_report_database_test.cc b/client/crash_report_database_test.cc index 3c6a05779b..9d3f1fc9b9 100644 --- a/client/crash_report_database_test.cc +++ b/client/crash_report_database_test.cc @@ -32,6 +32,9 @@ class CrashReportDatabaseTest : public testing::Test { public: CrashReportDatabaseTest() {} + CrashReportDatabaseTest(const CrashReportDatabaseTest&) = delete; + CrashReportDatabaseTest& operator=(const CrashReportDatabaseTest&) = delete; + protected: // testing::Test: void SetUp() override { @@ -125,8 +128,6 @@ class CrashReportDatabaseTest : public testing::Test { private: ScopedTempDir temp_dir_; std::unique_ptr db_; - - DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseTest); }; TEST_F(CrashReportDatabaseTest, Initialize) { diff --git a/client/crash_report_database_win.cc b/client/crash_report_database_win.cc index 0195f6b172..b8ecadb788 100644 --- a/client/crash_report_database_win.cc +++ b/client/crash_report_database_win.cc @@ -24,6 +24,7 @@ #include #include "base/logging.h" +#include "base/macros.h" #include "base/numerics/safe_math.h" #include "base/strings/utf_string_conversions.h" #include "client/settings.h" @@ -208,6 +209,9 @@ ReportDisk::ReportDisk(const UUID& uuid, //! to disk, and queries. class Metadata { public: + Metadata(const Metadata&) = delete; + Metadata& operator=(const Metadata&) = delete; + //! \brief Writes any changes if necessary, unlocks and closes the file //! handle. ~Metadata(); @@ -296,8 +300,6 @@ class Metadata { const base::FilePath report_dir_; bool dirty_; //! \brief `true` when a Write() is required on destruction. std::vector reports_; - - DISALLOW_COPY_AND_ASSIGN(Metadata); }; Metadata::~Metadata() { @@ -615,6 +617,10 @@ bool CreateDirectoryIfNecessary(const base::FilePath& path) { class CrashReportDatabaseWin : public CrashReportDatabase { public: explicit CrashReportDatabaseWin(const base::FilePath& path); + + CrashReportDatabaseWin(const CrashReportDatabaseWin&) = delete; + CrashReportDatabaseWin& operator=(const CrashReportDatabaseWin&) = delete; + ~CrashReportDatabaseWin() override; bool Initialize(bool may_create); @@ -662,8 +668,6 @@ class CrashReportDatabaseWin : public CrashReportDatabase { base::FilePath base_dir_; Settings settings_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseWin); }; base::FilePath CrashReportDatabaseWin::AttachmentsRootPath() { diff --git a/client/crashpad_client.h b/client/crashpad_client.h index eea953d44e..c8016d25f4 100644 --- a/client/crashpad_client.h +++ b/client/crashpad_client.h @@ -23,7 +23,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "util/file/file_io.h" @@ -46,6 +45,10 @@ namespace crashpad { class CrashpadClient { public: CrashpadClient(); + + CrashpadClient(const CrashpadClient&) = delete; + CrashpadClient& operator=(const CrashpadClient&) = delete; + ~CrashpadClient(); //! \brief Starts a Crashpad handler process, performing any necessary @@ -744,8 +747,6 @@ class CrashpadClient { #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) std::set unhandled_signals_; #endif // OS_APPLE - - DISALLOW_COPY_AND_ASSIGN(CrashpadClient); }; } // namespace crashpad diff --git a/client/crashpad_client_ios.cc b/client/crashpad_client_ios.cc index f53a6d5c7d..b32678d6e3 100644 --- a/client/crashpad_client_ios.cc +++ b/client/crashpad_client_ios.cc @@ -42,6 +42,9 @@ class CrashHandler : public Thread, public UniversalMachExcServer::Interface, public ObjcExceptionDelegate { public: + CrashHandler(const CrashHandler&) = delete; + CrashHandler& operator=(const CrashHandler&) = delete; + static CrashHandler* Get() { static CrashHandler* instance = new CrashHandler(); return instance; @@ -215,8 +218,6 @@ class CrashHandler : public Thread, struct sigaction old_action_ = {}; internal::IOSSystemDataCollector system_data_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(CrashHandler); }; } // namespace diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc index cf94e6bd31..eccf204ca1 100644 --- a/client/crashpad_client_linux.cc +++ b/client/crashpad_client_linux.cc @@ -129,6 +129,9 @@ std::vector BuildArgsToLaunchWithLinker( // A base class for Crashpad signal handler implementations. class SignalHandler { public: + SignalHandler(const SignalHandler&) = delete; + SignalHandler& operator=(const SignalHandler&) = delete; + // Returns the currently installed signal hander. May be `nullptr` if no // handler has been installed. static SignalHandler* Get() { return handler_; } @@ -208,8 +211,6 @@ class SignalHandler { static SignalHandler* handler_; static thread_local bool disabled_for_thread_; - - DISALLOW_COPY_AND_ASSIGN(SignalHandler); }; SignalHandler* SignalHandler::handler_ = nullptr; thread_local bool SignalHandler::disabled_for_thread_ = false; @@ -217,6 +218,9 @@ thread_local bool SignalHandler::disabled_for_thread_ = false; // Launches a single use handler to snapshot this process. class LaunchAtCrashHandler : public SignalHandler { public: + LaunchAtCrashHandler(const LaunchAtCrashHandler&) = delete; + LaunchAtCrashHandler& operator=(const LaunchAtCrashHandler&) = delete; + static LaunchAtCrashHandler* Get() { static LaunchAtCrashHandler* instance = new LaunchAtCrashHandler(); return instance; @@ -272,12 +276,13 @@ class LaunchAtCrashHandler : public SignalHandler { std::vector envp_strings_; std::vector envp_; bool set_envp_ = false; - - DISALLOW_COPY_AND_ASSIGN(LaunchAtCrashHandler); }; class RequestCrashDumpHandler : public SignalHandler { public: + RequestCrashDumpHandler(const RequestCrashDumpHandler&) = delete; + RequestCrashDumpHandler& operator=(const RequestCrashDumpHandler&) = delete; + static RequestCrashDumpHandler* Get() { static RequestCrashDumpHandler* instance = new RequestCrashDumpHandler(); return instance; @@ -365,8 +370,6 @@ class RequestCrashDumpHandler : public SignalHandler { // don't anything with it except pass it along). uint64_t crash_loop_before_time_ = 0; #endif - - DISALLOW_COPY_AND_ASSIGN(RequestCrashDumpHandler); }; } // namespace diff --git a/client/crashpad_client_linux_test.cc b/client/crashpad_client_linux_test.cc index 0153355f56..a17589add0 100644 --- a/client/crashpad_client_linux_test.cc +++ b/client/crashpad_client_linux_test.cc @@ -81,6 +81,10 @@ class StartHandlerForSelfTest std::tuple> { public: StartHandlerForSelfTest() = default; + + StartHandlerForSelfTest(const StartHandlerForSelfTest&) = delete; + StartHandlerForSelfTest& operator=(const StartHandlerForSelfTest&) = delete; + ~StartHandlerForSelfTest() = default; void SetUp() override { @@ -95,8 +99,6 @@ class StartHandlerForSelfTest private: StartHandlerForSelfTestOptions options_; - - DISALLOW_COPY_AND_ASSIGN(StartHandlerForSelfTest); }; bool HandleCrashSuccessfully(int, siginfo_t*, ucontext_t*) { @@ -212,6 +214,9 @@ class ScopedAltSignalStack { public: ScopedAltSignalStack() = default; + ScopedAltSignalStack(const ScopedAltSignalStack&) = delete; + ScopedAltSignalStack& operator=(const ScopedAltSignalStack&) = delete; + ~ScopedAltSignalStack() { if (stack_mem_.is_valid()) { stack_t stack; @@ -242,8 +247,6 @@ class ScopedAltSignalStack { private: ScopedMmap stack_mem_; - - DISALLOW_COPY_AND_ASSIGN(ScopedAltSignalStack); }; class CrashThread : public Thread { @@ -252,6 +255,9 @@ class CrashThread : public Thread { CrashpadClient* client) : client_signal_stack_(), options_(options), client_(client) {} + CrashThread(const CrashThread&) = delete; + CrashThread& operator=(const CrashThread&) = delete; + private: void ThreadMain() override { // It is only necessary to call InitializeSignalStackForThread() once, but @@ -269,8 +275,6 @@ class CrashThread : public Thread { ScopedAltSignalStack client_signal_stack_; const StartHandlerForSelfTestOptions& options_; CrashpadClient* client_; - - DISALLOW_COPY_AND_ASSIGN(CrashThread); }; CRASHPAD_CHILD_TEST_MAIN(StartHandlerForSelfTestChild) { @@ -360,6 +364,11 @@ class StartHandlerForSelfInChildTest : public MultiprocessExec { } } + StartHandlerForSelfInChildTest(const StartHandlerForSelfInChildTest&) = + delete; + StartHandlerForSelfInChildTest& operator=( + const StartHandlerForSelfInChildTest&) = delete; + private: void MultiprocessParent() override { ScopedTempDir temp_dir; @@ -415,8 +424,6 @@ class StartHandlerForSelfInChildTest : public MultiprocessExec { } StartHandlerForSelfTestOptions options_; - - DISALLOW_COPY_AND_ASSIGN(StartHandlerForSelfInChildTest); }; TEST_P(StartHandlerForSelfTest, StartHandlerInChild) { @@ -450,6 +457,11 @@ INSTANTIATE_TEST_SUITE_P( class StartHandlerForClientTest { public: StartHandlerForClientTest() = default; + + StartHandlerForClientTest(const StartHandlerForClientTest&) = delete; + StartHandlerForClientTest& operator=(const StartHandlerForClientTest&) = + delete; + ~StartHandlerForClientTest() = default; bool Initialize(bool sanitize) { @@ -513,6 +525,9 @@ class StartHandlerForClientTest { // more privileged, process. class SandboxedHandler { public: + SandboxedHandler(const SandboxedHandler&) = delete; + SandboxedHandler& operator=(const SandboxedHandler&) = delete; + static SandboxedHandler* Get() { static SandboxedHandler* instance = new SandboxedHandler(); return instance; @@ -565,22 +580,22 @@ class StartHandlerForClientTest { FileHandle client_sock_; bool sanitize_; - - DISALLOW_COPY_AND_ASSIGN(SandboxedHandler); }; ScopedTempDir temp_dir_; ScopedFileHandle client_sock_; ScopedFileHandle server_sock_; bool sanitize_; - - DISALLOW_COPY_AND_ASSIGN(StartHandlerForClientTest); }; // Tests starting the handler for a child process. class StartHandlerForChildTest : public Multiprocess { public: StartHandlerForChildTest() = default; + + StartHandlerForChildTest(const StartHandlerForChildTest&) = delete; + StartHandlerForChildTest& operator=(const StartHandlerForChildTest&) = delete; + ~StartHandlerForChildTest() = default; bool Initialize(bool sanitize) { @@ -607,8 +622,6 @@ class StartHandlerForChildTest : public Multiprocess { } StartHandlerForClientTest test_state_; - - DISALLOW_COPY_AND_ASSIGN(StartHandlerForChildTest); }; TEST(CrashpadClient, StartHandlerForChild) { diff --git a/client/crashpad_client_mac.cc b/client/crashpad_client_mac.cc index ddcd485f5a..f4256f0cd3 100644 --- a/client/crashpad_client_mac.cc +++ b/client/crashpad_client_mac.cc @@ -25,6 +25,7 @@ #include "base/logging.h" #include "base/mac/mach_logging.h" +#include "base/macros.h" #include "base/strings/stringprintf.h" #include "util/mac/mac_util.h" #include "util/mach/bootstrap.h" @@ -94,6 +95,9 @@ class ScopedPthreadAttrDestroy { : pthread_attr_(pthread_attr) { } + ScopedPthreadAttrDestroy(const ScopedPthreadAttrDestroy&) = delete; + ScopedPthreadAttrDestroy& operator=(const ScopedPthreadAttrDestroy&) = delete; + ~ScopedPthreadAttrDestroy() { errno = pthread_attr_destroy(pthread_attr_); PLOG_IF(WARNING, errno != 0) << "pthread_attr_destroy"; @@ -101,13 +105,14 @@ class ScopedPthreadAttrDestroy { private: pthread_attr_t* pthread_attr_; - - DISALLOW_COPY_AND_ASSIGN(ScopedPthreadAttrDestroy); }; //! \brief Starts a Crashpad handler, possibly restarting it if it dies. class HandlerStarter final : public NotifyServer::DefaultInterface { public: + HandlerStarter(const HandlerStarter&) = delete; + HandlerStarter& operator=(const HandlerStarter&) = delete; + ~HandlerStarter() {} //! \brief Starts a Crashpad handler initially, as opposed to starting it for @@ -427,8 +432,6 @@ class HandlerStarter final : public NotifyServer::DefaultInterface { std::vector arguments_; base::mac::ScopedMachReceiveRight notify_port_; uint64_t last_start_time_; - - DISALLOW_COPY_AND_ASSIGN(HandlerStarter); }; } // namespace diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc index 4ae8da0393..0973c2a672 100644 --- a/client/crashpad_client_win.cc +++ b/client/crashpad_client_win.cc @@ -24,7 +24,6 @@ #include "base/atomicops.h" #include "base/logging.h" -#include "base/macros.h" #include "base/scoped_generic.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -339,6 +338,11 @@ class ScopedCallSetHandlerStartupState { public: ScopedCallSetHandlerStartupState() : successful_(false) {} + ScopedCallSetHandlerStartupState(const ScopedCallSetHandlerStartupState&) = + delete; + ScopedCallSetHandlerStartupState& operator=( + const ScopedCallSetHandlerStartupState&) = delete; + ~ScopedCallSetHandlerStartupState() { SetHandlerStartupState(successful_ ? StartupState::kSucceeded : StartupState::kFailed); @@ -348,8 +352,6 @@ class ScopedCallSetHandlerStartupState { private: bool successful_; - - DISALLOW_COPY_AND_ASSIGN(ScopedCallSetHandlerStartupState); }; bool StartHandlerProcess( diff --git a/client/crashpad_info.h b/client/crashpad_info.h index 62efc10dc7..cc05398e3f 100644 --- a/client/crashpad_info.h +++ b/client/crashpad_info.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "client/annotation_list.h" #include "client/simple_address_range_bag.h" @@ -71,6 +70,9 @@ struct CrashpadInfo { CrashpadInfo(); + CrashpadInfo(const CrashpadInfo&) = delete; + CrashpadInfo& operator=(const CrashpadInfo&) = delete; + //! \brief Sets the bag of extra memory ranges to be included in the snapshot. //! //! Extra memory ranges may exist in \a address_range_bag at the time that @@ -270,8 +272,6 @@ struct CrashpadInfo { #if defined(__clang__) #pragma clang diagnostic pop #endif - - DISALLOW_COPY_AND_ASSIGN(CrashpadInfo); }; } // namespace crashpad diff --git a/client/ios_handler/in_process_intermediate_dump_handler.cc b/client/ios_handler/in_process_intermediate_dump_handler.cc index 43552a7a54..9c1a31644b 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler.cc @@ -64,6 +64,9 @@ class ScopedTaskThreads { mach_msg_type_number_t thread_count) : threads_(threads), thread_count_(thread_count) {} + ScopedTaskThreads(const ScopedTaskThreads&) = delete; + ScopedTaskThreads& operator=(const ScopedTaskThreads&) = delete; + ~ScopedTaskThreads() { for (uint32_t thread_index = 0; thread_index < thread_count_; ++thread_index) { @@ -77,8 +80,6 @@ class ScopedTaskThreads { private: thread_act_array_t threads_; mach_msg_type_number_t thread_count_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTaskThreads); }; //! \brief Log \a key as a string. diff --git a/client/ios_handler/in_process_intermediate_dump_handler.h b/client/ios_handler/in_process_intermediate_dump_handler.h index 9a33ff49ae..6281563006 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.h +++ b/client/ios_handler/in_process_intermediate_dump_handler.h @@ -32,6 +32,12 @@ namespace internal { //! Note: All methods are `RUNS-DURING-CRASH`. class InProcessIntermediateDumpHandler final { public: + InProcessIntermediateDumpHandler() = delete; + InProcessIntermediateDumpHandler(const InProcessIntermediateDumpHandler&) = + delete; + InProcessIntermediateDumpHandler& operator=( + const InProcessIntermediateDumpHandler&) = delete; + //! \brief Set kVersion to 1. //! //! \param[in] writer The dump writer @@ -136,8 +142,6 @@ class InProcessIntermediateDumpHandler final { //! \brief Write Crashpad annotations list. static void WriteCrashpadAnnotationsList(IOSIntermediateDumpWriter* writer, CrashpadInfo* crashpad_info); - - DISALLOW_IMPLICIT_CONSTRUCTORS(InProcessIntermediateDumpHandler); }; } // namespace internal diff --git a/client/prune_crash_reports.h b/client/prune_crash_reports.h index 07a70980f1..b80cf7a591 100644 --- a/client/prune_crash_reports.h +++ b/client/prune_crash_reports.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "client/crash_report_database.h" namespace crashpad { @@ -81,14 +80,16 @@ class AgePruneCondition final : public PruneCondition { //! \param[in] max_age_in_days Reports created more than this many days ago //! will be deleted. explicit AgePruneCondition(int max_age_in_days); + + AgePruneCondition(const AgePruneCondition&) = delete; + AgePruneCondition& operator=(const AgePruneCondition&) = delete; + ~AgePruneCondition(); bool ShouldPruneReport(const CrashReportDatabase::Report& report) override; private: const time_t oldest_report_time_; - - DISALLOW_COPY_AND_ASSIGN(AgePruneCondition); }; //! \brief A PruneCondition that deletes older reports to keep the total @@ -102,6 +103,11 @@ class DatabaseSizePruneCondition final : public PruneCondition { //! \param[in] max_size_in_kb The maximum number of kilobytes that all crash //! reports should consume. explicit DatabaseSizePruneCondition(size_t max_size_in_kb); + + DatabaseSizePruneCondition(const DatabaseSizePruneCondition&) = delete; + DatabaseSizePruneCondition& operator=(const DatabaseSizePruneCondition&) = + delete; + ~DatabaseSizePruneCondition(); bool ShouldPruneReport(const CrashReportDatabase::Report& report) override; @@ -109,8 +115,6 @@ class DatabaseSizePruneCondition final : public PruneCondition { private: const size_t max_size_in_kb_; size_t measured_size_in_kb_; - - DISALLOW_COPY_AND_ASSIGN(DatabaseSizePruneCondition); }; //! \brief A PruneCondition that conjoins two other PruneConditions. @@ -133,6 +137,10 @@ class BinaryPruneCondition final : public PruneCondition { //! \param[in] lhs The left-hand side of \a op. This class takes ownership. //! \param[in] rhs The right-hand side of \a op. This class takes ownership. BinaryPruneCondition(Operator op, PruneCondition* lhs, PruneCondition* rhs); + + BinaryPruneCondition(const BinaryPruneCondition&) = delete; + BinaryPruneCondition& operator=(const BinaryPruneCondition&) = delete; + ~BinaryPruneCondition(); bool ShouldPruneReport(const CrashReportDatabase::Report& report) override; @@ -141,8 +149,6 @@ class BinaryPruneCondition final : public PruneCondition { const Operator op_; std::unique_ptr lhs_; std::unique_ptr rhs_; - - DISALLOW_COPY_AND_ASSIGN(BinaryPruneCondition); }; } // namespace crashpad diff --git a/client/prune_crash_reports_test.cc b/client/prune_crash_reports_test.cc index 333c37ea61..b989d2f615 100644 --- a/client/prune_crash_reports_test.cc +++ b/client/prune_crash_reports_test.cc @@ -149,6 +149,10 @@ TEST(PruneCrashReports, SizeCondition) { class StaticCondition final : public PruneCondition { public: explicit StaticCondition(bool value) : value_(value), did_execute_(false) {} + + StaticCondition(const StaticCondition&) = delete; + StaticCondition& operator=(const StaticCondition&) = delete; + ~StaticCondition() {} bool ShouldPruneReport(const CrashReportDatabase::Report& report) override { @@ -161,8 +165,6 @@ class StaticCondition final : public PruneCondition { private: const bool value_; bool did_execute_; - - DISALLOW_COPY_AND_ASSIGN(StaticCondition); }; TEST(PruneCrashReports, BinaryCondition) { diff --git a/client/settings.h b/client/settings.h index 5761c6b965..d17f357ed4 100644 --- a/client/settings.h +++ b/client/settings.h @@ -20,7 +20,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "base/scoped_generic.h" #include "build/build_config.h" #include "util/file/file_io.h" @@ -46,6 +45,10 @@ struct ScopedLockedFileHandleTraits { class Settings { public: Settings(); + + Settings(const Settings&) = delete; + Settings& operator=(const Settings&) = delete; + ~Settings(); //! \brief Initializes the settings data store. @@ -130,6 +133,10 @@ class Settings { const base::FilePath& lockfile_path); ScopedLockedFileHandle(ScopedLockedFileHandle&& other); ScopedLockedFileHandle& operator=(ScopedLockedFileHandle&& other); + + ScopedLockedFileHandle(const ScopedLockedFileHandle&) = delete; + ScopedLockedFileHandle& operator=(const ScopedLockedFileHandle&) = delete; + ~ScopedLockedFileHandle(); // These mirror the non-Fuchsia ScopedLockedFileHandle via ScopedGeneric so @@ -147,8 +154,6 @@ class Settings { FileHandle handle_; base::FilePath lockfile_path_; - - DISALLOW_COPY_AND_ASSIGN(ScopedLockedFileHandle); }; #else // OS_FUCHSIA using ScopedLockedFileHandle = @@ -221,8 +226,6 @@ class Settings { base::FilePath file_path_; InitializationState initialized_; - - DISALLOW_COPY_AND_ASSIGN(Settings); }; } // namespace crashpad diff --git a/client/settings_test.cc b/client/settings_test.cc index 3a5730bd80..5f13cfcca8 100644 --- a/client/settings_test.cc +++ b/client/settings_test.cc @@ -28,6 +28,9 @@ class SettingsTest : public testing::Test { public: SettingsTest() = default; + SettingsTest(const SettingsTest&) = delete; + SettingsTest& operator=(const SettingsTest&) = delete; + base::FilePath settings_path() { return temp_dir_.path().Append(FILE_PATH_LITERAL("settings")); } @@ -55,8 +58,6 @@ class SettingsTest : public testing::Test { private: ScopedTempDir temp_dir_; Settings settings_; - - DISALLOW_COPY_AND_ASSIGN(SettingsTest); }; TEST_F(SettingsTest, ClientID) { diff --git a/client/simple_address_range_bag.h b/client/simple_address_range_bag.h index 0a87a89b31..1bdfa82494 100644 --- a/client/simple_address_range_bag.h +++ b/client/simple_address_range_bag.h @@ -22,7 +22,6 @@ #include "base/check_op.h" #include "base/logging.h" -#include "base/macros.h" #include "base/numerics/safe_conversions.h" #include "util/misc/from_pointer_cast.h" #include "util/numeric/checked_range.h" @@ -66,6 +65,9 @@ class TSimpleAddressRangeBag { current_(0) { } + Iterator(const Iterator&) = delete; + Iterator& operator=(const Iterator&) = delete; + //! \brief Returns the next entry in the bag, or `nullptr` if at the end of //! the collection. const Entry* Next() { @@ -81,8 +83,6 @@ class TSimpleAddressRangeBag { private: const TSimpleAddressRangeBag& bag_; size_t current_; - - DISALLOW_COPY_AND_ASSIGN(Iterator); }; TSimpleAddressRangeBag() diff --git a/client/simple_string_dictionary.h b/client/simple_string_dictionary.h index 31c7548de5..43483dd87f 100644 --- a/client/simple_string_dictionary.h +++ b/client/simple_string_dictionary.h @@ -22,7 +22,6 @@ #include #include "base/check_op.h" -#include "base/macros.h" #include "base/strings/string_piece.h" #include "util/misc/implicit_cast.h" @@ -82,6 +81,9 @@ class TSimpleStringDictionary { current_(0) { } + Iterator(const Iterator&) = delete; + Iterator& operator=(const Iterator&) = delete; + //! \brief Returns the next entry in the map, or `nullptr` if at the end of //! the collection. const Entry* Next() { @@ -97,8 +99,6 @@ class TSimpleStringDictionary { private: const TSimpleStringDictionary& map_; size_t current_; - - DISALLOW_COPY_AND_ASSIGN(Iterator); }; TSimpleStringDictionary() diff --git a/client/simulate_crash_mac_test.cc b/client/simulate_crash_mac_test.cc index 92ae73e79e..f22b2a69de 100644 --- a/client/simulate_crash_mac_test.cc +++ b/client/simulate_crash_mac_test.cc @@ -19,7 +19,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -80,6 +79,9 @@ class TestSimulateCrashMac final : public MachMultiprocess, succeed_(true) { } + TestSimulateCrashMac(const TestSimulateCrashMac&) = delete; + TestSimulateCrashMac& operator=(const TestSimulateCrashMac&) = delete; + ~TestSimulateCrashMac() {} // UniversalMachExcServer::Interface: @@ -325,8 +327,6 @@ class TestSimulateCrashMac final : public MachMultiprocess, exception_behavior_t behavior_; thread_state_flavor_t flavor_; bool succeed_; - - DISALLOW_COPY_AND_ASSIGN(TestSimulateCrashMac); }; TEST(SimulateCrash, SimulateCrash) { diff --git a/handler/crash_report_upload_thread.h b/handler/crash_report_upload_thread.h index 2ec1147d26..1a88a087b5 100644 --- a/handler/crash_report_upload_thread.h +++ b/handler/crash_report_upload_thread.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "client/crash_report_database.h" #include "util/misc/uuid.h" #include "util/stdlib/thread_safe_vector.h" @@ -70,6 +69,10 @@ class CrashReportUploadThread : public WorkerThread::Delegate, CrashReportUploadThread(CrashReportDatabase* database, const std::string& url, const Options& options); + + CrashReportUploadThread(const CrashReportUploadThread&) = delete; + CrashReportUploadThread& operator=(const CrashReportUploadThread&) = delete; + ~CrashReportUploadThread(); //! \brief Informs the upload thread that a new pending report has been added @@ -172,8 +175,6 @@ class CrashReportUploadThread : public WorkerThread::Delegate, WorkerThread thread_; ThreadSafeVector known_pending_report_uuids_; CrashReportDatabase* database_; // weak - - DISALLOW_COPY_AND_ASSIGN(CrashReportUploadThread); }; } // namespace crashpad diff --git a/handler/crashpad_handler_test_extended_handler.cc b/handler/crashpad_handler_test_extended_handler.cc index 7a8f456350..4abcacd50f 100644 --- a/handler/crashpad_handler_test_extended_handler.cc +++ b/handler/crashpad_handler_test_extended_handler.cc @@ -14,7 +14,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "handler/handler_main.h" #include "minidump/test/minidump_user_extension_stream_util.h" @@ -30,11 +29,11 @@ class TestUserStreamDataSource : public crashpad::UserStreamDataSource { public: TestUserStreamDataSource() {} + TestUserStreamDataSource(const TestUserStreamDataSource&) = delete; + TestUserStreamDataSource& operator=(const TestUserStreamDataSource&) = delete; + std::unique_ptr ProduceStreamData(crashpad::ProcessSnapshot* process_snapshot) override; - - private: - DISALLOW_COPY_AND_ASSIGN(TestUserStreamDataSource); }; std::unique_ptr diff --git a/handler/handler_main.cc b/handler/handler_main.cc index 737ee4e09f..5733463bed 100644 --- a/handler/handler_main.cc +++ b/handler/handler_main.cc @@ -270,12 +270,14 @@ int ExitFailure() { class CallMetricsRecordNormalExit { public: CallMetricsRecordNormalExit() {} + + CallMetricsRecordNormalExit(const CallMetricsRecordNormalExit&) = delete; + CallMetricsRecordNormalExit& operator=(const CallMetricsRecordNormalExit&) = + delete; + ~CallMetricsRecordNormalExit() { MetricsRecordExit(Metrics::LifetimeMilestone::kExitedNormally); } - - private: - DISALLOW_COPY_AND_ASSIGN(CallMetricsRecordNormalExit); }; #if defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ @@ -391,6 +393,10 @@ BOOL WINAPI ConsoleHandler(DWORD console_event) { class TerminateHandler final : public SessionEndWatcher { public: TerminateHandler() : SessionEndWatcher() {} + + TerminateHandler(const TerminateHandler&) = delete; + TerminateHandler& operator=(const TerminateHandler&) = delete; + ~TerminateHandler() override {} private: @@ -398,8 +404,6 @@ class TerminateHandler final : public SessionEndWatcher { void SessionEnding() override { MetricsRecordExit(Metrics::LifetimeMilestone::kTerminated); } - - DISALLOW_COPY_AND_ASSIGN(TerminateHandler); }; void ReinstallCrashHandler() { @@ -489,6 +493,9 @@ class ScopedStoppable { public: ScopedStoppable() = default; + ScopedStoppable(const ScopedStoppable&) = delete; + ScopedStoppable& operator=(const ScopedStoppable&) = delete; + ~ScopedStoppable() { if (stoppable_) { stoppable_->Stop(); @@ -501,8 +508,6 @@ class ScopedStoppable { private: std::unique_ptr stoppable_; - - DISALLOW_COPY_AND_ASSIGN(ScopedStoppable); }; void InitCrashpadLogging() { diff --git a/handler/linux/crash_report_exception_handler.cc b/handler/linux/crash_report_exception_handler.cc index 9dc313cdaf..4d37582b7f 100644 --- a/handler/linux/crash_report_exception_handler.cc +++ b/handler/linux/crash_report_exception_handler.cc @@ -46,6 +46,10 @@ namespace { class Logger final : public LogOutputStream::Delegate { public: Logger() = default; + + Logger(const Logger&) = delete; + Logger& operator=(const Logger&) = delete; + ~Logger() override = default; #if defined(OS_ANDROID) @@ -72,9 +76,6 @@ class Logger final : public LogOutputStream::Delegate { size_t OutputCap() override { return 0; } size_t LineWidth() override { return 0; } #endif - - private: - DISALLOW_COPY_AND_ASSIGN(Logger); }; bool WriteMinidumpLogFromFile(FileReaderInterface* file_reader) { diff --git a/handler/linux/crash_report_exception_handler.h b/handler/linux/crash_report_exception_handler.h index ae28430171..76fce92fbf 100644 --- a/handler/linux/crash_report_exception_handler.h +++ b/handler/linux/crash_report_exception_handler.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "client/crash_report_database.h" #include "handler/crash_report_upload_thread.h" #include "handler/linux/exception_handler_server.h" @@ -72,6 +71,10 @@ class CrashReportExceptionHandler : public ExceptionHandlerServer::Delegate { bool write_minidump_to_log, const UserStreamDataSources* user_stream_data_sources); + CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete; + CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) = + delete; + ~CrashReportExceptionHandler() override; // ExceptionHandlerServer::Delegate: @@ -113,8 +116,6 @@ class CrashReportExceptionHandler : public ExceptionHandlerServer::Delegate { bool write_minidump_to_database_; bool write_minidump_to_log_; const UserStreamDataSources* user_stream_data_sources_; // weak - - DISALLOW_COPY_AND_ASSIGN(CrashReportExceptionHandler); }; } // namespace crashpad diff --git a/handler/linux/cros_crash_report_exception_handler.h b/handler/linux/cros_crash_report_exception_handler.h index 0b14544810..eaa6eb1659 100644 --- a/handler/linux/cros_crash_report_exception_handler.h +++ b/handler/linux/cros_crash_report_exception_handler.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "client/crash_report_database.h" #include "handler/linux/exception_handler_server.h" #include "handler/user_stream_data_source.h" @@ -58,6 +57,11 @@ class CrosCrashReportExceptionHandler const std::map* process_annotations, const UserStreamDataSources* user_stream_data_sources); + CrosCrashReportExceptionHandler(const CrosCrashReportExceptionHandler&) = + delete; + CrosCrashReportExceptionHandler& operator=( + const CrosCrashReportExceptionHandler&) = delete; + ~CrosCrashReportExceptionHandler() override; // ExceptionHandlerServer::Delegate: @@ -92,8 +96,6 @@ class CrosCrashReportExceptionHandler const UserStreamDataSources* user_stream_data_sources_; // weak base::FilePath dump_dir_; bool always_allow_feedback_; - - DISALLOW_COPY_AND_ASSIGN(CrosCrashReportExceptionHandler); }; } // namespace crashpad diff --git a/handler/linux/exception_handler_server.h b/handler/linux/exception_handler_server.h index ac430a4c5a..60bf496d91 100644 --- a/handler/linux/exception_handler_server.h +++ b/handler/linux/exception_handler_server.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "util/file/file_io.h" #include "util/linux/exception_handler_protocol.h" #include "util/misc/address_types.h" @@ -116,6 +115,10 @@ class ExceptionHandlerServer { }; ExceptionHandlerServer(); + + ExceptionHandlerServer(const ExceptionHandlerServer&) = delete; + ExceptionHandlerServer& operator=(const ExceptionHandlerServer&) = delete; + ~ExceptionHandlerServer(); //! \brief Sets the handler's PtraceStrategyDecider. @@ -187,8 +190,6 @@ class ExceptionHandlerServer { ScopedFileHandle pollfd_; std::atomic keep_running_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); }; } // namespace crashpad diff --git a/handler/linux/exception_handler_server_test.cc b/handler/linux/exception_handler_server_test.cc index 81687fdcb8..786bab1baa 100644 --- a/handler/linux/exception_handler_server_test.cc +++ b/handler/linux/exception_handler_server_test.cc @@ -45,6 +45,9 @@ class RunServerThread : public Thread { ExceptionHandlerServer::Delegate* delegate) : server_(server), delegate_(delegate), join_sem_(0) {} + RunServerThread(const RunServerThread&) = delete; + RunServerThread& operator=(const RunServerThread&) = delete; + ~RunServerThread() override {} bool JoinWithTimeout(double timeout) { @@ -65,8 +68,6 @@ class RunServerThread : public Thread { ExceptionHandlerServer* server_; ExceptionHandlerServer::Delegate* delegate_; Semaphore join_sem_; - - DISALLOW_COPY_AND_ASSIGN(RunServerThread); }; class ScopedStopServerAndJoinThread { @@ -75,6 +76,10 @@ class ScopedStopServerAndJoinThread { RunServerThread* thread) : server_(server), thread_(thread) {} + ScopedStopServerAndJoinThread(const ScopedStopServerAndJoinThread&) = delete; + ScopedStopServerAndJoinThread& operator=( + const ScopedStopServerAndJoinThread&) = delete; + ~ScopedStopServerAndJoinThread() { server_->Stop(); EXPECT_TRUE(thread_->JoinWithTimeout(5.0)); @@ -83,8 +88,6 @@ class ScopedStopServerAndJoinThread { private: ExceptionHandlerServer* server_; RunServerThread* thread_; - - DISALLOW_COPY_AND_ASSIGN(ScopedStopServerAndJoinThread); }; class TestDelegate : public ExceptionHandlerServer::Delegate { @@ -92,6 +95,9 @@ class TestDelegate : public ExceptionHandlerServer::Delegate { TestDelegate() : Delegate(), last_exception_address_(0), last_client_(-1), sem_(0) {} + TestDelegate(const TestDelegate&) = delete; + TestDelegate& operator=(const TestDelegate&) = delete; + ~TestDelegate() {} bool WaitForException(double timeout_seconds, @@ -159,8 +165,6 @@ class TestDelegate : public ExceptionHandlerServer::Delegate { VMAddress last_exception_address_; pid_t last_client_; Semaphore sem_; - - DISALLOW_COPY_AND_ASSIGN(TestDelegate); }; class MockPtraceStrategyDecider : public PtraceStrategyDecider { @@ -168,6 +172,10 @@ class MockPtraceStrategyDecider : public PtraceStrategyDecider { MockPtraceStrategyDecider(PtraceStrategyDecider::Strategy strategy) : PtraceStrategyDecider(), strategy_(strategy) {} + MockPtraceStrategyDecider(const MockPtraceStrategyDecider&) = delete; + MockPtraceStrategyDecider& operator=(const MockPtraceStrategyDecider&) = + delete; + ~MockPtraceStrategyDecider() {} Strategy ChooseStrategy(int sock, @@ -198,8 +206,6 @@ class MockPtraceStrategyDecider : public PtraceStrategyDecider { private: Strategy strategy_; - - DISALLOW_COPY_AND_ASSIGN(MockPtraceStrategyDecider); }; class ExceptionHandlerServerTest : public testing::TestWithParam { @@ -211,6 +217,10 @@ class ExceptionHandlerServerTest : public testing::TestWithParam { sock_to_handler_(), use_multi_client_socket_(GetParam()) {} + ExceptionHandlerServerTest(const ExceptionHandlerServerTest&) = delete; + ExceptionHandlerServerTest& operator=(const ExceptionHandlerServerTest&) = + delete; + ~ExceptionHandlerServerTest() = default; int SockToHandler() { return sock_to_handler_.get(); } @@ -228,6 +238,9 @@ class ExceptionHandlerServerTest : public testing::TestWithParam { CrashDumpTest(ExceptionHandlerServerTest* server_test, bool succeeds) : Multiprocess(), server_test_(server_test), succeeds_(succeeds) {} + CrashDumpTest(const CrashDumpTest&) = delete; + CrashDumpTest& operator=(const CrashDumpTest&) = delete; + ~CrashDumpTest() = default; void MultiprocessParent() override { @@ -267,8 +280,6 @@ class ExceptionHandlerServerTest : public testing::TestWithParam { private: ExceptionHandlerServerTest* server_test_; bool succeeds_; - - DISALLOW_COPY_AND_ASSIGN(CrashDumpTest); }; void ExpectCrashDumpUsingStrategy(PtraceStrategyDecider::Strategy strategy, @@ -303,8 +314,6 @@ class ExceptionHandlerServerTest : public testing::TestWithParam { ScopedFileHandle sock_to_handler_; int sock_to_client_; bool use_multi_client_socket_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServerTest); }; TEST_P(ExceptionHandlerServerTest, ShutdownWithNoClients) { diff --git a/handler/mac/crash_report_exception_handler.h b/handler/mac/crash_report_exception_handler.h index b5a59e4322..16c669126e 100644 --- a/handler/mac/crash_report_exception_handler.h +++ b/handler/mac/crash_report_exception_handler.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "client/crash_report_database.h" #include "handler/crash_report_upload_thread.h" #include "handler/user_stream_data_source.h" @@ -59,6 +58,10 @@ class CrashReportExceptionHandler final const std::map* process_annotations, const UserStreamDataSources* user_stream_data_sources); + CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete; + CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) = + delete; + ~CrashReportExceptionHandler(); // UniversalMachExcServer::Interface: @@ -86,8 +89,6 @@ class CrashReportExceptionHandler final CrashReportUploadThread* upload_thread_; // weak const std::map* process_annotations_; // weak const UserStreamDataSources* user_stream_data_sources_; // weak - - DISALLOW_COPY_AND_ASSIGN(CrashReportExceptionHandler); }; } // namespace crashpad diff --git a/handler/mac/exception_handler_server.cc b/handler/mac/exception_handler_server.cc index 3f30e03a1d..83bb269686 100644 --- a/handler/mac/exception_handler_server.cc +++ b/handler/mac/exception_handler_server.cc @@ -50,6 +50,10 @@ class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface, composite_mach_message_server_.AddHandler(¬ify_server_); } + ExceptionHandlerServerRun(const ExceptionHandlerServerRun&) = delete; + ExceptionHandlerServerRun& operator=(const ExceptionHandlerServerRun&) = + delete; + ~ExceptionHandlerServerRun() { } @@ -183,8 +187,6 @@ class ExceptionHandlerServerRun : public UniversalMachExcServer::Interface, mach_port_t notify_port_; // weak bool running_; bool launchd_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServerRun); }; } // namespace diff --git a/handler/mac/exception_handler_server.h b/handler/mac/exception_handler_server.h index 272cf76244..c27ecf340f 100644 --- a/handler/mac/exception_handler_server.h +++ b/handler/mac/exception_handler_server.h @@ -18,7 +18,6 @@ #include #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "util/mach/exc_server_variants.h" namespace crashpad { @@ -37,6 +36,10 @@ class ExceptionHandlerServer { //! signal. ExceptionHandlerServer(base::mac::ScopedMachReceiveRight receive_port, bool launchd); + + ExceptionHandlerServer(const ExceptionHandlerServer&) = delete; + ExceptionHandlerServer& operator=(const ExceptionHandlerServer&) = delete; + ~ExceptionHandlerServer(); //! \brief Runs the exception-handling server. @@ -73,8 +76,6 @@ class ExceptionHandlerServer { base::mac::ScopedMachReceiveRight receive_port_; base::mac::ScopedMachReceiveRight notify_port_; bool launchd_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); }; } // namespace crashpad diff --git a/handler/prune_crash_reports_thread.h b/handler/prune_crash_reports_thread.h index 0fd365b0e7..5009ed6559 100644 --- a/handler/prune_crash_reports_thread.h +++ b/handler/prune_crash_reports_thread.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/thread/stoppable.h" #include "util/thread/worker_thread.h" @@ -41,6 +40,10 @@ class PruneCrashReportThread : public WorkerThread::Delegate, public Stoppable { //! pruning. PruneCrashReportThread(CrashReportDatabase* database, std::unique_ptr condition); + + PruneCrashReportThread(const PruneCrashReportThread&) = delete; + PruneCrashReportThread& operator=(const PruneCrashReportThread&) = delete; + ~PruneCrashReportThread(); // Stoppable: @@ -70,8 +73,6 @@ class PruneCrashReportThread : public WorkerThread::Delegate, public Stoppable { WorkerThread thread_; std::unique_ptr condition_; CrashReportDatabase* database_; // weak - - DISALLOW_COPY_AND_ASSIGN(PruneCrashReportThread); }; } // namespace crashpad diff --git a/handler/win/crash_report_exception_handler.h b/handler/win/crash_report_exception_handler.h index cefb898194..d322370f14 100644 --- a/handler/win/crash_report_exception_handler.h +++ b/handler/win/crash_report_exception_handler.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "handler/user_stream_data_source.h" #include "util/win/exception_handler_server.h" @@ -63,6 +62,10 @@ class CrashReportExceptionHandler final const std::vector* attachments, const UserStreamDataSources* user_stream_data_sources); + CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete; + CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) = + delete; + ~CrashReportExceptionHandler(); // ExceptionHandlerServer::Delegate: @@ -81,8 +84,6 @@ class CrashReportExceptionHandler final const std::map* process_annotations_; // weak const std::vector* attachments_; // weak const UserStreamDataSources* user_stream_data_sources_; // weak - - DISALLOW_COPY_AND_ASSIGN(CrashReportExceptionHandler); }; } // namespace crashpad diff --git a/minidump/minidump_annotation_writer.h b/minidump/minidump_annotation_writer.h index fc30dbc3a4..ffb931de44 100644 --- a/minidump/minidump_annotation_writer.h +++ b/minidump/minidump_annotation_writer.h @@ -36,6 +36,10 @@ namespace crashpad { class MinidumpAnnotationWriter final : public internal::MinidumpWritable { public: MinidumpAnnotationWriter(); + + MinidumpAnnotationWriter(const MinidumpAnnotationWriter&) = delete; + MinidumpAnnotationWriter& operator=(const MinidumpAnnotationWriter&) = delete; + ~MinidumpAnnotationWriter(); //! \brief Initializes the annotation writer with data from an @@ -62,8 +66,6 @@ class MinidumpAnnotationWriter final : public internal::MinidumpWritable { MinidumpAnnotation annotation_; internal::MinidumpUTF8StringWriter name_; MinidumpByteArrayWriter value_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpAnnotationWriter); }; //! \brief The writer for a MinidumpAnnotationList object in a minidump file, @@ -71,6 +73,11 @@ class MinidumpAnnotationWriter final : public internal::MinidumpWritable { class MinidumpAnnotationListWriter final : public internal::MinidumpWritable { public: MinidumpAnnotationListWriter(); + + MinidumpAnnotationListWriter(const MinidumpAnnotationListWriter&) = delete; + MinidumpAnnotationListWriter& operator=(const MinidumpAnnotationListWriter&) = + delete; + ~MinidumpAnnotationListWriter(); //! \brief Initializes the annotation list writer with a list of @@ -100,8 +107,6 @@ class MinidumpAnnotationListWriter final : public internal::MinidumpWritable { private: std::unique_ptr minidump_list_; std::vector> objects_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpAnnotationListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_byte_array_writer.h b/minidump/minidump_byte_array_writer.h index c399f0358d..2cbc279c59 100644 --- a/minidump/minidump_byte_array_writer.h +++ b/minidump/minidump_byte_array_writer.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_writable.h" @@ -29,6 +28,10 @@ namespace crashpad { class MinidumpByteArrayWriter final : public internal::MinidumpWritable { public: MinidumpByteArrayWriter(); + + MinidumpByteArrayWriter(const MinidumpByteArrayWriter&) = delete; + MinidumpByteArrayWriter& operator=(const MinidumpByteArrayWriter&) = delete; + ~MinidumpByteArrayWriter() override; //! \brief Sets the data to be written. @@ -56,8 +59,6 @@ class MinidumpByteArrayWriter final : public internal::MinidumpWritable { private: std::unique_ptr minidump_array_; std::vector data_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpByteArrayWriter); }; } // namespace crashpad diff --git a/minidump/minidump_context_writer.h b/minidump/minidump_context_writer.h index d4ab936ee7..80b312b23c 100644 --- a/minidump/minidump_context_writer.h +++ b/minidump/minidump_context_writer.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "minidump/minidump_context.h" #include "minidump/minidump_writable.h" @@ -33,6 +32,9 @@ struct CPUContextX86_64; //! files. class MinidumpContextWriter : public internal::MinidumpWritable { public: + MinidumpContextWriter(const MinidumpContextWriter&) = delete; + MinidumpContextWriter& operator=(const MinidumpContextWriter&) = delete; + ~MinidumpContextWriter() override; //! \brief Creates a MinidumpContextWriter based on \a context_snapshot. @@ -59,15 +61,16 @@ class MinidumpContextWriter : public internal::MinidumpWritable { // MinidumpWritable: size_t SizeOfObject() final; - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpContextWriter); }; //! \brief The writer for a MinidumpContextX86 structure in a minidump file. class MinidumpContextX86Writer final : public MinidumpContextWriter { public: MinidumpContextX86Writer(); + + MinidumpContextX86Writer(const MinidumpContextX86Writer&) = delete; + MinidumpContextX86Writer& operator=(const MinidumpContextX86Writer&) = delete; + ~MinidumpContextX86Writer() override; //! \brief Initializes the MinidumpContextX86 based on \a context_snapshot. @@ -100,14 +103,17 @@ class MinidumpContextX86Writer final : public MinidumpContextWriter { private: MinidumpContextX86 context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextX86Writer); }; //! \brief The writer for a MinidumpContextAMD64 structure in a minidump file. class MinidumpContextAMD64Writer final : public MinidumpContextWriter { public: MinidumpContextAMD64Writer(); + + MinidumpContextAMD64Writer(const MinidumpContextAMD64Writer&) = delete; + MinidumpContextAMD64Writer& operator=(const MinidumpContextAMD64Writer&) = + delete; + ~MinidumpContextAMD64Writer() override; // Ensure proper alignment of heap-allocated objects. This should not be @@ -151,14 +157,16 @@ class MinidumpContextAMD64Writer final : public MinidumpContextWriter { private: MinidumpContextAMD64 context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextAMD64Writer); }; //! \brief The writer for a MinidumpContextARM structure in a minidump file. class MinidumpContextARMWriter final : public MinidumpContextWriter { public: MinidumpContextARMWriter(); + + MinidumpContextARMWriter(const MinidumpContextARMWriter&) = delete; + MinidumpContextARMWriter& operator=(const MinidumpContextARMWriter&) = delete; + ~MinidumpContextARMWriter() override; //! \brief Initializes the MinidumpContextARM based on \a context_snapshot. @@ -191,14 +199,17 @@ class MinidumpContextARMWriter final : public MinidumpContextWriter { private: MinidumpContextARM context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextARMWriter); }; //! \brief The writer for a MinidumpContextARM64 structure in a minidump file. class MinidumpContextARM64Writer final : public MinidumpContextWriter { public: MinidumpContextARM64Writer(); + + MinidumpContextARM64Writer(const MinidumpContextARM64Writer&) = delete; + MinidumpContextARM64Writer& operator=(const MinidumpContextARM64Writer&) = + delete; + ~MinidumpContextARM64Writer() override; //! \brief Initializes the MinidumpContextARM64 based on \a context_snapshot. @@ -231,14 +242,17 @@ class MinidumpContextARM64Writer final : public MinidumpContextWriter { private: MinidumpContextARM64 context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextARM64Writer); }; //! \brief The writer for a MinidumpContextMIPS structure in a minidump file. class MinidumpContextMIPSWriter final : public MinidumpContextWriter { public: MinidumpContextMIPSWriter(); + + MinidumpContextMIPSWriter(const MinidumpContextMIPSWriter&) = delete; + MinidumpContextMIPSWriter& operator=(const MinidumpContextMIPSWriter&) = + delete; + ~MinidumpContextMIPSWriter() override; //! \brief Initializes the MinidumpContextMIPS based on \a context_snapshot. @@ -271,14 +285,17 @@ class MinidumpContextMIPSWriter final : public MinidumpContextWriter { private: MinidumpContextMIPS context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextMIPSWriter); }; //! \brief The writer for a MinidumpContextMIPS64 structure in a minidump file. class MinidumpContextMIPS64Writer final : public MinidumpContextWriter { public: MinidumpContextMIPS64Writer(); + + MinidumpContextMIPS64Writer(const MinidumpContextMIPS64Writer&) = delete; + MinidumpContextMIPS64Writer& operator=(const MinidumpContextMIPS64Writer&) = + delete; + ~MinidumpContextMIPS64Writer() override; //! \brief Initializes the MinidumpContextMIPS based on \a context_snapshot. @@ -311,8 +328,6 @@ class MinidumpContextMIPS64Writer final : public MinidumpContextWriter { private: MinidumpContextMIPS64 context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpContextMIPS64Writer); }; } // namespace crashpad diff --git a/minidump/minidump_crashpad_info_writer.h b/minidump/minidump_crashpad_info_writer.h index 4624b24d23..b7aa2d895a 100644 --- a/minidump/minidump_crashpad_info_writer.h +++ b/minidump/minidump_crashpad_info_writer.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_stream_writer.h" #include "util/misc/uuid.h" @@ -35,6 +34,11 @@ class ProcessSnapshot; class MinidumpCrashpadInfoWriter final : public internal::MinidumpStreamWriter { public: MinidumpCrashpadInfoWriter(); + + MinidumpCrashpadInfoWriter(const MinidumpCrashpadInfoWriter&) = delete; + MinidumpCrashpadInfoWriter& operator=(const MinidumpCrashpadInfoWriter&) = + delete; + ~MinidumpCrashpadInfoWriter() override; //! \brief Initializes MinidumpCrashpadInfo based on \a process_snapshot. @@ -105,8 +109,6 @@ class MinidumpCrashpadInfoWriter final : public internal::MinidumpStreamWriter { MinidumpCrashpadInfo crashpad_info_; std::unique_ptr simple_annotations_; std::unique_ptr module_list_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpCrashpadInfoWriter); }; } // namespace crashpad diff --git a/minidump/minidump_exception_writer.h b/minidump/minidump_exception_writer.h index cc8c6bef04..82299a5a75 100644 --- a/minidump/minidump_exception_writer.h +++ b/minidump/minidump_exception_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_thread_id_map.h" @@ -37,6 +36,10 @@ class MinidumpMemoryListWriter; class MinidumpExceptionWriter final : public internal::MinidumpStreamWriter { public: MinidumpExceptionWriter(); + + MinidumpExceptionWriter(const MinidumpExceptionWriter&) = delete; + MinidumpExceptionWriter& operator=(const MinidumpExceptionWriter&) = delete; + ~MinidumpExceptionWriter() override; //! \brief Initializes the MINIDUMP_EXCEPTION_STREAM based on \a @@ -117,8 +120,6 @@ class MinidumpExceptionWriter final : public internal::MinidumpStreamWriter { private: MINIDUMP_EXCEPTION_STREAM exception_; std::unique_ptr context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpExceptionWriter); }; } // namespace crashpad diff --git a/minidump/minidump_file_writer.h b/minidump/minidump_file_writer.h index 0a1b064f42..443a947e9d 100644 --- a/minidump/minidump_file_writer.h +++ b/minidump/minidump_file_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -41,6 +40,10 @@ class MinidumpUserExtensionStreamDataSource; class MinidumpFileWriter final : public internal::MinidumpWritable { public: MinidumpFileWriter(); + + MinidumpFileWriter(const MinidumpFileWriter&) = delete; + MinidumpFileWriter& operator=(const MinidumpFileWriter&) = delete; + ~MinidumpFileWriter() override; //! \brief Initializes the MinidumpFileWriter and populates it with @@ -163,8 +166,6 @@ class MinidumpFileWriter final : public internal::MinidumpWritable { // Protects against multiple streams with the same ID being added. std::set stream_types_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpFileWriter); }; } // namespace crashpad diff --git a/minidump/minidump_file_writer_test.cc b/minidump/minidump_file_writer_test.cc index c5d2845df0..efeaeab4cb 100644 --- a/minidump/minidump_file_writer_test.cc +++ b/minidump/minidump_file_writer_test.cc @@ -64,6 +64,9 @@ class TestStream final : public internal::MinidumpStreamWriter { uint8_t stream_value) : stream_data_(stream_size, stream_value), stream_type_(stream_type) {} + TestStream(const TestStream&) = delete; + TestStream& operator=(const TestStream&) = delete; + ~TestStream() override {} // MinidumpStreamWriter: @@ -86,13 +89,15 @@ class TestStream final : public internal::MinidumpStreamWriter { private: std::string stream_data_; MinidumpStreamType stream_type_; - - DISALLOW_COPY_AND_ASSIGN(TestStream); }; class StringFileOutputStream : public OutputStreamInterface { public: StringFileOutputStream() = default; + + StringFileOutputStream(const StringFileOutputStream&) = delete; + StringFileOutputStream& operator=(const StringFileOutputStream&) = delete; + ~StringFileOutputStream() override = default; bool Write(const uint8_t* data, size_t size) override { return string_file_.Write(data, size); @@ -102,8 +107,6 @@ class StringFileOutputStream : public OutputStreamInterface { private: StringFile string_file_; - - DISALLOW_COPY_AND_ASSIGN(StringFileOutputStream); }; TEST(MinidumpFileWriter, OneStream) { diff --git a/minidump/minidump_handle_writer.h b/minidump/minidump_handle_writer.h index f8eaeef941..348f55e814 100644 --- a/minidump/minidump_handle_writer.h +++ b/minidump/minidump_handle_writer.h @@ -43,6 +43,10 @@ namespace crashpad { class MinidumpHandleDataWriter final : public internal::MinidumpStreamWriter { public: MinidumpHandleDataWriter(); + + MinidumpHandleDataWriter(const MinidumpHandleDataWriter&) = delete; + MinidumpHandleDataWriter& operator=(const MinidumpHandleDataWriter&) = delete; + ~MinidumpHandleDataWriter() override; //! \brief Adds a MINIDUMP_HANDLE_DESCRIPTOR for each handle in \a @@ -68,8 +72,6 @@ class MinidumpHandleDataWriter final : public internal::MinidumpStreamWriter { MINIDUMP_HANDLE_DATA_STREAM handle_data_stream_base_; std::vector handle_descriptors_; std::map strings_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpHandleDataWriter); }; } // namespace crashpad diff --git a/minidump/minidump_memory_info_writer.h b/minidump/minidump_memory_info_writer.h index ec66019703..a4159a7d3b 100644 --- a/minidump/minidump_memory_info_writer.h +++ b/minidump/minidump_memory_info_writer.h @@ -22,7 +22,6 @@ #include -#include "base/macros.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -39,6 +38,11 @@ class MinidumpMemoryInfoListWriter final : public internal::MinidumpStreamWriter { public: MinidumpMemoryInfoListWriter(); + + MinidumpMemoryInfoListWriter(const MinidumpMemoryInfoListWriter&) = delete; + MinidumpMemoryInfoListWriter& operator=(const MinidumpMemoryInfoListWriter&) = + delete; + ~MinidumpMemoryInfoListWriter() override; //! \brief Initializes a MINIDUMP_MEMORY_INFO_LIST based on \a memory_map. @@ -63,8 +67,6 @@ class MinidumpMemoryInfoListWriter final private: MINIDUMP_MEMORY_INFO_LIST memory_info_list_base_; std::vector items_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryInfoListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_memory_writer.h b/minidump/minidump_memory_writer.h index 4f4f27f6cd..ef18de24b0 100644 --- a/minidump/minidump_memory_writer.h +++ b/minidump/minidump_memory_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" #include "snapshot/memory_snapshot.h" @@ -37,6 +36,11 @@ class SnapshotMinidumpMemoryWriter : public internal::MinidumpWritable, public MemorySnapshot::Delegate { public: explicit SnapshotMinidumpMemoryWriter(const MemorySnapshot* memory_snapshot); + + SnapshotMinidumpMemoryWriter(const SnapshotMinidumpMemoryWriter&) = delete; + SnapshotMinidumpMemoryWriter& operator=(const SnapshotMinidumpMemoryWriter&) = + delete; + ~SnapshotMinidumpMemoryWriter() override; //! \brief Returns a MINIDUMP_MEMORY_DESCRIPTOR referencing the data that this @@ -111,8 +115,6 @@ class SnapshotMinidumpMemoryWriter : public internal::MinidumpWritable, std::vector registered_memory_descriptors_; const MemorySnapshot* memory_snapshot_; FileWriterInterface* file_writer_; - - DISALLOW_COPY_AND_ASSIGN(SnapshotMinidumpMemoryWriter); }; //! \brief The writer for a MINIDUMP_MEMORY_LIST stream in a minidump file, @@ -120,6 +122,10 @@ class SnapshotMinidumpMemoryWriter : public internal::MinidumpWritable, class MinidumpMemoryListWriter final : public internal::MinidumpStreamWriter { public: MinidumpMemoryListWriter(); + + MinidumpMemoryListWriter(const MinidumpMemoryListWriter&) = delete; + MinidumpMemoryListWriter& operator=(const MinidumpMemoryListWriter&) = delete; + ~MinidumpMemoryListWriter() override; //! \brief Adds a concrete initialized SnapshotMinidumpMemoryWriter for each @@ -197,8 +203,6 @@ class MinidumpMemoryListWriter final : public internal::MinidumpStreamWriter { snapshots_created_during_merge_; std::vector all_memory_writers_; // weak MINIDUMP_MEMORY_LIST memory_list_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_memory_writer_test.cc b/minidump/minidump_memory_writer_test.cc index 24dac9bc0e..02a352fcea 100644 --- a/minidump/minidump_memory_writer_test.cc +++ b/minidump/minidump_memory_writer_test.cc @@ -235,6 +235,9 @@ class TestMemoryStream final : public internal::MinidumpStreamWriter { TestMemoryStream(uint64_t base_address, size_t size, uint8_t value) : MinidumpStreamWriter(), memory_(base_address, size, value) {} + TestMemoryStream(const TestMemoryStream&) = delete; + TestMemoryStream& operator=(const TestMemoryStream&) = delete; + ~TestMemoryStream() override {} TestMinidumpMemoryWriter* memory() { @@ -266,8 +269,6 @@ class TestMemoryStream final : public internal::MinidumpStreamWriter { private: TestMinidumpMemoryWriter memory_; - - DISALLOW_COPY_AND_ASSIGN(TestMemoryStream); }; TEST(MinidumpMemoryWriter, ExtraMemory) { diff --git a/minidump/minidump_misc_info_writer.h b/minidump/minidump_misc_info_writer.h index 0905e80599..9d89fe6480 100644 --- a/minidump/minidump_misc_info_writer.h +++ b/minidump/minidump_misc_info_writer.h @@ -24,7 +24,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -60,6 +59,10 @@ std::string MinidumpMiscInfoDebugBuildString(); class MinidumpMiscInfoWriter final : public internal::MinidumpStreamWriter { public: MinidumpMiscInfoWriter(); + + MinidumpMiscInfoWriter(const MinidumpMiscInfoWriter&) = delete; + MinidumpMiscInfoWriter& operator=(const MinidumpMiscInfoWriter&) = delete; + ~MinidumpMiscInfoWriter() override; //! \brief Initializes MINIDUMP_MISC_INFO_N based on \a process_snapshot. @@ -135,8 +138,6 @@ class MinidumpMiscInfoWriter final : public internal::MinidumpStreamWriter { MINIDUMP_MISC_INFO_N misc_info_; bool has_xstate_data_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpMiscInfoWriter); }; //! \brief Conversion functions from a native UTF16 C-string to a char16_t diff --git a/minidump/minidump_module_crashpad_info_writer.h b/minidump/minidump_module_crashpad_info_writer.h index 850db04038..9af5c83fa3 100644 --- a/minidump/minidump_module_crashpad_info_writer.h +++ b/minidump/minidump_module_crashpad_info_writer.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_string_writer.h" #include "minidump/minidump_writable.h" @@ -38,6 +37,12 @@ class MinidumpModuleCrashpadInfoWriter final : public internal::MinidumpWritable { public: MinidumpModuleCrashpadInfoWriter(); + + MinidumpModuleCrashpadInfoWriter(const MinidumpModuleCrashpadInfoWriter&) = + delete; + MinidumpModuleCrashpadInfoWriter& operator=( + const MinidumpModuleCrashpadInfoWriter&) = delete; + ~MinidumpModuleCrashpadInfoWriter() override; //! \brief Initializes MinidumpModuleCrashpadInfo based on \a module_snapshot. @@ -107,8 +112,6 @@ class MinidumpModuleCrashpadInfoWriter final std::unique_ptr list_annotations_; std::unique_ptr simple_annotations_; std::unique_ptr annotation_objects_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); }; //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump @@ -117,6 +120,12 @@ class MinidumpModuleCrashpadInfoListWriter final : public internal::MinidumpWritable { public: MinidumpModuleCrashpadInfoListWriter(); + + MinidumpModuleCrashpadInfoListWriter( + const MinidumpModuleCrashpadInfoListWriter&) = delete; + MinidumpModuleCrashpadInfoListWriter& operator=( + const MinidumpModuleCrashpadInfoListWriter&) = delete; + ~MinidumpModuleCrashpadInfoListWriter() override; //! \brief Adds an initialized MinidumpModuleCrashpadInfo for modules in \a @@ -171,8 +180,6 @@ class MinidumpModuleCrashpadInfoListWriter final module_crashpad_infos_; std::vector module_crashpad_info_links_; MinidumpModuleCrashpadInfoList module_crashpad_info_list_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_module_writer.h b/minidump/minidump_module_writer.h index 423b9b5058..d450892c8e 100644 --- a/minidump/minidump_module_writer.h +++ b/minidump/minidump_module_writer.h @@ -25,7 +25,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -42,13 +41,15 @@ class MinidumpUTF16StringWriter; //! MINIDUMP_MODULE::CvRecord in minidump files. class MinidumpModuleCodeViewRecordWriter : public internal::MinidumpWritable { public: + MinidumpModuleCodeViewRecordWriter( + const MinidumpModuleCodeViewRecordWriter&) = delete; + MinidumpModuleCodeViewRecordWriter& operator=( + const MinidumpModuleCodeViewRecordWriter&) = delete; + ~MinidumpModuleCodeViewRecordWriter() override; protected: MinidumpModuleCodeViewRecordWriter() : MinidumpWritable() {} - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordWriter); }; namespace internal { @@ -59,6 +60,11 @@ template class MinidumpModuleCodeViewRecordPDBLinkWriter : public MinidumpModuleCodeViewRecordWriter { public: + MinidumpModuleCodeViewRecordPDBLinkWriter( + const MinidumpModuleCodeViewRecordPDBLinkWriter&) = delete; + MinidumpModuleCodeViewRecordPDBLinkWriter& operator=( + const MinidumpModuleCodeViewRecordPDBLinkWriter&) = delete; + //! \brief Sets the name of the `.pdb` file being linked to. void SetPDBName(const std::string& pdb_name) { pdb_name_ = pdb_name; } @@ -79,8 +85,6 @@ class MinidumpModuleCodeViewRecordPDBLinkWriter private: CodeViewRecordType codeview_record_; std::string pdb_name_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordPDBLinkWriter); }; } // namespace internal @@ -97,13 +101,15 @@ class MinidumpModuleCodeViewRecordPDB20Writer final : internal::MinidumpModuleCodeViewRecordPDBLinkWriter< CodeViewRecordPDB20>() {} + MinidumpModuleCodeViewRecordPDB20Writer( + const MinidumpModuleCodeViewRecordPDB20Writer&) = delete; + MinidumpModuleCodeViewRecordPDB20Writer& operator=( + const MinidumpModuleCodeViewRecordPDB20Writer&) = delete; + ~MinidumpModuleCodeViewRecordPDB20Writer() override; //! \brief Sets CodeViewRecordPDB20::timestamp and CodeViewRecordPDB20::age. void SetTimestampAndAge(time_t timestamp, uint32_t age); - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordPDB20Writer); }; //! \brief The writer for a CodeViewRecordPDB70 object in a minidump file. @@ -115,6 +121,11 @@ class MinidumpModuleCodeViewRecordPDB70Writer final : internal::MinidumpModuleCodeViewRecordPDBLinkWriter< CodeViewRecordPDB70>() {} + MinidumpModuleCodeViewRecordPDB70Writer( + const MinidumpModuleCodeViewRecordPDB70Writer&) = delete; + MinidumpModuleCodeViewRecordPDB70Writer& operator=( + const MinidumpModuleCodeViewRecordPDB70Writer&) = delete; + ~MinidumpModuleCodeViewRecordPDB70Writer() override; //! \brief Initializes the CodeViewRecordPDB70 based on \a module_snapshot. @@ -131,9 +142,6 @@ class MinidumpModuleCodeViewRecordPDB70Writer final codeview_record()->uuid = uuid; codeview_record()->age = age; } - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordPDB70Writer); }; //! \brief The writer for a CodeViewRecordBuildID object in a minidump file. @@ -141,6 +149,12 @@ class MinidumpModuleCodeViewRecordBuildIDWriter final : public MinidumpModuleCodeViewRecordWriter { public: MinidumpModuleCodeViewRecordBuildIDWriter(); + + MinidumpModuleCodeViewRecordBuildIDWriter( + const MinidumpModuleCodeViewRecordBuildIDWriter&) = delete; + MinidumpModuleCodeViewRecordBuildIDWriter& operator=( + const MinidumpModuleCodeViewRecordBuildIDWriter&) = delete; + ~MinidumpModuleCodeViewRecordBuildIDWriter() override; //! \brief Sets the build ID used for symbol lookup. @@ -152,8 +166,6 @@ class MinidumpModuleCodeViewRecordBuildIDWriter final bool WriteObject(FileWriterInterface* file_writer) override; std::vector build_id_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordBuildIDWriter); }; //! \brief The writer for an IMAGE_DEBUG_MISC object in a minidump file. @@ -163,6 +175,12 @@ class MinidumpModuleMiscDebugRecordWriter final : public internal::MinidumpWritable { public: MinidumpModuleMiscDebugRecordWriter(); + + MinidumpModuleMiscDebugRecordWriter( + const MinidumpModuleMiscDebugRecordWriter&) = delete; + MinidumpModuleMiscDebugRecordWriter& operator=( + const MinidumpModuleMiscDebugRecordWriter&) = delete; + ~MinidumpModuleMiscDebugRecordWriter() override; //! \brief Sets IMAGE_DEBUG_MISC::DataType. @@ -189,8 +207,6 @@ class MinidumpModuleMiscDebugRecordWriter final IMAGE_DEBUG_MISC image_debug_misc_; std::string data_; std::u16string data_utf16_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleMiscDebugRecordWriter); }; //! \brief The writer for a MINIDUMP_MODULE object in a minidump file. @@ -202,6 +218,10 @@ class MinidumpModuleMiscDebugRecordWriter final class MinidumpModuleWriter final : public internal::MinidumpWritable { public: MinidumpModuleWriter(); + + MinidumpModuleWriter(const MinidumpModuleWriter&) = delete; + MinidumpModuleWriter& operator=(const MinidumpModuleWriter&) = delete; + ~MinidumpModuleWriter() override; //! \brief Initializes the MINIDUMP_MODULE based on \a module_snapshot. @@ -320,8 +340,6 @@ class MinidumpModuleWriter final : public internal::MinidumpWritable { std::unique_ptr name_; std::unique_ptr codeview_record_; std::unique_ptr misc_debug_record_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleWriter); }; //! \brief The writer for a MINIDUMP_MODULE_LIST stream in a minidump file, @@ -329,6 +347,10 @@ class MinidumpModuleWriter final : public internal::MinidumpWritable { class MinidumpModuleListWriter final : public internal::MinidumpStreamWriter { public: MinidumpModuleListWriter(); + + MinidumpModuleListWriter(const MinidumpModuleListWriter&) = delete; + MinidumpModuleListWriter& operator=(const MinidumpModuleListWriter&) = delete; + ~MinidumpModuleListWriter() override; //! \brief Adds an initialized MINIDUMP_MODULE for each module in \a @@ -363,8 +385,6 @@ class MinidumpModuleListWriter final : public internal::MinidumpStreamWriter { private: std::vector> modules_; MINIDUMP_MODULE_LIST module_list_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpModuleListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_rva_list_writer.h b/minidump/minidump_rva_list_writer.h index af584f13cc..ba7bd68644 100644 --- a/minidump/minidump_rva_list_writer.h +++ b/minidump/minidump_rva_list_writer.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_writable.h" @@ -33,6 +32,10 @@ namespace internal { class MinidumpRVAListWriter : public MinidumpWritable { protected: MinidumpRVAListWriter(); + + MinidumpRVAListWriter(const MinidumpRVAListWriter&) = delete; + MinidumpRVAListWriter& operator=(const MinidumpRVAListWriter&) = delete; + ~MinidumpRVAListWriter() override; //! \brief Adds an ::RVA referencing an MinidumpWritable to the @@ -68,8 +71,6 @@ class MinidumpRVAListWriter : public MinidumpWritable { std::unique_ptr rva_list_base_; std::vector> children_; std::vector child_rvas_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpRVAListWriter); }; } // namespace internal diff --git a/minidump/minidump_rva_list_writer_test.cc b/minidump/minidump_rva_list_writer_test.cc index 8ae2b9e88d..f99d9435c2 100644 --- a/minidump/minidump_rva_list_writer_test.cc +++ b/minidump/minidump_rva_list_writer_test.cc @@ -31,15 +31,17 @@ namespace { class TestMinidumpRVAListWriter final : public internal::MinidumpRVAListWriter { public: TestMinidumpRVAListWriter() : MinidumpRVAListWriter() {} + + TestMinidumpRVAListWriter(const TestMinidumpRVAListWriter&) = delete; + TestMinidumpRVAListWriter& operator=(const TestMinidumpRVAListWriter&) = + delete; + ~TestMinidumpRVAListWriter() override {} void AddChild(uint32_t value) { auto child = std::make_unique(value); MinidumpRVAListWriter::AddChild(std::move(child)); } - - private: - DISALLOW_COPY_AND_ASSIGN(TestMinidumpRVAListWriter); }; TEST(MinidumpRVAListWriter, Empty) { diff --git a/minidump/minidump_simple_string_dictionary_writer.h b/minidump/minidump_simple_string_dictionary_writer.h index f2662bccff..5e46a64795 100644 --- a/minidump/minidump_simple_string_dictionary_writer.h +++ b/minidump/minidump_simple_string_dictionary_writer.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_string_writer.h" #include "minidump/minidump_writable.h" @@ -41,6 +40,12 @@ class MinidumpSimpleStringDictionaryEntryWriter final : public internal::MinidumpWritable { public: MinidumpSimpleStringDictionaryEntryWriter(); + + MinidumpSimpleStringDictionaryEntryWriter( + const MinidumpSimpleStringDictionaryEntryWriter&) = delete; + MinidumpSimpleStringDictionaryEntryWriter& operator=( + const MinidumpSimpleStringDictionaryEntryWriter&) = delete; + ~MinidumpSimpleStringDictionaryEntryWriter() override; //! \brief Returns a MinidumpSimpleStringDictionaryEntry referencing this @@ -76,8 +81,6 @@ class MinidumpSimpleStringDictionaryEntryWriter final struct MinidumpSimpleStringDictionaryEntry entry_; internal::MinidumpUTF8StringWriter key_; internal::MinidumpUTF8StringWriter value_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryEntryWriter); }; //! \brief The writer for a MinidumpSimpleStringDictionary object in a minidump @@ -89,6 +92,12 @@ class MinidumpSimpleStringDictionaryWriter final : public internal::MinidumpWritable { public: MinidumpSimpleStringDictionaryWriter(); + + MinidumpSimpleStringDictionaryWriter( + const MinidumpSimpleStringDictionaryWriter&) = delete; + MinidumpSimpleStringDictionaryWriter& operator=( + const MinidumpSimpleStringDictionaryWriter&) = delete; + ~MinidumpSimpleStringDictionaryWriter() override; //! \brief Adds an initialized MinidumpSimpleStringDictionaryEntryWriter for @@ -138,8 +147,6 @@ class MinidumpSimpleStringDictionaryWriter final std::unique_ptr simple_string_dictionary_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryWriter); }; } // namespace crashpad diff --git a/minidump/minidump_stream_writer.h b/minidump/minidump_stream_writer.h index 894889ae8d..447566b902 100644 --- a/minidump/minidump_stream_writer.h +++ b/minidump/minidump_stream_writer.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_writable.h" @@ -32,6 +31,9 @@ namespace internal { //! MinidumpFileWriter object. class MinidumpStreamWriter : public MinidumpWritable { public: + MinidumpStreamWriter(const MinidumpStreamWriter&) = delete; + MinidumpStreamWriter& operator=(const MinidumpStreamWriter&) = delete; + ~MinidumpStreamWriter() override; //! \brief Returns an object’s stream type. @@ -56,8 +58,6 @@ class MinidumpStreamWriter : public MinidumpWritable { private: MINIDUMP_DIRECTORY directory_list_entry_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpStreamWriter); }; } // namespace internal diff --git a/minidump/minidump_string_writer.h b/minidump/minidump_string_writer.h index 33186dd1d0..d11e8cc18e 100644 --- a/minidump/minidump_string_writer.h +++ b/minidump/minidump_string_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_rva_list_writer.h" #include "minidump/minidump_writable.h" @@ -55,6 +54,10 @@ template class MinidumpStringWriter : public MinidumpWritable { public: MinidumpStringWriter(); + + MinidumpStringWriter(const MinidumpStringWriter&) = delete; + MinidumpStringWriter& operator=(const MinidumpStringWriter&) = delete; + ~MinidumpStringWriter() override; protected: @@ -78,8 +81,6 @@ class MinidumpStringWriter : public MinidumpWritable { private: std::unique_ptr string_base_; StringType string_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpStringWriter); }; //! \brief Writes a variable-length UTF-16-encoded MINIDUMP_STRING to a minidump @@ -91,6 +92,11 @@ class MinidumpUTF16StringWriter final : public MinidumpStringWriter { public: MinidumpUTF16StringWriter() : MinidumpStringWriter() {} + + MinidumpUTF16StringWriter(const MinidumpUTF16StringWriter&) = delete; + MinidumpUTF16StringWriter& operator=(const MinidumpUTF16StringWriter&) = + delete; + ~MinidumpUTF16StringWriter() override; //! \brief Converts a UTF-8 string to UTF-16 and sets it as the string to be @@ -98,9 +104,6 @@ class MinidumpUTF16StringWriter final //! //! \note Valid in #kStateMutable. void SetUTF8(const std::string& string_utf8); - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpUTF16StringWriter); }; //! \brief Writes a variable-length UTF-8-encoded MinidumpUTF8String to a @@ -112,6 +115,10 @@ class MinidumpUTF8StringWriter final : public MinidumpStringWriter { public: MinidumpUTF8StringWriter() : MinidumpStringWriter() {} + + MinidumpUTF8StringWriter(const MinidumpUTF8StringWriter&) = delete; + MinidumpUTF8StringWriter& operator=(const MinidumpUTF8StringWriter&) = delete; + ~MinidumpUTF8StringWriter() override; //! \brief Sets the string to be written. @@ -123,9 +130,6 @@ class MinidumpUTF8StringWriter final //! //! \note Valid in any state. const std::string& UTF8() const { return string(); } - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter); }; //! \brief The writer for a MinidumpRVAList object in a minidump file, @@ -134,6 +138,10 @@ template class MinidumpStringListWriter final : public MinidumpRVAListWriter { public: MinidumpStringListWriter(); + + MinidumpStringListWriter(const MinidumpStringListWriter&) = delete; + MinidumpStringListWriter& operator=(const MinidumpStringListWriter&) = delete; + ~MinidumpStringListWriter() override; //! \brief Adds a new \a Traits::MinidumpStringWriterType for each element in @@ -166,9 +174,6 @@ class MinidumpStringListWriter final : public MinidumpRVAListWriter { //! //! \return `true` if the object is useful, `false` otherwise. bool IsUseful() const; - - private: - DISALLOW_COPY_AND_ASSIGN(MinidumpStringListWriter); }; } // namespace internal diff --git a/minidump/minidump_system_info_writer.h b/minidump/minidump_system_info_writer.h index 866530c304..07dbcf35b8 100644 --- a/minidump/minidump_system_info_writer.h +++ b/minidump/minidump_system_info_writer.h @@ -24,7 +24,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -41,6 +40,10 @@ class MinidumpUTF16StringWriter; class MinidumpSystemInfoWriter final : public internal::MinidumpStreamWriter { public: MinidumpSystemInfoWriter(); + + MinidumpSystemInfoWriter(const MinidumpSystemInfoWriter&) = delete; + MinidumpSystemInfoWriter& operator=(const MinidumpSystemInfoWriter&) = delete; + ~MinidumpSystemInfoWriter() override; //! \brief Initializes MINIDUMP_SYSTEM_INFO based on \a system_snapshot. @@ -188,8 +191,6 @@ class MinidumpSystemInfoWriter final : public internal::MinidumpStreamWriter { private: MINIDUMP_SYSTEM_INFO system_info_; std::unique_ptr csd_version_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpSystemInfoWriter); }; } // namespace crashpad diff --git a/minidump/minidump_thread_id_map_test.cc b/minidump/minidump_thread_id_map_test.cc index 0c48c0192c..e972aebc9f 100644 --- a/minidump/minidump_thread_id_map_test.cc +++ b/minidump/minidump_thread_id_map_test.cc @@ -19,7 +19,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "snapshot/test/test_thread_snapshot.h" @@ -35,6 +34,9 @@ class MinidumpThreadIDMapTest : public testing::Test { test_thread_snapshots_() { } + MinidumpThreadIDMapTest(const MinidumpThreadIDMapTest&) = delete; + MinidumpThreadIDMapTest& operator=(const MinidumpThreadIDMapTest&) = delete; + ~MinidumpThreadIDMapTest() override {} // testing::Test: @@ -72,8 +74,6 @@ class MinidumpThreadIDMapTest : public testing::Test { private: std::vector thread_snapshots_; TestThreadSnapshot test_thread_snapshots_[5]; - - DISALLOW_COPY_AND_ASSIGN(MinidumpThreadIDMapTest); }; TEST_F(MinidumpThreadIDMapTest, NoThreads) { diff --git a/minidump/minidump_thread_writer.h b/minidump/minidump_thread_writer.h index 82092e2b61..9ea428bfc3 100644 --- a/minidump/minidump_thread_writer.h +++ b/minidump/minidump_thread_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_thread_id_map.h" #include "minidump/minidump_writable.h" @@ -44,6 +43,10 @@ class ThreadSnapshot; class MinidumpThreadWriter final : public internal::MinidumpWritable { public: MinidumpThreadWriter(); + + MinidumpThreadWriter(const MinidumpThreadWriter&) = delete; + MinidumpThreadWriter& operator=(const MinidumpThreadWriter&) = delete; + ~MinidumpThreadWriter() override; //! \brief Initializes the MINIDUMP_THREAD based on \a thread_snapshot. @@ -131,8 +134,6 @@ class MinidumpThreadWriter final : public internal::MinidumpWritable { MINIDUMP_THREAD thread_; std::unique_ptr stack_; std::unique_ptr context_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpThreadWriter); }; //! \brief The writer for a MINIDUMP_THREAD_LIST stream in a minidump file, @@ -140,6 +141,10 @@ class MinidumpThreadWriter final : public internal::MinidumpWritable { class MinidumpThreadListWriter final : public internal::MinidumpStreamWriter { public: MinidumpThreadListWriter(); + + MinidumpThreadListWriter(const MinidumpThreadListWriter&) = delete; + MinidumpThreadListWriter& operator=(const MinidumpThreadListWriter&) = delete; + ~MinidumpThreadListWriter() override; //! \brief Adds an initialized MINIDUMP_THREAD for each thread in \a @@ -205,8 +210,6 @@ class MinidumpThreadListWriter final : public internal::MinidumpStreamWriter { std::vector> threads_; MinidumpMemoryListWriter* memory_list_writer_; // weak MINIDUMP_THREAD_LIST thread_list_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpThreadListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_unloaded_module_writer.h b/minidump/minidump_unloaded_module_writer.h index 97651dbac8..6b3ac90591 100644 --- a/minidump/minidump_unloaded_module_writer.h +++ b/minidump/minidump_unloaded_module_writer.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_string_writer.h" #include "minidump/minidump_writable.h" @@ -41,6 +40,11 @@ namespace crashpad { class MinidumpUnloadedModuleWriter final : public internal::MinidumpWritable { public: MinidumpUnloadedModuleWriter(); + + MinidumpUnloadedModuleWriter(const MinidumpUnloadedModuleWriter&) = delete; + MinidumpUnloadedModuleWriter& operator=(const MinidumpUnloadedModuleWriter&) = + delete; + ~MinidumpUnloadedModuleWriter() override; //! \brief Initializes the MINIDUMP_UNLOADED_MODULE based on \a @@ -97,8 +101,6 @@ class MinidumpUnloadedModuleWriter final : public internal::MinidumpWritable { private: MINIDUMP_UNLOADED_MODULE unloaded_module_; std::unique_ptr name_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpUnloadedModuleWriter); }; //! \brief The writer for a MINIDUMP_UNLOADED_MODULE_LIST stream in a minidump @@ -107,6 +109,12 @@ class MinidumpUnloadedModuleListWriter final : public internal::MinidumpStreamWriter { public: MinidumpUnloadedModuleListWriter(); + + MinidumpUnloadedModuleListWriter(const MinidumpUnloadedModuleListWriter&) = + delete; + MinidumpUnloadedModuleListWriter& operator=( + const MinidumpUnloadedModuleListWriter&) = delete; + ~MinidumpUnloadedModuleListWriter() override; //! \brief Adds an initialized MINIDUMP_UNLOADED_MODULE for each unloaded @@ -145,8 +153,6 @@ class MinidumpUnloadedModuleListWriter final private: std::vector> unloaded_modules_; MINIDUMP_UNLOADED_MODULE_LIST unloaded_module_list_base_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpUnloadedModuleListWriter); }; } // namespace crashpad diff --git a/minidump/minidump_user_extension_stream_data_source.h b/minidump/minidump_user_extension_stream_data_source.h index 3eb0c8743a..4a45e45f1a 100644 --- a/minidump/minidump_user_extension_stream_data_source.h +++ b/minidump/minidump_user_extension_stream_data_source.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" @@ -54,6 +53,12 @@ class MinidumpUserExtensionStreamDataSource { //! //! \param[in] stream_type The type of the user extension stream. explicit MinidumpUserExtensionStreamDataSource(uint32_t stream_type); + + MinidumpUserExtensionStreamDataSource( + const MinidumpUserExtensionStreamDataSource&) = delete; + MinidumpUserExtensionStreamDataSource& operator=( + const MinidumpUserExtensionStreamDataSource&) = delete; + virtual ~MinidumpUserExtensionStreamDataSource(); MinidumpStreamType stream_type() const { return stream_type_; } @@ -75,8 +80,6 @@ class MinidumpUserExtensionStreamDataSource { private: MinidumpStreamType stream_type_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpUserExtensionStreamDataSource); }; } // namespace crashpad diff --git a/minidump/minidump_user_stream_writer.cc b/minidump/minidump_user_stream_writer.cc index 29bb71c614..4fbe252575 100644 --- a/minidump/minidump_user_stream_writer.cc +++ b/minidump/minidump_user_stream_writer.cc @@ -33,6 +33,9 @@ class MinidumpUserStreamWriter::SnapshotContentsWriter final explicit SnapshotContentsWriter(const MemorySnapshot* snapshot) : snapshot_(snapshot), writer_(nullptr) {} + SnapshotContentsWriter(const SnapshotContentsWriter&) = delete; + SnapshotContentsWriter& operator=(const SnapshotContentsWriter&) = delete; + bool WriteContents(FileWriterInterface* writer) override { DCHECK(!writer_); @@ -52,8 +55,6 @@ class MinidumpUserStreamWriter::SnapshotContentsWriter final private: const MemorySnapshot* snapshot_; FileWriterInterface* writer_; - - DISALLOW_COPY_AND_ASSIGN(SnapshotContentsWriter); }; class MinidumpUserStreamWriter::ExtensionStreamContentsWriter final @@ -64,6 +65,10 @@ class MinidumpUserStreamWriter::ExtensionStreamContentsWriter final std::unique_ptr data_source) : data_source_(std::move(data_source)), writer_(nullptr) {} + ExtensionStreamContentsWriter(const ExtensionStreamContentsWriter&) = delete; + ExtensionStreamContentsWriter& operator=( + const ExtensionStreamContentsWriter&) = delete; + bool WriteContents(FileWriterInterface* writer) override { DCHECK(!writer_); @@ -80,8 +85,6 @@ class MinidumpUserStreamWriter::ExtensionStreamContentsWriter final private: std::unique_ptr data_source_; FileWriterInterface* writer_; - - DISALLOW_COPY_AND_ASSIGN(ExtensionStreamContentsWriter); }; MinidumpUserStreamWriter::MinidumpUserStreamWriter() : stream_type_() {} diff --git a/minidump/minidump_user_stream_writer.h b/minidump/minidump_user_stream_writer.h index c1bad0ac92..8f123e2e09 100644 --- a/minidump/minidump_user_stream_writer.h +++ b/minidump/minidump_user_stream_writer.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -35,6 +34,10 @@ namespace crashpad { class MinidumpUserStreamWriter final : public internal::MinidumpStreamWriter { public: MinidumpUserStreamWriter(); + + MinidumpUserStreamWriter(const MinidumpUserStreamWriter&) = delete; + MinidumpUserStreamWriter& operator=(const MinidumpUserStreamWriter&) = delete; + ~MinidumpUserStreamWriter() override; //! \brief Initializes a MINIDUMP_USER_STREAM based on \a stream. @@ -70,8 +73,6 @@ class MinidumpUserStreamWriter final : public internal::MinidumpStreamWriter { std::unique_ptr contents_writer_; MinidumpStreamType stream_type_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpUserStreamWriter); }; } // namespace crashpad diff --git a/minidump/minidump_writable.h b/minidump/minidump_writable.h index b2ebf04e7d..bc36cb5c05 100644 --- a/minidump/minidump_writable.h +++ b/minidump/minidump_writable.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "util/file/file_io.h" namespace crashpad { @@ -35,6 +34,9 @@ namespace internal { //! file. class MinidumpWritable { public: + MinidumpWritable(const MinidumpWritable&) = delete; + MinidumpWritable& operator=(const MinidumpWritable&) = delete; + virtual ~MinidumpWritable(); //! \brief Writes an object and all of its children to a minidump file. @@ -270,8 +272,6 @@ class MinidumpWritable { size_t leading_pad_bytes_; State state_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpWritable); }; } // namespace internal diff --git a/minidump/minidump_writable_test.cc b/minidump/minidump_writable_test.cc index 74b51a83e8..ef34e54225 100644 --- a/minidump/minidump_writable_test.cc +++ b/minidump/minidump_writable_test.cc @@ -17,7 +17,6 @@ #include #include -#include "base/macros.h" #include "gtest/gtest.h" #include "util/file/string_file.h" @@ -37,6 +36,9 @@ class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable { has_phase_(false), verified_(false) {} + BaseTestMinidumpWritable(const BaseTestMinidumpWritable&) = delete; + BaseTestMinidumpWritable& operator=(const BaseTestMinidumpWritable&) = delete; + ~BaseTestMinidumpWritable() { EXPECT_TRUE(verified_); } void SetAlignment(size_t alignment) { @@ -113,14 +115,16 @@ class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable { bool has_alignment_; bool has_phase_; bool verified_; - - DISALLOW_COPY_AND_ASSIGN(BaseTestMinidumpWritable); }; class TestStringMinidumpWritable final : public BaseTestMinidumpWritable { public: TestStringMinidumpWritable() : BaseTestMinidumpWritable(), data_() {} + TestStringMinidumpWritable(const TestStringMinidumpWritable&) = delete; + TestStringMinidumpWritable& operator=(const TestStringMinidumpWritable&) = + delete; + ~TestStringMinidumpWritable() {} void SetData(const std::string& string) { data_ = string; } @@ -140,8 +144,6 @@ class TestStringMinidumpWritable final : public BaseTestMinidumpWritable { private: std::string data_; - - DISALLOW_COPY_AND_ASSIGN(TestStringMinidumpWritable); }; TEST(MinidumpWritable, MinidumpWritable) { @@ -487,6 +489,9 @@ class TestRVAMinidumpWritable final : public BaseTestMinidumpWritable { public: TestRVAMinidumpWritable() : BaseTestMinidumpWritable(), rva_() {} + TestRVAMinidumpWritable(const TestRVAMinidumpWritable&) = delete; + TestRVAMinidumpWritable& operator=(const TestRVAMinidumpWritable&) = delete; + ~TestRVAMinidumpWritable() {} void SetRVA(MinidumpWritable* other) { other->RegisterRVA(&rva_); } @@ -505,8 +510,6 @@ class TestRVAMinidumpWritable final : public BaseTestMinidumpWritable { private: RVA rva_; - - DISALLOW_COPY_AND_ASSIGN(TestRVAMinidumpWritable); }; RVA RVAAtIndex(const std::string& string, size_t index) { @@ -620,6 +623,11 @@ class TestLocationDescriptorMinidumpWritable final TestLocationDescriptorMinidumpWritable() : BaseTestMinidumpWritable(), location_descriptor_(), string_() {} + TestLocationDescriptorMinidumpWritable( + const TestLocationDescriptorMinidumpWritable&) = delete; + TestLocationDescriptorMinidumpWritable& operator=( + const TestLocationDescriptorMinidumpWritable&) = delete; + ~TestLocationDescriptorMinidumpWritable() {} void SetLocationDescriptor(MinidumpWritable* other) { @@ -652,8 +660,6 @@ class TestLocationDescriptorMinidumpWritable final private: MINIDUMP_LOCATION_DESCRIPTOR location_descriptor_; std::string string_; - - DISALLOW_COPY_AND_ASSIGN(TestLocationDescriptorMinidumpWritable); }; struct LocationDescriptorAndData { diff --git a/minidump/minidump_writer_util.h b/minidump/minidump_writer_util.h index 16a4e5b2e6..6bb7a5c602 100644 --- a/minidump/minidump_writer_util.h +++ b/minidump/minidump_writer_util.h @@ -21,7 +21,6 @@ #include -#include "base/macros.h" namespace crashpad { namespace internal { @@ -30,6 +29,10 @@ namespace internal { //! of classes. class MinidumpWriterUtil final { public: + MinidumpWriterUtil() = delete; + MinidumpWriterUtil(const MinidumpWriterUtil&) = delete; + MinidumpWriterUtil& operator=(const MinidumpWriterUtil&) = delete; + //! \brief Assigns a `time_t` value, logging a warning if the result overflows //! the destination buffer and will be truncated. //! @@ -78,9 +81,6 @@ class MinidumpWriterUtil final { static void AssignUTF8ToUTF16(char16_t* destination, size_t destination_size, const std::string& source); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(MinidumpWriterUtil); }; } // namespace internal diff --git a/minidump/test/minidump_memory_writer_test_util.h b/minidump/test/minidump_memory_writer_test_util.h index 90c3b86398..83b31384e2 100644 --- a/minidump/test/minidump_memory_writer_test_util.h +++ b/minidump/test/minidump_memory_writer_test_util.h @@ -24,7 +24,6 @@ #include -#include "base/macros.h" #include "snapshot/test/test_memory_snapshot.h" #include "util/file/file_writer.h" @@ -38,14 +37,16 @@ namespace test { class TestMinidumpMemoryWriter final : public SnapshotMinidumpMemoryWriter { public: TestMinidumpMemoryWriter(uint64_t base_address, size_t size, uint8_t value); + + TestMinidumpMemoryWriter(const TestMinidumpMemoryWriter&) = delete; + TestMinidumpMemoryWriter& operator=(const TestMinidumpMemoryWriter&) = delete; + ~TestMinidumpMemoryWriter(); void SetShouldFailRead(bool should_fail); private: TestMemorySnapshot test_snapshot_; - - DISALLOW_COPY_AND_ASSIGN(TestMinidumpMemoryWriter); }; //! \brief Verifies, via Google Test assertions, that a diff --git a/minidump/test/minidump_user_extension_stream_util.h b/minidump/test/minidump_user_extension_stream_util.h index 3a31b94898..2dc60f4a6f 100644 --- a/minidump/test/minidump_user_extension_stream_util.h +++ b/minidump/test/minidump_user_extension_stream_util.h @@ -38,13 +38,16 @@ class BufferExtensionStreamDataSource final const void* data, size_t data_size); + BufferExtensionStreamDataSource(const BufferExtensionStreamDataSource&) = + delete; + BufferExtensionStreamDataSource& operator=( + const BufferExtensionStreamDataSource&) = delete; + size_t StreamDataSize() override; bool ReadStreamData(Delegate* delegate) override; private: std::vector data_; - - DISALLOW_COPY_AND_ASSIGN(BufferExtensionStreamDataSource); }; } // namespace test diff --git a/minidump/test/minidump_writable_test_util.h b/minidump/test/minidump_writable_test_util.h index 84c10739a6..9ebb9d0266 100644 --- a/minidump/test/minidump_writable_test_util.h +++ b/minidump/test/minidump_writable_test_util.h @@ -22,7 +22,6 @@ #include -#include "base/macros.h" #include "gtest/gtest.h" #include "minidump/minidump_extensions.h" #include "minidump/minidump_writable.h" @@ -277,6 +276,10 @@ class TestUInt32MinidumpWritable final : public internal::MinidumpWritable { //! \brief Constructs the object to write a `uint32_t` with value \a value. explicit TestUInt32MinidumpWritable(uint32_t value); + TestUInt32MinidumpWritable(const TestUInt32MinidumpWritable&) = delete; + TestUInt32MinidumpWritable& operator=(const TestUInt32MinidumpWritable&) = + delete; + ~TestUInt32MinidumpWritable() override; protected: @@ -286,8 +289,6 @@ class TestUInt32MinidumpWritable final : public internal::MinidumpWritable { private: uint32_t value_; - - DISALLOW_COPY_AND_ASSIGN(TestUInt32MinidumpWritable); }; } // namespace test diff --git a/snapshot/capture_memory.h b/snapshot/capture_memory.h index a134824c17..c4ca1f550c 100644 --- a/snapshot/capture_memory.h +++ b/snapshot/capture_memory.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "snapshot/cpu_context.h" #include "util/numeric/checked_range.h" @@ -65,6 +64,10 @@ class CaptureMemory { const CheckedRange& range) = 0; }; + CaptureMemory() = delete; + CaptureMemory(const CaptureMemory&) = delete; + CaptureMemory& operator=(const CaptureMemory&) = delete; + //! \brief For all registers that appear to be pointer-like in \a context, //! captures a small amount of memory near their pointed to location. //! @@ -88,9 +91,6 @@ class CaptureMemory { //! process and adding new ranges. static void PointedToByMemoryRange(const MemorySnapshot& memory, Delegate* delegate); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureMemory); }; } // namespace internal diff --git a/snapshot/crashpad_info_client_options_test.cc b/snapshot/crashpad_info_client_options_test.cc index a0d22c198b..f5baa5bc68 100644 --- a/snapshot/crashpad_info_client_options_test.cc +++ b/snapshot/crashpad_info_client_options_test.cc @@ -16,7 +16,6 @@ #include "base/auto_reset.h" #include "base/files/file_path.h" -#include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "client/crashpad_info.h" @@ -63,6 +62,11 @@ class ScopedUnsetCrashpadInfoOptions { : crashpad_info_(crashpad_info) { } + ScopedUnsetCrashpadInfoOptions(const ScopedUnsetCrashpadInfoOptions&) = + delete; + ScopedUnsetCrashpadInfoOptions& operator=( + const ScopedUnsetCrashpadInfoOptions&) = delete; + ~ScopedUnsetCrashpadInfoOptions() { crashpad_info_->set_crashpad_handler_behavior(TriState::kUnset); crashpad_info_->set_system_crash_reporter_forwarding(TriState::kUnset); @@ -72,8 +76,6 @@ class ScopedUnsetCrashpadInfoOptions { private: CrashpadInfo* crashpad_info_; - - DISALLOW_COPY_AND_ASSIGN(ScopedUnsetCrashpadInfoOptions); }; CrashpadInfoClientOptions SelfProcessSnapshotAndGetCrashpadOptions() { diff --git a/snapshot/crashpad_types/crashpad_info_reader.h b/snapshot/crashpad_types/crashpad_info_reader.h index 5f2352efae..9494522f72 100644 --- a/snapshot/crashpad_types/crashpad_info_reader.h +++ b/snapshot/crashpad_types/crashpad_info_reader.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/misc/tri_state.h" @@ -32,6 +31,10 @@ namespace crashpad { class CrashpadInfoReader { public: CrashpadInfoReader(); + + CrashpadInfoReader(const CrashpadInfoReader&) = delete; + CrashpadInfoReader& operator=(const CrashpadInfoReader&) = delete; + ~CrashpadInfoReader(); //! \brief Initializes this object. @@ -66,8 +69,6 @@ class CrashpadInfoReader { std::unique_ptr container_; bool is_64_bit_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(CrashpadInfoReader); }; } // namespace crashpad diff --git a/snapshot/crashpad_types/crashpad_info_reader_test.cc b/snapshot/crashpad_types/crashpad_info_reader_test.cc index 556ead1b4d..3a1806a383 100644 --- a/snapshot/crashpad_types/crashpad_info_reader_test.cc +++ b/snapshot/crashpad_types/crashpad_info_reader_test.cc @@ -49,6 +49,9 @@ class ScopedUnsetCrashpadInfo { explicit ScopedUnsetCrashpadInfo(CrashpadInfo* crashpad_info) : crashpad_info_(crashpad_info) {} + ScopedUnsetCrashpadInfo(const ScopedUnsetCrashpadInfo&) = delete; + ScopedUnsetCrashpadInfo& operator=(const ScopedUnsetCrashpadInfo&) = delete; + ~ScopedUnsetCrashpadInfo() { crashpad_info_->set_crashpad_handler_behavior(TriState::kUnset); crashpad_info_->set_system_crash_reporter_forwarding(TriState::kUnset); @@ -61,8 +64,6 @@ class ScopedUnsetCrashpadInfo { private: CrashpadInfo* crashpad_info_; - - DISALLOW_COPY_AND_ASSIGN(ScopedUnsetCrashpadInfo); }; class CrashpadInfoTestDataSetup { @@ -80,6 +81,10 @@ class CrashpadInfoTestDataSetup { kGatherIndirectlyReferencedMemory, kIndirectlyReferencedMemoryCap); } + CrashpadInfoTestDataSetup(const CrashpadInfoTestDataSetup&) = delete; + CrashpadInfoTestDataSetup& operator=(const CrashpadInfoTestDataSetup&) = + delete; + void GetAddresses(VMAddress* info_address, VMAddress* extra_memory_address, VMAddress* simple_annotations_address, @@ -96,8 +101,6 @@ class CrashpadInfoTestDataSetup { SimpleAddressRangeBag extra_memory_; SimpleStringDictionary simple_annotations_; AnnotationList annotation_list_; - - DISALLOW_COPY_AND_ASSIGN(CrashpadInfoTestDataSetup); }; void ExpectCrashpadInfo(ProcessType process, @@ -184,6 +187,9 @@ class ReadFromChildTest : public MultiprocessExec { SetChildTestMainFunction("ReadFromChildTestMain"); } + ReadFromChildTest(const ReadFromChildTest&) = delete; + ReadFromChildTest& operator=(const ReadFromChildTest&) = delete; + ~ReadFromChildTest() = default; private: @@ -215,8 +221,6 @@ class ReadFromChildTest : public MultiprocessExec { simple_annotations_address, annotations_list_address); } - - DISALLOW_COPY_AND_ASSIGN(ReadFromChildTest); }; TEST(CrashpadInfoReader, ReadFromChild) { diff --git a/snapshot/crashpad_types/image_annotation_reader.h b/snapshot/crashpad_types/image_annotation_reader.h index e425bef6d7..f7bb512573 100644 --- a/snapshot/crashpad_types/image_annotation_reader.h +++ b/snapshot/crashpad_types/image_annotation_reader.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "snapshot/annotation_snapshot.h" #include "util/misc/address_types.h" #include "util/process/process_memory_range.h" @@ -37,6 +36,9 @@ class ImageAnnotationReader { //! \param[in] memory A memory reader for the remote process. explicit ImageAnnotationReader(const ProcessMemoryRange* memory); + ImageAnnotationReader(const ImageAnnotationReader&) = delete; + ImageAnnotationReader& operator=(const ImageAnnotationReader&) = delete; + ~ImageAnnotationReader(); //! \brief Reads annotations that are organized as key-value pairs, where all @@ -67,8 +69,6 @@ class ImageAnnotationReader { std::vector* annotations) const; const ProcessMemoryRange* memory_; // weak - - DISALLOW_COPY_AND_ASSIGN(ImageAnnotationReader); }; } // namespace crashpad diff --git a/snapshot/crashpad_types/image_annotation_reader_test.cc b/snapshot/crashpad_types/image_annotation_reader_test.cc index 9d9970e658..b5289e7a7f 100644 --- a/snapshot/crashpad_types/image_annotation_reader_test.cc +++ b/snapshot/crashpad_types/image_annotation_reader_test.cc @@ -163,6 +163,9 @@ class ReadFromChildTest : public MultiprocessExec { SetChildTestMainFunction("ReadAnnotationsFromChildTestMain"); } + ReadFromChildTest(const ReadFromChildTest&) = delete; + ReadFromChildTest& operator=(const ReadFromChildTest&) = delete; + ~ReadFromChildTest() = default; private: @@ -182,8 +185,6 @@ class ReadFromChildTest : public MultiprocessExec { ExpectAnnotations( ChildProcess(), am_64_bit, simple_map_address, annotations_address); } - - DISALLOW_COPY_AND_ASSIGN(ReadFromChildTest); }; TEST(ImageAnnotationReader, ReadFromChild) { diff --git a/snapshot/elf/elf_dynamic_array_reader.h b/snapshot/elf/elf_dynamic_array_reader.h index e80a8cbc55..f5cddf6f00 100644 --- a/snapshot/elf/elf_dynamic_array_reader.h +++ b/snapshot/elf/elf_dynamic_array_reader.h @@ -20,7 +20,6 @@ #include #include "base/logging.h" -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/reinterpret_bytes.h" #include "util/process/process_memory_range.h" @@ -31,6 +30,10 @@ namespace crashpad { class ElfDynamicArrayReader { public: ElfDynamicArrayReader(); + + ElfDynamicArrayReader(const ElfDynamicArrayReader&) = delete; + ElfDynamicArrayReader& operator=(const ElfDynamicArrayReader&) = delete; + ~ElfDynamicArrayReader(); //! \brief Initializes the reader. @@ -66,8 +69,6 @@ class ElfDynamicArrayReader { private: std::map values_; - - DISALLOW_COPY_AND_ASSIGN(ElfDynamicArrayReader); }; } // namespace crashpad diff --git a/snapshot/elf/elf_image_reader.cc b/snapshot/elf/elf_image_reader.cc index 1f361ac785..5ea14c0fe3 100644 --- a/snapshot/elf/elf_image_reader.cc +++ b/snapshot/elf/elf_image_reader.cc @@ -57,6 +57,12 @@ class ElfImageReader::ProgramHeaderTableSpecific : public ElfImageReader::ProgramHeaderTable { public: ProgramHeaderTableSpecific() {} + + ProgramHeaderTableSpecific( + const ProgramHeaderTableSpecific&) = delete; + ProgramHeaderTableSpecific& operator=( + const ProgramHeaderTableSpecific&) = delete; + ~ProgramHeaderTableSpecific() {} bool Initialize(const ProcessMemoryRange& memory, @@ -183,8 +189,6 @@ class ElfImageReader::ProgramHeaderTableSpecific private: std::vector table_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProgramHeaderTableSpecific); }; ElfImageReader::NoteReader::~NoteReader() = default; diff --git a/snapshot/elf/elf_image_reader.h b/snapshot/elf/elf_image_reader.h index ab1799f3b5..1fd399fc41 100644 --- a/snapshot/elf/elf_image_reader.h +++ b/snapshot/elf/elf_image_reader.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "snapshot/elf/elf_dynamic_array_reader.h" #include "snapshot/elf/elf_symbol_table_reader.h" #include "util/misc/address_types.h" @@ -46,6 +45,9 @@ class ElfImageReader { //! ElfImageReader::Notes() or ElfImageReader::NotesWithNameAndType(). class NoteReader { public: + NoteReader(const NoteReader&) = delete; + NoteReader& operator=(const NoteReader&) = delete; + ~NoteReader(); //! \brief The return value for NextNote(). @@ -111,11 +113,13 @@ class ElfImageReader { bool use_filter_; bool is_valid_; bool retry_; - - DISALLOW_COPY_AND_ASSIGN(NoteReader); }; ElfImageReader(); + + ElfImageReader(const ElfImageReader&) = delete; + ElfImageReader& operator=(const ElfImageReader&) = delete; + ~ElfImageReader(); //! \brief Initializes the reader. @@ -285,8 +289,6 @@ class ElfImageReader { InitializationStateDcheck initialized_; InitializationState dynamic_array_initialized_; InitializationState symbol_table_initialized_; - - DISALLOW_COPY_AND_ASSIGN(ElfImageReader); }; } // namespace crashpad diff --git a/snapshot/elf/elf_symbol_table_reader.h b/snapshot/elf/elf_symbol_table_reader.h index 15930372ca..89f99e9af2 100644 --- a/snapshot/elf/elf_symbol_table_reader.h +++ b/snapshot/elf/elf_symbol_table_reader.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/process/process_memory_range.h" @@ -63,6 +62,10 @@ class ElfSymbolTableReader { ElfImageReader* elf_reader, VMAddress address, VMSize num_entries); + + ElfSymbolTableReader(const ElfSymbolTableReader&) = delete; + ElfSymbolTableReader& operator=(const ElfSymbolTableReader&) = delete; + ~ElfSymbolTableReader(); //! \brief Lookup information about a symbol. @@ -80,8 +83,6 @@ class ElfSymbolTableReader { ElfImageReader* const elf_reader_; // weak const VMAddress base_address_; const VMSize num_entries_; - - DISALLOW_COPY_AND_ASSIGN(ElfSymbolTableReader); }; } // namespace crashpad diff --git a/snapshot/elf/module_snapshot_elf.h b/snapshot/elf/module_snapshot_elf.h index 67ecdf7eb7..86741b3e1b 100644 --- a/snapshot/elf/module_snapshot_elf.h +++ b/snapshot/elf/module_snapshot_elf.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "client/crashpad_info.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/crashpad_types/crashpad_info_reader.h" @@ -50,6 +49,10 @@ class ModuleSnapshotElf final : public ModuleSnapshot { ModuleSnapshot::ModuleType type, ProcessMemoryRange* process_memory_range, const ProcessMemory* process_memory); + + ModuleSnapshotElf(const ModuleSnapshotElf&) = delete; + ModuleSnapshotElf& operator=(const ModuleSnapshotElf&) = delete; + ~ModuleSnapshotElf() override; //! \brief Initializes the object. @@ -98,8 +101,6 @@ class ModuleSnapshotElf final : public ModuleSnapshot { InitializationStateDcheck initialized_; // Too const-y: https://crashpad.chromium.org/bug/9. mutable std::vector> streams_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotElf); }; } // namespace internal diff --git a/snapshot/fuchsia/exception_snapshot_fuchsia.h b/snapshot/fuchsia/exception_snapshot_fuchsia.h index 31269446ee..1b0a4e2396 100644 --- a/snapshot/fuchsia/exception_snapshot_fuchsia.h +++ b/snapshot/fuchsia/exception_snapshot_fuchsia.h @@ -35,6 +35,10 @@ namespace internal { class ExceptionSnapshotFuchsia final : public ExceptionSnapshot { public: ExceptionSnapshotFuchsia(); + + ExceptionSnapshotFuchsia(const ExceptionSnapshotFuchsia&) = delete; + ExceptionSnapshotFuchsia& operator=(const ExceptionSnapshotFuchsia&) = delete; + ~ExceptionSnapshotFuchsia() override; //! \brief Initializes the object. @@ -73,8 +77,6 @@ class ExceptionSnapshotFuchsia final : public ExceptionSnapshot { uint32_t exception_; uint32_t exception_info_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotFuchsia); }; } // namespace internal diff --git a/snapshot/fuchsia/memory_map_fuchsia.h b/snapshot/fuchsia/memory_map_fuchsia.h index cdbdb179ad..1c2736a712 100644 --- a/snapshot/fuchsia/memory_map_fuchsia.h +++ b/snapshot/fuchsia/memory_map_fuchsia.h @@ -28,6 +28,10 @@ namespace crashpad { class MemoryMapFuchsia { public: MemoryMapFuchsia(); + + MemoryMapFuchsia(const MemoryMapFuchsia&) = delete; + MemoryMapFuchsia& operator=(const MemoryMapFuchsia&) = delete; + ~MemoryMapFuchsia(); //! \brief Initializes this object with information about the mapped memory @@ -53,8 +57,6 @@ class MemoryMapFuchsia { private: std::vector map_entries_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MemoryMapFuchsia); }; } // namespace crashpad diff --git a/snapshot/fuchsia/process_reader_fuchsia.h b/snapshot/fuchsia/process_reader_fuchsia.h index 91c6331c7f..b57f0b9efa 100644 --- a/snapshot/fuchsia/process_reader_fuchsia.h +++ b/snapshot/fuchsia/process_reader_fuchsia.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/elf/elf_image_reader.h" #include "snapshot/fuchsia/memory_map_fuchsia.h" @@ -88,6 +87,10 @@ class ProcessReaderFuchsia { }; ProcessReaderFuchsia(); + + ProcessReaderFuchsia(const ProcessReaderFuchsia&) = delete; + ProcessReaderFuchsia& operator=(const ProcessReaderFuchsia&) = delete; + ~ProcessReaderFuchsia(); //! \brief Initializes this object. This method must be called before any @@ -138,8 +141,6 @@ class ProcessReaderFuchsia { bool initialized_threads_ = false; bool initialized_memory_map_ = false; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderFuchsia); }; } // namespace crashpad diff --git a/snapshot/fuchsia/process_reader_fuchsia_test.cc b/snapshot/fuchsia/process_reader_fuchsia_test.cc index 4fcf6a43fd..f5a8aea750 100644 --- a/snapshot/fuchsia/process_reader_fuchsia_test.cc +++ b/snapshot/fuchsia/process_reader_fuchsia_test.cc @@ -92,6 +92,10 @@ class BasicChildTest : public MultiprocessExec { BasicChildTest() : MultiprocessExec() { SetChildTestMainFunction("ProcessReaderBasicChildTestMain"); } + + BasicChildTest(const BasicChildTest&) = delete; + BasicChildTest& operator=(const BasicChildTest&) = delete; + ~BasicChildTest() {} private: @@ -106,8 +110,6 @@ class BasicChildTest : public MultiprocessExec { ASSERT_TRUE(process_reader.Memory()->ReadCString(addr, &read_string)); EXPECT_EQ(read_string, kTestMemory); } - - DISALLOW_COPY_AND_ASSIGN(BasicChildTest); }; TEST(ProcessReaderFuchsia, ChildBasic) { @@ -156,6 +158,10 @@ class ThreadsChildTest : public MultiprocessExec { ThreadsChildTest() : MultiprocessExec() { SetChildTestMainFunction("ProcessReaderChildThreadsTestMain"); } + + ThreadsChildTest(const ThreadsChildTest&) = delete; + ThreadsChildTest& operator=(const ThreadsChildTest&) = delete; + ~ThreadsChildTest() {} private: @@ -178,8 +184,6 @@ class ThreadsChildTest : public MultiprocessExec { EXPECT_LE(threads[i].stack_regions[0].size(), i * 4096u); } } - - DISALLOW_COPY_AND_ASSIGN(ThreadsChildTest); }; // TODO(scottmg): US-553. ScopedTaskSuspend fails sometimes, with a 50ms diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.h b/snapshot/fuchsia/process_snapshot_fuchsia.h index 6af2ebebc3..47efaa3412 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.h +++ b/snapshot/fuchsia/process_snapshot_fuchsia.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/elf/elf_image_reader.h" #include "snapshot/elf/module_snapshot_elf.h" @@ -45,6 +44,10 @@ namespace crashpad { class ProcessSnapshotFuchsia : public ProcessSnapshot { public: ProcessSnapshotFuchsia(); + + ProcessSnapshotFuchsia(const ProcessSnapshotFuchsia&) = delete; + ProcessSnapshotFuchsia& operator=(const ProcessSnapshotFuchsia&) = delete; + ~ProcessSnapshotFuchsia() override; //! \brief Initializes the object. @@ -145,8 +148,6 @@ class ProcessSnapshotFuchsia : public ProcessSnapshot { UUID client_id_; timeval snapshot_time_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotFuchsia); }; } // namespace crashpad diff --git a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc index 04730117b5..496d97a82d 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc +++ b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc @@ -103,6 +103,10 @@ class AddressSpaceTest : public MultiprocessExec { AddressSpaceTest() : MultiprocessExec() { SetChildTestMainFunction("AddressSpaceChildTestMain"); } + + AddressSpaceTest(const AddressSpaceTest&) = delete; + AddressSpaceTest& operator=(const AddressSpaceTest&) = delete; + ~AddressSpaceTest() {} private: @@ -131,8 +135,6 @@ class AddressSpaceTest : public MultiprocessExec { t.minidump_perm); } } - - DISALLOW_COPY_AND_ASSIGN(AddressSpaceTest); }; TEST(ProcessSnapshotFuchsiaTest, AddressSpaceMapping) { @@ -171,6 +173,10 @@ class InvalidStackPointerTest : public MultiprocessExec { SetExpectedChildTermination(kTerminationNormal, ZX_TASK_RETCODE_SYSCALL_KILL); } + + InvalidStackPointerTest(const InvalidStackPointerTest&) = delete; + InvalidStackPointerTest& operator=(const InvalidStackPointerTest&) = delete; + ~InvalidStackPointerTest() {} private: @@ -215,8 +221,6 @@ class InvalidStackPointerTest : public MultiprocessExec { // As we've corrupted the child, don't let it run again. ASSERT_EQ(ChildProcess()->kill(), ZX_OK); } - - DISALLOW_COPY_AND_ASSIGN(InvalidStackPointerTest); }; // This is a test for a specific failure detailed in diff --git a/snapshot/fuchsia/system_snapshot_fuchsia.h b/snapshot/fuchsia/system_snapshot_fuchsia.h index c7cd35dcce..aadffac912 100644 --- a/snapshot/fuchsia/system_snapshot_fuchsia.h +++ b/snapshot/fuchsia/system_snapshot_fuchsia.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/system_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -33,6 +32,10 @@ namespace internal { class SystemSnapshotFuchsia final : public SystemSnapshot { public: SystemSnapshotFuchsia(); + + SystemSnapshotFuchsia(const SystemSnapshotFuchsia&) = delete; + SystemSnapshotFuchsia& operator=(const SystemSnapshotFuchsia&) = delete; + ~SystemSnapshotFuchsia() override; //! \brief Initializes the object. @@ -77,8 +80,6 @@ class SystemSnapshotFuchsia final : public SystemSnapshot { CpuidReader cpuid_; #endif // ARCH_CPU_X86_FAMILY InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotFuchsia); }; } // namespace internal diff --git a/snapshot/fuchsia/thread_snapshot_fuchsia.h b/snapshot/fuchsia/thread_snapshot_fuchsia.h index 45d4f11749..b91a514d92 100644 --- a/snapshot/fuchsia/thread_snapshot_fuchsia.h +++ b/snapshot/fuchsia/thread_snapshot_fuchsia.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/fuchsia/process_reader_fuchsia.h" @@ -34,6 +33,10 @@ namespace internal { class ThreadSnapshotFuchsia final : public ThreadSnapshot { public: ThreadSnapshotFuchsia(); + + ThreadSnapshotFuchsia(const ThreadSnapshotFuchsia&) = delete; + ThreadSnapshotFuchsia& operator=(const ThreadSnapshotFuchsia&) = delete; + ~ThreadSnapshotFuchsia() override; //! \brief Initializes the object. @@ -71,8 +74,6 @@ class ThreadSnapshotFuchsia final : public ThreadSnapshot { zx_koid_t thread_id_; zx_vaddr_t thread_specific_data_address_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotFuchsia); }; } // namespace internal diff --git a/snapshot/ios/exception_snapshot_ios_intermediate_dump.h b/snapshot/ios/exception_snapshot_ios_intermediate_dump.h index 88d5ea6c7a..7e22330bc1 100644 --- a/snapshot/ios/exception_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/exception_snapshot_ios_intermediate_dump.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" @@ -37,6 +36,12 @@ namespace internal { class ExceptionSnapshotIOSIntermediateDump final : public ExceptionSnapshot { public: ExceptionSnapshotIOSIntermediateDump(); + + ExceptionSnapshotIOSIntermediateDump( + const ExceptionSnapshotIOSIntermediateDump&) = delete; + ExceptionSnapshotIOSIntermediateDump& operator=( + const ExceptionSnapshotIOSIntermediateDump&) = delete; + ~ExceptionSnapshotIOSIntermediateDump() override; //! \brief Initialize the snapshot as a signal exception. @@ -102,8 +107,6 @@ class ExceptionSnapshotIOSIntermediateDump final : public ExceptionSnapshot { uint32_t exception_; uint32_t exception_info_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/ios/memory_snapshot_ios_intermediate_dump.h b/snapshot/ios/memory_snapshot_ios_intermediate_dump.h index 895cbd0d56..a93200020c 100644 --- a/snapshot/ios/memory_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/memory_snapshot_ios_intermediate_dump.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_SNAPSHOT_IOS_INTERMEDIATE_DUMP_MEMORY_SNAPSHOT_IOS_INTERMEDIATEDUMP_H_ #define CRASHPAD_SNAPSHOT_IOS_INTERMEDIATE_DUMP_MEMORY_SNAPSHOT_IOS_INTERMEDIATEDUMP_H_ -#include "base/macros.h" #include "snapshot/memory_snapshot.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -27,6 +26,12 @@ namespace internal { class MemorySnapshotIOSIntermediateDump final : public MemorySnapshot { public: MemorySnapshotIOSIntermediateDump() = default; + + MemorySnapshotIOSIntermediateDump(const MemorySnapshotIOSIntermediateDump&) = + delete; + MemorySnapshotIOSIntermediateDump& operator=( + const MemorySnapshotIOSIntermediateDump&) = delete; + ~MemorySnapshotIOSIntermediateDump() = default; //! \brief Initializes the object. @@ -52,8 +57,6 @@ class MemorySnapshotIOSIntermediateDump final : public MemorySnapshot { vm_address_t data_; vm_size_t size_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MemorySnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/ios/module_snapshot_ios_intermediate_dump.h b/snapshot/ios/module_snapshot_ios_intermediate_dump.h index cd85c44f19..55b7ace880 100644 --- a/snapshot/ios/module_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/module_snapshot_ios_intermediate_dump.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/module_snapshot.h" #include "util/ios/ios_intermediate_dump_map.h" @@ -37,6 +36,12 @@ namespace internal { class ModuleSnapshotIOSIntermediateDump final : public ModuleSnapshot { public: ModuleSnapshotIOSIntermediateDump(); + + ModuleSnapshotIOSIntermediateDump(const ModuleSnapshotIOSIntermediateDump&) = + delete; + ModuleSnapshotIOSIntermediateDump& operator=( + const ModuleSnapshotIOSIntermediateDump&) = delete; + ~ModuleSnapshotIOSIntermediateDump() override; //! \brief Initialize the snapshot @@ -84,8 +89,6 @@ class ModuleSnapshotIOSIntermediateDump final : public ModuleSnapshot { std::vector annotation_objects_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.h b/snapshot/ios/process_snapshot_ios_intermediate_dump.h index 70a4d7da69..61312f0741 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.h @@ -39,6 +39,11 @@ class ProcessSnapshotIOSIntermediateDump final : public ProcessSnapshot { public: ProcessSnapshotIOSIntermediateDump() = default; + ProcessSnapshotIOSIntermediateDump( + const ProcessSnapshotIOSIntermediateDump&) = delete; + ProcessSnapshotIOSIntermediateDump& operator=( + const ProcessSnapshotIOSIntermediateDump&) = delete; + //! \brief Initializes the object. //! //! \param[in] dump_path A class containing various system data points. @@ -103,8 +108,6 @@ class ProcessSnapshotIOSIntermediateDump final : public ProcessSnapshot { std::map annotations_simple_map_; timeval snapshot_time_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/ios/system_snapshot_ios_intermediate_dump.h b/snapshot/ios/system_snapshot_ios_intermediate_dump.h index 72eaa64b86..9708e7fd1a 100644 --- a/snapshot/ios/system_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/system_snapshot_ios_intermediate_dump.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "snapshot/system_snapshot.h" #include "util/ios/ios_intermediate_dump_map.h" #include "util/ios/ios_system_data_collector.h" @@ -33,6 +32,12 @@ namespace internal { class SystemSnapshotIOSIntermediateDump final : public SystemSnapshot { public: SystemSnapshotIOSIntermediateDump(); + + SystemSnapshotIOSIntermediateDump(const SystemSnapshotIOSIntermediateDump&) = + delete; + SystemSnapshotIOSIntermediateDump& operator=( + const SystemSnapshotIOSIntermediateDump&) = delete; + ~SystemSnapshotIOSIntermediateDump() override; //! \brief Initializes the object. @@ -87,8 +92,6 @@ class SystemSnapshotIOSIntermediateDump final : public SystemSnapshot { std::string standard_name_; std::string daylight_name_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/ios/thread_snapshot_ios_intermediate_dump.h b/snapshot/ios/thread_snapshot_ios_intermediate_dump.h index d986c4938e..cf9ccec023 100644 --- a/snapshot/ios/thread_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/thread_snapshot_ios_intermediate_dump.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_SNAPSHOT_IOS_INTERMEDIATE_DUMP_THREAD_SNAPSHOT_IOS_INTERMEDIATEDUMP_H_ #define CRASHPAD_SNAPSHOT_IOS_INTERMEDIATE_DUMP_THREAD_SNAPSHOT_IOS_INTERMEDIATEDUMP_H_ -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/ios/memory_snapshot_ios_intermediate_dump.h" @@ -30,6 +29,12 @@ namespace internal { class ThreadSnapshotIOSIntermediateDump final : public ThreadSnapshot { public: ThreadSnapshotIOSIntermediateDump(); + + ThreadSnapshotIOSIntermediateDump(const ThreadSnapshotIOSIntermediateDump&) = + delete; + ThreadSnapshotIOSIntermediateDump& operator=( + const ThreadSnapshotIOSIntermediateDump&) = delete; + ~ThreadSnapshotIOSIntermediateDump() override; //! \brief Initializes the object. @@ -67,8 +72,6 @@ class ThreadSnapshotIOSIntermediateDump final : public ThreadSnapshot { std::vector> extra_memory_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotIOSIntermediateDump); }; } // namespace internal diff --git a/snapshot/linux/debug_rendezvous.h b/snapshot/linux/debug_rendezvous.h index 90106c9d18..f92051740f 100644 --- a/snapshot/linux/debug_rendezvous.h +++ b/snapshot/linux/debug_rendezvous.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "util/linux/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory_range.h" @@ -48,6 +47,10 @@ class DebugRendezvous { }; DebugRendezvous(); + + DebugRendezvous(const DebugRendezvous&) = delete; + DebugRendezvous& operator=(const DebugRendezvous&) = delete; + ~DebugRendezvous(); //! \brief Initializes this object by reading an `r_debug` struct from a @@ -79,8 +82,6 @@ class DebugRendezvous { std::vector modules_; LinkEntry executable_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(DebugRendezvous); }; } // namespace crashpad diff --git a/snapshot/linux/debug_rendezvous_test.cc b/snapshot/linux/debug_rendezvous_test.cc index 41956aa5d8..c77e86263a 100644 --- a/snapshot/linux/debug_rendezvous_test.cc +++ b/snapshot/linux/debug_rendezvous_test.cc @@ -239,6 +239,10 @@ TEST(DebugRendezvous, Self) { class ChildTest : public Multiprocess { public: ChildTest() {} + + ChildTest(const ChildTest&) = delete; + ChildTest& operator=(const ChildTest&) = delete; + ~ChildTest() {} private: @@ -250,8 +254,6 @@ class ChildTest : public Multiprocess { } void MultiprocessChild() { CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(ChildTest); }; TEST(DebugRendezvous, Child) { diff --git a/snapshot/linux/exception_snapshot_linux.h b/snapshot/linux/exception_snapshot_linux.h index ea0cd21066..c722ac77ad 100644 --- a/snapshot/linux/exception_snapshot_linux.h +++ b/snapshot/linux/exception_snapshot_linux.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" @@ -37,6 +36,10 @@ namespace internal { class ExceptionSnapshotLinux final : public ExceptionSnapshot { public: ExceptionSnapshotLinux(); + + ExceptionSnapshotLinux(const ExceptionSnapshotLinux&) = delete; + ExceptionSnapshotLinux& operator=(const ExceptionSnapshotLinux&) = delete; + ~ExceptionSnapshotLinux() override; //! \brief Initializes the object. @@ -93,8 +96,6 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot { uint32_t signal_number_; uint32_t signal_code_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotLinux); }; } // namespace internal diff --git a/snapshot/linux/exception_snapshot_linux_test.cc b/snapshot/linux/exception_snapshot_linux_test.cc index 1f72fe8028..51d3fd3808 100644 --- a/snapshot/linux/exception_snapshot_linux_test.cc +++ b/snapshot/linux/exception_snapshot_linux_test.cc @@ -23,7 +23,6 @@ #include "base/bit_cast.h" #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "snapshot/cpu_architecture.h" @@ -333,6 +332,9 @@ class ScopedSigactionRestore { public: ScopedSigactionRestore() : old_action_(), signo_(-1), valid_(false) {} + ScopedSigactionRestore(const ScopedSigactionRestore&) = delete; + ScopedSigactionRestore& operator=(const ScopedSigactionRestore&) = delete; + ~ScopedSigactionRestore() { Reset(); } bool Reset() { @@ -361,12 +363,14 @@ class ScopedSigactionRestore { struct sigaction old_action_; int signo_; bool valid_; - - DISALLOW_COPY_AND_ASSIGN(ScopedSigactionRestore); }; class RaiseTest { public: + RaiseTest() = delete; + RaiseTest(const RaiseTest&) = delete; + RaiseTest& operator=(const RaiseTest&) = delete; + static void Run() { test_complete_ = false; @@ -406,8 +410,6 @@ class RaiseTest { static constexpr uint32_t kSigno = SIGUSR1; static bool test_complete_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(RaiseTest); }; bool RaiseTest::test_complete_ = false; @@ -418,6 +420,10 @@ TEST(ExceptionSnapshotLinux, Raise) { class TimerTest { public: TimerTest() : event_(), timer_(-1), test_complete_(false) { test_ = this; } + + TimerTest(const TimerTest&) = delete; + TimerTest& operator=(const TimerTest&) = delete; + ~TimerTest() { test_ = nullptr; } void Run() { @@ -479,8 +485,6 @@ class TimerTest { static constexpr uint32_t kSigno = SIGALRM; static TimerTest* test_; - - DISALLOW_COPY_AND_ASSIGN(TimerTest); }; TimerTest* TimerTest::test_; diff --git a/snapshot/linux/process_reader_linux.h b/snapshot/linux/process_reader_linux.h index 258e102aa4..0eb1d40405 100644 --- a/snapshot/linux/process_reader_linux.h +++ b/snapshot/linux/process_reader_linux.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "snapshot/elf/elf_image_reader.h" #include "snapshot/module_snapshot.h" #include "util/linux/address_types.h" @@ -99,6 +98,10 @@ class ProcessReaderLinux { }; ProcessReaderLinux(); + + ProcessReaderLinux(const ProcessReaderLinux&) = delete; + ProcessReaderLinux& operator=(const ProcessReaderLinux&) = delete; + ~ProcessReaderLinux(); //! \brief Initializes this object. @@ -175,8 +178,6 @@ class ProcessReaderLinux { bool initialized_threads_; bool initialized_modules_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderLinux); }; } // namespace crashpad diff --git a/snapshot/linux/process_reader_linux_test.cc b/snapshot/linux/process_reader_linux_test.cc index 5a0d1378cf..250f12dabb 100644 --- a/snapshot/linux/process_reader_linux_test.cc +++ b/snapshot/linux/process_reader_linux_test.cc @@ -103,6 +103,10 @@ constexpr char kTestMemory[] = "Read me from another process"; class BasicChildTest : public Multiprocess { public: BasicChildTest() : Multiprocess() {} + + BasicChildTest(const BasicChildTest&) = delete; + BasicChildTest& operator=(const BasicChildTest&) = delete; + ~BasicChildTest() {} private: @@ -129,8 +133,6 @@ class BasicChildTest : public Multiprocess { } void MultiprocessChild() override { CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(BasicChildTest); }; TEST(ProcessReaderLinux, ChildBasic) { @@ -151,6 +153,9 @@ class TestThreadPool { TestThreadPool() : threads_() {} + TestThreadPool(const TestThreadPool&) = delete; + TestThreadPool& operator=(const TestThreadPool&) = delete; + ~TestThreadPool() { for (const auto& thread : threads_) { thread->exit_semaphore.Signal(); @@ -252,8 +257,6 @@ class TestThreadPool { } std::vector> threads_; - - DISALLOW_COPY_AND_ASSIGN(TestThreadPool); }; using ThreadMap = std::map; @@ -307,6 +310,10 @@ class ChildThreadTest : public Multiprocess { public: ChildThreadTest(size_t stack_size = 0) : Multiprocess(), stack_size_(stack_size) {} + + ChildThreadTest(const ChildThreadTest&) = delete; + ChildThreadTest& operator=(const ChildThreadTest&) = delete; + ~ChildThreadTest() {} private: @@ -375,8 +382,6 @@ class ChildThreadTest : public Multiprocess { static constexpr size_t kThreadCount = 3; const size_t stack_size_; - - DISALLOW_COPY_AND_ASSIGN(ChildThreadTest); }; TEST(ProcessReaderLinux, ChildWithThreads) { @@ -393,6 +398,10 @@ TEST(ProcessReaderLinux, ChildThreadsWithSmallUserStacks) { class ChildWithSplitStackTest : public Multiprocess { public: ChildWithSplitStackTest() : Multiprocess(), page_size_(getpagesize()) {} + + ChildWithSplitStackTest(const ChildWithSplitStackTest&) = delete; + ChildWithSplitStackTest& operator=(const ChildWithSplitStackTest&) = delete; + ~ChildWithSplitStackTest() {} private: @@ -465,8 +474,6 @@ class ChildWithSplitStackTest : public Multiprocess { } const size_t page_size_; - - DISALLOW_COPY_AND_ASSIGN(ChildWithSplitStackTest); }; // AddressSanitizer with use-after-return detection causes stack variables to @@ -587,6 +594,10 @@ TEST(ProcessReaderLinux, SelfModules) { class ChildModuleTest : public Multiprocess { public: ChildModuleTest() : Multiprocess(), module_soname_("test_module_soname") {} + + ChildModuleTest(const ChildModuleTest&) = delete; + ChildModuleTest& operator=(const ChildModuleTest&) = delete; + ~ChildModuleTest() = default; private: @@ -620,8 +631,6 @@ class ChildModuleTest : public Multiprocess { } const std::string module_soname_; - - DISALLOW_COPY_AND_ASSIGN(ChildModuleTest); }; TEST(ProcessReaderLinux, ChildModules) { diff --git a/snapshot/linux/process_snapshot_linux.h b/snapshot/linux/process_snapshot_linux.h index 06b72aff1a..62517bbf5d 100644 --- a/snapshot/linux/process_snapshot_linux.h +++ b/snapshot/linux/process_snapshot_linux.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/elf/module_snapshot_elf.h" #include "snapshot/linux/exception_snapshot_linux.h" @@ -49,6 +48,10 @@ namespace crashpad { class ProcessSnapshotLinux final : public ProcessSnapshot { public: ProcessSnapshotLinux(); + + ProcessSnapshotLinux(const ProcessSnapshotLinux&) = delete; + ProcessSnapshotLinux& operator=(const ProcessSnapshotLinux&) = delete; + ~ProcessSnapshotLinux() override; //! \brief Initializes the object. @@ -147,8 +150,6 @@ class ProcessSnapshotLinux final : public ProcessSnapshot { ProcessReaderLinux process_reader_; ProcessMemoryRange memory_range_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotLinux); }; } // namespace crashpad diff --git a/snapshot/linux/system_snapshot_linux.h b/snapshot/linux/system_snapshot_linux.h index d22c49a616..e13c9dfb31 100644 --- a/snapshot/linux/system_snapshot_linux.h +++ b/snapshot/linux/system_snapshot_linux.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/linux/process_reader_linux.h" #include "snapshot/system_snapshot.h" @@ -37,6 +36,10 @@ namespace internal { class SystemSnapshotLinux final : public SystemSnapshot { public: SystemSnapshotLinux(); + + SystemSnapshotLinux(const SystemSnapshotLinux&) = delete; + SystemSnapshotLinux& operator=(const SystemSnapshotLinux&) = delete; + ~SystemSnapshotLinux() override; //! \brief Initializes the object. @@ -103,8 +106,6 @@ class SystemSnapshotLinux final : public SystemSnapshot { uint32_t target_cpu_; uint8_t cpu_count_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotLinux); }; } // namespace internal diff --git a/snapshot/linux/thread_snapshot_linux.h b/snapshot/linux/thread_snapshot_linux.h index 44cc6f6d97..17a6668dad 100644 --- a/snapshot/linux/thread_snapshot_linux.h +++ b/snapshot/linux/thread_snapshot_linux.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/linux/process_reader_linux.h" @@ -33,6 +32,10 @@ namespace internal { class ThreadSnapshotLinux final : public ThreadSnapshot { public: ThreadSnapshotLinux(); + + ThreadSnapshotLinux(const ThreadSnapshotLinux&) = delete; + ThreadSnapshotLinux& operator=(const ThreadSnapshotLinux&) = delete; + ~ThreadSnapshotLinux() override; //! \brief Initializes the object. @@ -78,8 +81,6 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { pid_t thread_id_; int priority_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotLinux); }; } // namespace internal diff --git a/snapshot/mac/exception_snapshot_mac.h b/snapshot/mac/exception_snapshot_mac.h index 7c0b87cf04..ea7150a931 100644 --- a/snapshot/mac/exception_snapshot_mac.h +++ b/snapshot/mac/exception_snapshot_mac.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" @@ -38,6 +37,10 @@ namespace internal { class ExceptionSnapshotMac final : public ExceptionSnapshot { public: ExceptionSnapshotMac(); + + ExceptionSnapshotMac(const ExceptionSnapshotMac&) = delete; + ExceptionSnapshotMac& operator=(const ExceptionSnapshotMac&) = delete; + ~ExceptionSnapshotMac() override; //! \brief Initializes the object. @@ -96,8 +99,6 @@ class ExceptionSnapshotMac final : public ExceptionSnapshot { exception_type_t exception_; uint32_t exception_code_0_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotMac); }; } // namespace internal diff --git a/snapshot/mac/mach_o_image_annotations_reader.h b/snapshot/mac/mach_o_image_annotations_reader.h index a56b073b99..7a1a0a1c07 100644 --- a/snapshot/mac/mach_o_image_annotations_reader.h +++ b/snapshot/mac/mach_o_image_annotations_reader.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "snapshot/annotation_snapshot.h" #include "snapshot/mac/process_types.h" @@ -58,6 +57,10 @@ class MachOImageAnnotationsReader { const MachOImageReader* image_reader, const std::string& name); + MachOImageAnnotationsReader(const MachOImageAnnotationsReader&) = delete; + MachOImageAnnotationsReader& operator=(const MachOImageAnnotationsReader&) = + delete; + ~MachOImageAnnotationsReader() {} //! \brief Returns the module’s annotations that are organized as a vector of @@ -93,8 +96,6 @@ class MachOImageAnnotationsReader { std::string name_; ProcessReaderMac* process_reader_; // weak const MachOImageReader* image_reader_; // weak - - DISALLOW_COPY_AND_ASSIGN(MachOImageAnnotationsReader); }; } // namespace crashpad diff --git a/snapshot/mac/mach_o_image_annotations_reader_test.cc b/snapshot/mac/mach_o_image_annotations_reader_test.cc index cddc39942a..74a21be670 100644 --- a/snapshot/mac/mach_o_image_annotations_reader_test.cc +++ b/snapshot/mac/mach_o_image_annotations_reader_test.cc @@ -27,7 +27,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "client/annotation.h" #include "client/annotation_list.h" #include "client/crashpad_info.h" @@ -128,6 +127,11 @@ class TestMachOImageAnnotationsReader final } } + TestMachOImageAnnotationsReader(const TestMachOImageAnnotationsReader&) = + delete; + TestMachOImageAnnotationsReader& operator=( + const TestMachOImageAnnotationsReader&) = delete; + ~TestMachOImageAnnotationsReader() {} // UniversalMachExcServer::Interface: @@ -442,8 +446,6 @@ class TestMachOImageAnnotationsReader final } TestType test_type_; - - DISALLOW_COPY_AND_ASSIGN(TestMachOImageAnnotationsReader); }; TEST(MachOImageAnnotationsReader, DontCrash) { diff --git a/snapshot/mac/mach_o_image_reader.h b/snapshot/mac/mach_o_image_reader.h index aded956cef..0c60bcad2a 100644 --- a/snapshot/mac/mach_o_image_reader.h +++ b/snapshot/mac/mach_o_image_reader.h @@ -24,7 +24,6 @@ #include #include -#include "base/macros.h" #include "snapshot/mac/process_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/misc/uuid.h" @@ -45,6 +44,10 @@ class ProcessReaderMac; class MachOImageReader { public: MachOImageReader(); + + MachOImageReader(const MachOImageReader&) = delete; + MachOImageReader& operator=(const MachOImageReader&) = delete; + ~MachOImageReader(); //! \brief Reads the Mach-O image file’s load commands from another process. @@ -347,8 +350,6 @@ class MachOImageReader { // set. symbol_table_initialized_ will be valid without symbol_table_ being // set in modules that have no symbol table. mutable InitializationState symbol_table_initialized_; - - DISALLOW_COPY_AND_ASSIGN(MachOImageReader); }; } // namespace crashpad diff --git a/snapshot/mac/mach_o_image_segment_reader.h b/snapshot/mac/mach_o_image_segment_reader.h index 708cc37d5a..d639a5d3a4 100644 --- a/snapshot/mac/mach_o_image_segment_reader.h +++ b/snapshot/mac/mach_o_image_segment_reader.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "snapshot/mac/process_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -78,6 +77,10 @@ bool IsMalformedCLKernelsModule(uint32_t mach_o_file_type, class MachOImageSegmentReader { public: MachOImageSegmentReader(); + + MachOImageSegmentReader(const MachOImageSegmentReader&) = delete; + MachOImageSegmentReader& operator=(const MachOImageSegmentReader&) = delete; + ~MachOImageSegmentReader(); //! \brief Reads the segment load command from another process. @@ -291,8 +294,6 @@ class MachOImageSegmentReader { InitializationStateDcheck initialized_; InitializationStateDcheck initialized_slide_; - - DISALLOW_COPY_AND_ASSIGN(MachOImageSegmentReader); }; } // namespace crashpad diff --git a/snapshot/mac/mach_o_image_symbol_table_reader.cc b/snapshot/mac/mach_o_image_symbol_table_reader.cc index bf72ac9c5f..ef5a598fad 100644 --- a/snapshot/mac/mach_o_image_symbol_table_reader.cc +++ b/snapshot/mac/mach_o_image_symbol_table_reader.cc @@ -53,6 +53,11 @@ class MachOImageSymbolTableReaderInitializer { DCHECK(linkedit_range_.IsValid()); } + MachOImageSymbolTableReaderInitializer( + const MachOImageSymbolTableReaderInitializer&) = delete; + MachOImageSymbolTableReaderInitializer& operator=( + const MachOImageSymbolTableReaderInitializer&) = delete; + ~MachOImageSymbolTableReaderInitializer() {} //! \brief Reads the symbol table from another process. @@ -246,8 +251,6 @@ class MachOImageSymbolTableReaderInitializer { CheckedMachAddressRange linkedit_range_; ProcessReaderMac* process_reader_; // weak const MachOImageSegmentReader* linkedit_segment_; // weak - - DISALLOW_COPY_AND_ASSIGN(MachOImageSymbolTableReaderInitializer); }; } // namespace internal diff --git a/snapshot/mac/mach_o_image_symbol_table_reader.h b/snapshot/mac/mach_o_image_symbol_table_reader.h index b1bcc3a2d9..2af485394b 100644 --- a/snapshot/mac/mach_o_image_symbol_table_reader.h +++ b/snapshot/mac/mach_o_image_symbol_table_reader.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "snapshot/mac/mach_o_image_segment_reader.h" #include "snapshot/mac/process_reader_mac.h" #include "snapshot/mac/process_types.h" @@ -66,6 +65,11 @@ class MachOImageSymbolTableReader { using SymbolInformationMap = std::map; MachOImageSymbolTableReader(); + + MachOImageSymbolTableReader(const MachOImageSymbolTableReader&) = delete; + MachOImageSymbolTableReader& operator=(const MachOImageSymbolTableReader&) = + delete; + ~MachOImageSymbolTableReader(); //! \brief Reads the symbol table from another process. @@ -123,8 +127,6 @@ class MachOImageSymbolTableReader { private: SymbolInformationMap external_defined_symbols_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MachOImageSymbolTableReader); }; } // namespace crashpad diff --git a/snapshot/mac/module_snapshot_mac.h b/snapshot/mac/module_snapshot_mac.h index d78c326660..ce1e19dabc 100644 --- a/snapshot/mac/module_snapshot_mac.h +++ b/snapshot/mac/module_snapshot_mac.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "client/crashpad_info.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/mac/process_reader_mac.h" @@ -41,6 +40,10 @@ namespace internal { class ModuleSnapshotMac final : public ModuleSnapshot { public: ModuleSnapshotMac(); + + ModuleSnapshotMac(const ModuleSnapshotMac&) = delete; + ModuleSnapshotMac& operator=(const ModuleSnapshotMac&) = delete; + ~ModuleSnapshotMac() override; //! \brief Initializes the object. @@ -90,8 +93,6 @@ class ModuleSnapshotMac final : public ModuleSnapshot { const MachOImageReader* mach_o_image_reader_; // weak ProcessReaderMac* process_reader_; // weak InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotMac); }; } // namespace internal diff --git a/snapshot/mac/process_reader_mac.h b/snapshot/mac/process_reader_mac.h index 2f8ea9dcec..85cfe7c988 100644 --- a/snapshot/mac/process_reader_mac.h +++ b/snapshot/mac/process_reader_mac.h @@ -26,7 +26,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "util/misc/initialization_state_dcheck.h" #include "util/posix/process_info.h" @@ -111,6 +110,10 @@ class ProcessReaderMac { }; ProcessReaderMac(); + + ProcessReaderMac(const ProcessReaderMac&) = delete; + ProcessReaderMac& operator=(const ProcessReaderMac&) = delete; + ~ProcessReaderMac(); //! \brief Initializes this object. This method must be called before any @@ -262,8 +265,6 @@ class ProcessReaderMac { bool initialized_threads_; bool initialized_modules_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderMac); }; } // namespace crashpad diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc index c2c504cf1d..2f3775847f 100644 --- a/snapshot/mac/process_reader_mac_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -82,6 +82,9 @@ class ProcessReaderChild final : public MachMultiprocess { public: ProcessReaderChild() : MachMultiprocess() {} + ProcessReaderChild(const ProcessReaderChild&) = delete; + ProcessReaderChild& operator=(const ProcessReaderChild&) = delete; + ~ProcessReaderChild() {} private: @@ -118,8 +121,6 @@ class ProcessReaderChild final : public MachMultiprocess { // the pipe. CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderChild); }; TEST(ProcessReaderMac, ChildBasic) { @@ -166,6 +167,9 @@ class TestThreadPool { TestThreadPool() : thread_infos_() {} + TestThreadPool(const TestThreadPool&) = delete; + TestThreadPool& operator=(const TestThreadPool&) = delete; + // Resumes suspended threads, signals each thread’s exit semaphore asking it // to exit, and joins each thread, blocking until they have all exited. ~TestThreadPool() { @@ -289,8 +293,6 @@ class TestThreadPool { // This is a vector of pointers because the address of a ThreadInfo object is // passed to each thread’s ThreadMain(), so they cannot move around in memory. std::vector> thread_infos_; - - DISALLOW_COPY_AND_ASSIGN(TestThreadPool); }; using ThreadMap = std::map; @@ -432,6 +434,10 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { explicit ProcessReaderThreadedChild(size_t thread_count) : MachMultiprocess(), thread_count_(thread_count) {} + ProcessReaderThreadedChild(const ProcessReaderThreadedChild&) = delete; + ProcessReaderThreadedChild& operator=(const ProcessReaderThreadedChild&) = + delete; + ~ProcessReaderThreadedChild() {} private: @@ -516,8 +522,6 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { } size_t thread_count_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderThreadedChild); }; TEST(ProcessReaderMac, ChildOneThread) { @@ -622,6 +626,9 @@ class ScopedOpenCLNoOpKernel { kernel_(nullptr), success_(false) {} + ScopedOpenCLNoOpKernel(const ScopedOpenCLNoOpKernel&) = delete; + ScopedOpenCLNoOpKernel& operator=(const ScopedOpenCLNoOpKernel&) = delete; + ~ScopedOpenCLNoOpKernel() { if (kernel_) { cl_int rv = clReleaseKernel(kernel_); @@ -720,8 +727,6 @@ class ScopedOpenCLNoOpKernel { cl_program program_; cl_kernel kernel_; bool success_; - - DISALLOW_COPY_AND_ASSIGN(ScopedOpenCLNoOpKernel); }; // Although Mac OS X 10.6 has OpenCL and can compile and execute OpenCL code, @@ -809,6 +814,10 @@ class ProcessReaderModulesChild final : public MachMultiprocess { : MachMultiprocess(), ensure_cl_kernels_success_(ensure_cl_kernels_success) {} + ProcessReaderModulesChild(const ProcessReaderModulesChild&) = delete; + ProcessReaderModulesChild& operator=(const ProcessReaderModulesChild&) = + delete; + ~ProcessReaderModulesChild() {} private: @@ -925,8 +934,6 @@ class ProcessReaderModulesChild final : public MachMultiprocess { } bool ensure_cl_kernels_success_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderModulesChild); }; TEST(ProcessReaderMac, ChildModules) { diff --git a/snapshot/mac/process_snapshot_mac.h b/snapshot/mac/process_snapshot_mac.h index 2edc222084..59239102c6 100644 --- a/snapshot/mac/process_snapshot_mac.h +++ b/snapshot/mac/process_snapshot_mac.h @@ -24,7 +24,6 @@ #include #include -#include "base/macros.h" #include "client/crashpad_info.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/exception_snapshot.h" @@ -50,6 +49,10 @@ namespace crashpad { class ProcessSnapshotMac final : public ProcessSnapshot { public: ProcessSnapshotMac(); + + ProcessSnapshotMac(const ProcessSnapshotMac&) = delete; + ProcessSnapshotMac& operator=(const ProcessSnapshotMac&) = delete; + ~ProcessSnapshotMac() override; //! \brief Initializes the object. @@ -150,8 +153,6 @@ class ProcessSnapshotMac final : public ProcessSnapshot { std::map annotations_simple_map_; timeval snapshot_time_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotMac); }; } // namespace crashpad diff --git a/snapshot/mac/system_snapshot_mac.h b/snapshot/mac/system_snapshot_mac.h index 62b2ae6136..cca6be2532 100644 --- a/snapshot/mac/system_snapshot_mac.h +++ b/snapshot/mac/system_snapshot_mac.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "snapshot/system_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -33,6 +32,10 @@ namespace internal { class SystemSnapshotMac final : public SystemSnapshot { public: SystemSnapshotMac(); + + SystemSnapshotMac(const SystemSnapshotMac&) = delete; + SystemSnapshotMac& operator=(const SystemSnapshotMac&) = delete; + ~SystemSnapshotMac() override; //! \brief Initializes the object. @@ -91,8 +94,6 @@ class SystemSnapshotMac final : public SystemSnapshot { int os_version_bugfix_; bool os_server_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotMac); }; } // namespace internal diff --git a/snapshot/mac/system_snapshot_mac_test.cc b/snapshot/mac/system_snapshot_mac_test.cc index 0cf1a7cf44..6bf32b1fae 100644 --- a/snapshot/mac/system_snapshot_mac_test.cc +++ b/snapshot/mac/system_snapshot_mac_test.cc @@ -43,6 +43,9 @@ class SystemSnapshotMacTest : public testing::Test { system_snapshot_() { } + SystemSnapshotMacTest(const SystemSnapshotMacTest&) = delete; + SystemSnapshotMacTest& operator=(const SystemSnapshotMacTest&) = delete; + const internal::SystemSnapshotMac& system_snapshot() const { return system_snapshot_; } @@ -59,8 +62,6 @@ class SystemSnapshotMacTest : public testing::Test { ProcessReaderMac process_reader_; timeval snapshot_time_; internal::SystemSnapshotMac system_snapshot_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotMacTest); }; TEST_F(SystemSnapshotMacTest, GetCPUArchitecture) { diff --git a/snapshot/mac/thread_snapshot_mac.h b/snapshot/mac/thread_snapshot_mac.h index 06331fa842..4d9cb3167f 100644 --- a/snapshot/mac/thread_snapshot_mac.h +++ b/snapshot/mac/thread_snapshot_mac.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/mac/process_reader_mac.h" @@ -38,6 +37,10 @@ namespace internal { class ThreadSnapshotMac final : public ThreadSnapshot { public: ThreadSnapshotMac(); + + ThreadSnapshotMac(const ThreadSnapshotMac&) = delete; + ThreadSnapshotMac& operator=(const ThreadSnapshotMac&) = delete; + ~ThreadSnapshotMac() override; //! \brief Initializes the object. @@ -81,8 +84,6 @@ class ThreadSnapshotMac final : public ThreadSnapshot { int suspend_count_; int priority_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotMac); }; } // namespace internal diff --git a/snapshot/memory_snapshot_generic.h b/snapshot/memory_snapshot_generic.h index 6e50a58517..b09e7a9607 100644 --- a/snapshot/memory_snapshot_generic.h +++ b/snapshot/memory_snapshot_generic.h @@ -19,7 +19,6 @@ #include #include "base/logging.h" -#include "base/macros.h" #include "base/numerics/safe_math.h" #include "snapshot/memory_snapshot.h" #include "util/misc/address_types.h" @@ -35,6 +34,10 @@ namespace internal { class MemorySnapshotGeneric final : public MemorySnapshot { public: MemorySnapshotGeneric() = default; + + MemorySnapshotGeneric(const MemorySnapshotGeneric&) = delete; + MemorySnapshotGeneric& operator=(const MemorySnapshotGeneric&) = delete; + ~MemorySnapshotGeneric() = default; //! \brief Initializes the object. @@ -110,8 +113,6 @@ class MemorySnapshotGeneric final : public MemorySnapshot { VMAddress address_; size_t size_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MemorySnapshotGeneric); }; } // namespace internal diff --git a/snapshot/memory_snapshot_test.cc b/snapshot/memory_snapshot_test.cc index 91e847fb26..14ba78ee94 100644 --- a/snapshot/memory_snapshot_test.cc +++ b/snapshot/memory_snapshot_test.cc @@ -14,7 +14,6 @@ #include "snapshot/memory_snapshot.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "snapshot/test/test_memory_snapshot.h" diff --git a/snapshot/minidump/exception_snapshot_minidump.h b/snapshot/minidump/exception_snapshot_minidump.h index 62f834fea6..917c237f1d 100644 --- a/snapshot/minidump/exception_snapshot_minidump.h +++ b/snapshot/minidump/exception_snapshot_minidump.h @@ -32,6 +32,11 @@ namespace internal { class ExceptionSnapshotMinidump final : public ExceptionSnapshot { public: ExceptionSnapshotMinidump(); + + ExceptionSnapshotMinidump(const ExceptionSnapshotMinidump&) = delete; + ExceptionSnapshotMinidump& operator=(const ExceptionSnapshotMinidump&) = + delete; + ~ExceptionSnapshotMinidump() override; //! \brief Initializes the object. @@ -66,8 +71,6 @@ class ExceptionSnapshotMinidump final : public ExceptionSnapshot { MinidumpContextConverter context_; std::vector exception_information_; InitializationState initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotMinidump); }; } // namespace internal diff --git a/snapshot/minidump/memory_snapshot_minidump.h b/snapshot/minidump/memory_snapshot_minidump.h index 69521be0bb..0ab05b2ca5 100644 --- a/snapshot/minidump/memory_snapshot_minidump.h +++ b/snapshot/minidump/memory_snapshot_minidump.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "snapshot/memory_snapshot.h" #include "util/file/file_reader.h" #include "util/misc/initialization_state_dcheck.h" @@ -30,6 +29,10 @@ namespace internal { class MemorySnapshotMinidump : public MemorySnapshot { public: MemorySnapshotMinidump(); + + MemorySnapshotMinidump(const MemorySnapshotMinidump&) = delete; + MemorySnapshotMinidump& operator=(const MemorySnapshotMinidump&) = delete; + ~MemorySnapshotMinidump() override; //! \brief Initializes the object. @@ -53,8 +56,6 @@ class MemorySnapshotMinidump : public MemorySnapshot { uint64_t address_; std::vector data_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MemorySnapshotMinidump); }; } // namespace internal diff --git a/snapshot/minidump/minidump_stream.h b/snapshot/minidump/minidump_stream.h index 2b0ac2e12b..20f1dda4e5 100644 --- a/snapshot/minidump/minidump_stream.h +++ b/snapshot/minidump/minidump_stream.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -29,14 +28,15 @@ class MinidumpStream { MinidumpStream(uint32_t stream_type, std::vector data) : stream_type_(stream_type), data_(data) {} + MinidumpStream(const MinidumpStream&) = delete; + MinidumpStream& operator=(const MinidumpStream&) = delete; + uint32_t stream_type() const { return stream_type_; } const std::vector& data() const { return data_; } private: uint32_t stream_type_; std::vector data_; - - DISALLOW_COPY_AND_ASSIGN(MinidumpStream); }; } // namespace crashpad diff --git a/snapshot/minidump/module_snapshot_minidump.h b/snapshot/minidump/module_snapshot_minidump.h index 023d0d5950..f00e566b8b 100644 --- a/snapshot/minidump/module_snapshot_minidump.h +++ b/snapshot/minidump/module_snapshot_minidump.h @@ -24,7 +24,6 @@ #include #include -#include "base/macros.h" #include "snapshot/annotation_snapshot.h" #include "snapshot/module_snapshot.h" #include "util/file/file_reader.h" @@ -37,6 +36,10 @@ namespace internal { class ModuleSnapshotMinidump final : public ModuleSnapshot { public: ModuleSnapshotMinidump(); + + ModuleSnapshotMinidump(const ModuleSnapshotMinidump&) = delete; + ModuleSnapshotMinidump& operator=(const ModuleSnapshotMinidump&) = delete; + ~ModuleSnapshotMinidump() override; //! \brief Initializes the object. @@ -103,8 +106,6 @@ class ModuleSnapshotMinidump final : public ModuleSnapshot { std::string debug_file_name_; uint32_t age_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotMinidump); }; } // namespace internal diff --git a/snapshot/minidump/process_snapshot_minidump.h b/snapshot/minidump/process_snapshot_minidump.h index cf2d82bdee..f76956d219 100644 --- a/snapshot/minidump/process_snapshot_minidump.h +++ b/snapshot/minidump/process_snapshot_minidump.h @@ -25,7 +25,6 @@ #include #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "snapshot/exception_snapshot.h" #include "snapshot/memory_snapshot.h" @@ -54,6 +53,10 @@ class MemoryMapRegionSnapshotMinidump; class ProcessSnapshotMinidump final : public ProcessSnapshot { public: ProcessSnapshotMinidump(); + + ProcessSnapshotMinidump(const ProcessSnapshotMinidump&) = delete; + ProcessSnapshotMinidump& operator=(const ProcessSnapshotMinidump&) = delete; + ~ProcessSnapshotMinidump() override; //! \brief Initializes the object. @@ -157,8 +160,6 @@ class ProcessSnapshotMinidump final : public ProcessSnapshot { uint32_t user_time_; uint32_t kernel_time_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotMinidump); }; } // namespace crashpad diff --git a/snapshot/minidump/system_snapshot_minidump.h b/snapshot/minidump/system_snapshot_minidump.h index 0f2880e181..8a7ad1f1f2 100644 --- a/snapshot/minidump/system_snapshot_minidump.h +++ b/snapshot/minidump/system_snapshot_minidump.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "minidump/minidump_extensions.h" #include "snapshot/system_snapshot.h" #include "util/file/file_reader.h" @@ -30,6 +29,10 @@ namespace internal { class SystemSnapshotMinidump : public SystemSnapshot { public: SystemSnapshotMinidump(); + + SystemSnapshotMinidump(const SystemSnapshotMinidump&) = delete; + SystemSnapshotMinidump& operator=(const SystemSnapshotMinidump&) = delete; + ~SystemSnapshotMinidump() override; //! \brief Initializes the object. @@ -77,8 +80,6 @@ class SystemSnapshotMinidump : public SystemSnapshot { std::string minidump_build_name_; std::string full_version_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotMinidump); }; } // namespace internal diff --git a/snapshot/minidump/thread_snapshot_minidump.h b/snapshot/minidump/thread_snapshot_minidump.h index 262b8da6ab..7efb18d71c 100644 --- a/snapshot/minidump/thread_snapshot_minidump.h +++ b/snapshot/minidump/thread_snapshot_minidump.h @@ -32,6 +32,10 @@ namespace internal { class ThreadSnapshotMinidump : public ThreadSnapshot { public: ThreadSnapshotMinidump(); + + ThreadSnapshotMinidump(const ThreadSnapshotMinidump&) = delete; + ThreadSnapshotMinidump& operator=(const ThreadSnapshotMinidump&) = delete; + ~ThreadSnapshotMinidump() override; //! \brief Initializes the object. @@ -70,8 +74,6 @@ class ThreadSnapshotMinidump : public ThreadSnapshot { MinidumpContextConverter context_; MemorySnapshotMinidump stack_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotMinidump); }; } // namespace internal diff --git a/snapshot/module_snapshot.h b/snapshot/module_snapshot.h index f7eb83c827..5f205cee70 100644 --- a/snapshot/module_snapshot.h +++ b/snapshot/module_snapshot.h @@ -40,6 +40,9 @@ class UserMinidumpStream { UserMinidumpStream(uint32_t stream_type, MemorySnapshot* memory) : memory_(memory), stream_type_(stream_type) {} + UserMinidumpStream(const UserMinidumpStream&) = delete; + UserMinidumpStream& operator=(const UserMinidumpStream&) = delete; + const MemorySnapshot* memory() const { return memory_.get(); } uint32_t stream_type() const { return stream_type_; } @@ -49,8 +52,6 @@ class UserMinidumpStream { //! \brief The stream type that the minidump stream will be tagged with. uint32_t stream_type_; - - DISALLOW_COPY_AND_ASSIGN(UserMinidumpStream); }; //! \brief An abstract interface to a snapshot representing a code module diff --git a/snapshot/posix/timezone_test.cc b/snapshot/posix/timezone_test.cc index 4d60b83790..6a343767e3 100644 --- a/snapshot/posix/timezone_test.cc +++ b/snapshot/posix/timezone_test.cc @@ -21,7 +21,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -43,6 +42,9 @@ class ScopedSetTZ { tzset(); } + ScopedSetTZ(const ScopedSetTZ&) = delete; + ScopedSetTZ& operator=(const ScopedSetTZ&) = delete; + ~ScopedSetTZ() { if (old_tz_set_) { EXPECT_EQ(setenv(kTZ, old_tz_.c_str(), 1), 0) << ErrnoMessage("setenv"); @@ -57,8 +59,6 @@ class ScopedSetTZ { bool old_tz_set_; static constexpr char kTZ[] = "TZ"; - - DISALLOW_COPY_AND_ASSIGN(ScopedSetTZ); }; constexpr char ScopedSetTZ::kTZ[]; diff --git a/snapshot/sanitized/memory_snapshot_sanitized.cc b/snapshot/sanitized/memory_snapshot_sanitized.cc index e71629dff0..a25349180e 100644 --- a/snapshot/sanitized/memory_snapshot_sanitized.cc +++ b/snapshot/sanitized/memory_snapshot_sanitized.cc @@ -32,6 +32,9 @@ class MemorySanitizer : public MemorySnapshot::Delegate { address_(address), is_64_bit_(is_64_bit) {} + MemorySanitizer(const MemorySanitizer&) = delete; + MemorySanitizer& operator=(const MemorySanitizer&) = delete; + ~MemorySanitizer() = default; bool MemorySnapshotDelegateRead(void* data, size_t size) override { @@ -77,8 +80,6 @@ class MemorySanitizer : public MemorySnapshot::Delegate { RangeSet* ranges_; VMAddress address_; bool is_64_bit_; - - DISALLOW_COPY_AND_ASSIGN(MemorySanitizer); }; } // namespace diff --git a/snapshot/sanitized/memory_snapshot_sanitized.h b/snapshot/sanitized/memory_snapshot_sanitized.h index be3e5d4ac5..30885f5f82 100644 --- a/snapshot/sanitized/memory_snapshot_sanitized.h +++ b/snapshot/sanitized/memory_snapshot_sanitized.h @@ -47,6 +47,9 @@ class MemorySnapshotSanitized final : public MemorySnapshot { RangeSet* ranges, bool is_64_bit); + MemorySnapshotSanitized(const MemorySnapshotSanitized&) = delete; + MemorySnapshotSanitized& operator=(const MemorySnapshotSanitized&) = delete; + ~MemorySnapshotSanitized() override; // MemorySnapshot: @@ -64,8 +67,6 @@ class MemorySnapshotSanitized final : public MemorySnapshot { const MemorySnapshot* snapshot_; RangeSet* ranges_; bool is_64_bit_; - - DISALLOW_COPY_AND_ASSIGN(MemorySnapshotSanitized); }; } // namespace internal diff --git a/snapshot/sanitized/module_snapshot_sanitized.h b/snapshot/sanitized/module_snapshot_sanitized.h index b64999e178..f8937f3730 100644 --- a/snapshot/sanitized/module_snapshot_sanitized.h +++ b/snapshot/sanitized/module_snapshot_sanitized.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "snapshot/module_snapshot.h" namespace crashpad { @@ -36,6 +35,10 @@ class ModuleSnapshotSanitized final : public ModuleSnapshot { //! `nullptr`, all annotations will be returned. ModuleSnapshotSanitized(const ModuleSnapshot* snapshot, const std::vector* allowed_annotations); + + ModuleSnapshotSanitized(const ModuleSnapshotSanitized&) = delete; + ModuleSnapshotSanitized& operator=(const ModuleSnapshotSanitized&) = delete; + ~ModuleSnapshotSanitized() override; // ModuleSnapshot: @@ -65,8 +68,6 @@ class ModuleSnapshotSanitized final : public ModuleSnapshot { private: const ModuleSnapshot* snapshot_; const std::vector* allowed_annotations_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotSanitized); }; } // namespace internal diff --git a/snapshot/sanitized/process_snapshot_sanitized.h b/snapshot/sanitized/process_snapshot_sanitized.h index eb059732cb..86c7c4e4ec 100644 --- a/snapshot/sanitized/process_snapshot_sanitized.h +++ b/snapshot/sanitized/process_snapshot_sanitized.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "snapshot/exception_snapshot.h" #include "snapshot/process_snapshot.h" #include "snapshot/sanitized/module_snapshot_sanitized.h" @@ -39,6 +38,10 @@ namespace crashpad { class ProcessSnapshotSanitized final : public ProcessSnapshot { public: ProcessSnapshotSanitized(); + + ProcessSnapshotSanitized(const ProcessSnapshotSanitized&) = delete; + ProcessSnapshotSanitized& operator=(const ProcessSnapshotSanitized&) = delete; + ~ProcessSnapshotSanitized() override; //! \brief Initializes this object. @@ -105,8 +108,6 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot { std::unique_ptr> allowed_annotations_; bool sanitize_stacks_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotSanitized); }; } // namespace crashpad diff --git a/snapshot/sanitized/process_snapshot_sanitized_test.cc b/snapshot/sanitized/process_snapshot_sanitized_test.cc index 48aad785c4..0bdea432b0 100644 --- a/snapshot/sanitized/process_snapshot_sanitized_test.cc +++ b/snapshot/sanitized/process_snapshot_sanitized_test.cc @@ -17,7 +17,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/notreached.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -41,6 +40,9 @@ namespace { class ExceptionGenerator { public: + ExceptionGenerator(const ExceptionGenerator&) = delete; + ExceptionGenerator& operator=(const ExceptionGenerator&) = delete; + static ExceptionGenerator* Get() { static ExceptionGenerator* instance = new ExceptionGenerator(); return instance; @@ -73,8 +75,6 @@ class ExceptionGenerator { FileHandle in_; FileHandle out_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionGenerator); }; constexpr char kAllowedAnnotationName[] = "name_of_allowed_anno"; @@ -248,6 +248,9 @@ class SanitizeTest : public MultiprocessExec { SetExpectedChildTerminationBuiltinTrap(); } + SanitizeTest(const SanitizeTest&) = delete; + SanitizeTest& operator=(const SanitizeTest&) = delete; + ~SanitizeTest() = default; private: @@ -298,8 +301,6 @@ class SanitizeTest : public MultiprocessExec { EXPECT_FALSE(screened_snapshot.Initialize( &snapshot, nullptr, nullptr, addrs.non_module_address, false)); } - - DISALLOW_COPY_AND_ASSIGN(SanitizeTest); }; TEST(ProcessSnapshotSanitized, Sanitize) { diff --git a/snapshot/sanitized/thread_snapshot_sanitized.h b/snapshot/sanitized/thread_snapshot_sanitized.h index 081627a66a..dca0a0e917 100644 --- a/snapshot/sanitized/thread_snapshot_sanitized.h +++ b/snapshot/sanitized/thread_snapshot_sanitized.h @@ -34,6 +34,9 @@ class ThreadSnapshotSanitized final : public ThreadSnapshot { //! thread's stacks. \see internal::MemorySnapshotSanitized. ThreadSnapshotSanitized(const ThreadSnapshot* snapshot, RangeSet* ranges); + ThreadSnapshotSanitized(const ThreadSnapshotSanitized&) = delete; + ThreadSnapshotSanitized& operator=(const ThreadSnapshotSanitized&) = delete; + ~ThreadSnapshotSanitized() override; // ThreadSnapshot: @@ -49,8 +52,6 @@ class ThreadSnapshotSanitized final : public ThreadSnapshot { private: const ThreadSnapshot* snapshot_; MemorySnapshotSanitized stack_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotSanitized); }; } // namespace internal diff --git a/snapshot/test/test_exception_snapshot.h b/snapshot/test/test_exception_snapshot.h index aa75539de6..0f6b7c0727 100644 --- a/snapshot/test/test_exception_snapshot.h +++ b/snapshot/test/test_exception_snapshot.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" @@ -33,6 +32,10 @@ namespace test { class TestExceptionSnapshot final : public ExceptionSnapshot { public: TestExceptionSnapshot(); + + TestExceptionSnapshot(const TestExceptionSnapshot&) = delete; + TestExceptionSnapshot& operator=(const TestExceptionSnapshot&) = delete; + ~TestExceptionSnapshot(); //! \brief Obtains a pointer to the underlying mutable CPUContext structure. @@ -85,8 +88,6 @@ class TestExceptionSnapshot final : public ExceptionSnapshot { uint64_t exception_address_; std::vector codes_; std::vector> extra_memory_; - - DISALLOW_COPY_AND_ASSIGN(TestExceptionSnapshot); }; } // namespace test diff --git a/snapshot/test/test_memory_map_region_snapshot.h b/snapshot/test/test_memory_map_region_snapshot.h index 0a76888578..c4e1ca7528 100644 --- a/snapshot/test/test_memory_map_region_snapshot.h +++ b/snapshot/test/test_memory_map_region_snapshot.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "snapshot/memory_map_region_snapshot.h" namespace crashpad { @@ -28,6 +27,11 @@ namespace test { class TestMemoryMapRegionSnapshot final : public MemoryMapRegionSnapshot { public: TestMemoryMapRegionSnapshot(); + + TestMemoryMapRegionSnapshot(const TestMemoryMapRegionSnapshot&) = delete; + TestMemoryMapRegionSnapshot& operator=(const TestMemoryMapRegionSnapshot&) = + delete; + ~TestMemoryMapRegionSnapshot() override; void SetMindumpMemoryInfo(const MINIDUMP_MEMORY_INFO& mmi); @@ -37,8 +41,6 @@ class TestMemoryMapRegionSnapshot final : public MemoryMapRegionSnapshot { private: MINIDUMP_MEMORY_INFO memory_info_; - - DISALLOW_COPY_AND_ASSIGN(TestMemoryMapRegionSnapshot); }; } // namespace test diff --git a/snapshot/test/test_memory_snapshot.h b/snapshot/test/test_memory_snapshot.h index 011e6c6f14..a9e8fb1a2c 100644 --- a/snapshot/test/test_memory_snapshot.h +++ b/snapshot/test/test_memory_snapshot.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "snapshot/memory_snapshot.h" namespace crashpad { @@ -29,6 +28,10 @@ namespace test { class TestMemorySnapshot final : public MemorySnapshot { public: TestMemorySnapshot(); + + TestMemorySnapshot(const TestMemorySnapshot&) = delete; + TestMemorySnapshot& operator=(const TestMemorySnapshot&) = delete; + ~TestMemorySnapshot(); void SetAddress(uint64_t address) { address_ = address; } @@ -55,8 +58,6 @@ class TestMemorySnapshot final : public MemorySnapshot { size_t size_; char value_; bool should_fail_; - - DISALLOW_COPY_AND_ASSIGN(TestMemorySnapshot); }; } // namespace test diff --git a/snapshot/test/test_module_snapshot.h b/snapshot/test/test_module_snapshot.h index fb84aaf4ce..19e1299004 100644 --- a/snapshot/test/test_module_snapshot.h +++ b/snapshot/test/test_module_snapshot.h @@ -22,7 +22,6 @@ #include #include -#include "base/macros.h" #include "snapshot/module_snapshot.h" namespace crashpad { @@ -33,6 +32,10 @@ namespace test { class TestModuleSnapshot final : public ModuleSnapshot { public: TestModuleSnapshot(); + + TestModuleSnapshot(const TestModuleSnapshot&) = delete; + TestModuleSnapshot& operator=(const TestModuleSnapshot&) = delete; + ~TestModuleSnapshot() override; void SetName(const std::string& name) { name_ = name; } @@ -127,8 +130,6 @@ class TestModuleSnapshot final : public ModuleSnapshot { std::map annotations_simple_map_; std::vector annotation_objects_; std::set> extra_memory_ranges_; - - DISALLOW_COPY_AND_ASSIGN(TestModuleSnapshot); }; } // namespace test diff --git a/snapshot/test/test_process_snapshot.h b/snapshot/test/test_process_snapshot.h index 5495cba161..16873fee15 100644 --- a/snapshot/test/test_process_snapshot.h +++ b/snapshot/test/test_process_snapshot.h @@ -25,7 +25,6 @@ #include #include -#include "base/macros.h" #include "snapshot/exception_snapshot.h" #include "snapshot/memory_map_region_snapshot.h" #include "snapshot/memory_snapshot.h" @@ -46,6 +45,10 @@ namespace test { class TestProcessSnapshot final : public ProcessSnapshot { public: TestProcessSnapshot(); + + TestProcessSnapshot(const TestProcessSnapshot&) = delete; + TestProcessSnapshot& operator=(const TestProcessSnapshot&) = delete; + ~TestProcessSnapshot() override; void SetProcessID(crashpad::ProcessID process_id) { @@ -187,8 +190,6 @@ class TestProcessSnapshot final : public ProcessSnapshot { std::vector handles_; std::vector> extra_memory_; std::unique_ptr process_memory_; - - DISALLOW_COPY_AND_ASSIGN(TestProcessSnapshot); }; } // namespace test diff --git a/snapshot/test/test_system_snapshot.h b/snapshot/test/test_system_snapshot.h index 31787eba8f..6126265667 100644 --- a/snapshot/test/test_system_snapshot.h +++ b/snapshot/test/test_system_snapshot.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "snapshot/system_snapshot.h" namespace crashpad { @@ -30,6 +29,10 @@ namespace test { class TestSystemSnapshot final : public SystemSnapshot { public: TestSystemSnapshot(); + + TestSystemSnapshot(const TestSystemSnapshot&) = delete; + TestSystemSnapshot& operator=(const TestSystemSnapshot&) = delete; + ~TestSystemSnapshot() override; void SetCPUArchitecture(CPUArchitecture cpu_architecture) { @@ -138,8 +141,6 @@ class TestSystemSnapshot final : public SystemSnapshot { int time_zone_daylight_offset_seconds_; std::string time_zone_standard_name_; std::string time_zone_daylight_name_; - - DISALLOW_COPY_AND_ASSIGN(TestSystemSnapshot); }; } // namespace test diff --git a/snapshot/test/test_thread_snapshot.h b/snapshot/test/test_thread_snapshot.h index e705c164f6..f865bdfea7 100644 --- a/snapshot/test/test_thread_snapshot.h +++ b/snapshot/test/test_thread_snapshot.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "snapshot/cpu_context.h" #include "snapshot/memory_snapshot.h" #include "snapshot/thread_snapshot.h" @@ -34,6 +33,10 @@ namespace test { class TestThreadSnapshot final : public ThreadSnapshot { public: TestThreadSnapshot(); + + TestThreadSnapshot(const TestThreadSnapshot&) = delete; + TestThreadSnapshot& operator=(const TestThreadSnapshot&) = delete; + ~TestThreadSnapshot(); //! \brief Obtains a pointer to the underlying mutable CPUContext structure. @@ -97,8 +100,6 @@ class TestThreadSnapshot final : public ThreadSnapshot { int priority_; uint64_t thread_specific_data_address_; std::vector> extra_memory_; - - DISALLOW_COPY_AND_ASSIGN(TestThreadSnapshot); }; } // namespace test diff --git a/snapshot/win/exception_snapshot_win.h b/snapshot/win/exception_snapshot_win.h index fd4e854360..9167a9ef63 100644 --- a/snapshot/win/exception_snapshot_win.h +++ b/snapshot/win/exception_snapshot_win.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" @@ -50,6 +49,10 @@ union CPUContextUnion { class ExceptionSnapshotWin final : public ExceptionSnapshot { public: ExceptionSnapshotWin(); + + ExceptionSnapshotWin(const ExceptionSnapshotWin&) = delete; + ExceptionSnapshotWin& operator=(const ExceptionSnapshotWin&) = delete; + ~ExceptionSnapshotWin() override; //! \brief Initializes the object. @@ -102,8 +105,6 @@ class ExceptionSnapshotWin final : public ExceptionSnapshot { uint32_t exception_flags_; DWORD exception_code_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotWin); }; } // namespace internal diff --git a/snapshot/win/exception_snapshot_win_test.cc b/snapshot/win/exception_snapshot_win_test.cc index 63f9bf8ac2..dbf9cfc059 100644 --- a/snapshot/win/exception_snapshot_win_test.cc +++ b/snapshot/win/exception_snapshot_win_test.cc @@ -42,6 +42,10 @@ class RunServerThread : public Thread { RunServerThread(ExceptionHandlerServer* server, ExceptionHandlerServer::Delegate* delegate) : server_(server), delegate_(delegate) {} + + RunServerThread(const RunServerThread&) = delete; + RunServerThread& operator=(const RunServerThread&) = delete; + ~RunServerThread() override {} private: @@ -50,8 +54,6 @@ class RunServerThread : public Thread { ExceptionHandlerServer* server_; ExceptionHandlerServer::Delegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(RunServerThread); }; // During destruction, ensures that the server is stopped and the background @@ -60,6 +62,11 @@ class ScopedStopServerAndJoinThread { public: ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread) : server_(server), thread_(thread) {} + + ScopedStopServerAndJoinThread(const ScopedStopServerAndJoinThread&) = delete; + ScopedStopServerAndJoinThread& operator=( + const ScopedStopServerAndJoinThread&) = delete; + ~ScopedStopServerAndJoinThread() { server_->Stop(); thread_->Join(); @@ -68,7 +75,6 @@ class ScopedStopServerAndJoinThread { private: ExceptionHandlerServer* server_; Thread* thread_; - DISALLOW_COPY_AND_ASSIGN(ScopedStopServerAndJoinThread); }; class CrashingDelegate : public ExceptionHandlerServer::Delegate { @@ -77,6 +83,10 @@ class CrashingDelegate : public ExceptionHandlerServer::Delegate { : server_ready_(server_ready), completed_test_event_(completed_test_event), break_near_(0) {} + + CrashingDelegate(const CrashingDelegate&) = delete; + CrashingDelegate& operator=(const CrashingDelegate&) = delete; + ~CrashingDelegate() {} void set_break_near(WinVMAddress break_near) { break_near_ = break_near; } @@ -120,8 +130,6 @@ class CrashingDelegate : public ExceptionHandlerServer::Delegate { HANDLE server_ready_; // weak HANDLE completed_test_event_; // weak WinVMAddress break_near_; - - DISALLOW_COPY_AND_ASSIGN(CrashingDelegate); }; void TestCrashingChild(TestPaths::Architecture architecture) { @@ -192,6 +200,10 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate { : server_ready_(server_ready), completed_test_event_(completed_test_event), dump_near_(0) {} + + SimulateDelegate(const SimulateDelegate&) = delete; + SimulateDelegate& operator=(const SimulateDelegate&) = delete; + ~SimulateDelegate() {} void set_dump_near(WinVMAddress dump_near) { dump_near_ = dump_near; } @@ -240,8 +252,6 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate { HANDLE server_ready_; // weak HANDLE completed_test_event_; // weak WinVMAddress dump_near_; - - DISALLOW_COPY_AND_ASSIGN(SimulateDelegate); }; void TestDumpWithoutCrashingChild(TestPaths::Architecture architecture) { diff --git a/snapshot/win/module_snapshot_win.h b/snapshot/win/module_snapshot_win.h index b32216c3fa..5b375f431e 100644 --- a/snapshot/win/module_snapshot_win.h +++ b/snapshot/win/module_snapshot_win.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/crashpad_types/crashpad_info_reader.h" #include "snapshot/module_snapshot.h" @@ -44,6 +43,10 @@ namespace internal { class ModuleSnapshotWin final : public ModuleSnapshot { public: ModuleSnapshotWin(); + + ModuleSnapshotWin(const ModuleSnapshotWin&) = delete; + ModuleSnapshotWin& operator=(const ModuleSnapshotWin&) = delete; + ~ModuleSnapshotWin() override; //! \brief Initializes the object. @@ -124,8 +127,6 @@ class ModuleSnapshotWin final : public ModuleSnapshot { time_t timestamp_; uint32_t age_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotWin); }; } // namespace internal diff --git a/snapshot/win/pe_image_annotations_reader.h b/snapshot/win/pe_image_annotations_reader.h index 6379b27816..97b1e8feab 100644 --- a/snapshot/win/pe_image_annotations_reader.h +++ b/snapshot/win/pe_image_annotations_reader.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "snapshot/annotation_snapshot.h" namespace crashpad { @@ -49,6 +48,10 @@ class PEImageAnnotationsReader { PEImageAnnotationsReader(ProcessReaderWin* process_reader, const PEImageReader* pe_image_reader, const std::wstring& name); + + PEImageAnnotationsReader(const PEImageAnnotationsReader&) = delete; + PEImageAnnotationsReader& operator=(const PEImageAnnotationsReader&) = delete; + ~PEImageAnnotationsReader() {} //! \brief Returns the module's annotations that are organized as key-value @@ -73,8 +76,6 @@ class PEImageAnnotationsReader { std::wstring name_; ProcessReaderWin* process_reader_; // weak const PEImageReader* pe_image_reader_; // weak - - DISALLOW_COPY_AND_ASSIGN(PEImageAnnotationsReader); }; } // namespace crashpad diff --git a/snapshot/win/pe_image_reader.h b/snapshot/win/pe_image_reader.h index ebdbe5789f..a2bd28ecc1 100644 --- a/snapshot/win/pe_image_reader.h +++ b/snapshot/win/pe_image_reader.h @@ -21,7 +21,6 @@ #include -#include "base/macros.h" #include "snapshot/win/process_subrange_reader.h" #include "util/misc/initialization_state_dcheck.h" #include "util/misc/uuid.h" @@ -63,6 +62,10 @@ struct CrashpadInfo { class PEImageReader { public: PEImageReader(); + + PEImageReader(const PEImageReader&) = delete; + PEImageReader& operator=(const PEImageReader&) = delete; + ~PEImageReader(); //! \brief Initializes the reader. @@ -194,8 +197,6 @@ class PEImageReader { ProcessSubrangeReader module_subrange_reader_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(PEImageReader); }; } // namespace crashpad diff --git a/snapshot/win/pe_image_resource_reader.h b/snapshot/win/pe_image_resource_reader.h index ce339dd24c..a8468db7ca 100644 --- a/snapshot/win/pe_image_resource_reader.h +++ b/snapshot/win/pe_image_resource_reader.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "snapshot/win/process_subrange_reader.h" #include "util/misc/initialization_state_dcheck.h" #include "util/win/address_types.h" @@ -34,6 +33,10 @@ namespace crashpad { class PEImageResourceReader { public: PEImageResourceReader(); + + PEImageResourceReader(const PEImageResourceReader&) = delete; + PEImageResourceReader& operator=(const PEImageResourceReader&) = delete; + ~PEImageResourceReader(); //! \brief Initializes the resource reader. @@ -170,8 +173,6 @@ class PEImageResourceReader { ProcessSubrangeReader resources_subrange_reader_; WinVMAddress module_base_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(PEImageResourceReader); }; } // namespace crashpad diff --git a/snapshot/win/process_reader_win.h b/snapshot/win/process_reader_win.h index a4e32aaf83..7875de0412 100644 --- a/snapshot/win/process_reader_win.h +++ b/snapshot/win/process_reader_win.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory_win.h" @@ -63,6 +62,10 @@ class ProcessReaderWin { }; ProcessReaderWin(); + + ProcessReaderWin(const ProcessReaderWin&) = delete; + ProcessReaderWin& operator=(const ProcessReaderWin&) = delete; + ~ProcessReaderWin(); //! \brief Initializes this object. This method must be called before any @@ -135,8 +138,6 @@ class ProcessReaderWin { ProcessSuspensionState suspension_state_; bool initialized_threads_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); }; } // namespace crashpad diff --git a/snapshot/win/process_reader_win_test.cc b/snapshot/win/process_reader_win_test.cc index 7c6c7399f3..68933bbe63 100644 --- a/snapshot/win/process_reader_win_test.cc +++ b/snapshot/win/process_reader_win_test.cc @@ -55,6 +55,10 @@ constexpr char kTestMemory[] = "Read me from another process"; class ProcessReaderChild final : public WinMultiprocess { public: ProcessReaderChild() : WinMultiprocess() {} + + ProcessReaderChild(const ProcessReaderChild&) = delete; + ProcessReaderChild& operator=(const ProcessReaderChild&) = delete; + ~ProcessReaderChild() {} private: @@ -86,8 +90,6 @@ class ProcessReaderChild final : public WinMultiprocess { // the pipe. CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderChild); }; TEST(ProcessReaderWin, ChildBasic) { @@ -115,6 +117,12 @@ TEST(ProcessReaderWin, SelfOneThread) { class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess { public: ProcessReaderChildThreadSuspendCount() : WinMultiprocess() {} + + ProcessReaderChildThreadSuspendCount( + const ProcessReaderChildThreadSuspendCount&) = delete; + ProcessReaderChildThreadSuspendCount& operator=( + const ProcessReaderChildThreadSuspendCount&) = delete; + ~ProcessReaderChildThreadSuspendCount() {} private: @@ -190,8 +198,6 @@ class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess { for (auto& thread : threads) thread.Join(); } - - DISALLOW_COPY_AND_ASSIGN(ProcessReaderChildThreadSuspendCount); }; TEST(ProcessReaderWin, ChildThreadSuspendCounts) { diff --git a/snapshot/win/process_snapshot_win.h b/snapshot/win/process_snapshot_win.h index 8b0bf52690..7a8ae2fd3f 100644 --- a/snapshot/win/process_snapshot_win.h +++ b/snapshot/win/process_snapshot_win.h @@ -25,7 +25,6 @@ #include #include -#include "base/macros.h" #include "client/crashpad_info.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/exception_snapshot.h" @@ -55,6 +54,10 @@ namespace crashpad { class ProcessSnapshotWin final : public ProcessSnapshot { public: ProcessSnapshotWin(); + + ProcessSnapshotWin(const ProcessSnapshotWin&) = delete; + ProcessSnapshotWin& operator=(const ProcessSnapshotWin&) = delete; + ~ProcessSnapshotWin() override; //! \brief Initializes the object. @@ -192,8 +195,6 @@ class ProcessSnapshotWin final : public ProcessSnapshot { timeval snapshot_time_; CrashpadInfoClientOptions options_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotWin); }; } // namespace crashpad diff --git a/snapshot/win/process_subrange_reader.h b/snapshot/win/process_subrange_reader.h index f6af00ed55..bcdff5e21f 100644 --- a/snapshot/win/process_subrange_reader.h +++ b/snapshot/win/process_subrange_reader.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/misc/initialization_state_dcheck.h" #include "util/win/address_types.h" #include "util/win/checked_win_address_range.h" @@ -35,6 +34,10 @@ class ProcessReaderWin; class ProcessSubrangeReader { public: ProcessSubrangeReader(); + + ProcessSubrangeReader(const ProcessSubrangeReader&) = delete; + ProcessSubrangeReader& operator=(const ProcessSubrangeReader&) = delete; + ~ProcessSubrangeReader(); //! \brief Initializes the object. @@ -105,8 +108,6 @@ class ProcessSubrangeReader { CheckedWinAddressRange range_; ProcessReaderWin* process_reader_; // weak InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessSubrangeReader); }; } // namespace crashpad diff --git a/snapshot/win/system_snapshot_win.h b/snapshot/win/system_snapshot_win.h index fc209a5f8b..d10c25f230 100644 --- a/snapshot/win/system_snapshot_win.h +++ b/snapshot/win/system_snapshot_win.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "snapshot/system_snapshot.h" #include "snapshot/win/process_reader_win.h" #include "util/misc/initialization_state_dcheck.h" @@ -35,6 +34,10 @@ namespace internal { class SystemSnapshotWin final : public SystemSnapshot { public: SystemSnapshotWin(); + + SystemSnapshotWin(const SystemSnapshotWin&) = delete; + SystemSnapshotWin& operator=(const SystemSnapshotWin&) = delete; + ~SystemSnapshotWin() override; //! \brief Initializes the object. @@ -86,8 +89,6 @@ class SystemSnapshotWin final : public SystemSnapshot { int os_version_bugfix_; bool os_server_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotWin); }; } // namespace internal diff --git a/snapshot/win/system_snapshot_win_test.cc b/snapshot/win/system_snapshot_win_test.cc index d93c654cc7..c8716b33da 100644 --- a/snapshot/win/system_snapshot_win_test.cc +++ b/snapshot/win/system_snapshot_win_test.cc @@ -35,6 +35,9 @@ class SystemSnapshotWinTest : public testing::Test { system_snapshot_() { } + SystemSnapshotWinTest(const SystemSnapshotWinTest&) = delete; + SystemSnapshotWinTest& operator=(const SystemSnapshotWinTest&) = delete; + const internal::SystemSnapshotWin& system_snapshot() const { return system_snapshot_; } @@ -49,8 +52,6 @@ class SystemSnapshotWinTest : public testing::Test { private: ProcessReaderWin process_reader_; internal::SystemSnapshotWin system_snapshot_; - - DISALLOW_COPY_AND_ASSIGN(SystemSnapshotWinTest); }; TEST_F(SystemSnapshotWinTest, GetCPUArchitecture) { diff --git a/snapshot/win/thread_snapshot_win.h b/snapshot/win/thread_snapshot_win.h index 64ec43de0f..b9fafaa23c 100644 --- a/snapshot/win/thread_snapshot_win.h +++ b/snapshot/win/thread_snapshot_win.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/memory_snapshot.h" @@ -40,6 +39,10 @@ namespace internal { class ThreadSnapshotWin final : public ThreadSnapshot { public: ThreadSnapshotWin(); + + ThreadSnapshotWin(const ThreadSnapshotWin&) = delete; + ThreadSnapshotWin& operator=(const ThreadSnapshotWin&) = delete; + ~ThreadSnapshotWin() override; //! \brief Initializes the object. @@ -87,8 +90,6 @@ class ThreadSnapshotWin final : public ThreadSnapshot { ProcessReaderWin::Thread thread_; InitializationStateDcheck initialized_; std::vector> pointed_to_memory_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotWin); }; } // namespace internal diff --git a/test/linux/fake_ptrace_connection.h b/test/linux/fake_ptrace_connection.h index 79cdbd9656..bf09d95db9 100644 --- a/test/linux/fake_ptrace_connection.h +++ b/test/linux/fake_ptrace_connection.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory_linux.h" @@ -35,6 +34,10 @@ namespace test { class FakePtraceConnection : public PtraceConnection { public: FakePtraceConnection(); + + FakePtraceConnection(const FakePtraceConnection&) = delete; + FakePtraceConnection& operator=(const FakePtraceConnection&) = delete; + ~FakePtraceConnection(); //! \brief Initializes this connection for the process whose process ID is @@ -74,8 +77,6 @@ class FakePtraceConnection : public PtraceConnection { pid_t pid_; bool is_64_bit_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(FakePtraceConnection); }; } // namespace test diff --git a/test/mac/exception_swallower.cc b/test/mac/exception_swallower.cc index 76ca394812..3098643bd9 100644 --- a/test/mac/exception_swallower.cc +++ b/test/mac/exception_swallower.cc @@ -66,6 +66,9 @@ class ExceptionSwallower::ExceptionSwallowerThread Start(); } + ExceptionSwallowerThread(const ExceptionSwallowerThread&) = delete; + ExceptionSwallowerThread& operator=(const ExceptionSwallowerThread&) = delete; + ~ExceptionSwallowerThread() override {} void Stop() { exception_handler_server_.Stop(); } @@ -107,8 +110,6 @@ class ExceptionSwallower::ExceptionSwallowerThread ExceptionHandlerServer exception_handler_server_; pid_t pid_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSwallowerThread); }; ExceptionSwallower::ExceptionSwallower() : exception_swallower_thread_() { diff --git a/test/mac/exception_swallower.h b/test/mac/exception_swallower.h index 7c3a44211f..ac14562078 100644 --- a/test/mac/exception_swallower.h +++ b/test/mac/exception_swallower.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { namespace test { @@ -56,6 +55,10 @@ namespace test { class ExceptionSwallower { public: ExceptionSwallower(); + + ExceptionSwallower(const ExceptionSwallower&) = delete; + ExceptionSwallower& operator=(const ExceptionSwallower&) = delete; + ~ExceptionSwallower(); //! \brief In a test child process, arranges to swallow `EXC_CRASH` and @@ -76,8 +79,6 @@ class ExceptionSwallower { class ExceptionSwallowerThread; std::unique_ptr exception_swallower_thread_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionSwallower); }; } // namespace test diff --git a/test/mac/mach_multiprocess.cc b/test/mac/mach_multiprocess.cc index 01b242a6ff..35df0611ab 100644 --- a/test/mac/mach_multiprocess.cc +++ b/test/mac/mach_multiprocess.cc @@ -22,6 +22,7 @@ #include "base/auto_reset.h" #include "base/mac/scoped_mach_port.h" +#include "base/macros.h" #include "gtest/gtest.h" #include "test/errors.h" #include "test/mac/mach_errors.h" diff --git a/test/mac/mach_multiprocess.h b/test/mac/mach_multiprocess.h index 8b7063d654..b3b0bb1b6b 100644 --- a/test/mac/mach_multiprocess.h +++ b/test/mac/mach_multiprocess.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "test/multiprocess.h" namespace crashpad { @@ -43,6 +42,9 @@ class MachMultiprocess : public Multiprocess { public: MachMultiprocess(); + MachMultiprocess(const MachMultiprocess&) = delete; + MachMultiprocess& operator=(const MachMultiprocess&) = delete; + void Run(); protected: @@ -110,8 +112,6 @@ class MachMultiprocess : public Multiprocess { virtual void MachMultiprocessChild() = 0; internal::MachMultiprocessInfo* info_; - - DISALLOW_COPY_AND_ASSIGN(MachMultiprocess); }; } // namespace test diff --git a/test/mac/mach_multiprocess_test.cc b/test/mac/mach_multiprocess_test.cc index ef395591e6..455249bdec 100644 --- a/test/mac/mach_multiprocess_test.cc +++ b/test/mac/mach_multiprocess_test.cc @@ -16,7 +16,6 @@ #include -#include "base/macros.h" #include "gtest/gtest.h" namespace crashpad { @@ -27,6 +26,9 @@ class TestMachMultiprocess final : public MachMultiprocess { public: TestMachMultiprocess() : MachMultiprocess() {} + TestMachMultiprocess(const TestMachMultiprocess&) = delete; + TestMachMultiprocess& operator=(const TestMachMultiprocess&) = delete; + ~TestMachMultiprocess() {} private: @@ -35,8 +37,6 @@ class TestMachMultiprocess final : public MachMultiprocess { void MachMultiprocessParent() override {} void MachMultiprocessChild() override {} - - DISALLOW_COPY_AND_ASSIGN(TestMachMultiprocess); }; TEST(MachMultiprocess, MachMultiprocess) { diff --git a/test/multiprocess.h b/test/multiprocess.h index eb161616b7..ca48ce80af 100644 --- a/test/multiprocess.h +++ b/test/multiprocess.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "util/file/file_io.h" @@ -67,6 +66,9 @@ class Multiprocess { Multiprocess(); + Multiprocess(const Multiprocess&) = delete; + Multiprocess& operator=(const Multiprocess&) = delete; + //! \brief Runs the test. //! //! This method establishes the proper testing environment by calling @@ -222,8 +224,6 @@ class Multiprocess { internal::MultiprocessInfo* info_; ReturnCodeType code_; TerminationReason reason_; - - DISALLOW_COPY_AND_ASSIGN(Multiprocess); }; } // namespace test diff --git a/test/multiprocess_exec.h b/test/multiprocess_exec.h index 1e17a07a3e..a03f8c1ade 100644 --- a/test/multiprocess_exec.h +++ b/test/multiprocess_exec.h @@ -19,7 +19,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "build/build_config.h" #include "test/multiprocess.h" #include "test/process_type.h" @@ -89,6 +88,9 @@ class MultiprocessExec : public Multiprocess { public: MultiprocessExec(); + MultiprocessExec(const MultiprocessExec&) = delete; + MultiprocessExec& operator=(const MultiprocessExec&) = delete; + //! \brief Sets the command to `exec()` in the child. //! //! This method must be called before the test can be Run(). @@ -144,8 +146,6 @@ class MultiprocessExec : public Multiprocess { #elif defined(OS_WIN) std::wstring command_line_; #endif // OS_POSIX - - DISALLOW_COPY_AND_ASSIGN(MultiprocessExec); }; } // namespace test diff --git a/test/multiprocess_exec_test.cc b/test/multiprocess_exec_test.cc index 4f5418ad9e..fb77d642fb 100644 --- a/test/multiprocess_exec_test.cc +++ b/test/multiprocess_exec_test.cc @@ -15,7 +15,6 @@ #include "test/multiprocess_exec.h" #include "base/logging.h" -#include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -30,6 +29,9 @@ class TestMultiprocessExec final : public MultiprocessExec { public: TestMultiprocessExec() : MultiprocessExec() {} + TestMultiprocessExec(const TestMultiprocessExec&) = delete; + TestMultiprocessExec& operator=(const TestMultiprocessExec&) = delete; + ~TestMultiprocessExec() {} private: @@ -44,8 +46,6 @@ class TestMultiprocessExec final : public MultiprocessExec { ASSERT_TRUE(LoggingReadFileExactly(ReadPipeHandle(), &c, 1)); EXPECT_EQ(c, 'Z'); } - - DISALLOW_COPY_AND_ASSIGN(TestMultiprocessExec); }; TEST(MultiprocessExec, MultiprocessExec) { @@ -82,12 +82,15 @@ CRASHPAD_CHILD_TEST_MAIN(SimpleMultiprocessReturnsNonZero) { class TestMultiprocessExecEmpty final : public MultiprocessExec { public: TestMultiprocessExecEmpty() = default; + + TestMultiprocessExecEmpty(const TestMultiprocessExecEmpty&) = delete; + TestMultiprocessExecEmpty& operator=(const TestMultiprocessExecEmpty&) = + delete; + ~TestMultiprocessExecEmpty() = default; private: void MultiprocessParent() override {} - - DISALLOW_COPY_AND_ASSIGN(TestMultiprocessExecEmpty); }; TEST(MultiprocessExec, MultiprocessExecSimpleChildReturnsNonZero) { @@ -112,12 +115,14 @@ class TestBuiltinTrapTermination final : public MultiprocessExec { SetExpectedChildTerminationBuiltinTrap(); } + TestBuiltinTrapTermination(const TestBuiltinTrapTermination&) = delete; + TestBuiltinTrapTermination& operator=(const TestBuiltinTrapTermination&) = + delete; + ~TestBuiltinTrapTermination() = default; private: void MultiprocessParent() override {} - - DISALLOW_COPY_AND_ASSIGN(TestBuiltinTrapTermination); }; TEST(MultiprocessExec, BuiltinTrapTermination) { diff --git a/test/multiprocess_posix_test.cc b/test/multiprocess_posix_test.cc index b866695784..dd5f63f791 100644 --- a/test/multiprocess_posix_test.cc +++ b/test/multiprocess_posix_test.cc @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "gtest/gtest.h" #include "test/gtest_death.h" #include "util/file/file_io.h" @@ -31,6 +30,9 @@ class TestMultiprocess final : public Multiprocess { public: TestMultiprocess() : Multiprocess() {} + TestMultiprocess(const TestMultiprocess&) = delete; + TestMultiprocess& operator=(const TestMultiprocess&) = delete; + ~TestMultiprocess() {} private: @@ -66,8 +68,6 @@ class TestMultiprocess final : public Multiprocess { CheckedReadFileExactly(ReadPipeHandle(), &c, 1); EXPECT_EQ(c, 'm'); } - - DISALLOW_COPY_AND_ASSIGN(TestMultiprocess); }; TEST(Multiprocess, Multiprocess) { @@ -94,6 +94,9 @@ class TestMultiprocessUnclean final : public Multiprocess { } } + TestMultiprocessUnclean(const TestMultiprocessUnclean&) = delete; + TestMultiprocessUnclean& operator=(const TestMultiprocessUnclean&) = delete; + ~TestMultiprocessUnclean() {} private: @@ -115,8 +118,6 @@ class TestMultiprocessUnclean final : public Multiprocess { } TerminationType type_; - - DISALLOW_COPY_AND_ASSIGN(TestMultiprocessUnclean); }; TEST(Multiprocess, SuccessfulExit) { @@ -159,6 +160,10 @@ class TestMultiprocessClosePipe final : public Multiprocess { testing::GTEST_FLAG(death_test_style) = "fast"; } + TestMultiprocessClosePipe(const TestMultiprocessClosePipe&) = delete; + TestMultiprocessClosePipe& operator=(const TestMultiprocessClosePipe&) = + delete; + ~TestMultiprocessClosePipe() {} private: @@ -241,8 +246,6 @@ class TestMultiprocessClosePipe final : public Multiprocess { WhoCloses who_closes_; WhatCloses what_closes_; - - DISALLOW_COPY_AND_ASSIGN(TestMultiprocessClosePipe); }; TEST(MultiprocessDeathTest, ParentClosesReadPipe) { diff --git a/test/scoped_guarded_page.h b/test/scoped_guarded_page.h index 55ef272751..f7513d4f74 100644 --- a/test/scoped_guarded_page.h +++ b/test/scoped_guarded_page.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_TEST_SCOPED_GUARDED_PAGE_ #define CRASHPAD_TEST_SCOPED_GUARDED_PAGE_ -#include "base/macros.h" namespace crashpad { namespace test { @@ -31,6 +30,10 @@ namespace test { class ScopedGuardedPage { public: ScopedGuardedPage(); + + ScopedGuardedPage(const ScopedGuardedPage&) = delete; + ScopedGuardedPage& operator=(const ScopedGuardedPage&) = delete; + ~ScopedGuardedPage(); //! \brief Returns the address of the read-write page. @@ -40,7 +43,6 @@ class ScopedGuardedPage { private: void* ptr_; - DISALLOW_COPY_AND_ASSIGN(ScopedGuardedPage); }; } // namespace test diff --git a/test/scoped_module_handle.h b/test/scoped_module_handle.h index bbab066d55..0e96c9510b 100644 --- a/test/scoped_module_handle.h +++ b/test/scoped_module_handle.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_TEST_SCOPED_MODULE_HANDLE_H_ #define CRASHPAD_TEST_SCOPED_MODULE_HANDLE_H_ -#include "base/macros.h" #include "build/build_config.h" #if defined(OS_POSIX) @@ -33,6 +32,10 @@ class ScopedModuleHandle { private: class Impl { public: + Impl() = delete; + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; + #if defined(OS_POSIX) using ModuleHandle = void*; @@ -48,9 +51,6 @@ class ScopedModuleHandle { #endif static void Close(ModuleHandle handle); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(Impl); }; public: @@ -58,6 +58,10 @@ class ScopedModuleHandle { explicit ScopedModuleHandle(ModuleHandle handle); ScopedModuleHandle(ScopedModuleHandle&& handle); + + ScopedModuleHandle(const ScopedModuleHandle&) = delete; + ScopedModuleHandle& operator=(const ScopedModuleHandle&) = delete; + ~ScopedModuleHandle(); //! \return The module handle being managed. @@ -75,8 +79,6 @@ class ScopedModuleHandle { private: ModuleHandle handle_; - - DISALLOW_COPY_AND_ASSIGN(ScopedModuleHandle); }; } // namespace test diff --git a/test/scoped_temp_dir.h b/test/scoped_temp_dir.h index a648758009..a133190254 100644 --- a/test/scoped_temp_dir.h +++ b/test/scoped_temp_dir.h @@ -16,7 +16,6 @@ #define CRASHPAD_TEST_SCOPED_TEMP_DIR_ #include "base/files/file_path.h" -#include "base/macros.h" namespace crashpad { namespace test { @@ -29,6 +28,10 @@ namespace test { class ScopedTempDir { public: ScopedTempDir(); + + ScopedTempDir(const ScopedTempDir&) = delete; + ScopedTempDir& operator=(const ScopedTempDir&) = delete; + ~ScopedTempDir(); //! \brief Returns the path of the temporary directory. @@ -54,8 +57,6 @@ class ScopedTempDir { static void RecursivelyDeleteTemporaryDirectory(const base::FilePath& path); base::FilePath path_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTempDir); }; } // namespace test diff --git a/test/test_paths.h b/test/test_paths.h index 89ca4851f0..72bb155392 100644 --- a/test/test_paths.h +++ b/test/test_paths.h @@ -16,7 +16,6 @@ #define CRASHPAD_TEST_TEST_PATHS_H_ #include "base/files/file_path.h" -#include "base/macros.h" #include "build/build_config.h" namespace crashpad { @@ -60,6 +59,10 @@ class TestPaths { #endif // OS_WIN && ARCH_CPU_64_BITS }; + TestPaths() = delete; + TestPaths(const TestPaths&) = delete; + TestPaths& operator=(const TestPaths&) = delete; + //! \brief Returns the pathname of the currently-running test executable. //! //! On failure, aborts execution. @@ -140,8 +143,6 @@ class TestPaths { //! with Architecture::kDefault. static bool Has32BitBuildArtifacts(); #endif // OS_WIN && ARCH_CPU_64_BITS - - DISALLOW_IMPLICIT_CONSTRUCTORS(TestPaths); }; } // namespace test diff --git a/test/win/win_child_process.h b/test/win/win_child_process.h index a28da65e6a..a93f3ca82b 100644 --- a/test/win/win_child_process.h +++ b/test/win/win_child_process.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/file/file_io.h" #include "util/win/scoped_handle.h" @@ -41,6 +40,10 @@ class WinChildProcess { }; WinChildProcess(); + + WinChildProcess(const WinChildProcess&) = delete; + WinChildProcess& operator=(const WinChildProcess&) = delete; + virtual ~WinChildProcess() {} //! \brief Returns true if the current process is a child process. @@ -109,8 +112,6 @@ class WinChildProcess { ScopedFileHANDLE pipe_read_; ScopedFileHANDLE pipe_write_; - - DISALLOW_COPY_AND_ASSIGN(WinChildProcess); }; } // namespace test diff --git a/test/win/win_child_process_test.cc b/test/win/win_child_process_test.cc index eb38ba98b1..45b2dce5b1 100644 --- a/test/win/win_child_process_test.cc +++ b/test/win/win_child_process_test.cc @@ -17,7 +17,6 @@ #include #include -#include "base/macros.h" #include "gtest/gtest.h" namespace crashpad { @@ -43,6 +42,9 @@ class TestWinChildProcess final : public WinChildProcess { public: TestWinChildProcess() : WinChildProcess() {} + TestWinChildProcess(const TestWinChildProcess&) = delete; + TestWinChildProcess& operator=(const TestWinChildProcess&) = delete; + ~TestWinChildProcess() {} private: @@ -52,8 +54,6 @@ class TestWinChildProcess final : public WinChildProcess { WriteInt(WritePipeHandle(), value); return testing::Test::HasFailure() ? EXIT_FAILURE : EXIT_SUCCESS; } - - DISALLOW_COPY_AND_ASSIGN(TestWinChildProcess); }; TEST(WinChildProcessTest, WinChildProcess) { diff --git a/test/win/win_multiprocess.h b/test/win/win_multiprocess.h index d145563eec..91bee7e2cc 100644 --- a/test/win/win_multiprocess.h +++ b/test/win/win_multiprocess.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "gtest/gtest.h" #include "test/win/win_child_process.h" #include "util/file/file_io.h" @@ -31,6 +30,9 @@ class WinMultiprocess { public: WinMultiprocess(); + WinMultiprocess(const WinMultiprocess&) = delete; + WinMultiprocess& operator=(const WinMultiprocess&) = delete; + //! \brief Runs the test. //! //! This method establishes the testing environment by respawning the process @@ -127,15 +129,16 @@ class WinMultiprocess { class ChildProcessHelperBase : public WinChildProcess { public: ChildProcessHelperBase() {} + + ChildProcessHelperBase(const ChildProcessHelperBase&) = delete; + ChildProcessHelperBase& operator=(const ChildProcessHelperBase&) = delete; + ~ChildProcessHelperBase() override {} void CloseWritePipeForwarder() { CloseWritePipe(); } void CloseReadPipeForwarder() { CloseReadPipe(); } FileHandle ReadPipeHandleForwarder() const { return ReadPipeHandle(); } FileHandle WritePipeHandleForwarder() const { return WritePipeHandle(); } - - private: - DISALLOW_COPY_AND_ASSIGN(ChildProcessHelperBase); }; // Forwards WinChildProcess::Run to T::WinMultiprocessChild. @@ -143,6 +146,10 @@ class WinMultiprocess { class ChildProcessHelper : public ChildProcessHelperBase { public: ChildProcessHelper() {} + + ChildProcessHelper(const ChildProcessHelper&) = delete; + ChildProcessHelper& operator=(const ChildProcessHelper&) = delete; + ~ChildProcessHelper() override {} private: @@ -154,8 +161,6 @@ class WinMultiprocess { return 255; return EXIT_SUCCESS; } - - DISALLOW_COPY_AND_ASSIGN(ChildProcessHelper); }; //! \brief The subclass-provided parent routine. @@ -197,8 +202,6 @@ class WinMultiprocess { unsigned int exit_code_; WinChildProcess::Handles* child_handles_; ChildProcessHelperBase* child_process_helper_; - - DISALLOW_COPY_AND_ASSIGN(WinMultiprocess); }; } // namespace test diff --git a/test/win/win_multiprocess_test.cc b/test/win/win_multiprocess_test.cc index e1a315e2ff..60eb9d8d02 100644 --- a/test/win/win_multiprocess_test.cc +++ b/test/win/win_multiprocess_test.cc @@ -14,7 +14,6 @@ #include "test/win/win_multiprocess.h" -#include "base/macros.h" #include "gtest/gtest.h" namespace crashpad { @@ -26,6 +25,9 @@ class TestWinMultiprocess final : public WinMultiprocess { public: TestWinMultiprocess() {} + TestWinMultiprocess(const TestWinMultiprocess&) = delete; + TestWinMultiprocess& operator=(const TestWinMultiprocess&) = delete; + private: // WinMultiprocess will have already exercised the pipes. void WinMultiprocessParent() override { SetExpectedChildExitCode(ExitCode); } @@ -33,34 +35,38 @@ class TestWinMultiprocess final : public WinMultiprocess { void WinMultiprocessChild() override { exit(ExitCode); } - - DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess); }; class TestWinMultiprocessChildAsserts final : public WinMultiprocess { public: TestWinMultiprocessChildAsserts() {} + TestWinMultiprocessChildAsserts(const TestWinMultiprocessChildAsserts&) = + delete; + TestWinMultiprocessChildAsserts& operator=( + const TestWinMultiprocessChildAsserts&) = delete; + private: void WinMultiprocessParent() override { SetExpectedChildExitCode(255); } void WinMultiprocessChild() override { ASSERT_FALSE(true); } - - DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildAsserts); }; class TestWinMultiprocessChildExpects final : public WinMultiprocess { public: TestWinMultiprocessChildExpects() {} + TestWinMultiprocessChildExpects(const TestWinMultiprocessChildExpects&) = + delete; + TestWinMultiprocessChildExpects& operator=( + const TestWinMultiprocessChildExpects&) = delete; + private: void WinMultiprocessParent() override { SetExpectedChildExitCode(255); } void WinMultiprocessChild() override { EXPECT_FALSE(true); } - - DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildExpects); }; TEST(WinMultiprocess, WinMultiprocess) { diff --git a/test/win/win_multiprocess_with_temp_dir.h b/test/win/win_multiprocess_with_temp_dir.h index 6840cc6ba5..5e47c22a06 100644 --- a/test/win/win_multiprocess_with_temp_dir.h +++ b/test/win/win_multiprocess_with_temp_dir.h @@ -22,7 +22,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "test/scoped_temp_dir.h" #include "test/win/win_multiprocess.h" @@ -40,6 +39,10 @@ class WinMultiprocessWithTempDir : public WinMultiprocess { public: WinMultiprocessWithTempDir(); + WinMultiprocessWithTempDir(const WinMultiprocessWithTempDir&) = delete; + WinMultiprocessWithTempDir& operator=(const WinMultiprocessWithTempDir&) = + delete; + protected: void WinMultiprocessParentBeforeChild() override; void WinMultiprocessParentAfterChild(HANDLE child) override; @@ -51,6 +54,11 @@ class WinMultiprocessWithTempDir : public WinMultiprocess { class ScopedEnvironmentVariable { public: explicit ScopedEnvironmentVariable(const wchar_t* name); + + ScopedEnvironmentVariable(const ScopedEnvironmentVariable&) = delete; + ScopedEnvironmentVariable& operator=(const ScopedEnvironmentVariable&) = + delete; + ~ScopedEnvironmentVariable(); std::wstring GetValue() const; @@ -65,14 +73,10 @@ class WinMultiprocessWithTempDir : public WinMultiprocess { std::wstring original_value_; const wchar_t* name_; bool was_defined_; - - DISALLOW_COPY_AND_ASSIGN(ScopedEnvironmentVariable); }; std::unique_ptr temp_dir_; ScopedEnvironmentVariable temp_dir_env_; - - DISALLOW_COPY_AND_ASSIGN(WinMultiprocessWithTempDir); }; } // namespace test diff --git a/tools/mac/exception_port_tool.cc b/tools/mac/exception_port_tool.cc index 9e977b406e..2fdc580018 100644 --- a/tools/mac/exception_port_tool.cc +++ b/tools/mac/exception_port_tool.cc @@ -27,7 +27,6 @@ #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "tools/tool_support.h" #include "util/mach/bootstrap.h" #include "util/mach/exception_ports.h" @@ -65,6 +64,9 @@ class MachSendRightPool { : send_rights_() { } + MachSendRightPool(const MachSendRightPool&) = delete; + MachSendRightPool& operator=(const MachSendRightPool&) = delete; + ~MachSendRightPool() { for (mach_port_t send_right : send_rights_) { kern_return_t kr = mach_port_deallocate(mach_task_self(), send_right); @@ -94,8 +96,6 @@ class MachSendRightPool { private: std::vector send_rights_; - - DISALLOW_COPY_AND_ASSIGN(MachSendRightPool); }; struct ExceptionHandlerDescription { diff --git a/tools/tool_support.h b/tools/tool_support.h index 48f412f35f..fd4955e432 100644 --- a/tools/tool_support.h +++ b/tools/tool_support.h @@ -18,7 +18,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "base/strings/string_piece.h" #include "build/build_config.h" @@ -27,6 +26,10 @@ namespace crashpad { //! \brief Common functions used by command line tools. class ToolSupport { public: + ToolSupport() = delete; + ToolSupport(const ToolSupport&) = delete; + ToolSupport& operator=(const ToolSupport&) = delete; + //! \brief Handles `--version`. //! //! \param[in] me The tool’s name, the basename of `argv[0]`. @@ -83,9 +86,6 @@ class ToolSupport { //! Wmain(). static std::string FilePathToCommandLineArgument( const base::FilePath& file_path); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ToolSupport); }; } // namespace crashpad diff --git a/util/file/delimited_file_reader.h b/util/file/delimited_file_reader.h index 93fd738062..16bef2566f 100644 --- a/util/file/delimited_file_reader.h +++ b/util/file/delimited_file_reader.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/file/file_reader.h" namespace crashpad { @@ -51,6 +50,10 @@ class DelimitedFileReader { }; explicit DelimitedFileReader(FileReaderInterface* file_reader); + + DelimitedFileReader(const DelimitedFileReader&) = delete; + DelimitedFileReader& operator=(const DelimitedFileReader&) = delete; + ~DelimitedFileReader(); //! \brief Reads a single field from the file. @@ -84,8 +87,6 @@ class DelimitedFileReader { uint16_t buf_pos_; // Index into buf_ of the start of the next field. uint16_t buf_len_; // The size of buf_ that’s been filled. bool eof_; // Caches the EOF signal when detected following a partial field. - - DISALLOW_COPY_AND_ASSIGN(DelimitedFileReader); }; } // namespace crashpad diff --git a/util/file/directory_reader.h b/util/file/directory_reader.h index d3976929c9..096d120d63 100644 --- a/util/file/directory_reader.h +++ b/util/file/directory_reader.h @@ -16,7 +16,6 @@ #define CRASHPAD_UTIL_FILE_DIRECTORY_READER_H_ #include "base/files/file_path.h" -#include "base/macros.h" #include "build/build_config.h" #if defined(OS_POSIX) @@ -48,6 +47,10 @@ class DirectoryReader { }; DirectoryReader(); + + DirectoryReader(const DirectoryReader&) = delete; + DirectoryReader& operator=(const DirectoryReader&) = delete; + ~DirectoryReader(); //! \brief Opens the directory specified by \a path for reading. @@ -78,8 +81,6 @@ class DirectoryReader { ScopedSearchHANDLE handle_; bool first_entry_; #endif // OS_POSIX - - DISALLOW_COPY_AND_ASSIGN(DirectoryReader); }; } // namespace crashpad diff --git a/util/file/file_io.cc b/util/file/file_io.cc index 3bd86cc465..48da6383db 100644 --- a/util/file/file_io.cc +++ b/util/file/file_io.cc @@ -16,7 +16,6 @@ #include "base/check_op.h" #include "base/logging.h" -#include "base/macros.h" #include "base/numerics/safe_conversions.h" namespace crashpad { @@ -27,6 +26,10 @@ class FileIOReadExactly final : public internal::ReadExactlyInternal { public: explicit FileIOReadExactly(FileHandle file) : ReadExactlyInternal(), file_(file) {} + + FileIOReadExactly(const FileIOReadExactly&) = delete; + FileIOReadExactly& operator=(const FileIOReadExactly&) = delete; + ~FileIOReadExactly() {} private: @@ -41,13 +44,15 @@ class FileIOReadExactly final : public internal::ReadExactlyInternal { } FileHandle file_; - - DISALLOW_COPY_AND_ASSIGN(FileIOReadExactly); }; class FileIOWriteAll final : public internal::WriteAllInternal { public: explicit FileIOWriteAll(FileHandle file) : WriteAllInternal(), file_(file) {} + + FileIOWriteAll(const FileIOWriteAll&) = delete; + FileIOWriteAll& operator=(const FileIOWriteAll&) = delete; + ~FileIOWriteAll() {} private: @@ -57,8 +62,6 @@ class FileIOWriteAll final : public internal::WriteAllInternal { } FileHandle file_; - - DISALLOW_COPY_AND_ASSIGN(FileIOWriteAll); }; } // namespace diff --git a/util/file/file_io.h b/util/file/file_io.h index 3b6d7679ea..526debddae 100644 --- a/util/file/file_io.h +++ b/util/file/file_io.h @@ -164,6 +164,9 @@ constexpr char kNativeWriteFunctionName[] = "WriteFile"; //! FileReaderInterface::ReadExactly() instead. class ReadExactlyInternal { public: + ReadExactlyInternal(const ReadExactlyInternal&) = delete; + ReadExactlyInternal& operator=(const ReadExactlyInternal&) = delete; + //! \brief Calls Read(), retrying following a short read, ensuring that //! exactly \a size bytes are read. //! @@ -182,8 +185,6 @@ class ReadExactlyInternal { //! \return The number of bytes read and placed into \a buffer, or `-1` on //! error. When returning `-1`, if \a can_log is `true`, logs a message. virtual FileOperationResult Read(void* buffer, size_t size, bool can_log) = 0; - - DISALLOW_COPY_AND_ASSIGN(ReadExactlyInternal); }; //! \brief The internal implementation of WriteFile() and its wrappers. @@ -194,6 +195,9 @@ class ReadExactlyInternal { //! FileWriterInterface::Write() instead. class WriteAllInternal { public: + WriteAllInternal(const WriteAllInternal&) = delete; + WriteAllInternal& operator=(const WriteAllInternal&) = delete; + //! \brief Calls Write(), retrying following a short write, ensuring that //! exactly \a size bytes are written. //! @@ -210,8 +214,6 @@ class WriteAllInternal { //! //! \return The number of bytes written from \a buffer, or `-1` on error. virtual FileOperationResult Write(const void* buffer, size_t size) = 0; - - DISALLOW_COPY_AND_ASSIGN(WriteAllInternal); }; //! \brief Writes to a file, retrying when interrupted on POSIX. diff --git a/util/file/file_io_test.cc b/util/file/file_io_test.cc index fc61857529..abfef12916 100644 --- a/util/file/file_io_test.cc +++ b/util/file/file_io_test.cc @@ -22,7 +22,6 @@ #include "base/atomicops.h" #include "base/cxx17_backports.h" #include "base/files/file_path.h" -#include "base/macros.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -42,6 +41,10 @@ using testing::Return; class MockReadExactly : public internal::ReadExactlyInternal { public: MockReadExactly() : ReadExactlyInternal() {} + + MockReadExactly(const MockReadExactly&) = delete; + MockReadExactly& operator=(const MockReadExactly&) = delete; + ~MockReadExactly() {} // Since it’s more convenient for the test to use uintptr_t than void*, @@ -57,9 +60,6 @@ class MockReadExactly : public internal::ReadExactlyInternal { FileOperationResult Read(void* data, size_t size, bool can_log) { return ReadInt(reinterpret_cast(data), size, can_log); } - - private: - DISALLOW_COPY_AND_ASSIGN(MockReadExactly); }; TEST(FileIO, ReadExactly_Zero) { @@ -239,6 +239,10 @@ TEST(FileIO, ReadExactly_TripleMax) { class MockWriteAll : public internal::WriteAllInternal { public: MockWriteAll() : WriteAllInternal() {} + + MockWriteAll(const MockWriteAll&) = delete; + MockWriteAll& operator=(const MockWriteAll&) = delete; + ~MockWriteAll() {} // Since it’s more convenient for the test to use uintptr_t than const void*, @@ -254,9 +258,6 @@ class MockWriteAll : public internal::WriteAllInternal { FileOperationResult Write(const void* data, size_t size) { return WriteInt(reinterpret_cast(data), size); } - - private: - DISALLOW_COPY_AND_ASSIGN(MockWriteAll); }; TEST(FileIO, WriteAll_Zero) { @@ -582,6 +583,9 @@ class LockingTestThread : public Thread { LockingTestThread() : file_(), lock_type_(), iterations_(), actual_iterations_() {} + LockingTestThread(const LockingTestThread&) = delete; + LockingTestThread& operator=(const LockingTestThread&) = delete; + void Init(FileHandle file, FileLocking lock_type, int iterations, @@ -608,8 +612,6 @@ class LockingTestThread : public Thread { FileLocking lock_type_; int iterations_; base::subtle::Atomic32* actual_iterations_; - - DISALLOW_COPY_AND_ASSIGN(LockingTestThread); }; void LockingTest(FileLocking main_lock, FileLocking other_locks) { diff --git a/util/file/file_reader.cc b/util/file/file_reader.cc index 6f272f013f..f22bd7ec66 100644 --- a/util/file/file_reader.cc +++ b/util/file/file_reader.cc @@ -26,6 +26,10 @@ class FileReaderReadExactly final : public internal::ReadExactlyInternal { public: explicit FileReaderReadExactly(FileReaderInterface* file_reader) : ReadExactlyInternal(), file_reader_(file_reader) {} + + FileReaderReadExactly(const FileReaderReadExactly&) = delete; + FileReaderReadExactly& operator=(const FileReaderReadExactly&) = delete; + ~FileReaderReadExactly() {} private: @@ -36,8 +40,6 @@ class FileReaderReadExactly final : public internal::ReadExactlyInternal { } FileReaderInterface* file_reader_; // weak - - DISALLOW_COPY_AND_ASSIGN(FileReaderReadExactly); }; } // namespace diff --git a/util/file/file_reader.h b/util/file/file_reader.h index d44be1c142..f24366c117 100644 --- a/util/file/file_reader.h +++ b/util/file/file_reader.h @@ -18,7 +18,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "util/file/file_io.h" #include "util/file/file_seeker.h" @@ -65,6 +64,10 @@ class FileReaderInterface : public virtual FileSeekerInterface { class WeakFileHandleFileReader : public FileReaderInterface { public: explicit WeakFileHandleFileReader(FileHandle file_handle); + + WeakFileHandleFileReader(const WeakFileHandleFileReader&) = delete; + WeakFileHandleFileReader& operator=(const WeakFileHandleFileReader&) = delete; + ~WeakFileHandleFileReader() override; // FileReaderInterface: @@ -89,8 +92,6 @@ class WeakFileHandleFileReader : public FileReaderInterface { // construction because no file descriptor will be available until // FileReader::Open() is called. friend class FileReader; - - DISALLOW_COPY_AND_ASSIGN(WeakFileHandleFileReader); }; //! \brief A file reader implementation that wraps traditional system file @@ -98,6 +99,10 @@ class WeakFileHandleFileReader : public FileReaderInterface { class FileReader : public FileReaderInterface { public: FileReader(); + + FileReader(const FileReader&) = delete; + FileReader& operator=(const FileReader&) = delete; + ~FileReader() override; // FileReaderInterface: @@ -137,8 +142,6 @@ class FileReader : public FileReaderInterface { private: ScopedFileHandle file_; WeakFileHandleFileReader weak_file_handle_file_reader_; - - DISALLOW_COPY_AND_ASSIGN(FileReader); }; } // namespace crashpad diff --git a/util/file/file_reader_test.cc b/util/file/file_reader_test.cc index ea2dd3556b..bda1a3b4a9 100644 --- a/util/file/file_reader_test.cc +++ b/util/file/file_reader_test.cc @@ -33,6 +33,10 @@ using testing::Return; class MockFileReader : public FileReaderInterface { public: MockFileReader() : FileReaderInterface() {} + + MockFileReader(const MockFileReader&) = delete; + MockFileReader& operator=(const MockFileReader&) = delete; + ~MockFileReader() override {} // Since it’s more convenient for the test to use uintptr_t than void*, @@ -51,9 +55,6 @@ class MockFileReader : public FileReaderInterface { // FileSeekerInterface: MOCK_METHOD(FileOffset, Seek, (FileOffset, int), (override)); - - private: - DISALLOW_COPY_AND_ASSIGN(MockFileReader); }; TEST(FileReader, ReadExactly_Zero) { diff --git a/util/file/file_writer.h b/util/file/file_writer.h index 987c0f59d5..4ba7a43868 100644 --- a/util/file/file_writer.h +++ b/util/file/file_writer.h @@ -20,7 +20,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "util/file/file_io.h" #include "util/file/file_seeker.h" @@ -82,6 +81,10 @@ class FileWriterInterface : public virtual FileSeekerInterface { class WeakFileHandleFileWriter : public FileWriterInterface { public: explicit WeakFileHandleFileWriter(FileHandle file_handle); + + WeakFileHandleFileWriter(const WeakFileHandleFileWriter&) = delete; + WeakFileHandleFileWriter& operator=(const WeakFileHandleFileWriter&) = delete; + ~WeakFileHandleFileWriter() override; // FileWriterInterface: @@ -107,8 +110,6 @@ class WeakFileHandleFileWriter : public FileWriterInterface { // construction because no file descriptor will be available until // FileWriter::Open() is called. friend class FileWriter; - - DISALLOW_COPY_AND_ASSIGN(WeakFileHandleFileWriter); }; //! \brief A file writer implementation that wraps traditional system file @@ -116,6 +117,10 @@ class WeakFileHandleFileWriter : public FileWriterInterface { class FileWriter : public FileWriterInterface { public: FileWriter(); + + FileWriter(const FileWriter&) = delete; + FileWriter& operator=(const FileWriter&) = delete; + ~FileWriter() override; // FileWriterInterface: @@ -179,8 +184,6 @@ class FileWriter : public FileWriterInterface { private: ScopedFileHandle file_; WeakFileHandleFileWriter weak_file_handle_file_writer_; - - DISALLOW_COPY_AND_ASSIGN(FileWriter); }; } // namespace crashpad diff --git a/util/file/output_stream_file_writer.h b/util/file/output_stream_file_writer.h index 6bf1c2c198..60965f9219 100644 --- a/util/file/output_stream_file_writer.h +++ b/util/file/output_stream_file_writer.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/file/file_writer.h" namespace crashpad { @@ -31,6 +30,10 @@ class OutputStreamFileWriter : public FileWriterInterface { //! \param[in] output_stream The output stream that this object writes to. explicit OutputStreamFileWriter( std::unique_ptr output_stream); + + OutputStreamFileWriter(const OutputStreamFileWriter&) = delete; + OutputStreamFileWriter& operator=(const OutputStreamFileWriter&) = delete; + ~OutputStreamFileWriter() override; // FileWriterInterface: @@ -53,8 +56,6 @@ class OutputStreamFileWriter : public FileWriterInterface { std::unique_ptr output_stream_; bool flush_needed_; bool flushed_; - - DISALLOW_COPY_AND_ASSIGN(OutputStreamFileWriter); }; } // namespace crashpad diff --git a/util/file/string_file.h b/util/file/string_file.h index 313310e678..bd68987464 100644 --- a/util/file/string_file.h +++ b/util/file/string_file.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "base/numerics/safe_math.h" #include "util/file/file_io.h" #include "util/file/file_reader.h" @@ -37,6 +36,10 @@ namespace crashpad { class StringFile : public FileReaderInterface, public FileWriterInterface { public: StringFile(); + + StringFile(const StringFile&) = delete; + StringFile& operator=(const StringFile&) = delete; + ~StringFile() override; //! \brief Returns a string containing the virtual file’s contents. @@ -72,8 +75,6 @@ class StringFile : public FileReaderInterface, public FileWriterInterface { //! report file offsets. The implementation must take care when converting //! between these distinct types. base::CheckedNumeric offset_; - - DISALLOW_COPY_AND_ASSIGN(StringFile); }; } // namespace crashpad diff --git a/util/fuchsia/scoped_task_suspend.h b/util/fuchsia/scoped_task_suspend.h index afe497bc30..49a73cf5ee 100644 --- a/util/fuchsia/scoped_task_suspend.h +++ b/util/fuchsia/scoped_task_suspend.h @@ -21,7 +21,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -36,12 +35,14 @@ namespace crashpad { class ScopedTaskSuspend { public: explicit ScopedTaskSuspend(const zx::process& process); + + ScopedTaskSuspend(const ScopedTaskSuspend&) = delete; + ScopedTaskSuspend& operator=(const ScopedTaskSuspend&) = delete; + ~ScopedTaskSuspend() = default; private: zx::suspend_token suspend_token_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTaskSuspend); }; } // namespace crashpad diff --git a/util/ios/ios_intermediate_dump_data.h b/util/ios/ios_intermediate_dump_data.h index def5ab9c09..c2613e90f3 100644 --- a/util/ios/ios_intermediate_dump_data.h +++ b/util/ios/ios_intermediate_dump_data.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "util/ios/ios_intermediate_dump_object.h" namespace crashpad { @@ -28,6 +27,10 @@ namespace internal { class IOSIntermediateDumpData : public IOSIntermediateDumpObject { public: IOSIntermediateDumpData(); + + IOSIntermediateDumpData(const IOSIntermediateDumpData&) = delete; + IOSIntermediateDumpData& operator=(const IOSIntermediateDumpData&) = delete; + ~IOSIntermediateDumpData() override; //! \brief Constructs a new data object which owns a std::vector. @@ -58,8 +61,6 @@ class IOSIntermediateDumpData : public IOSIntermediateDumpObject { bool GetValueInternal(void* value, size_t value_size) const; std::vector data_; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpData); }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_list.h b/util/ios/ios_intermediate_dump_list.h index 42d1ef299d..e2ad92537d 100644 --- a/util/ios/ios_intermediate_dump_list.h +++ b/util/ios/ios_intermediate_dump_list.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/ios/ios_intermediate_dump_map.h" #include "util/ios/ios_intermediate_dump_object.h" @@ -30,6 +29,10 @@ namespace internal { class IOSIntermediateDumpList : public IOSIntermediateDumpObject { public: IOSIntermediateDumpList(); + + IOSIntermediateDumpList(const IOSIntermediateDumpList&) = delete; + IOSIntermediateDumpList& operator=(const IOSIntermediateDumpList&) = delete; + ~IOSIntermediateDumpList() override; // IOSIntermediateDumpObject: @@ -45,8 +48,6 @@ class IOSIntermediateDumpList : public IOSIntermediateDumpObject { private: VectorType list_; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpList); }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_map.h b/util/ios/ios_intermediate_dump_map.h index a11d6a63d3..ca26cb37e2 100644 --- a/util/ios/ios_intermediate_dump_map.h +++ b/util/ios/ios_intermediate_dump_map.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "util/ios/ios_intermediate_dump_format.h" #include "util/ios/ios_intermediate_dump_object.h" @@ -34,6 +33,10 @@ class IOSIntermediateDumpData; class IOSIntermediateDumpMap : public IOSIntermediateDumpObject { public: IOSIntermediateDumpMap(); + + IOSIntermediateDumpMap(const IOSIntermediateDumpMap&) = delete; + IOSIntermediateDumpMap& operator=(const IOSIntermediateDumpMap&) = delete; + ~IOSIntermediateDumpMap() override; // IOSIntermediateDumpObject: @@ -60,8 +63,6 @@ class IOSIntermediateDumpMap : public IOSIntermediateDumpObject { friend class IOSIntermediateDumpReader; std::map> map_; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpMap); }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_object.h b/util/ios/ios_intermediate_dump_object.h index 21ccd29704..fde7e1e46b 100644 --- a/util/ios/ios_intermediate_dump_object.h +++ b/util/ios/ios_intermediate_dump_object.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_OBJECT_H_ #define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_OBJECT_H_ -#include "base/macros.h" #include "util/ios/ios_intermediate_dump_writer.h" namespace crashpad { @@ -25,6 +24,11 @@ namespace internal { class IOSIntermediateDumpObject { public: IOSIntermediateDumpObject(); + + IOSIntermediateDumpObject(const IOSIntermediateDumpObject&) = delete; + IOSIntermediateDumpObject& operator=(const IOSIntermediateDumpObject&) = + delete; + virtual ~IOSIntermediateDumpObject(); //! \brief The type of object stored in the intermediate dump. . @@ -41,8 +45,6 @@ class IOSIntermediateDumpObject { //! \brief Returns a type. virtual Type GetType() const = 0; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpObject); }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_reader.h b/util/ios/ios_intermediate_dump_reader.h index 2966e7c9f9..e1c42172a2 100644 --- a/util/ios/ios_intermediate_dump_reader.h +++ b/util/ios/ios_intermediate_dump_reader.h @@ -16,7 +16,6 @@ #define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_ #include "base/files/file_path.h" -#include "base/macros.h" #include "util/file/file_reader.h" #include "util/ios/ios_intermediate_dump_map.h" @@ -28,6 +27,10 @@ class IOSIntermediateDumpReader { public: IOSIntermediateDumpReader() {} + IOSIntermediateDumpReader(const IOSIntermediateDumpReader&) = delete; + IOSIntermediateDumpReader& operator=(const IOSIntermediateDumpReader&) = + delete; + //! \brief Open and parses \a path, ignoring empty files. //! //! Will attempt to parse the binary file, similar to a JSON file, using the @@ -48,8 +51,6 @@ class IOSIntermediateDumpReader { private: bool Parse(FileReaderInterface* reader, FileOffset file_size); IOSIntermediateDumpMap minidump_; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpReader); }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_writer.h b/util/ios/ios_intermediate_dump_writer.h index 0f8b1b7db5..836fbe7ac6 100644 --- a/util/ios/ios_intermediate_dump_writer.h +++ b/util/ios/ios_intermediate_dump_writer.h @@ -16,7 +16,6 @@ #define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_WRITER_H_ #include "base/files/file_path.h" -#include "base/macros.h" #include "util/ios/ios_intermediate_dump_format.h" namespace crashpad { @@ -42,6 +41,10 @@ class IOSIntermediateDumpWriter final { public: IOSIntermediateDumpWriter() = default; + IOSIntermediateDumpWriter(const IOSIntermediateDumpWriter&) = delete; + IOSIntermediateDumpWriter& operator=(const IOSIntermediateDumpWriter&) = + delete; + //! \brief Command instructions for the intermediate dump reader. enum class CommandType : uint8_t { //! \brief Indicates a new map, followed by associated key. @@ -88,11 +91,14 @@ class IOSIntermediateDumpWriter final { : writer_(writer) { writer->RootMapStart(); } + + ScopedRootMap(const ScopedRootMap&) = delete; + ScopedRootMap& operator=(const ScopedRootMap&) = delete; + ~ScopedRootMap() { writer_->RootMapEnd(); } private: IOSIntermediateDumpWriter* writer_; - DISALLOW_COPY_AND_ASSIGN(ScopedRootMap); }; //! \brief A scoped wrapper for calls to MapStart and MapEnd. @@ -103,11 +109,14 @@ class IOSIntermediateDumpWriter final { : writer_(writer) { writer->MapStart(key); } + + ScopedMap(const ScopedMap&) = delete; + ScopedMap& operator=(const ScopedMap&) = delete; + ~ScopedMap() { writer_->MapEnd(); } private: IOSIntermediateDumpWriter* writer_; - DISALLOW_COPY_AND_ASSIGN(ScopedMap); }; //! \brief A scoped wrapper for calls to ArrayMapStart and MapEnd. @@ -117,11 +126,14 @@ class IOSIntermediateDumpWriter final { : writer_(writer) { writer->ArrayMapStart(); } + + ScopedArrayMap(const ScopedArrayMap&) = delete; + ScopedArrayMap& operator=(const ScopedArrayMap&) = delete; + ~ScopedArrayMap() { writer_->MapEnd(); } private: IOSIntermediateDumpWriter* writer_; - DISALLOW_COPY_AND_ASSIGN(ScopedArrayMap); }; //! \brief A scoped wrapper for calls to ArrayStart and ArrayEnd. @@ -132,11 +144,14 @@ class IOSIntermediateDumpWriter final { : writer_(writer) { writer->ArrayStart(key); } + + ScopedArray(const ScopedArray&) = delete; + ScopedArray& operator=(const ScopedArray&) = delete; + ~ScopedArray() { writer_->ArrayEnd(); } private: IOSIntermediateDumpWriter* writer_; - DISALLOW_COPY_AND_ASSIGN(ScopedArray); }; //! \return The `true` if able to AddPropertyInternal the \a key \a value @@ -187,8 +202,6 @@ class IOSIntermediateDumpWriter final { bool RootMapEnd(); int fd_; - - DISALLOW_COPY_AND_ASSIGN(IOSIntermediateDumpWriter); }; } // namespace internal diff --git a/util/ios/scoped_vm_read.h b/util/ios/scoped_vm_read.h index 3f396d4541..3fa1249c66 100644 --- a/util/ios/scoped_vm_read.h +++ b/util/ios/scoped_vm_read.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { namespace internal { @@ -28,6 +27,10 @@ namespace internal { class ScopedVMReadInternal { public: ScopedVMReadInternal(); + + ScopedVMReadInternal(const ScopedVMReadInternal&) = delete; + ScopedVMReadInternal& operator=(const ScopedVMReadInternal&) = delete; + ~ScopedVMReadInternal(); //! \brief Releases any previously read data and vm_reads \a data. Logs an @@ -51,8 +54,6 @@ class ScopedVMReadInternal { // The size of the pages that were actually read. mach_msg_type_number_t vm_read_data_count_; - - DISALLOW_COPY_AND_ASSIGN(ScopedVMReadInternal); }; //! \brief A scoped wrapper for calls to `vm_read` and `vm_deallocate`. Allows @@ -63,6 +64,10 @@ template class ScopedVMRead { public: ScopedVMRead() : internal_() {} + + ScopedVMRead(const ScopedVMRead&) = delete; + ScopedVMRead& operator=(const ScopedVMRead&) = delete; + ~ScopedVMRead() {} //! \brief Releases any previously read data and vm_reads data. @@ -96,7 +101,6 @@ class ScopedVMRead { private: ScopedVMReadInternal internal_; - DISALLOW_COPY_AND_ASSIGN(ScopedVMRead); }; } // namespace internal diff --git a/util/linux/auxiliary_vector.h b/util/linux/auxiliary_vector.h index a6a44c487a..63a115438b 100644 --- a/util/linux/auxiliary_vector.h +++ b/util/linux/auxiliary_vector.h @@ -20,7 +20,6 @@ #include #include "base/logging.h" -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/misc/reinterpret_bytes.h" @@ -30,6 +29,10 @@ namespace crashpad { class AuxiliaryVector { public: AuxiliaryVector(); + + AuxiliaryVector(const AuxiliaryVector&) = delete; + AuxiliaryVector& operator=(const AuxiliaryVector&) = delete; + ~AuxiliaryVector(); //! \brief Initializes this object with the auxiliary vector for the process @@ -65,8 +68,6 @@ class AuxiliaryVector { private: template bool Read(PtraceConnection* connection); - - DISALLOW_COPY_AND_ASSIGN(AuxiliaryVector); }; } // namespace crashpad diff --git a/util/linux/auxiliary_vector_test.cc b/util/linux/auxiliary_vector_test.cc index 2f6c942267..75c20d1a09 100644 --- a/util/linux/auxiliary_vector_test.cc +++ b/util/linux/auxiliary_vector_test.cc @@ -21,7 +21,6 @@ #include #include "base/bit_cast.h" -#include "base/macros.h" #include "build/build_config.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -151,14 +150,16 @@ TEST(AuxiliaryVector, ReadSelf) { class ReadChildTest : public Multiprocess { public: ReadChildTest() : Multiprocess() {} + + ReadChildTest(const ReadChildTest&) = delete; + ReadChildTest& operator=(const ReadChildTest&) = delete; + ~ReadChildTest() {} private: void MultiprocessParent() override { TestAgainstCloneOrSelf(ChildPID()); } void MultiprocessChild() override { CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(ReadChildTest); }; TEST(AuxiliaryVector, ReadChild) { diff --git a/util/linux/direct_ptrace_connection.h b/util/linux/direct_ptrace_connection.h index 99ad233a13..a120889a59 100644 --- a/util/linux/direct_ptrace_connection.h +++ b/util/linux/direct_ptrace_connection.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/linux/ptracer.h" #include "util/linux/scoped_ptrace_attach.h" @@ -36,6 +35,10 @@ namespace crashpad { class DirectPtraceConnection : public PtraceConnection { public: DirectPtraceConnection(); + + DirectPtraceConnection(const DirectPtraceConnection&) = delete; + DirectPtraceConnection& operator=(const DirectPtraceConnection&) = delete; + ~DirectPtraceConnection(); //! \brief Initializes this connection for the process whose process ID is @@ -65,8 +68,6 @@ class DirectPtraceConnection : public PtraceConnection { pid_t pid_; Ptracer ptracer_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(DirectPtraceConnection); }; } // namespace crashpad diff --git a/util/linux/exception_handler_client.cc b/util/linux/exception_handler_client.cc index 98edb30636..608a199c0d 100644 --- a/util/linux/exception_handler_client.cc +++ b/util/linux/exception_handler_client.cc @@ -46,6 +46,9 @@ class ScopedSigprocmaskRestore { DPLOG_IF(ERROR, !mask_is_set_) << "sigprocmask"; } + ScopedSigprocmaskRestore(const ScopedSigprocmaskRestore&) = delete; + ScopedSigprocmaskRestore& operator=(const ScopedSigprocmaskRestore&) = delete; + ~ScopedSigprocmaskRestore() { if (mask_is_set_ && sys_sigprocmask(SIG_SETMASK, &orig_mask_, nullptr) != 0) { @@ -56,8 +59,6 @@ class ScopedSigprocmaskRestore { private: kernel_sigset_t orig_mask_; bool mask_is_set_; - - DISALLOW_COPY_AND_ASSIGN(ScopedSigprocmaskRestore); }; } // namespace diff --git a/util/linux/exception_handler_client.h b/util/linux/exception_handler_client.h index 4e10fa62fa..7b28bd4867 100644 --- a/util/linux/exception_handler_client.h +++ b/util/linux/exception_handler_client.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "util/linux/exception_handler_protocol.h" namespace crashpad { @@ -33,6 +32,9 @@ class ExceptionHandlerClient { //! clients. ExceptionHandlerClient(int sock, bool multiple_clients); + ExceptionHandlerClient(const ExceptionHandlerClient&) = delete; + ExceptionHandlerClient& operator=(const ExceptionHandlerClient&) = delete; + ~ExceptionHandlerClient(); //! \brief Communicates with the handler to determine its credentials. @@ -78,8 +80,6 @@ class ExceptionHandlerClient { pid_t ptracer_; bool can_set_ptracer_; bool multiple_clients_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerClient); }; } // namespace crashpad diff --git a/util/linux/exception_handler_protocol.h b/util/linux/exception_handler_protocol.h index 60b0b1b7ed..cbd24418a6 100644 --- a/util/linux/exception_handler_protocol.h +++ b/util/linux/exception_handler_protocol.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "util/file/file_io.h" #include "util/misc/address_types.h" @@ -124,9 +123,11 @@ class ExceptionHandlerProtocol { pid_t pid; }; -#pragma pack(pop) + ExceptionHandlerProtocol() = delete; + ExceptionHandlerProtocol(const ExceptionHandlerProtocol&) = delete; + ExceptionHandlerProtocol& operator=(const ExceptionHandlerProtocol&) = delete; - DISALLOW_IMPLICIT_CONSTRUCTORS(ExceptionHandlerProtocol); +#pragma pack(pop) }; } // namespace crashpad diff --git a/util/linux/memory_map.cc b/util/linux/memory_map.cc index 0890cd611e..dabc114d91 100644 --- a/util/linux/memory_map.cc +++ b/util/linux/memory_map.cc @@ -190,6 +190,9 @@ class SparseReverseIterator : public MemoryMap::Iterator { SparseReverseIterator() : mappings_(), riter_(mappings_.rend()) {} + SparseReverseIterator(const SparseReverseIterator&) = delete; + SparseReverseIterator& operator=(const SparseReverseIterator&) = delete; + // Iterator: const MemoryMap::Mapping* Next() override { return riter_ == mappings_.rend() ? nullptr : *(riter_++); @@ -200,8 +203,6 @@ class SparseReverseIterator : public MemoryMap::Iterator { private: std::vector mappings_; std::vector::reverse_iterator riter_; - - DISALLOW_COPY_AND_ASSIGN(SparseReverseIterator); }; class FullReverseIterator : public MemoryMap::Iterator { @@ -211,6 +212,9 @@ class FullReverseIterator : public MemoryMap::Iterator { std::vector::const_reverse_iterator rend) : riter_(rbegin), rend_(rend) {} + FullReverseIterator(const FullReverseIterator&) = delete; + FullReverseIterator& operator=(const FullReverseIterator&) = delete; + // Iterator: const MemoryMap::Mapping* Next() override { return riter_ == rend_ ? nullptr : &*riter_++; @@ -221,8 +225,6 @@ class FullReverseIterator : public MemoryMap::Iterator { private: std::vector::const_reverse_iterator riter_; std::vector::const_reverse_iterator rend_; - - DISALLOW_COPY_AND_ASSIGN(FullReverseIterator); }; } // namespace diff --git a/util/linux/memory_map_test.cc b/util/linux/memory_map_test.cc index 0ee9080012..4ab7b05c43 100644 --- a/util/linux/memory_map_test.cc +++ b/util/linux/memory_map_test.cc @@ -136,6 +136,10 @@ void InitializeFile(const base::FilePath& path, class MapChildTest : public Multiprocess { public: MapChildTest() : Multiprocess(), page_size_(getpagesize()) {} + + MapChildTest(const MapChildTest&) = delete; + MapChildTest& operator=(const MapChildTest&) = delete; + ~MapChildTest() {} private: @@ -249,8 +253,6 @@ class MapChildTest : public Multiprocess { } const size_t page_size_; - - DISALLOW_COPY_AND_ASSIGN(MapChildTest); }; TEST(MemoryMap, MapChild) { @@ -326,6 +328,10 @@ TEST(MemoryMap, SelfLargeMapFile) { class MapRunningChildTest : public Multiprocess { public: MapRunningChildTest() : Multiprocess(), page_size_(getpagesize()) {} + + MapRunningChildTest(const MapRunningChildTest&) = delete; + MapRunningChildTest& operator=(const MapRunningChildTest&) = delete; + ~MapRunningChildTest() {} private: @@ -384,8 +390,6 @@ class MapRunningChildTest : public Multiprocess { static constexpr size_t kNumMappings = 1024; const size_t page_size_; - - DISALLOW_COPY_AND_ASSIGN(MapRunningChildTest); }; TEST(MemoryMap, MapRunningChild) { diff --git a/util/linux/proc_stat_reader.h b/util/linux/proc_stat_reader.h index 6eae8fbb2c..193330c7b3 100644 --- a/util/linux/proc_stat_reader.h +++ b/util/linux/proc_stat_reader.h @@ -21,7 +21,6 @@ #include -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/misc/initialization_state_dcheck.h" @@ -31,6 +30,10 @@ namespace crashpad { class ProcStatReader { public: ProcStatReader(); + + ProcStatReader(const ProcStatReader&) = delete; + ProcStatReader& operator=(const ProcStatReader&) = delete; + ~ProcStatReader(); //! \brief Initializes the reader. @@ -74,8 +77,6 @@ class ProcStatReader { std::string contents_; size_t third_column_position_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcStatReader); }; } // namespace crashpad diff --git a/util/linux/proc_task_reader_test.cc b/util/linux/proc_task_reader_test.cc index a93b2d4e46..ab2650f50a 100644 --- a/util/linux/proc_task_reader_test.cc +++ b/util/linux/proc_task_reader_test.cc @@ -14,7 +14,6 @@ #include "util/linux/proc_task_reader.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/multiprocess_exec.h" @@ -123,6 +122,9 @@ class ProcTaskTest : public MultiprocessExec { SetChildTestMainFunction("ProcTaskTestChild"); } + ProcTaskTest(const ProcTaskTest&) = delete; + ProcTaskTest& operator=(const ProcTaskTest&) = delete; + private: bool ReadIDFromChild(std::vector* threads) { pid_t tid; @@ -147,8 +149,6 @@ class ProcTaskTest : public MultiprocessExec { EXPECT_TRUE(FindThreadID(ids_to_find[index], threads)); } } - - DISALLOW_COPY_AND_ASSIGN(ProcTaskTest); }; TEST(ProcTaskReader, ReadChild) { diff --git a/util/linux/ptrace_broker.cc b/util/linux/ptrace_broker.cc index 13c8b79813..9bf133bc89 100644 --- a/util/linux/ptrace_broker.cc +++ b/util/linux/ptrace_broker.cc @@ -61,6 +61,9 @@ class PtraceBroker::AttachmentsArray { public: AttachmentsArray() : allocation_(false), attach_count_(0) {} + AttachmentsArray(const AttachmentsArray&) = delete; + AttachmentsArray& operator=(const AttachmentsArray&) = delete; + ~AttachmentsArray() { for (size_t index = 0; index < attach_count_; ++index) { PtraceDetach(Attachments()[index], false); @@ -98,8 +101,6 @@ class PtraceBroker::AttachmentsArray { ScopedMmap allocation_; size_t attach_count_; - - DISALLOW_COPY_AND_ASSIGN(AttachmentsArray); }; PtraceBroker::PtraceBroker(int sock, pid_t pid, bool is_64_bit) diff --git a/util/linux/ptrace_broker.h b/util/linux/ptrace_broker.h index 5d90cb2027..4502da2004 100644 --- a/util/linux/ptrace_broker.h +++ b/util/linux/ptrace_broker.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "util/file/file_io.h" #include "util/linux/exception_handler_protocol.h" #include "util/linux/ptrace_connection.h" @@ -163,6 +162,9 @@ class PtraceBroker { //! 64-bit process. PtraceBroker(int sock, pid_t pid, bool is_64_bit); + PtraceBroker(const PtraceBroker&) = delete; + PtraceBroker& operator=(const PtraceBroker&) = delete; + ~PtraceBroker(); //! \brief Restricts the broker to serving the contents of files under \a @@ -210,8 +212,6 @@ class PtraceBroker { int sock_; pid_t memory_pid_; bool tried_opening_mem_file_; - - DISALLOW_COPY_AND_ASSIGN(PtraceBroker); }; } // namespace crashpad diff --git a/util/linux/ptrace_broker_test.cc b/util/linux/ptrace_broker_test.cc index 2012df386f..b07a9be57c 100644 --- a/util/linux/ptrace_broker_test.cc +++ b/util/linux/ptrace_broker_test.cc @@ -40,6 +40,10 @@ namespace { class ScopedTimeoutThread : public Thread { public: ScopedTimeoutThread() : join_sem_(0) {} + + ScopedTimeoutThread(const ScopedTimeoutThread&) = delete; + ScopedTimeoutThread& operator=(const ScopedTimeoutThread&) = delete; + ~ScopedTimeoutThread() { EXPECT_TRUE(JoinWithTimeout(5.0)); } protected: @@ -55,8 +59,6 @@ class ScopedTimeoutThread : public Thread { } Semaphore join_sem_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTimeoutThread); }; class RunBrokerThread : public ScopedTimeoutThread { @@ -64,6 +66,9 @@ class RunBrokerThread : public ScopedTimeoutThread { RunBrokerThread(PtraceBroker* broker) : ScopedTimeoutThread(), broker_(broker) {} + RunBrokerThread(const RunBrokerThread&) = delete; + RunBrokerThread& operator=(const RunBrokerThread&) = delete; + ~RunBrokerThread() {} private: @@ -73,8 +78,6 @@ class RunBrokerThread : public ScopedTimeoutThread { } PtraceBroker* broker_; - - DISALLOW_COPY_AND_ASSIGN(RunBrokerThread); }; class BlockOnReadThread : public ScopedTimeoutThread { @@ -82,6 +85,9 @@ class BlockOnReadThread : public ScopedTimeoutThread { BlockOnReadThread(int readfd, int writefd) : ScopedTimeoutThread(), readfd_(readfd), writefd_(writefd) {} + BlockOnReadThread(const BlockOnReadThread&) = delete; + BlockOnReadThread& operator=(const BlockOnReadThread&) = delete; + ~BlockOnReadThread() {} private: @@ -98,13 +104,15 @@ class BlockOnReadThread : public ScopedTimeoutThread { int readfd_; int writefd_; - - DISALLOW_COPY_AND_ASSIGN(BlockOnReadThread); }; class SameBitnessTest : public Multiprocess { public: SameBitnessTest() : Multiprocess(), mapping_() {} + + SameBitnessTest(const SameBitnessTest&) = delete; + SameBitnessTest& operator=(const SameBitnessTest&) = delete; + ~SameBitnessTest() {} protected: @@ -267,8 +275,6 @@ class SameBitnessTest : public Multiprocess { } ScopedMmap mapping_; - - DISALLOW_COPY_AND_ASSIGN(SameBitnessTest); }; TEST(PtraceBroker, SameBitness) { diff --git a/util/linux/ptrace_client.h b/util/linux/ptrace_client.h index 896a8b4c29..299aafc993 100644 --- a/util/linux/ptrace_client.h +++ b/util/linux/ptrace_client.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -35,6 +34,10 @@ namespace crashpad { class PtraceClient : public PtraceConnection { public: PtraceClient(); + + PtraceClient(const PtraceClient&) = delete; + PtraceClient& operator=(const PtraceClient&) = delete; + ~PtraceClient(); //! \brief Initializes this object. @@ -69,8 +72,6 @@ class PtraceClient : public PtraceConnection { pid_t pid_; bool is_64_bit_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(PtraceClient); }; } // namespace crashpad diff --git a/util/linux/ptracer.h b/util/linux/ptracer.h index 33eeb3aeb9..696ac33277 100644 --- a/util/linux/ptracer.h +++ b/util/linux/ptracer.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/linux/address_types.h" #include "util/linux/thread_info.h" #include "util/misc/initialization_state_dcheck.h" @@ -46,6 +45,9 @@ class Ptracer { //! \param[in] can_log Whether methods in this class can log error messages. explicit Ptracer(bool can_log); + Ptracer(const Ptracer&) = delete; + Ptracer& operator=(const Ptracer&) = delete; + ~Ptracer(); //! \brief Initializes this object to the bitness of the process whose process @@ -98,8 +100,6 @@ class Ptracer { bool is_64_bit_; bool can_log_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(Ptracer); }; } // namespace crashpad diff --git a/util/linux/ptracer_test.cc b/util/linux/ptracer_test.cc index 9a75985052..7465f90aa4 100644 --- a/util/linux/ptracer_test.cc +++ b/util/linux/ptracer_test.cc @@ -28,6 +28,10 @@ namespace { class SameBitnessTest : public Multiprocess { public: SameBitnessTest() : Multiprocess() {} + + SameBitnessTest(const SameBitnessTest&) = delete; + SameBitnessTest& operator=(const SameBitnessTest&) = delete; + ~SameBitnessTest() {} private: @@ -65,8 +69,6 @@ class SameBitnessTest : public Multiprocess { CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(SameBitnessTest); }; TEST(Ptracer, SameBitness) { diff --git a/util/linux/scoped_pr_set_dumpable.h b/util/linux/scoped_pr_set_dumpable.h index 168193093f..7cd3aa7a1d 100644 --- a/util/linux/scoped_pr_set_dumpable.h +++ b/util/linux/scoped_pr_set_dumpable.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_LINUX_SCOPED_PR_SET_DUMPABLE_H_ #define CRASHPAD_UTIL_LINUX_SCOPED_PR_SET_DUMPABLE_H_ -#include "base/macros.h" namespace crashpad { @@ -30,13 +29,14 @@ class ScopedPrSetDumpable { //! \param[in] may_log `true` if this object may log error messages. explicit ScopedPrSetDumpable(bool may_log); + ScopedPrSetDumpable(const ScopedPrSetDumpable&) = delete; + ScopedPrSetDumpable& operator=(const ScopedPrSetDumpable&) = delete; + ~ScopedPrSetDumpable(); private: bool was_dumpable_; bool may_log_; - - DISALLOW_COPY_AND_ASSIGN(ScopedPrSetDumpable); }; } // namespace crashpad diff --git a/util/linux/scoped_pr_set_ptracer.h b/util/linux/scoped_pr_set_ptracer.h index 2bc8677b1c..3d5e55c606 100644 --- a/util/linux/scoped_pr_set_ptracer.h +++ b/util/linux/scoped_pr_set_ptracer.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -37,13 +36,14 @@ class ScopedPrSetPtracer { //! \param[in] may_log if `true`, this class may log error messages. ScopedPrSetPtracer(pid_t pid, bool may_log); + ScopedPrSetPtracer(const ScopedPrSetPtracer&) = delete; + ScopedPrSetPtracer& operator=(const ScopedPrSetPtracer&) = delete; + ~ScopedPrSetPtracer(); private: bool success_; bool may_log_; - - DISALLOW_COPY_AND_ASSIGN(ScopedPrSetPtracer); }; } // namespace crashpad diff --git a/util/linux/scoped_ptrace_attach.h b/util/linux/scoped_ptrace_attach.h index f380d254db..e38464ae9c 100644 --- a/util/linux/scoped_ptrace_attach.h +++ b/util/linux/scoped_ptrace_attach.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -45,6 +44,10 @@ bool PtraceDetach(pid_t pid, bool can_log = true); class ScopedPtraceAttach { public: ScopedPtraceAttach(); + + ScopedPtraceAttach(const ScopedPtraceAttach&) = delete; + ScopedPtraceAttach& operator=(const ScopedPtraceAttach&) = delete; + ~ScopedPtraceAttach(); //! \brief Detaches from the process by calling `ptrace()`. @@ -61,8 +64,6 @@ class ScopedPtraceAttach { private: pid_t pid_; - - DISALLOW_COPY_AND_ASSIGN(ScopedPtraceAttach); }; } // namespace crashpad diff --git a/util/linux/scoped_ptrace_attach_test.cc b/util/linux/scoped_ptrace_attach_test.cc index d009e68279..b22c5aecac 100644 --- a/util/linux/scoped_ptrace_attach_test.cc +++ b/util/linux/scoped_ptrace_attach_test.cc @@ -39,18 +39,23 @@ namespace { class AttachTest : public Multiprocess { public: AttachTest() : Multiprocess() {} + + AttachTest(const AttachTest&) = delete; + AttachTest& operator=(const AttachTest&) = delete; + ~AttachTest() {} protected: const long kWord = 42; - - private: - DISALLOW_COPY_AND_ASSIGN(AttachTest); }; class AttachToChildTest : public AttachTest { public: AttachToChildTest() : AttachTest() {} + + AttachToChildTest(const AttachToChildTest&) = delete; + AttachToChildTest& operator=(const AttachToChildTest&) = delete; + ~AttachToChildTest() {} private: @@ -82,8 +87,6 @@ class AttachToChildTest : public AttachTest { CheckedReadFileAtEOF(ReadPipeHandle()); } - - DISALLOW_COPY_AND_ASSIGN(AttachToChildTest); }; TEST(ScopedPtraceAttach, AttachChild) { @@ -94,6 +97,10 @@ TEST(ScopedPtraceAttach, AttachChild) { class AttachToParentResetTest : public AttachTest { public: AttachToParentResetTest() : AttachTest() {} + + AttachToParentResetTest(const AttachToParentResetTest&) = delete; + AttachToParentResetTest& operator=(const AttachToParentResetTest&) = delete; + ~AttachToParentResetTest() {} private: @@ -124,8 +131,6 @@ class AttachToParentResetTest : public AttachTest { ASSERT_EQ(ptrace(PTRACE_PEEKDATA, pid, &kWord, nullptr), -1); EXPECT_EQ(errno, ESRCH) << ErrnoMessage("ptrace"); } - - DISALLOW_COPY_AND_ASSIGN(AttachToParentResetTest); }; TEST(ScopedPtraceAttach, AttachParentReset) { @@ -136,6 +141,11 @@ TEST(ScopedPtraceAttach, AttachParentReset) { class AttachToParentDestructorTest : public AttachTest { public: AttachToParentDestructorTest() : AttachTest() {} + + AttachToParentDestructorTest(const AttachToParentDestructorTest&) = delete; + AttachToParentDestructorTest& operator=(const AttachToParentDestructorTest&) = + delete; + ~AttachToParentDestructorTest() {} private: @@ -164,8 +174,6 @@ class AttachToParentDestructorTest : public AttachTest { ASSERT_EQ(ptrace(PTRACE_PEEKDATA, pid, &kWord, nullptr), -1); EXPECT_EQ(errno, ESRCH) << ErrnoMessage("ptrace"); } - - DISALLOW_COPY_AND_ASSIGN(AttachToParentDestructorTest); }; TEST(ScopedPtraceAttach, AttachParentDestructor) { diff --git a/util/linux/socket.h b/util/linux/socket.h index d762592baf..f232778d77 100644 --- a/util/linux/socket.h +++ b/util/linux/socket.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "util/file/file_io.h" namespace crashpad { @@ -29,6 +28,10 @@ namespace crashpad { //! sockets. class UnixCredentialSocket { public: + UnixCredentialSocket() = delete; + UnixCredentialSocket(const UnixCredentialSocket&) = delete; + UnixCredentialSocket& operator=(const UnixCredentialSocket&) = delete; + //! \brief Creates an `AF_UNIX` family socket pair with `SO_PASSCRED` set on //! each socket. //! @@ -86,9 +89,6 @@ class UnixCredentialSocket { size_t buf_size, ucred* creds, std::vector* fds = nullptr); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(UnixCredentialSocket); }; } // namespace crashpad diff --git a/util/linux/socket_test.cc b/util/linux/socket_test.cc index d73ec0b482..284953f67d 100644 --- a/util/linux/socket_test.cc +++ b/util/linux/socket_test.cc @@ -14,7 +14,6 @@ #include "util/linux/socket.h" -#include "base/macros.h" #include "base/posix/eintr_wrapper.h" #include "gtest/gtest.h" #include "util/linux/socket.h" diff --git a/util/mach/child_port_handshake.cc b/util/mach/child_port_handshake.cc index 433cb052d3..28fdbae6db 100644 --- a/util/mach/child_port_handshake.cc +++ b/util/mach/child_port_handshake.cc @@ -51,6 +51,10 @@ namespace { class ChildPortHandshakeServer final : public ChildPortServer::Interface { public: ChildPortHandshakeServer(); + + ChildPortHandshakeServer(const ChildPortHandshakeServer&) = delete; + ChildPortHandshakeServer& operator=(const ChildPortHandshakeServer&) = delete; + ~ChildPortHandshakeServer(); mach_port_t RunServer(base::ScopedFD server_write_fd, @@ -69,8 +73,6 @@ class ChildPortHandshakeServer final : public ChildPortServer::Interface { mach_port_t port_; mach_msg_type_name_t right_type_; bool checked_in_; - - DISALLOW_COPY_AND_ASSIGN(ChildPortHandshakeServer); }; ChildPortHandshakeServer::ChildPortHandshakeServer() diff --git a/util/mach/child_port_handshake.h b/util/mach/child_port_handshake.h index 429164a9b5..0399f9b80b 100644 --- a/util/mach/child_port_handshake.h +++ b/util/mach/child_port_handshake.h @@ -155,6 +155,10 @@ class ChildPortHandshake { }; ChildPortHandshake(); + + ChildPortHandshake(const ChildPortHandshake&) = delete; + ChildPortHandshake& operator=(const ChildPortHandshake&) = delete; + ~ChildPortHandshake(); //! \brief Obtains the “read” side of the pipe, to be used by the client. @@ -321,8 +325,6 @@ class ChildPortHandshake { base::ScopedFD server_write_fd_; friend class test::ChildPortHandshakeTest; - - DISALLOW_COPY_AND_ASSIGN(ChildPortHandshake); }; } // namespace crashpad diff --git a/util/mach/child_port_handshake_test.cc b/util/mach/child_port_handshake_test.cc index 44139b117b..5301c4ce33 100644 --- a/util/mach/child_port_handshake_test.cc +++ b/util/mach/child_port_handshake_test.cc @@ -87,6 +87,9 @@ class ChildPortHandshakeTest : public Multiprocess { test_type_(test_type) { } + ChildPortHandshakeTest(const ChildPortHandshakeTest&) = delete; + ChildPortHandshakeTest& operator=(const ChildPortHandshakeTest&) = delete; + ~ChildPortHandshakeTest() { } @@ -254,8 +257,6 @@ class ChildPortHandshakeTest : public Multiprocess { ChildPortHandshake child_port_handshake_; ClientProcess client_process_; TestType test_type_; - - DISALLOW_COPY_AND_ASSIGN(ChildPortHandshakeTest); }; TEST(ChildPortHandshake, ChildClientChecksIn_ReceiveRight) { diff --git a/util/mach/child_port_server.h b/util/mach/child_port_server.h index 47d72e4da9..b7a9895d2e 100644 --- a/util/mach/child_port_server.h +++ b/util/mach/child_port_server.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/mach/child_port_types.h" #include "util/mach/mach_message_server.h" @@ -62,6 +61,9 @@ class ChildPortServer : public MachMessageServer::Interface { //! \param[in] interface The interface to dispatch requests to. Weak. explicit ChildPortServer(Interface* interface); + ChildPortServer(const ChildPortServer&) = delete; + ChildPortServer& operator=(const ChildPortServer&) = delete; + // MachMessageServer::Interface: bool MachMessageServerFunction(const mach_msg_header_t* in_header, mach_msg_header_t* out_header, @@ -72,8 +74,6 @@ class ChildPortServer : public MachMessageServer::Interface { private: Interface* interface_; // weak - - DISALLOW_COPY_AND_ASSIGN(ChildPortServer); }; } // namespace crashpad diff --git a/util/mach/composite_mach_message_server.h b/util/mach/composite_mach_message_server.h index 785af4dc61..f1f75f3c11 100644 --- a/util/mach/composite_mach_message_server.h +++ b/util/mach/composite_mach_message_server.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "util/mach/mach_message_server.h" namespace crashpad { @@ -41,6 +40,11 @@ namespace crashpad { class CompositeMachMessageServer : public MachMessageServer::Interface { public: CompositeMachMessageServer(); + + CompositeMachMessageServer(const CompositeMachMessageServer&) = delete; + CompositeMachMessageServer& operator=(const CompositeMachMessageServer&) = + delete; + ~CompositeMachMessageServer(); //! \brief Adds a handler that messages can be dispatched to based on request @@ -94,8 +98,6 @@ class CompositeMachMessageServer : public MachMessageServer::Interface { HandlerMap handler_map_; // weak mach_msg_size_t request_size_; mach_msg_size_t reply_size_; - - DISALLOW_COPY_AND_ASSIGN(CompositeMachMessageServer); }; } // namespace crashpad diff --git a/util/mach/composite_mach_message_server_test.cc b/util/mach/composite_mach_message_server_test.cc index af4a600256..91a3851f2e 100644 --- a/util/mach/composite_mach_message_server_test.cc +++ b/util/mach/composite_mach_message_server_test.cc @@ -55,6 +55,9 @@ class TestMachMessageHandler : public MachMessageServer::Interface { destroy_complex_request_(false) { } + TestMachMessageHandler(const TestMachMessageHandler&) = delete; + TestMachMessageHandler& operator=(const TestMachMessageHandler&) = delete; + ~TestMachMessageHandler() { } @@ -110,8 +113,6 @@ class TestMachMessageHandler : public MachMessageServer::Interface { kern_return_t return_code_; bool return_value_; bool destroy_complex_request_; - - DISALLOW_COPY_AND_ASSIGN(TestMachMessageHandler); }; TEST(CompositeMachMessageServer, HandlerDoesNotHandle) { diff --git a/util/mach/exc_client_variants_test.cc b/util/mach/exc_client_variants_test.cc index 867eb080fe..aba72052fb 100644 --- a/util/mach/exc_client_variants_test.cc +++ b/util/mach/exc_client_variants_test.cc @@ -20,7 +20,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/mac/mach_errors.h" @@ -50,6 +49,9 @@ class TestExcClientVariants : public MachMultiprocess, ++exception_subcode_; } + TestExcClientVariants(const TestExcClientVariants&) = delete; + TestExcClientVariants& operator=(const TestExcClientVariants&) = delete; + // UniversalMachExcServer::Interface: virtual kern_return_t CatchMachException( @@ -251,8 +253,6 @@ class TestExcClientVariants : public MachMultiprocess, static exception_type_t exception_; static mach_exception_code_t exception_code_; static mach_exception_subcode_t exception_subcode_; - - DISALLOW_COPY_AND_ASSIGN(TestExcClientVariants); }; exception_type_t TestExcClientVariants::exception_ = 0; diff --git a/util/mach/exc_server_variants.cc b/util/mach/exc_server_variants.cc index 94070b1f52..b9357a7802 100644 --- a/util/mach/exc_server_variants.cc +++ b/util/mach/exc_server_variants.cc @@ -230,6 +230,9 @@ class ExcServer : public MachMessageServer::Interface { explicit ExcServer(Interface* interface) : MachMessageServer::Interface(), interface_(interface) {} + ExcServer(const ExcServer&) = delete; + ExcServer& operator=(const ExcServer&) = delete; + // MachMessageServer::Interface: bool MachMessageServerFunction(const mach_msg_header_t* in_header, @@ -256,8 +259,6 @@ class ExcServer : public MachMessageServer::Interface { private: Interface* interface_; // weak - - DISALLOW_COPY_AND_ASSIGN(ExcServer); }; template @@ -453,6 +454,9 @@ class SimplifiedExcServer final : public ExcServer, ExcServer::Interface(), interface_(interface) {} + SimplifiedExcServer(const SimplifiedExcServer&) = delete; + SimplifiedExcServer& operator=(const SimplifiedExcServer&) = delete; + // ExcServer::Interface: kern_return_t CatchExceptionRaise(exception_handler_t exception_port, @@ -544,8 +548,6 @@ class SimplifiedExcServer final : public ExcServer, private: Interface* interface_; // weak - - DISALLOW_COPY_AND_ASSIGN(SimplifiedExcServer); }; } // namespace @@ -569,6 +571,10 @@ class UniversalMachExcServerImpl final AddHandler(&mach_exc_server_); } + UniversalMachExcServerImpl(const UniversalMachExcServerImpl&) = delete; + UniversalMachExcServerImpl& operator=(const UniversalMachExcServerImpl&) = + delete; + ~UniversalMachExcServerImpl() {} // SimplifiedExcServer::Interface: @@ -643,8 +649,6 @@ class UniversalMachExcServerImpl final SimplifiedExcServer exc_server_; SimplifiedExcServer mach_exc_server_; UniversalMachExcServer::Interface* interface_; // weak - - DISALLOW_COPY_AND_ASSIGN(UniversalMachExcServerImpl); }; } // namespace internal diff --git a/util/mach/exc_server_variants.h b/util/mach/exc_server_variants.h index c7b35d4184..15d1cb2ad5 100644 --- a/util/mach/exc_server_variants.h +++ b/util/mach/exc_server_variants.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "util/mach/mach_extensions.h" #include "util/mach/mach_message_server.h" @@ -115,6 +114,9 @@ class UniversalMachExcServer final : public MachMessageServer::Interface { //! \param[in] interface The interface to dispatch requests to. Weak. explicit UniversalMachExcServer(Interface* interface); + UniversalMachExcServer(const UniversalMachExcServer&) = delete; + UniversalMachExcServer& operator=(const UniversalMachExcServer&) = delete; + ~UniversalMachExcServer(); // MachMessageServer::Interface: @@ -127,8 +129,6 @@ class UniversalMachExcServer final : public MachMessageServer::Interface { private: std::unique_ptr impl_; - - DISALLOW_COPY_AND_ASSIGN(UniversalMachExcServer); }; //! \brief Computes an approriate successful return value for an exception diff --git a/util/mach/exc_server_variants_test.cc b/util/mach/exc_server_variants_test.cc index 836048b81b..d74cbc5915 100644 --- a/util/mach/exc_server_variants_test.cc +++ b/util/mach/exc_server_variants_test.cc @@ -979,6 +979,9 @@ class TestExcServerVariants : public MachMultiprocess, SetExpectedChildTerminationBuiltinTrap(); } + TestExcServerVariants(const TestExcServerVariants&) = delete; + TestExcServerVariants& operator=(const TestExcServerVariants&) = delete; + // UniversalMachExcServer::Interface: virtual kern_return_t CatchMachException( @@ -1089,8 +1092,6 @@ class TestExcServerVariants : public MachMultiprocess, static const mach_msg_option_t kMachMessageOptions = MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0); - - DISALLOW_COPY_AND_ASSIGN(TestExcServerVariants); }; TEST(ExcServerVariants, ExceptionRaise) { diff --git a/util/mach/exception_ports.h b/util/mach/exception_ports.h index e128f65408..06a952070b 100644 --- a/util/mach/exception_ports.h +++ b/util/mach/exception_ports.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -97,6 +96,10 @@ class ExceptionPorts { using VectorType = std::vector; ExceptionHandlerVector(); + + ExceptionHandlerVector(const ExceptionHandlerVector&) = delete; + ExceptionHandlerVector& operator=(const ExceptionHandlerVector&) = delete; + ~ExceptionHandlerVector(); VectorType::const_iterator begin() const { return vector_.begin(); } @@ -113,8 +116,6 @@ class ExceptionPorts { void Deallocate(); VectorType vector_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerVector); }; //! \brief Constructs an interface object to get or set exception ports on a @@ -136,6 +137,9 @@ class ExceptionPorts { //! appropriately for \a target_type. ExceptionPorts(TargetType target_type, mach_port_t target_port); + ExceptionPorts(const ExceptionPorts&) = delete; + ExceptionPorts& operator=(const ExceptionPorts&) = delete; + ~ExceptionPorts(); //! \brief Calls `*_get_exception_ports()` on the target. @@ -253,8 +257,6 @@ class ExceptionPorts { // even with a TASK_NULL target_port, because it is incorrect to deallocate // the result of mach_task_self(). bool dealloc_target_port_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionPorts); }; } // namespace crashpad diff --git a/util/mach/exception_ports_test.cc b/util/mach/exception_ports_test.cc index d3a211fb78..b29e125ebb 100644 --- a/util/mach/exception_ports_test.cc +++ b/util/mach/exception_ports_test.cc @@ -22,7 +22,6 @@ #include "base/check.h" #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "base/notreached.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -149,6 +148,9 @@ class TestExceptionPorts : public MachMultiprocess, } } + TestExceptionPorts(const TestExceptionPorts&) = delete; + TestExceptionPorts& operator=(const TestExceptionPorts&) = delete; + SetOrSwap set_or_swap() const { return set_or_swap_; } SetOn set_on() const { return set_on_; } SetType set_type() const { return set_type_; } @@ -230,6 +232,9 @@ class TestExceptionPorts : public MachMultiprocess, init_semaphore_(0), crash_semaphore_(0) {} + Child(const Child&) = delete; + Child& operator=(const Child&) = delete; + ~Child() {} void Run() { @@ -412,8 +417,6 @@ class TestExceptionPorts : public MachMultiprocess, // The child thread waits on this for the parent thread to indicate that the // child can test its exception ports and possibly crash, as appropriate. Semaphore crash_semaphore_; - - DISALLOW_COPY_AND_ASSIGN(Child); }; // MachMultiprocess: @@ -583,8 +586,6 @@ class TestExceptionPorts : public MachMultiprocess, // true if an exception message was handled. bool handled_; - - DISALLOW_COPY_AND_ASSIGN(TestExceptionPorts); }; TEST(ExceptionPorts, TaskExceptionPorts_SetInProcess_NoCrash) { diff --git a/util/mach/mach_message_server.cc b/util/mach/mach_message_server.cc index 396337301c..8cf119c4a3 100644 --- a/util/mach/mach_message_server.cc +++ b/util/mach/mach_message_server.cc @@ -32,6 +32,9 @@ class MachMessageBuffer { public: MachMessageBuffer() : vm_() {} + MachMessageBuffer(const MachMessageBuffer&) = delete; + MachMessageBuffer& operator=(const MachMessageBuffer&) = delete; + ~MachMessageBuffer() {} //! \return A pointer to the buffer. @@ -81,8 +84,6 @@ class MachMessageBuffer { private: base::mac::ScopedMachVM vm_; - - DISALLOW_COPY_AND_ASSIGN(MachMessageBuffer); }; // Wraps MachMessageWithDeadline(), using a MachMessageBuffer argument which diff --git a/util/mach/mach_message_server.h b/util/mach/mach_message_server.h index 5e96c4cef3..67812917e3 100644 --- a/util/mach/mach_message_server.h +++ b/util/mach/mach_message_server.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -125,6 +124,10 @@ class MachMessageServer { kReceiveLargeResize, }; + MachMessageServer() = delete; + MachMessageServer(const MachMessageServer&) = delete; + MachMessageServer& operator=(const MachMessageServer&) = delete; + //! \brief Runs a Mach message server to handle a Mach RPC request for MIG //! servers. //! @@ -173,9 +176,6 @@ class MachMessageServer { Persistent persistent, ReceiveLarge receive_large, mach_msg_timeout_t timeout_ms); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(MachMessageServer); }; } // namespace crashpad diff --git a/util/mach/mach_message_server_test.cc b/util/mach/mach_message_server_test.cc index 4a744d97b5..6785827b98 100644 --- a/util/mach/mach_message_server_test.cc +++ b/util/mach/mach_message_server_test.cc @@ -23,7 +23,6 @@ #include "base/cxx17_backports.h" #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "test/mac/mach_errors.h" #include "test/mac/mach_multiprocess.h" @@ -181,6 +180,9 @@ class TestMachMessageServer : public MachMessageServer::Interface, parent_complex_message_port_(MACH_PORT_NULL) { } + TestMachMessageServer(const TestMachMessageServer&) = delete; + TestMachMessageServer& operator=(const TestMachMessageServer&) = delete; + // Runs the test. void Test() { EXPECT_EQ(replies_, requests_); @@ -592,8 +594,6 @@ class TestMachMessageServer : public MachMessageServer::Interface, static constexpr mach_msg_id_t kRequestMessageID = 16237; static constexpr mach_msg_id_t kReplyMessageID = kRequestMessageID + 100; - - DISALLOW_COPY_AND_ASSIGN(TestMachMessageServer); }; uint32_t TestMachMessageServer::requests_; diff --git a/util/mach/notify_server.h b/util/mach/notify_server.h index ad0a888262..9e3182068c 100644 --- a/util/mach/notify_server.h +++ b/util/mach/notify_server.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/mach/mach_message_server.h" namespace crashpad { @@ -180,6 +179,9 @@ class NotifyServer : public MachMessageServer::Interface { //! was unexpected and not processed. class DefaultInterface : public Interface { public: + DefaultInterface(const DefaultInterface&) = delete; + DefaultInterface& operator=(const DefaultInterface&) = delete; + // Interface: kern_return_t DoMachNotifyPortDeleted( @@ -210,9 +212,6 @@ class NotifyServer : public MachMessageServer::Interface { protected: DefaultInterface() : Interface() {} ~DefaultInterface() {} - - private: - DISALLOW_COPY_AND_ASSIGN(DefaultInterface); }; //! \brief Constructs an object of this class. @@ -220,6 +219,9 @@ class NotifyServer : public MachMessageServer::Interface { //! \param[in] interface The interface to dispatch requests to. Weak. explicit NotifyServer(Interface* interface); + NotifyServer(const NotifyServer&) = delete; + NotifyServer& operator=(const NotifyServer&) = delete; + // MachMessageServer::Interface: bool MachMessageServerFunction(const mach_msg_header_t* in_header, @@ -233,8 +235,6 @@ class NotifyServer : public MachMessageServer::Interface { private: Interface* interface_; // weak - - DISALLOW_COPY_AND_ASSIGN(NotifyServer); }; } // namespace crashpad diff --git a/util/mach/notify_server_test.cc b/util/mach/notify_server_test.cc index 40a3826754..98a68820f4 100644 --- a/util/mach/notify_server_test.cc +++ b/util/mach/notify_server_test.cc @@ -163,6 +163,9 @@ mach_port_urefs_t DeadNameRightRefCount(mach_port_t port) { class NotifyServerTestBase : public testing::Test, public NotifyServer::Interface { public: + NotifyServerTestBase(const NotifyServerTestBase&) = delete; + NotifyServerTestBase& operator=(const NotifyServerTestBase&) = delete; + // NotifyServer::Interface: MOCK_METHOD(kern_return_t, @@ -282,8 +285,6 @@ class NotifyServerTestBase : public testing::Test, private: base::mac::ScopedMachReceiveRight server_port_; - - DISALLOW_COPY_AND_ASSIGN(NotifyServerTestBase); }; using NotifyServerTest = StrictMock; diff --git a/util/mach/scoped_task_suspend.h b/util/mach/scoped_task_suspend.h index 389ea5f62c..f935983b80 100644 --- a/util/mach/scoped_task_suspend.h +++ b/util/mach/scoped_task_suspend.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -32,12 +31,14 @@ namespace crashpad { class ScopedTaskSuspend { public: explicit ScopedTaskSuspend(task_t task); + + ScopedTaskSuspend(const ScopedTaskSuspend&) = delete; + ScopedTaskSuspend& operator=(const ScopedTaskSuspend&) = delete; + ~ScopedTaskSuspend(); private: task_t task_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTaskSuspend); }; } // namespace crashpad diff --git a/util/mach/scoped_task_suspend_test.cc b/util/mach/scoped_task_suspend_test.cc index b23e61241b..06a518da60 100644 --- a/util/mach/scoped_task_suspend_test.cc +++ b/util/mach/scoped_task_suspend_test.cc @@ -44,6 +44,10 @@ int SuspendCount(task_t task) { class ScopedTaskSuspendTest final : public MachMultiprocess { public: ScopedTaskSuspendTest() : MachMultiprocess() {} + + ScopedTaskSuspendTest(const ScopedTaskSuspendTest&) = delete; + ScopedTaskSuspendTest& operator=(const ScopedTaskSuspendTest&) = delete; + ~ScopedTaskSuspendTest() {} private: @@ -71,8 +75,6 @@ class ScopedTaskSuspendTest final : public MachMultiprocess { void MachMultiprocessChild() override { } - - DISALLOW_COPY_AND_ASSIGN(ScopedTaskSuspendTest); }; TEST(ScopedTaskSuspend, ScopedTaskSuspend) { diff --git a/util/misc/initialization_state.h b/util/misc/initialization_state.h index 85f9b2894d..c8e24052ba 100644 --- a/util/misc/initialization_state.h +++ b/util/misc/initialization_state.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -57,6 +56,10 @@ class InitializationState { }; InitializationState() : state_(kStateUninitialized) {} + + InitializationState(const InitializationState&) = delete; + InitializationState& operator=(const InitializationState&) = delete; + ~InitializationState() { state_ = kStateDestroyed; } //! \brief Returns `true` if the object’s state is #kStateUninitialized and it @@ -91,8 +94,6 @@ class InitializationState { // kStateDestroyed, limiting this class’ ability to catch use-after-free // errors. volatile State state_; - - DISALLOW_COPY_AND_ASSIGN(InitializationState); }; } // namespace crashpad diff --git a/util/misc/initialization_state_dcheck.h b/util/misc/initialization_state_dcheck.h index 9fcfc76057..e04ff234c3 100644 --- a/util/misc/initialization_state_dcheck.h +++ b/util/misc/initialization_state_dcheck.h @@ -19,7 +19,6 @@ #include "base/check_op.h" #include "base/compiler_specific.h" -#include "base/macros.h" #include "build/build_config.h" #include "util/misc/initialization_state.h" @@ -65,6 +64,10 @@ class InitializationStateDcheck : public InitializationState { public: InitializationStateDcheck() : InitializationState() {} + InitializationStateDcheck(const InitializationStateDcheck&) = delete; + InitializationStateDcheck& operator=(const InitializationStateDcheck&) = + delete; + //! \brief Returns the object’s state. //! //! Consumers of this class should not call this method. Use the @@ -99,9 +102,6 @@ class InitializationStateDcheck : public InitializationState { //! Consumers of this class should not call this method. Use the //! INITIALIZATION_STATE_SET_VALID() macro instead. State SetValid(); - - private: - DISALLOW_COPY_AND_ASSIGN(InitializationStateDcheck); }; // Using macros enables the non-DCHECK no-op implementation below to be more diff --git a/util/misc/metrics.h b/util/misc/metrics.h index 292f23a036..63c673a337 100644 --- a/util/misc/metrics.h +++ b/util/misc/metrics.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "util/file/file_io.h" @@ -35,6 +34,10 @@ namespace crashpad { //! Chromium's base, they allow integration with its metrics system. class Metrics { public: + Metrics() = delete; + Metrics(const Metrics&) = delete; + Metrics& operator=(const Metrics&) = delete; + //! \brief Values for CrashReportPending(). //! //! \note These are used as metrics enumeration values, so new values should @@ -209,9 +212,6 @@ class Metrics { static void InvalidIntermediateDumpKeySize( const internal::IntermediateDumpKey& key); #endif - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(Metrics); }; } // namespace crashpad diff --git a/util/misc/paths.h b/util/misc/paths.h index 30bbec5098..0b0cfe458f 100644 --- a/util/misc/paths.h +++ b/util/misc/paths.h @@ -16,13 +16,16 @@ #define CRASHPAD_UTIL_PATHS_H_ #include "base/files/file_path.h" -#include "base/macros.h" namespace crashpad { //! \brief Functions to obtain paths. class Paths { public: + Paths() = delete; + Paths(const Paths&) = delete; + Paths& operator=(const Paths&) = delete; + //! \brief Obtains the pathname of the currently-running executable. //! //! \param[out] path The pathname of the currently-running executable. @@ -31,8 +34,6 @@ class Paths { //! //! \note In test code, use test::TestPaths::Executable() instead. static bool Executable(base::FilePath* path); - - DISALLOW_IMPLICIT_CONSTRUCTORS(Paths); }; } // namespace crashpad diff --git a/util/misc/range_set.h b/util/misc/range_set.h index 573705ec2e..77be64cf77 100644 --- a/util/misc/range_set.h +++ b/util/misc/range_set.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" namespace crashpad { @@ -26,6 +25,10 @@ namespace crashpad { class RangeSet { public: RangeSet(); + + RangeSet(const RangeSet&) = delete; + RangeSet& operator=(const RangeSet&) = delete; + ~RangeSet(); //! \brief Inserts a range into the set. @@ -42,8 +45,6 @@ class RangeSet { // the range. Overlapping ranges are merged on insertion. Adjacent ranges may // be merged. std::map ranges_; - - DISALLOW_COPY_AND_ASSIGN(RangeSet); }; } // namespace crashpad diff --git a/util/misc/scoped_forbid_return.h b/util/misc/scoped_forbid_return.h index 4f1e214f79..31d48d843a 100644 --- a/util/misc/scoped_forbid_return.h +++ b/util/misc/scoped_forbid_return.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_MISC_SCOPED_FORBID_RETURN_H_ #define CRASHPAD_UTIL_MISC_SCOPED_FORBID_RETURN_H_ -#include "base/macros.h" namespace crashpad { @@ -31,6 +30,10 @@ namespace crashpad { class ScopedForbidReturn { public: ScopedForbidReturn() : armed_(true) {} + + ScopedForbidReturn(const ScopedForbidReturn&) = delete; + ScopedForbidReturn& operator=(const ScopedForbidReturn&) = delete; + ~ScopedForbidReturn(); //! \brief Arms the object so that it will abort execution when destroyed. @@ -45,8 +48,6 @@ class ScopedForbidReturn { private: bool armed_; - - DISALLOW_COPY_AND_ASSIGN(ScopedForbidReturn); }; } // namespace crashpad diff --git a/util/net/http_body.h b/util/net/http_body.h index 927e4a764b..7d8ce7eba9 100644 --- a/util/net/http_body.h +++ b/util/net/http_body.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "util/file/file_io.h" #include "util/file/file_reader.h" @@ -58,6 +57,9 @@ class StringHTTPBodyStream : public HTTPBodyStream { //! \param[in] string The string to turn into a stream. explicit StringHTTPBodyStream(const std::string& string); + StringHTTPBodyStream(const StringHTTPBodyStream&) = delete; + StringHTTPBodyStream& operator=(const StringHTTPBodyStream&) = delete; + ~StringHTTPBodyStream() override; // HTTPBodyStream: @@ -66,8 +68,6 @@ class StringHTTPBodyStream : public HTTPBodyStream { private: std::string string_; size_t bytes_read_; - - DISALLOW_COPY_AND_ASSIGN(StringHTTPBodyStream); }; //! \brief An implementation of HTTPBodyStream that reads from a @@ -80,6 +80,9 @@ class FileReaderHTTPBodyStream : public HTTPBodyStream { //! will read. explicit FileReaderHTTPBodyStream(FileReaderInterface* reader); + FileReaderHTTPBodyStream(const FileReaderHTTPBodyStream&) = delete; + FileReaderHTTPBodyStream& operator=(const FileReaderHTTPBodyStream&) = delete; + ~FileReaderHTTPBodyStream() override; // HTTPBodyStream: @@ -88,8 +91,6 @@ class FileReaderHTTPBodyStream : public HTTPBodyStream { private: FileReaderInterface* reader_; // weak bool reached_eof_; - - DISALLOW_COPY_AND_ASSIGN(FileReaderHTTPBodyStream); }; //! \brief An implementation of HTTPBodyStream that combines an array of @@ -106,6 +107,9 @@ class CompositeHTTPBodyStream : public HTTPBodyStream { //! an instance of this class. explicit CompositeHTTPBodyStream(const PartsList& parts); + CompositeHTTPBodyStream(const CompositeHTTPBodyStream&) = delete; + CompositeHTTPBodyStream& operator=(const CompositeHTTPBodyStream&) = delete; + ~CompositeHTTPBodyStream() override; // HTTPBodyStream: @@ -114,8 +118,6 @@ class CompositeHTTPBodyStream : public HTTPBodyStream { private: PartsList parts_; PartsList::iterator current_part_; - - DISALLOW_COPY_AND_ASSIGN(CompositeHTTPBodyStream); }; } // namespace crashpad diff --git a/util/net/http_body_gzip.h b/util/net/http_body_gzip.h index da3a5f24d9..461a9a9656 100644 --- a/util/net/http_body_gzip.h +++ b/util/net/http_body_gzip.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "util/file/file_io.h" #include "util/net/http_body.h" @@ -36,6 +35,9 @@ class GzipHTTPBodyStream : public HTTPBodyStream { public: explicit GzipHTTPBodyStream(std::unique_ptr source); + GzipHTTPBodyStream(const GzipHTTPBodyStream&) = delete; + GzipHTTPBodyStream& operator=(const GzipHTTPBodyStream&) = delete; + ~GzipHTTPBodyStream() override; // HTTPBodyStream: @@ -58,8 +60,6 @@ class GzipHTTPBodyStream : public HTTPBodyStream { std::unique_ptr source_; std::unique_ptr z_stream_; State state_; - - DISALLOW_COPY_AND_ASSIGN(GzipHTTPBodyStream); }; } // namespace crashpad diff --git a/util/net/http_body_gzip_test.cc b/util/net/http_body_gzip_test.cc index 926dfca753..125f4d4501 100644 --- a/util/net/http_body_gzip_test.cc +++ b/util/net/http_body_gzip_test.cc @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "base/rand_util.h" #include "base/numerics/safe_conversions.h" #include "gtest/gtest.h" @@ -36,6 +35,10 @@ namespace { class ScopedZlibInflateStream { public: explicit ScopedZlibInflateStream(z_stream* zlib) : zlib_(zlib) {} + + ScopedZlibInflateStream(const ScopedZlibInflateStream&) = delete; + ScopedZlibInflateStream& operator=(const ScopedZlibInflateStream&) = delete; + ~ScopedZlibInflateStream() { int zr = inflateEnd(zlib_); EXPECT_EQ(zr, Z_OK) << "inflateEnd: " << ZlibErrorString(zr); @@ -43,7 +46,6 @@ class ScopedZlibInflateStream { private: z_stream* zlib_; // weak - DISALLOW_COPY_AND_ASSIGN(ScopedZlibInflateStream); }; void GzipInflate(const std::string& compressed, diff --git a/util/net/http_multipart_builder.h b/util/net/http_multipart_builder.h index c7c59a7739..56ce52d799 100644 --- a/util/net/http_multipart_builder.h +++ b/util/net/http_multipart_builder.h @@ -19,7 +19,6 @@ #include #include -#include "base/macros.h" #include "util/file/file_reader.h" #include "util/net/http_headers.h" @@ -32,6 +31,10 @@ class HTTPBodyStream; class HTTPMultipartBuilder { public: HTTPMultipartBuilder(); + + HTTPMultipartBuilder(const HTTPMultipartBuilder&) = delete; + HTTPMultipartBuilder& operator=(const HTTPMultipartBuilder&) = delete; + ~HTTPMultipartBuilder(); //! \brief Enables or disables `gzip` compression. @@ -95,8 +98,6 @@ class HTTPMultipartBuilder { std::map form_data_; std::map file_attachments_; bool gzip_enabled_; - - DISALLOW_COPY_AND_ASSIGN(HTTPMultipartBuilder); }; } // namespace crashpad diff --git a/util/net/http_transport.h b/util/net/http_transport.h index acd4e44246..0937ed4102 100644 --- a/util/net/http_transport.h +++ b/util/net/http_transport.h @@ -19,7 +19,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "util/net/http_headers.h" namespace crashpad { @@ -35,6 +34,9 @@ class HTTPBodyStream; //! request that is appropriate for the host operating system. class HTTPTransport { public: + HTTPTransport(const HTTPTransport&) = delete; + HTTPTransport& operator=(const HTTPTransport&) = delete; + virtual ~HTTPTransport(); //! \brief Instantiates a concrete HTTPTransport class for the current @@ -112,8 +114,6 @@ class HTTPTransport { HTTPHeaders headers_; std::unique_ptr body_stream_; double timeout_; - - DISALLOW_COPY_AND_ASSIGN(HTTPTransport); }; } // namespace crashpad diff --git a/util/net/http_transport_libcurl.cc b/util/net/http_transport_libcurl.cc index 8993ebca1e..7e3f41186f 100644 --- a/util/net/http_transport_libcurl.cc +++ b/util/net/http_transport_libcurl.cc @@ -43,6 +43,9 @@ namespace { // as a linkage table for libcurl procedures. class Libcurl { public: + Libcurl(const Libcurl&) = delete; + Libcurl& operator=(const Libcurl&) = delete; + static bool Initialized() { static bool initialized = Get()->Initialize(); return initialized; @@ -155,8 +158,6 @@ class Libcurl { NoCfiIcall curl_slist_free_all_; NoCfiIcall curl_slist_append_; NoCfiIcall curl_version_; - - DISALLOW_COPY_AND_ASSIGN(Libcurl); }; std::string UserAgent() { @@ -271,6 +272,10 @@ using ScopedCURL = base::ScopedGeneric; class CurlSList { public: CurlSList() : list_(nullptr) {} + + CurlSList(const CurlSList&) = delete; + CurlSList& operator=(const CurlSList&) = delete; + ~CurlSList() { if (list_) { Libcurl::CurlSlistFreeAll(list_); @@ -289,14 +294,15 @@ class CurlSList { private: curl_slist* list_; - - DISALLOW_COPY_AND_ASSIGN(CurlSList); }; class ScopedClearString { public: explicit ScopedClearString(std::string* string) : string_(string) {} + ScopedClearString(const ScopedClearString&) = delete; + ScopedClearString& operator=(const ScopedClearString&) = delete; + ~ScopedClearString() { if (string_) { string_->clear(); @@ -307,13 +313,15 @@ class ScopedClearString { private: std::string* string_; - - DISALLOW_COPY_AND_ASSIGN(ScopedClearString); }; class HTTPTransportLibcurl final : public HTTPTransport { public: HTTPTransportLibcurl(); + + HTTPTransportLibcurl(const HTTPTransportLibcurl&) = delete; + HTTPTransportLibcurl& operator=(const HTTPTransportLibcurl&) = delete; + ~HTTPTransportLibcurl() override; // HTTPTransport: @@ -328,8 +336,6 @@ class HTTPTransportLibcurl final : public HTTPTransport { size_t size, size_t nitems, void* userdata); - - DISALLOW_COPY_AND_ASSIGN(HTTPTransportLibcurl); }; HTTPTransportLibcurl::HTTPTransportLibcurl() : HTTPTransport() {} diff --git a/util/net/http_transport_mac.mm b/util/net/http_transport_mac.mm index b9be11c8cc..e1cfd2543f 100644 --- a/util/net/http_transport_mac.mm +++ b/util/net/http_transport_mac.mm @@ -113,6 +113,10 @@ explicit HTTPBodyStreamCFReadStream(HTTPBodyStream* body_stream) : body_stream_(body_stream) { } + HTTPBodyStreamCFReadStream(const HTTPBodyStreamCFReadStream&) = delete; + HTTPBodyStreamCFReadStream& operator=(const HTTPBodyStreamCFReadStream&) = + delete; + // Creates a new NSInputStream, which the caller owns. NSInputStream* CreateInputStream() { CFStreamClientContext context = { @@ -213,19 +217,18 @@ static void Unschedule(CFReadStreamRef stream, void* info) {} HTTPBodyStream* body_stream_; // weak - - DISALLOW_COPY_AND_ASSIGN(HTTPBodyStreamCFReadStream); }; class HTTPTransportMac final : public HTTPTransport { public: HTTPTransportMac(); + + HTTPTransportMac(const HTTPTransportMac&) = delete; + HTTPTransportMac& operator=(const HTTPTransportMac&) = delete; + ~HTTPTransportMac() override; bool ExecuteSynchronously(std::string* response_body) override; - - private: - DISALLOW_COPY_AND_ASSIGN(HTTPTransportMac); }; HTTPTransportMac::HTTPTransportMac() : HTTPTransport() { diff --git a/util/net/http_transport_socket.cc b/util/net/http_transport_socket.cc index c12702ac15..4de9280325 100644 --- a/util/net/http_transport_socket.cc +++ b/util/net/http_transport_socket.cc @@ -22,7 +22,6 @@ #include "base/cxx17_backports.h" #include "base/logging.h" -#include "base/macros.h" #include "base/numerics/safe_conversions.h" #include "base/posix/eintr_wrapper.h" #include "base/scoped_generic.h" @@ -47,12 +46,13 @@ constexpr const char kCRLFTerminator[] = "\r\n"; class HTTPTransportSocket final : public HTTPTransport { public: HTTPTransportSocket() = default; + + HTTPTransportSocket(const HTTPTransportSocket&) = delete; + HTTPTransportSocket& operator=(const HTTPTransportSocket&) = delete; + ~HTTPTransportSocket() override = default; bool ExecuteSynchronously(std::string* response_body) override; - - private: - DISALLOW_COPY_AND_ASSIGN(HTTPTransportSocket); }; struct ScopedAddrinfoTraits { @@ -74,6 +74,9 @@ class FdStream : public Stream { public: explicit FdStream(int fd) : fd_(fd) { CHECK(fd_ >= 0); } + FdStream(const FdStream&) = delete; + FdStream& operator=(const FdStream&) = delete; + bool LoggingWrite(const void* data, size_t size) override { return LoggingWriteFile(fd_, data, size); } @@ -88,8 +91,6 @@ class FdStream : public Stream { private: int fd_; - - DISALLOW_COPY_AND_ASSIGN(FdStream); }; #if defined(CRASHPAD_USE_BORINGSSL) @@ -97,6 +98,9 @@ class SSLStream : public Stream { public: SSLStream() = default; + SSLStream(const SSLStream&) = delete; + SSLStream& operator=(const SSLStream&) = delete; + bool Initialize(const base::FilePath& root_cert_path, int sock, const std::string& hostname) { @@ -210,8 +214,6 @@ class SSLStream : public Stream { ScopedSSLCTX ctx_; ScopedSSL ssl_; - - DISALLOW_COPY_AND_ASSIGN(SSLStream); }; #endif @@ -262,6 +264,9 @@ class ScopedSetNonblocking { } } + ScopedSetNonblocking(const ScopedSetNonblocking&) = delete; + ScopedSetNonblocking& operator=(const ScopedSetNonblocking&) = delete; + ~ScopedSetNonblocking() { if (sock_ >= 0) { int flags = fcntl(sock_, F_GETFL, 0); @@ -278,8 +283,6 @@ class ScopedSetNonblocking { private: int sock_; - - DISALLOW_COPY_AND_ASSIGN(ScopedSetNonblocking); }; base::ScopedFD CreateSocket(const std::string& hostname, diff --git a/util/net/http_transport_win.cc b/util/net/http_transport_win.cc index a91d2d2239..cb04c2e930 100644 --- a/util/net/http_transport_win.cc +++ b/util/net/http_transport_win.cc @@ -131,12 +131,13 @@ using ScopedHINTERNET = base::ScopedGeneric; class HTTPTransportWin final : public HTTPTransport { public: HTTPTransportWin(); + + HTTPTransportWin(const HTTPTransportWin&) = delete; + HTTPTransportWin& operator=(const HTTPTransportWin&) = delete; + ~HTTPTransportWin() override; bool ExecuteSynchronously(std::string* response_body) override; - - private: - DISALLOW_COPY_AND_ASSIGN(HTTPTransportWin); }; HTTPTransportWin::HTTPTransportWin() : HTTPTransport() { diff --git a/util/numeric/checked_address_range.h b/util/numeric/checked_address_range.h index 40c82390c7..5279bbc0da 100644 --- a/util/numeric/checked_address_range.h +++ b/util/numeric/checked_address_range.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "build/build_config.h" #include "util/numeric/checked_range.h" diff --git a/util/posix/process_info.h b/util/posix/process_info.h index d144c04b55..7a58788dfa 100644 --- a/util/posix/process_info.h +++ b/util/posix/process_info.h @@ -23,7 +23,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "util/misc/initialization_state.h" #include "util/misc/initialization_state_dcheck.h" @@ -42,6 +41,10 @@ namespace crashpad { class ProcessInfo { public: ProcessInfo(); + + ProcessInfo(const ProcessInfo&) = delete; + ProcessInfo& operator=(const ProcessInfo&) = delete; + ~ProcessInfo(); #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || DOXYGEN @@ -189,8 +192,6 @@ class ProcessInfo { mutable InitializationState start_time_initialized_; #endif InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessInfo); }; } // namespace crashpad diff --git a/util/posix/process_info_test.cc b/util/posix/process_info_test.cc index 780618471a..1d9b065743 100644 --- a/util/posix/process_info_test.cc +++ b/util/posix/process_info_test.cc @@ -206,6 +206,10 @@ TEST(ProcessInfo, Pid1) { class ProcessInfoForkedTest : public Multiprocess { public: ProcessInfoForkedTest() : Multiprocess() {} + + ProcessInfoForkedTest(const ProcessInfoForkedTest&) = delete; + ProcessInfoForkedTest& operator=(const ProcessInfoForkedTest&) = delete; + ~ProcessInfoForkedTest() {} // Multiprocess: @@ -233,9 +237,6 @@ class ProcessInfoForkedTest : public Multiprocess { // Hang around until the parent is done. CheckedReadFileAtEOF(ReadPipeHandle()); } - - private: - DISALLOW_COPY_AND_ASSIGN(ProcessInfoForkedTest); }; TEST(ProcessInfo, Forked) { diff --git a/util/posix/scoped_mmap.h b/util/posix/scoped_mmap.h index 12f5ceed71..706f1e7fad 100644 --- a/util/posix/scoped_mmap.h +++ b/util/posix/scoped_mmap.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_POSIX_SCOPED_MMAP_H_ #define CRASHPAD_UTIL_POSIX_SCOPED_MMAP_H_ -#include "base/macros.h" #include #include @@ -34,6 +33,10 @@ class ScopedMmap { //! //! \param can_log `true` if methods of this class may log messages. explicit ScopedMmap(bool can_log = true); + + ScopedMmap(const ScopedMmap&) = delete; + ScopedMmap& operator=(const ScopedMmap&) = delete; + ~ScopedMmap(); //! \brief Releases the memory-mapped region by calling `munmap()`. @@ -109,8 +112,6 @@ class ScopedMmap { void* addr_ = MAP_FAILED; size_t len_ = 0; bool can_log_; - - DISALLOW_COPY_AND_ASSIGN(ScopedMmap); }; } // namespace crashpad diff --git a/util/posix/scoped_mmap_test.cc b/util/posix/scoped_mmap_test.cc index 6509b3ace3..f8307cc698 100644 --- a/util/posix/scoped_mmap_test.cc +++ b/util/posix/scoped_mmap_test.cc @@ -59,6 +59,9 @@ class TestCookie { // SetUp() called on it. explicit TestCookie() : address_(&cookie_), cookie_(0) {} + TestCookie(const TestCookie&) = delete; + TestCookie& operator=(const TestCookie&) = delete; + ~TestCookie() {} void SetUp(uint64_t* address) { @@ -78,8 +81,6 @@ class TestCookie { private: uint64_t* address_; uint64_t cookie_; - - DISALLOW_COPY_AND_ASSIGN(TestCookie); }; TEST(ScopedMmap, Mmap) { diff --git a/util/posix/signals.h b/util/posix/signals.h index 368161bfe5..cfa196bdfc 100644 --- a/util/posix/signals.h +++ b/util/posix/signals.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -56,6 +55,9 @@ class Signals { // when an object of this class is given static storage duration. OldActions() = default; + OldActions(const OldActions&) = delete; + OldActions& operator=(const OldActions&) = delete; + //! \brief Returns a `struct sigaction` structure corresponding to the //! given signal. //! @@ -66,10 +68,12 @@ class Signals { // As a small storage optimization, don’t waste any space on a slot for // signal 0, because there is no signal 0. struct sigaction actions_[NSIG - 1]; - - DISALLOW_COPY_AND_ASSIGN(OldActions); }; + Signals() = delete; + Signals(const Signals&) = delete; + Signals& operator=(const Signals&) = delete; + //! \brief Installs a new signal handler. //! //! \param[in] sig The signal number to handle. @@ -235,9 +239,6 @@ class Signals { //! //! \note This function is safe to call from a signal handler. static bool IsTerminateSignal(int sig); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(Signals); }; } // namespace crashpad diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index 3538cf2bce..d26c291955 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -228,6 +228,10 @@ class SignalsTest : public Multiprocess { sig_(sig), test_type_(test_type), signal_source_(signal_source) {} + + SignalsTest(const SignalsTest&) = delete; + SignalsTest& operator=(const SignalsTest&) = delete; + ~SignalsTest() {} private: @@ -314,8 +318,6 @@ class SignalsTest : public Multiprocess { TestType test_type_; SignalSource signal_source_; static Signals::OldActions old_actions_; - - DISALLOW_COPY_AND_ASSIGN(SignalsTest); }; Signals::OldActions SignalsTest::old_actions_; diff --git a/util/process/process_memory_fuchsia.h b/util/process/process_memory_fuchsia.h index 6c9cebaad1..6693c5a9e8 100644 --- a/util/process/process_memory_fuchsia.h +++ b/util/process/process_memory_fuchsia.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory.h" @@ -30,6 +29,10 @@ namespace crashpad { class ProcessMemoryFuchsia final : public ProcessMemory { public: ProcessMemoryFuchsia(); + + ProcessMemoryFuchsia(const ProcessMemoryFuchsia&) = delete; + ProcessMemoryFuchsia& operator=(const ProcessMemoryFuchsia&) = delete; + ~ProcessMemoryFuchsia(); //! \brief Initializes this object to read the memory of a process by handle. @@ -50,8 +53,6 @@ class ProcessMemoryFuchsia final : public ProcessMemory { zx::unowned_process process_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemoryFuchsia); }; } // namespace crashpad diff --git a/util/process/process_memory_linux.h b/util/process/process_memory_linux.h index 1150f14c11..496cf2d545 100644 --- a/util/process/process_memory_linux.h +++ b/util/process/process_memory_linux.h @@ -21,7 +21,6 @@ #include #include "base/files/scoped_file.h" -#include "base/macros.h" #include "util/linux/ptrace_connection.h" #include "util/misc/address_types.h" #include "util/process/process_memory.h" @@ -32,6 +31,10 @@ namespace crashpad { class ProcessMemoryLinux final : public ProcessMemory { public: explicit ProcessMemoryLinux(PtraceConnection* connection); + + ProcessMemoryLinux(const ProcessMemoryLinux&) = delete; + ProcessMemoryLinux& operator=(const ProcessMemoryLinux&) = delete; + ~ProcessMemoryLinux(); private: @@ -39,8 +42,6 @@ class ProcessMemoryLinux final : public ProcessMemory { std::function read_up_to_; base::ScopedFD mem_fd_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemoryLinux); }; } // namespace crashpad diff --git a/util/process/process_memory_mac.h b/util/process/process_memory_mac.h index 214e489007..ba37383fd9 100644 --- a/util/process/process_memory_mac.h +++ b/util/process/process_memory_mac.h @@ -22,7 +22,6 @@ #include #include "base/mac/scoped_mach_vm.h" -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory.h" @@ -37,6 +36,9 @@ class ProcessMemoryMac : public ProcessMemory { //! The mapping is maintained until this object is destroyed. class MappedMemory { public: + MappedMemory(const MappedMemory&) = delete; + MappedMemory& operator=(const MappedMemory&) = delete; + ~MappedMemory(); //! \brief Returns a pointer to the data requested by the user. @@ -86,11 +88,13 @@ class ProcessMemoryMac : public ProcessMemory { // The outer class needs to be able to call this class’ private constructor. friend class ProcessMemoryMac; - - DISALLOW_COPY_AND_ASSIGN(MappedMemory); }; ProcessMemoryMac(); + + ProcessMemoryMac(const ProcessMemoryMac&) = delete; + ProcessMemoryMac& operator=(const ProcessMemoryMac&) = delete; + ~ProcessMemoryMac() {} //! \brief Initializes this object to read the memory of a task with the @@ -126,8 +130,6 @@ class ProcessMemoryMac : public ProcessMemory { task_t task_; // weak InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemoryMac); }; } // namespace crashpad diff --git a/util/process/process_memory_range.h b/util/process/process_memory_range.h index aabee4983d..21be765958 100644 --- a/util/process/process_memory_range.h +++ b/util/process/process_memory_range.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/numeric/checked_vm_address_range.h" @@ -31,6 +30,10 @@ namespace crashpad { class ProcessMemoryRange { public: ProcessMemoryRange(); + + ProcessMemoryRange(const ProcessMemoryRange&) = delete; + ProcessMemoryRange& operator=(const ProcessMemoryRange&) = delete; + ~ProcessMemoryRange(); //! \brief Initializes this object. @@ -120,8 +123,6 @@ class ProcessMemoryRange { const ProcessMemory* memory_; // weak CheckedVMAddressRange range_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemoryRange); }; } // namespace crashpad diff --git a/util/process/process_memory_sanitized.h b/util/process/process_memory_sanitized.h index e050a47f62..a406e01488 100644 --- a/util/process/process_memory_sanitized.h +++ b/util/process/process_memory_sanitized.h @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory.h" @@ -31,6 +30,10 @@ namespace crashpad { class ProcessMemorySanitized final : public ProcessMemory { public: ProcessMemorySanitized(); + + ProcessMemorySanitized(const ProcessMemorySanitized&) = delete; + ProcessMemorySanitized& operator=(const ProcessMemorySanitized&) = delete; + ~ProcessMemorySanitized(); //! \brief Initializes this object to read memory from the underlying @@ -53,8 +56,6 @@ class ProcessMemorySanitized final : public ProcessMemory { const ProcessMemory* memory_; InitializationStateDcheck initialized_; std::vector> allowed_ranges_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemorySanitized); }; } // namespace crashpad diff --git a/util/process/process_memory_test.cc b/util/process/process_memory_test.cc index 6857b04022..fe9971bcc7 100644 --- a/util/process/process_memory_test.cc +++ b/util/process/process_memory_test.cc @@ -131,6 +131,9 @@ class ReadTest : public MultiprocessAdaptor { SetChildTestMainFunction("ReadTestChild"); } + ReadTest(const ReadTest&) = delete; + ReadTest& operator=(const ReadTest&) = delete; + void RunAgainstSelf() { size_t region_size; std::unique_ptr region; @@ -209,8 +212,6 @@ class ReadTest : public MultiprocessAdaptor { EXPECT_EQ(result[0], 2); EXPECT_EQ(result[1], 'J'); } - - DISALLOW_COPY_AND_ASSIGN(ReadTest); }; TEST(ProcessMemory, ReadSelf) { @@ -279,6 +280,9 @@ class ReadCStringTest : public MultiprocessAdaptor { SetChildTestMainFunction("ReadCStringTestChild"); } + ReadCStringTest(const ReadCStringTest&) = delete; + ReadCStringTest& operator=(const ReadCStringTest&) = delete; + void RunAgainstSelf() { const char* const_empty; const char* const_short; @@ -357,8 +361,6 @@ class ReadCStringTest : public MultiprocessAdaptor { } const bool limit_size_; - - DISALLOW_COPY_AND_ASSIGN(ReadCStringTest); }; TEST(ProcessMemory, ReadCStringSelf) { @@ -406,6 +408,9 @@ class ReadUnmappedTest : public MultiprocessAdaptor { SetChildTestMainFunction("ReadUnmappedChildMain"); } + ReadUnmappedTest(const ReadUnmappedTest&) = delete; + ReadUnmappedTest& operator=(const ReadUnmappedTest&) = delete; + void RunAgainstChild() { Run(); } private: @@ -437,8 +442,6 @@ class ReadUnmappedTest : public MultiprocessAdaptor { EXPECT_FALSE(memory.Read(page_addr2, base::GetPageSize(), result.get())); EXPECT_FALSE(memory.Read(page_addr2 - 1, 2, result.get())); } - - DISALLOW_COPY_AND_ASSIGN(ReadUnmappedTest); }; TEST(ProcessMemory, ReadUnmappedChild) { @@ -534,6 +537,9 @@ class ReadCStringUnmappedTest : public MultiprocessAdaptor { SetChildTestMainFunction("ReadCStringUnmappedChildMain"); } + ReadCStringUnmappedTest(const ReadCStringUnmappedTest&) = delete; + ReadCStringUnmappedTest& operator=(const ReadCStringUnmappedTest&) = delete; + void RunAgainstChild() { Run(); } private: @@ -582,8 +588,6 @@ class ReadCStringUnmappedTest : public MultiprocessAdaptor { } const bool limit_size_; - - DISALLOW_COPY_AND_ASSIGN(ReadCStringUnmappedTest); }; TEST(ProcessMemory, ReadCStringUnmappedChild) { diff --git a/util/process/process_memory_win.h b/util/process/process_memory_win.h index 2856900ee4..919946e56e 100644 --- a/util/process/process_memory_win.h +++ b/util/process/process_memory_win.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" #include "util/process/process_memory.h" @@ -29,6 +28,10 @@ namespace crashpad { class ProcessMemoryWin final : public ProcessMemory { public: ProcessMemoryWin(); + + ProcessMemoryWin(const ProcessMemoryWin&) = delete; + ProcessMemoryWin& operator=(const ProcessMemoryWin&) = delete; + ~ProcessMemoryWin(); //! \brief Initializes this object to read the memory of a process with the @@ -57,8 +60,6 @@ class ProcessMemoryWin final : public ProcessMemory { HANDLE handle_; ProcessInfo process_info_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessMemoryWin); }; } // namespace crashpad diff --git a/util/stdlib/thread_safe_vector.h b/util/stdlib/thread_safe_vector.h index f97024d0a8..64a4bd2cf1 100644 --- a/util/stdlib/thread_safe_vector.h +++ b/util/stdlib/thread_safe_vector.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "base/synchronization/lock.h" namespace crashpad { @@ -32,6 +31,10 @@ template class ThreadSafeVector { public: ThreadSafeVector() : vector_(), lock_() {} + + ThreadSafeVector(const ThreadSafeVector&) = delete; + ThreadSafeVector& operator=(const ThreadSafeVector&) = delete; + ~ThreadSafeVector() {} //! \brief Wraps `std::vector<>::%push_back()`. @@ -54,8 +57,6 @@ class ThreadSafeVector { private: std::vector vector_; base::Lock lock_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSafeVector); }; } // namespace crashpad diff --git a/util/stdlib/thread_safe_vector_test.cc b/util/stdlib/thread_safe_vector_test.cc index f589ca68b9..8962430411 100644 --- a/util/stdlib/thread_safe_vector_test.cc +++ b/util/stdlib/thread_safe_vector_test.cc @@ -27,6 +27,11 @@ constexpr int kElementsPerThread = 100; class ThreadSafeVectorTestThread : public Thread { public: ThreadSafeVectorTestThread() : thread_safe_vector_(nullptr), start_(0) {} + + ThreadSafeVectorTestThread(const ThreadSafeVectorTestThread&) = delete; + ThreadSafeVectorTestThread& operator=(const ThreadSafeVectorTestThread&) = + delete; + ~ThreadSafeVectorTestThread() {} void SetTestParameters(ThreadSafeVector* thread_safe_vector, int start) { @@ -44,8 +49,6 @@ class ThreadSafeVectorTestThread : public Thread { private: ThreadSafeVector* thread_safe_vector_; int start_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSafeVectorTestThread); }; TEST(ThreadSafeVector, ThreadSafeVector) { diff --git a/util/stream/base94_output_stream.h b/util/stream/base94_output_stream.h index 9d27b2ac93..2f26d1cdf7 100644 --- a/util/stream/base94_output_stream.h +++ b/util/stream/base94_output_stream.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "util/stream/output_stream_interface.h" namespace crashpad { @@ -47,6 +46,10 @@ class Base94OutputStream : public OutputStreamInterface { //! \param[in] output_stream The output_stream that this object writes to. Base94OutputStream(Mode mode, std::unique_ptr output_stream); + + Base94OutputStream(const Base94OutputStream&) = delete; + Base94OutputStream& operator=(const Base94OutputStream&) = delete; + ~Base94OutputStream() override; // OutputStreamInterface: @@ -70,8 +73,6 @@ class Base94OutputStream : public OutputStreamInterface { char symbol_buffer_; bool flush_needed_; bool flushed_; - - DISALLOW_COPY_AND_ASSIGN(Base94OutputStream); }; } // namespace crashpad diff --git a/util/stream/base94_output_stream_test.cc b/util/stream/base94_output_stream_test.cc index c15d697272..d0a2985576 100644 --- a/util/stream/base94_output_stream_test.cc +++ b/util/stream/base94_output_stream_test.cc @@ -20,7 +20,6 @@ #include #include "base/cxx17_backports.h" -#include "base/macros.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -50,6 +49,9 @@ class Base94OutputStreamTest : public testing::Test { public: Base94OutputStreamTest() {} + Base94OutputStreamTest(const Base94OutputStreamTest&) = delete; + Base94OutputStreamTest& operator=(const Base94OutputStreamTest&) = delete; + protected: void SetUp() override { auto output_stream = std::make_unique(); @@ -127,8 +129,6 @@ class Base94OutputStreamTest : public testing::Test { TestOutputStream* round_trip_test_output_stream_; std::unique_ptr input_; std::unique_ptr deterministic_input_; - - DISALLOW_COPY_AND_ASSIGN(Base94OutputStreamTest); }; TEST_F(Base94OutputStreamTest, Encoding) { diff --git a/util/stream/file_encoder.h b/util/stream/file_encoder.h index 2f34b0bf6b..72ea307713 100644 --- a/util/stream/file_encoder.h +++ b/util/stream/file_encoder.h @@ -16,7 +16,6 @@ #define CRASHPAD_UTIL_STREAM_FILE_ENCODER_H_ #include "base/files/file_path.h" -#include "base/macros.h" namespace crashpad { @@ -38,6 +37,10 @@ class FileEncoder { FileEncoder(Mode mode, const base::FilePath& input_path, const base::FilePath& output_path); + + FileEncoder(const FileEncoder&) = delete; + FileEncoder& operator=(const FileEncoder&) = delete; + ~FileEncoder(); //! \brief Encode/decode the data from \a input_path_ file according work @@ -50,8 +53,6 @@ class FileEncoder { Mode mode_; base::FilePath input_path_; base::FilePath output_path_; - - DISALLOW_COPY_AND_ASSIGN(FileEncoder); }; } // namespace crashpad diff --git a/util/stream/file_encoder_test.cc b/util/stream/file_encoder_test.cc index ff98914654..23d78dd699 100644 --- a/util/stream/file_encoder_test.cc +++ b/util/stream/file_encoder_test.cc @@ -19,7 +19,6 @@ #include #include "base/files/file_path.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "test/scoped_temp_dir.h" #include "util/file/file_io.h" diff --git a/util/stream/file_output_stream.h b/util/stream/file_output_stream.h index 128ccd5eeb..d7fc017fc5 100644 --- a/util/stream/file_output_stream.h +++ b/util/stream/file_output_stream.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_STREAM_FILE_OUTPUT_STREAM_H_ #define CRASHPAD_UTIL_STREAM_FILE_OUTPUT_STREAM_H_ -#include "base/macros.h" #include "util/file/file_io.h" #include "util/file/file_writer.h" #include "util/stream/output_stream_interface.h" @@ -27,6 +26,10 @@ class FileOutputStream : public OutputStreamInterface { public: //! \param[in] file_handle The file that this object writes to. explicit FileOutputStream(FileHandle file_handle); + + FileOutputStream(const FileOutputStream&) = delete; + FileOutputStream& operator=(const FileOutputStream&) = delete; + ~FileOutputStream(); // OutputStream. @@ -37,8 +40,6 @@ class FileOutputStream : public OutputStreamInterface { WeakFileHandleFileWriter writer_; bool flush_needed_; bool flushed_; - - DISALLOW_COPY_AND_ASSIGN(FileOutputStream); }; } // namespace crashpad diff --git a/util/stream/log_output_stream.h b/util/stream/log_output_stream.h index a1b6df3ae7..a90a1565f7 100644 --- a/util/stream/log_output_stream.h +++ b/util/stream/log_output_stream.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "util/stream/output_stream_interface.h" namespace crashpad { @@ -51,6 +50,10 @@ class LogOutputStream : public OutputStreamInterface { }; explicit LogOutputStream(std::unique_ptr delegate); + + LogOutputStream(const LogOutputStream&) = delete; + LogOutputStream& operator=(const LogOutputStream&) = delete; + ~LogOutputStream() override; // OutputStreamInterface: @@ -68,8 +71,6 @@ class LogOutputStream : public OutputStreamInterface { size_t output_count_; bool flush_needed_; bool flushed_; - - DISALLOW_COPY_AND_ASSIGN(LogOutputStream); }; } // namespace crashpad diff --git a/util/stream/log_output_stream_test.cc b/util/stream/log_output_stream_test.cc index 9faf34b8cc..7c625134e3 100644 --- a/util/stream/log_output_stream_test.cc +++ b/util/stream/log_output_stream_test.cc @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "gtest/gtest.h" namespace crashpad { @@ -55,6 +54,9 @@ class LogOutputStreamTest : public testing::Test { public: LogOutputStreamTest() {} + LogOutputStreamTest(const LogOutputStreamTest&) = delete; + LogOutputStreamTest& operator=(const LogOutputStreamTest&) = delete; + protected: void SetUp() override { log_stream_ = std::make_unique( @@ -77,8 +79,6 @@ class LogOutputStreamTest : public testing::Test { std::unique_ptr log_stream_; std::string test_log_output_; std::unique_ptr deterministic_input_; - - DISALLOW_COPY_AND_ASSIGN(LogOutputStreamTest); }; TEST_F(LogOutputStreamTest, WriteShortLog) { diff --git a/util/stream/test_output_stream.h b/util/stream/test_output_stream.h index dcd0d45de7..e8f9cf9d35 100644 --- a/util/stream/test_output_stream.h +++ b/util/stream/test_output_stream.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "util/stream/output_stream_interface.h" namespace crashpad { @@ -30,6 +29,10 @@ namespace test { class TestOutputStream : public OutputStreamInterface { public: TestOutputStream(); + + TestOutputStream(const TestOutputStream&) = delete; + TestOutputStream& operator=(const TestOutputStream&) = delete; + ~TestOutputStream() override; // OutputStreamInterface: @@ -56,8 +59,6 @@ class TestOutputStream : public OutputStreamInterface { size_t write_count_; size_t flush_count_; bool flush_needed_; - - DISALLOW_COPY_AND_ASSIGN(TestOutputStream); }; } // namespace test diff --git a/util/stream/zlib_output_stream.h b/util/stream/zlib_output_stream.h index d8e62a6cd7..62253ee939 100644 --- a/util/stream/zlib_output_stream.h +++ b/util/stream/zlib_output_stream.h @@ -20,7 +20,6 @@ #include -#include "base/macros.h" #include "third_party/zlib/zlib_crashpad.h" #include "util/misc/initialization_state.h" #include "util/stream/output_stream_interface.h" @@ -56,6 +55,10 @@ class ZlibOutputStream : public OutputStreamInterface { //! ZlibOutputStream(Mode mode, std::unique_ptr output_stream); + + ZlibOutputStream(const ZlibOutputStream&) = delete; + ZlibOutputStream& operator=(const ZlibOutputStream&) = delete; + ~ZlibOutputStream() override; // OutputStreamInterface: @@ -73,8 +76,6 @@ class ZlibOutputStream : public OutputStreamInterface { Mode mode_; InitializationState initialized_; // protects zlib_stream_ bool flush_needed_; - - DISALLOW_COPY_AND_ASSIGN(ZlibOutputStream); }; } // namespace crashpad diff --git a/util/stream/zlib_output_stream_test.cc b/util/stream/zlib_output_stream_test.cc index 194f811d6e..306a61b1e5 100644 --- a/util/stream/zlib_output_stream_test.cc +++ b/util/stream/zlib_output_stream_test.cc @@ -42,6 +42,9 @@ class ZlibOutputStreamTest : public testing::Test { std::move(test_output_stream))); } + ZlibOutputStreamTest(const ZlibOutputStreamTest&) = delete; + ZlibOutputStreamTest& operator=(const ZlibOutputStreamTest&) = delete; + const uint8_t* BuildDeterministicInput(size_t size) { deterministic_input_ = std::make_unique(size); uint8_t* deterministic_input_base = deterministic_input_.get(); @@ -69,8 +72,6 @@ class ZlibOutputStreamTest : public testing::Test { std::unique_ptr input_; std::unique_ptr deterministic_input_; TestOutputStream* test_output_stream_; // weak, owned by zlib_output_stream_ - - DISALLOW_COPY_AND_ASSIGN(ZlibOutputStreamTest); }; TEST_F(ZlibOutputStreamTest, WriteDeterministicShortData) { diff --git a/util/thread/stoppable.h b/util/thread/stoppable.h index e7a5127794..62bb40bd16 100644 --- a/util/thread/stoppable.h +++ b/util/thread/stoppable.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_THREAD_STOPPABLE_H_ #define CRASHPAD_UTIL_THREAD_STOPPABLE_H_ -#include "base/macros.h" namespace crashpad { diff --git a/util/thread/thread.h b/util/thread/thread.h index 595d308e56..e06ca3c9db 100644 --- a/util/thread/thread.h +++ b/util/thread/thread.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_THREAD_THREAD_H_ #define CRASHPAD_UTIL_THREAD_THREAD_H_ -#include "base/macros.h" #include "build/build_config.h" #if defined(OS_POSIX) @@ -31,6 +30,10 @@ namespace crashpad { class Thread { public: Thread(); + + Thread(const Thread&) = delete; + Thread& operator=(const Thread&) = delete; + virtual ~Thread(); //! \brief Create a platform thread, and run ThreadMain() on that thread. Must @@ -58,8 +61,6 @@ class Thread { #elif defined(OS_WIN) HANDLE platform_thread_; #endif - - DISALLOW_COPY_AND_ASSIGN(Thread); }; } // namespace crashpad diff --git a/util/thread/thread_log_messages.cc b/util/thread/thread_log_messages.cc index 70680b31c7..230bb87a8a 100644 --- a/util/thread/thread_log_messages.cc +++ b/util/thread/thread_log_messages.cc @@ -34,6 +34,9 @@ namespace { // object of this class exists. class ThreadLogMessagesMaster { public: + ThreadLogMessagesMaster(const ThreadLogMessagesMaster&) = delete; + ThreadLogMessagesMaster& operator=(const ThreadLogMessagesMaster&) = delete; + void SetThreadMessageList(std::vector* message_list) { DCHECK_EQ(logging::GetLogMessageHandler(), &LogMessageHandler); DCHECK_NE(tls_.Get() != nullptr, message_list != nullptr); @@ -70,8 +73,6 @@ class ThreadLogMessagesMaster { } base::ThreadLocalStorage::Slot tls_; - - DISALLOW_COPY_AND_ASSIGN(ThreadLogMessagesMaster); }; } // namespace diff --git a/util/thread/thread_log_messages.h b/util/thread/thread_log_messages.h index e8eef358b6..67bee6203e 100644 --- a/util/thread/thread_log_messages.h +++ b/util/thread/thread_log_messages.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" namespace crashpad { @@ -31,6 +30,10 @@ namespace crashpad { class ThreadLogMessages { public: ThreadLogMessages(); + + ThreadLogMessages(const ThreadLogMessages&) = delete; + ThreadLogMessages& operator=(const ThreadLogMessages&) = delete; + ~ThreadLogMessages(); //! \return The log messages collected on the thread that this object was @@ -39,8 +42,6 @@ class ThreadLogMessages { private: std::vector log_messages_; - - DISALLOW_COPY_AND_ASSIGN(ThreadLogMessages); }; } // namespace crashpad diff --git a/util/thread/thread_log_messages_test.cc b/util/thread/thread_log_messages_test.cc index 143e4c134b..f3dc1a6659 100644 --- a/util/thread/thread_log_messages_test.cc +++ b/util/thread/thread_log_messages_test.cc @@ -104,6 +104,10 @@ TEST(ThreadLogMessages, Basic) { class LoggingTestThread : public Thread { public: LoggingTestThread() : thread_number_(0), start_(0), count_(0) {} + + LoggingTestThread(const LoggingTestThread&) = delete; + LoggingTestThread& operator=(const LoggingTestThread&) = delete; + ~LoggingTestThread() override {} void Initialize(size_t thread_number, int start, int count) { @@ -137,8 +141,6 @@ class LoggingTestThread : public Thread { size_t thread_number_; int start_; int count_; - - DISALLOW_COPY_AND_ASSIGN(LoggingTestThread); }; TEST(ThreadLogMessages, Multithreaded) { diff --git a/util/thread/thread_test.cc b/util/thread/thread_test.cc index 47a711c05c..f2ea345f2d 100644 --- a/util/thread/thread_test.cc +++ b/util/thread/thread_test.cc @@ -24,31 +24,39 @@ namespace { class NoopThread : public Thread { public: NoopThread() {} + + NoopThread(const NoopThread&) = delete; + NoopThread& operator=(const NoopThread&) = delete; + ~NoopThread() override {} private: void ThreadMain() override {} - - DISALLOW_COPY_AND_ASSIGN(NoopThread); }; class WaitThread : public Thread { public: explicit WaitThread(Semaphore* semaphore) : semaphore_(semaphore) {} + + WaitThread(const WaitThread&) = delete; + WaitThread& operator=(const WaitThread&) = delete; + ~WaitThread() override {} private: void ThreadMain() override { semaphore_->Wait(); } Semaphore* semaphore_; - - DISALLOW_COPY_AND_ASSIGN(WaitThread); }; class JoinAndSignalThread : public Thread { public: JoinAndSignalThread(Thread* thread, Semaphore* semaphore) : thread_(thread), semaphore_(semaphore) {} + + JoinAndSignalThread(const JoinAndSignalThread&) = delete; + JoinAndSignalThread& operator=(const JoinAndSignalThread&) = delete; + ~JoinAndSignalThread() override {} private: @@ -59,8 +67,6 @@ class JoinAndSignalThread : public Thread { Thread* thread_; Semaphore* semaphore_; - - DISALLOW_COPY_AND_ASSIGN(JoinAndSignalThread); }; TEST(ThreadTest, NoStart) { diff --git a/util/thread/worker_thread.h b/util/thread/worker_thread.h index 0fae009091..a07fd7d5e2 100644 --- a/util/thread/worker_thread.h +++ b/util/thread/worker_thread.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/synchronization/semaphore.h" namespace crashpad { @@ -53,6 +52,10 @@ class WorkerThread { //! called. //! \param[in] delegate The work delegate to invoke every interval. WorkerThread(double work_interval, Delegate* delegate); + + WorkerThread(const WorkerThread&) = delete; + WorkerThread& operator=(const WorkerThread&) = delete; + ~WorkerThread(); //! \brief Starts the worker thread. @@ -93,8 +96,6 @@ class WorkerThread { std::unique_ptr impl_; bool running_; bool do_work_now_; - - DISALLOW_COPY_AND_ASSIGN(WorkerThread); }; } // namespace crashpad diff --git a/util/thread/worker_thread_test.cc b/util/thread/worker_thread_test.cc index 4e4fbf9a12..811d09c375 100644 --- a/util/thread/worker_thread_test.cc +++ b/util/thread/worker_thread_test.cc @@ -27,6 +27,10 @@ constexpr uint64_t kNanosecondsPerSecond = static_cast(1E9); class WorkDelegate : public WorkerThread::Delegate { public: WorkDelegate() {} + + WorkDelegate(const WorkDelegate&) = delete; + WorkDelegate& operator=(const WorkDelegate&) = delete; + ~WorkDelegate() {} void DoWork(const WorkerThread* thread) override { @@ -53,8 +57,6 @@ class WorkDelegate : public WorkerThread::Delegate { Semaphore semaphore_{0}; int work_count_ = 0; int waiting_for_count_ = -1; - - DISALLOW_COPY_AND_ASSIGN(WorkDelegate); }; TEST(WorkerThread, DoWork) { diff --git a/util/win/exception_handler_server.cc b/util/win/exception_handler_server.cc index 9394256e05..92d5c5d47c 100644 --- a/util/win/exception_handler_server.cc +++ b/util/win/exception_handler_server.cc @@ -78,6 +78,9 @@ class PipeServiceContext { clients_(clients), shutdown_token_(shutdown_token) {} + PipeServiceContext(const PipeServiceContext&) = delete; + PipeServiceContext& operator=(const PipeServiceContext&) = delete; + HANDLE port() const { return port_; } HANDLE pipe() const { return pipe_.get(); } ExceptionHandlerServer::Delegate* delegate() const { return delegate_; } @@ -92,8 +95,6 @@ class PipeServiceContext { base::Lock* clients_lock_; // weak std::set* clients_; // weak uint64_t shutdown_token_; - - DISALLOW_COPY_AND_ASSIGN(PipeServiceContext); }; //! \brief The context data for registered threadpool waits. @@ -137,6 +138,9 @@ class ClientData { process_end_callback); } + ClientData(const ClientData&) = delete; + ClientData& operator=(const ClientData&) = delete; + ~ClientData() { // It is important that this only access the threadpool waits (it's called // from the main thread) until the waits are unregistered, to ensure that @@ -230,8 +234,6 @@ class ClientData { WinVMAddress crash_exception_information_address_; WinVMAddress non_crash_exception_information_address_; WinVMAddress debug_critical_section_address_; - - DISALLOW_COPY_AND_ASSIGN(ClientData); }; } // namespace internal diff --git a/util/win/exception_handler_server.h b/util/win/exception_handler_server.h index 994cdba47f..6d9a367ce7 100644 --- a/util/win/exception_handler_server.h +++ b/util/win/exception_handler_server.h @@ -18,7 +18,6 @@ #include #include -#include "base/macros.h" #include "base/synchronization/lock.h" #include "util/file/file_io.h" #include "util/win/address_types.h" @@ -70,6 +69,9 @@ class ExceptionHandlerServer { //! although Run() will always wait for the first client to connect. explicit ExceptionHandlerServer(bool persistent); + ExceptionHandlerServer(const ExceptionHandlerServer&) = delete; + ExceptionHandlerServer& operator=(const ExceptionHandlerServer&) = delete; + ~ExceptionHandlerServer(); //! \brief Sets the pipe name to listen for client registrations on. @@ -131,8 +133,6 @@ class ExceptionHandlerServer { std::set clients_; bool persistent_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); }; } // namespace crashpad diff --git a/util/win/exception_handler_server_test.cc b/util/win/exception_handler_server_test.cc index ce31677489..ed83e16b00 100644 --- a/util/win/exception_handler_server_test.cc +++ b/util/win/exception_handler_server_test.cc @@ -20,7 +20,6 @@ #include #include -#include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "client/crashpad_client.h" #include "gtest/gtest.h" @@ -41,6 +40,10 @@ class RunServerThread : public Thread { RunServerThread(ExceptionHandlerServer* server, ExceptionHandlerServer::Delegate* delegate) : server_(server), delegate_(delegate) {} + + RunServerThread(const RunServerThread&) = delete; + RunServerThread& operator=(const RunServerThread&) = delete; + ~RunServerThread() override {} private: @@ -49,13 +52,15 @@ class RunServerThread : public Thread { ExceptionHandlerServer* server_; ExceptionHandlerServer::Delegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(RunServerThread); }; class TestDelegate : public ExceptionHandlerServer::Delegate { public: explicit TestDelegate(HANDLE server_ready) : server_ready_(server_ready) {} + + TestDelegate(const TestDelegate&) = delete; + TestDelegate& operator=(const TestDelegate&) = delete; + ~TestDelegate() {} void ExceptionHandlerServerStarted() override { @@ -72,8 +77,6 @@ class TestDelegate : public ExceptionHandlerServer::Delegate { private: HANDLE server_ready_; // weak - - DISALLOW_COPY_AND_ASSIGN(TestDelegate); }; class ExceptionHandlerServerTest : public testing::Test { @@ -87,6 +90,10 @@ class ExceptionHandlerServerTest : public testing::Test { server_.SetPipeName(pipe_name_); } + ExceptionHandlerServerTest(const ExceptionHandlerServerTest&) = delete; + ExceptionHandlerServerTest& operator=(const ExceptionHandlerServerTest&) = + delete; + TestDelegate& delegate() { return delegate_; } ExceptionHandlerServer& server() { return server_; } Thread& server_thread() { return server_thread_; } @@ -98,8 +105,6 @@ class ExceptionHandlerServerTest : public testing::Test { ScopedKernelHANDLE server_ready_; TestDelegate delegate_; RunServerThread server_thread_; - - DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServerTest); }; // During destruction, ensures that the server is stopped and the background @@ -108,6 +113,11 @@ class ScopedStopServerAndJoinThread { public: ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread) : server_(server), thread_(thread) {} + + ScopedStopServerAndJoinThread(const ScopedStopServerAndJoinThread&) = delete; + ScopedStopServerAndJoinThread& operator=( + const ScopedStopServerAndJoinThread&) = delete; + ~ScopedStopServerAndJoinThread() { server_->Stop(); thread_->Join(); @@ -116,7 +126,6 @@ class ScopedStopServerAndJoinThread { private: ExceptionHandlerServer* server_; Thread* thread_; - DISALLOW_COPY_AND_ASSIGN(ScopedStopServerAndJoinThread); }; TEST_F(ExceptionHandlerServerTest, Instantiate) { @@ -163,6 +172,9 @@ class TestClient final : public WinChildProcess { public: TestClient() : WinChildProcess() {} + TestClient(const TestClient&) = delete; + TestClient& operator=(const TestClient&) = delete; + ~TestClient() {} private: @@ -176,8 +188,6 @@ class TestClient final : public WinChildProcess { WriteWString(WritePipeHandle(), L"OK"); return EXIT_SUCCESS; } - - DISALLOW_COPY_AND_ASSIGN(TestClient); }; TEST_F(ExceptionHandlerServerTest, MultipleConnections) { diff --git a/util/win/initial_client_data.h b/util/win/initial_client_data.h index f686959e4b..856de8d890 100644 --- a/util/win/initial_client_data.h +++ b/util/win/initial_client_data.h @@ -19,7 +19,6 @@ #include -#include "base/macros.h" #include "util/win/address_types.h" namespace crashpad { @@ -67,6 +66,9 @@ class InitialClientData { WinVMAddress non_crash_exception_information, WinVMAddress debug_critical_section_address); + InitialClientData(const InitialClientData&) = delete; + InitialClientData& operator=(const InitialClientData&) = delete; + //! \brief Returns whether the object has been initialized successfully. bool IsValid() const { return is_valid_; } @@ -107,8 +109,6 @@ class InitialClientData { HANDLE first_pipe_instance_; HANDLE client_process_; bool is_valid_; - - DISALLOW_COPY_AND_ASSIGN(InitialClientData); }; } // namespace crashpad diff --git a/util/win/ntstatus_logging.h b/util/win/ntstatus_logging.h index 7eececc95b..24e6d90ad3 100644 --- a/util/win/ntstatus_logging.h +++ b/util/win/ntstatus_logging.h @@ -18,7 +18,6 @@ #include #include "base/logging.h" -#include "base/macros.h" namespace logging { @@ -32,12 +31,14 @@ class NtstatusLogMessage : public logging::LogMessage { int line, LogSeverity severity, DWORD ntstatus); + + NtstatusLogMessage(const NtstatusLogMessage&) = delete; + NtstatusLogMessage& operator=(const NtstatusLogMessage&) = delete; + ~NtstatusLogMessage(); private: DWORD ntstatus_; - - DISALLOW_COPY_AND_ASSIGN(NtstatusLogMessage); }; } // namespace logging diff --git a/util/win/process_info.h b/util/win/process_info.h index afbe146266..7b28a65f11 100644 --- a/util/win/process_info.h +++ b/util/win/process_info.h @@ -21,7 +21,6 @@ #include #include -#include "base/macros.h" #include "util/misc/initialization_state_dcheck.h" #include "util/numeric/checked_range.h" #include "util/process/process_id.h" @@ -87,6 +86,10 @@ class ProcessInfo { }; ProcessInfo(); + + ProcessInfo(const ProcessInfo&) = delete; + ProcessInfo& operator=(const ProcessInfo&) = delete; + ~ProcessInfo(); //! \brief Initializes this object with information about the given @@ -202,8 +205,6 @@ class ProcessInfo { bool is_64_bit_; bool is_wow64_; InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ProcessInfo); }; //! \brief Given a memory map of a process, and a range to be read from the diff --git a/util/win/safe_terminate_process_test.cc b/util/win/safe_terminate_process_test.cc index 6904d030ca..6ca5aa6d3f 100644 --- a/util/win/safe_terminate_process_test.cc +++ b/util/win/safe_terminate_process_test.cc @@ -22,7 +22,6 @@ #include "base/check.h" #include "base/cxx17_backports.h" #include "base/files/file_path.h" -#include "base/macros.h" #include "build/build_config.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -46,6 +45,9 @@ class ScopedExecutablePatch { memcpy(target_, source, size_); } + ScopedExecutablePatch(const ScopedExecutablePatch&) = delete; + ScopedExecutablePatch& operator=(const ScopedExecutablePatch&) = delete; + ~ScopedExecutablePatch() { ScopedVirtualProtectRWX protect_rwx(target_, size_); memcpy(target_, original_.get(), size_); @@ -71,6 +73,9 @@ class ScopedExecutablePatch { << "VirtualProtect"; } + ScopedVirtualProtectRWX(const ScopedVirtualProtectRWX&) = delete; + ScopedVirtualProtectRWX& operator=(const ScopedVirtualProtectRWX&) = delete; + ~ScopedVirtualProtectRWX() { DWORD last_protect_; PCHECK(VirtualProtect(address_, size_, old_protect_, &last_protect_)) @@ -81,15 +86,11 @@ class ScopedExecutablePatch { void* address_; size_t size_; DWORD old_protect_; - - DISALLOW_COPY_AND_ASSIGN(ScopedVirtualProtectRWX); }; std::unique_ptr original_; void* target_; size_t size_; - - DISALLOW_COPY_AND_ASSIGN(ScopedExecutablePatch); }; // SafeTerminateProcess is calling convention specific only for x86. diff --git a/util/win/scoped_process_suspend.h b/util/win/scoped_process_suspend.h index 913886e5bf..e809723f4a 100644 --- a/util/win/scoped_process_suspend.h +++ b/util/win/scoped_process_suspend.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -33,6 +32,10 @@ class ScopedProcessSuspend { public: //! Does not take ownership of \a process. explicit ScopedProcessSuspend(HANDLE process); + + ScopedProcessSuspend(const ScopedProcessSuspend&) = delete; + ScopedProcessSuspend& operator=(const ScopedProcessSuspend&) = delete; + ~ScopedProcessSuspend(); //! \brief Informs the object that the suspended process may be terminating, @@ -47,8 +50,6 @@ class ScopedProcessSuspend { private: HANDLE process_; bool tolerate_termination_ = false; - - DISALLOW_COPY_AND_ASSIGN(ScopedProcessSuspend); }; } // namespace crashpad diff --git a/util/win/scoped_process_suspend_test.cc b/util/win/scoped_process_suspend_test.cc index 2d0f5a0b90..d8ca62f803 100644 --- a/util/win/scoped_process_suspend_test.cc +++ b/util/win/scoped_process_suspend_test.cc @@ -75,6 +75,10 @@ bool SuspendCountMatches(HANDLE process, DWORD desired_suspend_count) { class ScopedProcessSuspendTest final : public WinChildProcess { public: ScopedProcessSuspendTest() : WinChildProcess() {} + + ScopedProcessSuspendTest(const ScopedProcessSuspendTest&) = delete; + ScopedProcessSuspendTest& operator=(const ScopedProcessSuspendTest&) = delete; + ~ScopedProcessSuspendTest() {} private: @@ -85,8 +89,6 @@ class ScopedProcessSuspendTest final : public WinChildProcess { EXPECT_EQ(c, ' '); return EXIT_SUCCESS; } - - DISALLOW_COPY_AND_ASSIGN(ScopedProcessSuspendTest); }; TEST(ScopedProcessSuspend, ScopedProcessSuspend) { diff --git a/util/win/scoped_set_event.h b/util/win/scoped_set_event.h index 82a1b31486..ba58d2bd56 100644 --- a/util/win/scoped_set_event.h +++ b/util/win/scoped_set_event.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" namespace crashpad { @@ -28,6 +27,10 @@ namespace crashpad { class ScopedSetEvent { public: explicit ScopedSetEvent(HANDLE event); + + ScopedSetEvent(const ScopedSetEvent&) = delete; + ScopedSetEvent& operator=(const ScopedSetEvent&) = delete; + ~ScopedSetEvent(); //! \brief Calls `SetEvent()` immediately. @@ -39,8 +42,6 @@ class ScopedSetEvent { private: HANDLE event_; // weak - - DISALLOW_COPY_AND_ASSIGN(ScopedSetEvent); }; } // namespace crashpad diff --git a/util/win/session_end_watcher.h b/util/win/session_end_watcher.h index b23d391d8c..6da1af85b4 100644 --- a/util/win/session_end_watcher.h +++ b/util/win/session_end_watcher.h @@ -17,7 +17,6 @@ #include -#include "base/macros.h" #include "util/thread/thread.h" #include "util/win/scoped_handle.h" @@ -36,6 +35,9 @@ class SessionEndWatcher : public Thread { public: SessionEndWatcher(); + SessionEndWatcher(const SessionEndWatcher&) = delete; + SessionEndWatcher& operator=(const SessionEndWatcher&) = delete; + //! \note The destructor waits for the thread that runs the message loop to //! terminate. ~SessionEndWatcher() override; @@ -70,8 +72,6 @@ class SessionEndWatcher : public Thread { HWND window_; // Conceptually strong, but ownership managed in ThreadMain() ScopedKernelHANDLE started_; ScopedKernelHANDLE stopped_; - - DISALLOW_COPY_AND_ASSIGN(SessionEndWatcher); }; } // namespace crashpad diff --git a/util/win/session_end_watcher_test.cc b/util/win/session_end_watcher_test.cc index 692d76e327..d6749dac2c 100644 --- a/util/win/session_end_watcher_test.cc +++ b/util/win/session_end_watcher_test.cc @@ -25,6 +25,9 @@ class SessionEndWatcherTest final : public SessionEndWatcher { public: SessionEndWatcherTest() : SessionEndWatcher(), called_(false) {} + SessionEndWatcherTest(const SessionEndWatcherTest&) = delete; + SessionEndWatcherTest& operator=(const SessionEndWatcherTest&) = delete; + ~SessionEndWatcherTest() override {} void Run() { @@ -44,8 +47,6 @@ class SessionEndWatcherTest final : public SessionEndWatcher { void SessionEnding() override { called_ = true; } bool called_; - - DISALLOW_COPY_AND_ASSIGN(SessionEndWatcherTest); }; TEST(SessionEndWatcher, SessionEndWatcher) { From be2a8a47c1066c95b0465fcebd31d68067f46ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Tue, 21 Sep 2021 12:12:59 -0700 Subject: [PATCH 02/69] Roll mini_chromium into crashpad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings in the removal of DISALLOW_ macros from crashpad's base/macros.h. Bug: chromium:1010217 Change-Id: Ieae1ad702be54fda7069fa72efe7d39b81a96d04 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3173473 Commit-Queue: Peter Boström Reviewed-by: Mark Mentovai --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 2e20025380..fc7a1e2a73 100644 --- a/DEPS +++ b/DEPS @@ -39,7 +39,7 @@ deps = { '7bde79cc274d06451bf65ae82c012a5d3e476b5a', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - '8f7a60f2c637f2a3c5d25f320739b3de7c2e325d', + '14b219d5d503e305a6d853e64de201659cfcbe2d', 'crashpad/third_party/libfuzzer/src': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' + 'fda403cf93ecb8792cb1d061564d89a6553ca020', From 00b93a1772722bef23e1d873fab11979053df718 Mon Sep 17 00:00:00 2001 From: Nathan Mulcahey Date: Thu, 23 Sep 2021 12:18:43 -0700 Subject: [PATCH 03/69] [fuchsia] Move third_party/lss source location. Fuchsia is unnesting third_party dependencies to be in a flat structure in preperation for migrating to git submodules. Bug: b/189352193 Change-Id: I308bfc1db43eb308b89e2bfca8b4f6abf7177d80 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3179766 Commit-Queue: Francois Rousseau Reviewed-by: Francois Rousseau --- third_party/lss/BUILD.gn | 2 ++ third_party/lss/lss.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/third_party/lss/BUILD.gn b/third_party/lss/BUILD.gn index c0652cdf5f..f104825521 100644 --- a/third_party/lss/BUILD.gn +++ b/third_party/lss/BUILD.gn @@ -17,6 +17,8 @@ import("../../build/crashpad_buildconfig.gni") config("lss_config") { if (crashpad_is_in_chromium) { defines = [ "CRASHPAD_LSS_SOURCE_EXTERNAL" ] + } else if (crashpad_is_in_fuchsia) { + defines = [ "CRASHPAD_LSS_SOURCE_FUCHSIA" ] } else { defines = [ "CRASHPAD_LSS_SOURCE_EMBEDDED" ] } diff --git a/third_party/lss/lss.h b/third_party/lss/lss.h index 11209ff8b2..2646b6c008 100644 --- a/third_party/lss/lss.h +++ b/third_party/lss/lss.h @@ -19,6 +19,8 @@ #include "third_party/lss/linux_syscall_support.h" #elif defined(CRASHPAD_LSS_SOURCE_EMBEDDED) #include "third_party/lss/lss/linux_syscall_support.h" +#elif defined(CRASHPAD_LSS_SOURCE_FUCHSIA) +#include "../../../../third_party/lss/linux_syscall_support.h" #else #error Unknown lss source #endif From 3b71fc85b1d333d37adaf06b363f3f9f89aef6a5 Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Fri, 1 Oct 2021 10:46:54 -0700 Subject: [PATCH 04/69] Config LUCI with lucicfg Change-Id: I0cff5fe7eaf1b8a26857651b617f668eefd3b553 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3192690 Commit-Queue: Joshua Peraza Reviewed-by: Mark Mentovai --- infra/config/PRESUBMIT.py | 10 +- infra/config/generated/cr-buildbucket.cfg | 636 ++++++++++++++++++++++ infra/config/generated/project.cfg | 8 + infra/config/main.star | 166 ++++++ 4 files changed, 816 insertions(+), 4 deletions(-) create mode 100644 infra/config/generated/cr-buildbucket.cfg create mode 100644 infra/config/generated/project.cfg create mode 100644 infra/config/main.star diff --git a/infra/config/PRESUBMIT.py b/infra/config/PRESUBMIT.py index a1bf82f78f..3961942c38 100644 --- a/infra/config/PRESUBMIT.py +++ b/infra/config/PRESUBMIT.py @@ -14,13 +14,15 @@ USE_PYTHON3 = True +PRESUBMIT_VERSION = '2.0.0' -def CheckChangeOnUpload(input_api, output_api): +def CheckChangedLUCIConfigs(input_api, output_api): return input_api.canned_checks.CheckChangedLUCIConfigs( input_api, output_api) -def CheckChangeOnCommit(input_api, output_api): - return input_api.canned_checks.CheckChangedLUCIConfigs( - input_api, output_api) +def CheckLucicfgGenOutputMain(input_api, output_api): + return input_api.RunTests( + input_api.canned_checks.CheckLucicfgGenOutput(input_api, output_api, + 'main.star')) diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg new file mode 100644 index 0000000000..9042dd9312 --- /dev/null +++ b/infra/config/generated/cr-buildbucket.cfg @@ -0,0 +1,636 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see BuildbucketCfg message: +# https://luci-config.appspot.com/schemas/projects:buildbucket.cfg + +buckets { + name: "ci" + acls { + role: WRITER + group: "project-crashpad-admins" + } + acls { + group: "all" + } + acls { + role: SCHEDULER + identity: "user:luci-scheduler@appspot.gserviceaccount.com" + } + swarming { + builders { + name: "crashpad_fuchsia_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_linux_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"linux\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_linux_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"linux\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_mac_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"mac\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_mac" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_mac_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"mac\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_mac" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_win_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Windows-10" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"win\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_win_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Windows-10" + dimensions: "pool:luci.flex.ci" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"win\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + } +} +buckets { + name: "try" + acls { + role: WRITER + group: "project-crashpad-admins" + } + acls { + role: WRITER + group: "service-account-crashpad-cq" + } + acls { + group: "all" + } + acls { + role: SCHEDULER + group: "project-crashpad-tryjob-access" + } + acls { + role: SCHEDULER + group: "service-account-cq" + } + swarming { + builders { + name: "crashpad_fuchsia_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_fuchsia_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"fuchsia\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_cpu:\"arm64\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_ios_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"ios\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_ios" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_linux_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"linux\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_linux_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Ubuntu-16.04" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"linux\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_mac_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"mac\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_mac" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_mac_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"mac\"" + } + execution_timeout_secs: 10800 + caches { + name: "osx_sdk_mac" + path: "osx_sdk" + } + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_win_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Windows-10" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Debug\"" + properties_j: "target_os:\"win\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + builders { + name: "crashpad_win_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "os:Windows-10" + dimensions: "pool:luci.flex.try" + recipe { + name: "crashpad/build" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" + properties_j: "config:\"Release\"" + properties_j: "target_os:\"win\"" + } + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + } +} diff --git a/infra/config/generated/project.cfg b/infra/config/generated/project.cfg new file mode 100644 index 0000000000..b68f45b7fc --- /dev/null +++ b/infra/config/generated/project.cfg @@ -0,0 +1,8 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectCfg message: +# https://luci-config.appspot.com/schemas/projects:project.cfg + +name: "crashpad" +access: "group:all" diff --git a/infra/config/main.star b/infra/config/main.star new file mode 100644 index 0000000000..280de797a9 --- /dev/null +++ b/infra/config/main.star @@ -0,0 +1,166 @@ +#!/usr/bin/env lucicfg +# Copyright 2021 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. + +luci.project( + name = "crashpad", + buildbucket = "cr-buildbucket.appspot.com", + swarming = "chromium-swarm.appspot.com", + acls = [ + acl.entry( + roles = [ + acl.LOGDOG_READER, + acl.PROJECT_CONFIGS_READER, + acl.SCHEDULER_READER, + acl.BUILDBUCKET_READER, + ], + groups = "all", + ), + ], +) + +luci.bucket( + name = "ci", + acls = [ + acl.entry( + acl.BUILDBUCKET_OWNER, + groups = "project-crashpad-admins", + ), + acl.entry( + acl.BUILDBUCKET_TRIGGERER, + users = "luci-scheduler@appspot.gserviceaccount.com", + ), + ], +) + +luci.bucket( + name = "try", + acls = [ + acl.entry( + acl.BUILDBUCKET_OWNER, + groups = [ + "service-account-crashpad-cq", + "project-crashpad-admins", + ], + ), + acl.entry( + acl.BUILDBUCKET_TRIGGERER, + groups = "service-account-cq", + ), + acl.entry( + acl.BUILDBUCKET_TRIGGERER, + groups = "project-crashpad-tryjob-access", + ), + ], +) + +def crashpad_recipe(): + return luci.recipe( + name = "crashpad/build", + cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build", + ) + +def crashpad_caches(platform): + if platform == "ios": + return [swarming.cache("osx_sdk", name = "osx_sdk_ios")] + elif platform == "mac": + return [swarming.cache("osx_sdk", name = "osx_sdk_mac")] + +def crashpad_dimensions(platform, bucket): + dimensions = {} + dimensions["cpu"] = "x86-64" + dimensions["pool"] = "luci.flex." + bucket + + if platform == "fuchsia": + dimensions["os"] = "Ubuntu-16.04" + elif platform == "ios": + dimensions["os"] = "Mac-10.15" + elif platform == "linux": + dimensions["os"] = "Ubuntu-16.04" + elif platform == "mac": + dimensions["os"] = "Mac-10.15" + elif platform == "win": + dimensions["os"] = "Windows-10" + + if platform == "fuchsia" or platform == "linux" or platform == "win": + dimensions["cores"] = "8" + + return dimensions + +def crashpad_properties(platform, cpu, config, bucket): + properties = {} + properties["target_os"] = platform + properties["$kitchen"] = { + "devshell": True, + "git_auth": True, + } + + if cpu != "x64": + properties["target_cpu"] = cpu + + if bucket == "ci": + properties["$gatekeeper"] = { + "group": "client.crashpad", + } + + if config == "dbg": + properties["config"] = "Debug" + elif config == "rel": + properties["config"] = "Release" + + return properties + +def crashpad_builder(platform, cpu, config, bucket): + return luci.builder( + name = "_".join(["crashpad", platform, cpu, config]), + bucket = bucket, + executable = crashpad_recipe(), + build_numbers = True, + caches = crashpad_caches(platform), + dimensions = crashpad_dimensions(platform, bucket), + execution_timeout = 3 * time.hour, + properties = crashpad_properties(platform, cpu, config, bucket), + service_account = "crashpad-" + bucket + + "-builder@chops-service-accounts.iam.gserviceaccount.com", + ) + +crashpad_builder("fuchsia", "arm64", "dbg", "ci") +crashpad_builder("fuchsia", "arm64", "rel", "ci") +crashpad_builder("fuchsia", "x64", "dbg", "ci") +crashpad_builder("fuchsia", "x64", "rel", "ci") +crashpad_builder("ios", "arm64", "dbg", "ci") +crashpad_builder("ios", "arm64", "rel", "ci") +crashpad_builder("ios", "x64", "dbg", "ci") +crashpad_builder("ios", "x64", "rel", "ci") +crashpad_builder("linux", "x64", "dbg", "ci") +crashpad_builder("linux", "x64", "rel", "ci") +crashpad_builder("mac", "x64", "dbg", "ci") +crashpad_builder("mac", "x64", "rel", "ci") +crashpad_builder("win", "x64", "dbg", "ci") +crashpad_builder("win", "x64", "rel", "ci") + +crashpad_builder("fuchsia", "arm64", "dbg", "try") +crashpad_builder("fuchsia", "arm64", "rel", "try") +crashpad_builder("fuchsia", "x64", "dbg", "try") +crashpad_builder("fuchsia", "x64", "rel", "try") +crashpad_builder("ios", "arm64", "dbg", "try") +crashpad_builder("ios", "arm64", "rel", "try") +crashpad_builder("ios", "x64", "dbg", "try") +crashpad_builder("ios", "x64", "rel", "try") +crashpad_builder("linux", "x64", "dbg", "try") +crashpad_builder("linux", "x64", "rel", "try") +crashpad_builder("mac", "x64", "dbg", "try") +crashpad_builder("mac", "x64", "rel", "try") +crashpad_builder("win", "x64", "dbg", "try") +crashpad_builder("win", "x64", "rel", "try") From 4318922c9a4fb4636d19e36b8d2a2312216c7992 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Fri, 1 Oct 2021 20:28:53 +0200 Subject: [PATCH 05/69] [luci][realms] switch crashpad to LUCI security realms. R=jperaza@chromium.org Bug: chromium:1242890 Change-Id: I6b7a05806c27827fce213804348c84273ba21e7a No-Try: True Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3197578 Commit-Queue: Joshua Peraza Reviewed-by: Joshua Peraza --- infra/config/generated/cr-buildbucket.cfg | 112 ++++++++++++++++++++++ infra/config/generated/realms.cfg | 57 +++++++++++ infra/config/main.star | 9 ++ 3 files changed, 178 insertions(+) create mode 100644 infra/config/generated/realms.cfg mode change 100644 => 100755 infra/config/main.star diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 9042dd9312..6a0c463ab4 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -38,6 +38,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_arm64_rel" @@ -59,6 +63,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_x64_dbg" @@ -79,6 +87,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_x64_rel" @@ -99,6 +111,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_arm64_dbg" @@ -123,6 +139,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_arm64_rel" @@ -147,6 +167,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_x64_dbg" @@ -170,6 +194,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_x64_rel" @@ -193,6 +221,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_linux_x64_dbg" @@ -213,6 +245,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_linux_x64_rel" @@ -233,6 +269,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_mac_x64_dbg" @@ -256,6 +296,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_mac_x64_rel" @@ -279,6 +323,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_win_x64_dbg" @@ -299,6 +347,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_win_x64_rel" @@ -319,6 +371,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } } } @@ -363,6 +419,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_arm64_rel" @@ -383,6 +443,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_x64_dbg" @@ -402,6 +466,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_fuchsia_x64_rel" @@ -421,6 +489,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_arm64_dbg" @@ -444,6 +516,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_arm64_rel" @@ -467,6 +543,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_x64_dbg" @@ -489,6 +569,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_ios_x64_rel" @@ -511,6 +595,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_linux_x64_dbg" @@ -530,6 +618,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_linux_x64_rel" @@ -549,6 +641,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_mac_x64_dbg" @@ -571,6 +667,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_mac_x64_rel" @@ -593,6 +693,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_win_x64_dbg" @@ -612,6 +716,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } builders { name: "crashpad_win_x64_rel" @@ -631,6 +739,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.use_realms" + value: 100 + } } } } diff --git a/infra/config/generated/realms.cfg b/infra/config/generated/realms.cfg new file mode 100644 index 0000000000..41377301b7 --- /dev/null +++ b/infra/config/generated/realms.cfg @@ -0,0 +1,57 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see RealmsCfg message: +# https://luci-config.appspot.com/schemas/projects:realms.cfg + +realms { + name: "@root" + bindings { + role: "role/buildbucket.reader" + principals: "group:all" + } + bindings { + role: "role/configs.reader" + principals: "group:all" + } + bindings { + role: "role/logdog.reader" + principals: "group:all" + } + bindings { + role: "role/scheduler.reader" + principals: "group:all" + } +} +realms { + name: "ci" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/buildbucket.owner" + principals: "group:project-crashpad-admins" + } + bindings { + role: "role/buildbucket.triggerer" + principals: "user:luci-scheduler@appspot.gserviceaccount.com" + } +} +realms { + name: "try" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/buildbucket.owner" + principals: "group:project-crashpad-admins" + principals: "group:service-account-crashpad-cq" + } + bindings { + role: "role/buildbucket.triggerer" + principals: "group:project-crashpad-tryjob-access" + principals: "group:service-account-cq" + } +} diff --git a/infra/config/main.star b/infra/config/main.star old mode 100644 new mode 100755 index 280de797a9..fb8af22377 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +lucicfg.check_version("1.28.0", "Please update depot_tools") + +# Enable LUCI Realms support. +lucicfg.enable_experiment("crbug.com/1085650") + +# Launch 100% of Swarming tasks for builds in "realms-aware mode". +luci.builder.defaults.experiments.set({"luci.use_realms": 100}) + + luci.project( name = "crashpad", buildbucket = "cr-buildbucket.appspot.com", From 1992b3031758243ae61d91a3e7b4c6f8d25d7cbd Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Fri, 1 Oct 2021 16:53:34 -0700 Subject: [PATCH 06/69] Configure logdog, milo, and scheduling Change-Id: I9eefe0cd9322d8bb5905ea094ac5691b66228424 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3198116 Reviewed-by: Joshua Peraza --- infra/config/generated/commit-queue.cfg | 80 ++++++++++ infra/config/generated/luci-logdog.cfg | 9 ++ infra/config/generated/luci-milo.cfg | 131 ++++++++++++++++ infra/config/generated/luci-scheduler.cfg | 179 ++++++++++++++++++++++ infra/config/generated/realms.cfg | 8 + infra/config/main.star | 93 ++++++++++- 6 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 infra/config/generated/commit-queue.cfg create mode 100644 infra/config/generated/luci-logdog.cfg create mode 100644 infra/config/generated/luci-milo.cfg create mode 100644 infra/config/generated/luci-scheduler.cfg diff --git a/infra/config/generated/commit-queue.cfg b/infra/config/generated/commit-queue.cfg new file mode 100644 index 0000000000..95b31824f3 --- /dev/null +++ b/infra/config/generated/commit-queue.cfg @@ -0,0 +1,80 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see Config message: +# https://luci-config.appspot.com/schemas/projects:commit-queue.cfg + +cq_status_host: "chromium-cq-status.appspot.com" +submit_options { + max_burst: 4 + burst_delay { + seconds: 480 + } +} +config_groups { + name: "crashpad" + gerrit { + url: "https://chromium-review.googlesource.com" + projects { + name: "crashpad/crashpad" + ref_regexp: "refs/heads/.+" + } + } + verifiers { + gerrit_cq_ability { + committer_list: "project-crashpad-tryjob-access" + dry_run_access_list: "project-crashpad-tryjob-access" + } + tryjob { + builders { + name: "crashpad/try/crashpad_fuchsia_arm64_dbg" + } + builders { + name: "crashpad/try/crashpad_fuchsia_arm64_rel" + } + builders { + name: "crashpad/try/crashpad_fuchsia_x64_dbg" + } + builders { + name: "crashpad/try/crashpad_fuchsia_x64_rel" + } + builders { + name: "crashpad/try/crashpad_ios_arm64_dbg" + } + builders { + name: "crashpad/try/crashpad_ios_arm64_rel" + } + builders { + name: "crashpad/try/crashpad_ios_x64_dbg" + } + builders { + name: "crashpad/try/crashpad_ios_x64_rel" + } + builders { + name: "crashpad/try/crashpad_linux_x64_dbg" + } + builders { + name: "crashpad/try/crashpad_linux_x64_rel" + } + builders { + name: "crashpad/try/crashpad_mac_x64_dbg" + } + builders { + name: "crashpad/try/crashpad_mac_x64_rel" + } + builders { + name: "crashpad/try/crashpad_win_x64_dbg" + } + builders { + name: "crashpad/try/crashpad_win_x64_rel" + } + retry_config { + single_quota: 1 + global_quota: 2 + failure_weight: 1 + transient_failure_weight: 1 + timeout_weight: 2 + } + } + } +} diff --git a/infra/config/generated/luci-logdog.cfg b/infra/config/generated/luci-logdog.cfg new file mode 100644 index 0000000000..adc75bef49 --- /dev/null +++ b/infra/config/generated/luci-logdog.cfg @@ -0,0 +1,9 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectConfig message: +# https://luci-config.appspot.com/schemas/projects:luci-logdog.cfg + +reader_auth_groups: "all" +writer_auth_groups: "luci-logdog-chromium-writers" +archive_gs_bucket: "chromium-luci-logdog" diff --git a/infra/config/generated/luci-milo.cfg b/infra/config/generated/luci-milo.cfg new file mode 100644 index 0000000000..6c891b14d5 --- /dev/null +++ b/infra/config/generated/luci-milo.cfg @@ -0,0 +1,131 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see Project message: +# https://luci-config.appspot.com/schemas/projects:luci-milo.cfg + +consoles { + id: "main" + name: "Crashpad Main Console" + repo_url: "https://chromium.googlesource.com/crashpad/crashpad" + refs: "regexp:refs/heads/main" + manifest_name: "REVISION" + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_fuchsia_arm64_dbg" + category: "fuchsia|arm64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_fuchsia_arm64_rel" + category: "fuchsia|arm64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_fuchsia_x64_dbg" + category: "fuchsia|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_fuchsia_x64_rel" + category: "fuchsia|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_ios_arm64_dbg" + category: "ios|arm64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_ios_arm64_rel" + category: "ios|arm64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_ios_x64_dbg" + category: "ios|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_ios_x64_rel" + category: "ios|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_linux_x64_dbg" + category: "linux|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_linux_x64_rel" + category: "linux|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_mac_x64_dbg" + category: "mac|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_mac_x64_rel" + category: "mac|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_win_x64_dbg" + category: "win|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.crashpad.ci/crashpad_win_x64_rel" + category: "win|x64" + short_name: "rel" + } +} +consoles { + id: "try" + name: "Crashpad Try Builders" + builders { + name: "buildbucket/luci.crashpad.try/crashpad_fuchsia_arm64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_fuchsia_arm64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_fuchsia_x64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_fuchsia_x64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_ios_arm64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_ios_arm64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_ios_x64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_ios_x64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_linux_x64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_linux_x64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_mac_x64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_mac_x64_rel" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_win_x64_dbg" + } + builders { + name: "buildbucket/luci.crashpad.try/crashpad_win_x64_rel" + } + builder_view_only: true +} +logo_url: "https://storage.googleapis.com/chrome-infra-public/logo/crashpad-logo.svg" diff --git a/infra/config/generated/luci-scheduler.cfg b/infra/config/generated/luci-scheduler.cfg new file mode 100644 index 0000000000..6b3d04d1b3 --- /dev/null +++ b/infra/config/generated/luci-scheduler.cfg @@ -0,0 +1,179 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectConfig message: +# https://luci-config.appspot.com/schemas/projects:luci-scheduler.cfg + +job { + id: "crashpad_fuchsia_arm64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_fuchsia_arm64_dbg" + } +} +job { + id: "crashpad_fuchsia_arm64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_fuchsia_arm64_rel" + } +} +job { + id: "crashpad_fuchsia_x64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_fuchsia_x64_dbg" + } +} +job { + id: "crashpad_fuchsia_x64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_fuchsia_x64_rel" + } +} +job { + id: "crashpad_ios_arm64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_ios_arm64_dbg" + } +} +job { + id: "crashpad_ios_arm64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_ios_arm64_rel" + } +} +job { + id: "crashpad_ios_x64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_ios_x64_dbg" + } +} +job { + id: "crashpad_ios_x64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_ios_x64_rel" + } +} +job { + id: "crashpad_linux_x64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_linux_x64_dbg" + } +} +job { + id: "crashpad_linux_x64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_linux_x64_rel" + } +} +job { + id: "crashpad_mac_x64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_mac_x64_dbg" + } +} +job { + id: "crashpad_mac_x64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_mac_x64_rel" + } +} +job { + id: "crashpad_win_x64_dbg" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_win_x64_dbg" + } +} +job { + id: "crashpad_win_x64_rel" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "luci.crashpad.ci" + builder: "crashpad_win_x64_rel" + } +} +trigger { + id: "master-gitiles-trigger" + realm: "ci" + acl_sets: "ci" + triggers: "crashpad_fuchsia_arm64_dbg" + triggers: "crashpad_fuchsia_arm64_rel" + triggers: "crashpad_fuchsia_x64_dbg" + triggers: "crashpad_fuchsia_x64_rel" + triggers: "crashpad_ios_arm64_dbg" + triggers: "crashpad_ios_arm64_rel" + triggers: "crashpad_ios_x64_dbg" + triggers: "crashpad_ios_x64_rel" + triggers: "crashpad_linux_x64_dbg" + triggers: "crashpad_linux_x64_rel" + triggers: "crashpad_mac_x64_dbg" + triggers: "crashpad_mac_x64_rel" + triggers: "crashpad_win_x64_dbg" + triggers: "crashpad_win_x64_rel" + gitiles { + repo: "https://chromium.googlesource.com/crashpad/crashpad" + refs: "regexp:refs/heads/main" + } +} +acl_sets { + name: "ci" + acls { + role: OWNER + granted_to: "group:project-crashpad-admins" + } + acls { + granted_to: "group:all" + } +} diff --git a/infra/config/generated/realms.cfg b/infra/config/generated/realms.cfg index 41377301b7..8dc05f6b5a 100644 --- a/infra/config/generated/realms.cfg +++ b/infra/config/generated/realms.cfg @@ -18,6 +18,14 @@ realms { role: "role/logdog.reader" principals: "group:all" } + bindings { + role: "role/logdog.writer" + principals: "group:luci-logdog-chromium-writers" + } + bindings { + role: "role/scheduler.owner" + principals: "group:project-crashpad-admins" + } bindings { role: "role/scheduler.reader" principals: "group:all" diff --git a/infra/config/main.star b/infra/config/main.star index fb8af22377..632bcec776 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -21,6 +21,8 @@ lucicfg.enable_experiment("crbug.com/1085650") # Launch 100% of Swarming tasks for builds in "realms-aware mode". luci.builder.defaults.experiments.set({"luci.use_realms": 100}) +REPO_URL = "https://chromium.googlesource.com/crashpad/crashpad" +REVIEW_URL = "https://chromium-review.googlesource.com/crashpad/crashpad" luci.project( name = "crashpad", @@ -36,9 +38,73 @@ luci.project( ], groups = "all", ), + acl.entry( + roles = acl.LOGDOG_WRITER, + groups = "luci-logdog-chromium-writers", + ), + acl.entry( + roles = acl.SCHEDULER_OWNER, + groups = "project-crashpad-admins", + ), + ], + logdog = "luci-logdog.appspot.com", + milo = "luci-milo.appspot.com", + scheduler = "luci-scheduler.appspot.com", +) + +luci.cq( + status_host = "chromium-cq-status.appspot.com", + submit_max_burst = 4, + submit_burst_delay = 8 * time.minute, +) + +luci.cq_group( + name = "crashpad", + watch = cq.refset(repo = REVIEW_URL, refs = ["refs/heads/.+"]), + retry_config = cq.retry_config( + single_quota = 1, + global_quota = 2, + failure_weight = 1, + transient_failure_weight = 1, + timeout_weight = 2, + ), + acls = [ + acl.entry( + roles = acl.CQ_COMMITTER, + groups = "project-crashpad-tryjob-access", + ), + acl.entry( + roles = acl.CQ_DRY_RUNNER, + groups = "project-crashpad-tryjob-access", + ), ], ) +luci.gitiles_poller( + name = "master-gitiles-trigger", + bucket = "ci", + repo = REPO_URL, +) + +luci.logdog( + gs_bucket = "chromium-luci-logdog", +) + +luci.milo( + logo = "https://storage.googleapis.com/chrome-infra-public/logo/crashpad-logo.svg", +) + +luci.console_view( + name = "main", + repo = REPO_URL, + title = "Crashpad Main Console", +) + +luci.list_view( + name = "try", + title = "Crashpad Try Builders", +) + luci.bucket( name = "ci", acls = [ @@ -131,8 +197,29 @@ def crashpad_properties(platform, cpu, config, bucket): return properties def crashpad_builder(platform, cpu, config, bucket): + name = "_".join(["crashpad", platform, cpu, config]) + triggered_by = None + + if bucket == "ci": + luci.console_view_entry( + builder = "ci/" + name, + console_view = "main", + short_name = config, + category = platform + "|" + cpu, + ) + triggered_by = ["master-gitiles-trigger"] + elif bucket == "try": + luci.list_view_entry( + builder = "try/" + name, + list_view = "try", + ) + luci.cq_tryjob_verifier( + "try/" + name, + cq_group = "crashpad", + ) + return luci.builder( - name = "_".join(["crashpad", platform, cpu, config]), + name = name, bucket = bucket, executable = crashpad_recipe(), build_numbers = True, @@ -140,8 +227,8 @@ def crashpad_builder(platform, cpu, config, bucket): dimensions = crashpad_dimensions(platform, bucket), execution_timeout = 3 * time.hour, properties = crashpad_properties(platform, cpu, config, bucket), - service_account = "crashpad-" + bucket + - "-builder@chops-service-accounts.iam.gserviceaccount.com", + service_account = "crashpad-" + bucket + "-builder@chops-service-accounts.iam.gserviceaccount.com", + triggered_by = triggered_by, ) crashpad_builder("fuchsia", "arm64", "dbg", "ci") From 87c998f191996b16eb291e9b94e7b31dff04ee90 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Tue, 5 Oct 2021 00:02:41 +0200 Subject: [PATCH 07/69] [lucicfg] noop change to kick LUCI config to ingest this revision. R=jperaza@google.com Change-Id: Iff5e56a47691b05480a25dc82169471e4d0e90bc Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3203810 Reviewed-by: Joshua Peraza Reviewed-by: Mark Mentovai Commit-Queue: Joshua Peraza Commit-Queue: Andrii Shyshkalov Commit-Queue: Mark Mentovai --- infra/config/main.star | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/infra/config/main.star b/infra/config/main.star index 632bcec776..4aaeb80a7d 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -15,10 +15,9 @@ lucicfg.check_version("1.28.0", "Please update depot_tools") -# Enable LUCI Realms support. +# Enable LUCI Realms support and Launch 100% of Swarming tasks for builds in +# "realms-aware mode". lucicfg.enable_experiment("crbug.com/1085650") - -# Launch 100% of Swarming tasks for builds in "realms-aware mode". luci.builder.defaults.experiments.set({"luci.use_realms": 100}) REPO_URL = "https://chromium.googlesource.com/crashpad/crashpad" From 718d5d52ea4774ba8f63b81e3966263c376c3a91 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 4 Oct 2021 09:20:12 -0400 Subject: [PATCH 08/69] win: Swap win_console and win_windowed for external handler. Bug: crashpad:377 Change-Id: I1c4d16d6012701e02d54f2468f4048d2d7a19842 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3201106 Reviewed-by: Joshua Peraza Commit-Queue: Justin Cohen --- handler/BUILD.gn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/handler/BUILD.gn b/handler/BUILD.gn index a697b338e8..f66da69a4c 100644 --- a/handler/BUILD.gn +++ b/handler/BUILD.gn @@ -169,6 +169,11 @@ if (!crashpad_is_ios) { if (crashpad_is_in_chromium || crashpad_is_in_dart) { remove_configs = [ "//build/config/win:console" ] configs = [ "//build/config/win:windowed" ] + } else if (crashpad_is_external) { + remove_configs = + [ "//../../mini_chromium/mini_chromium/build/config:win_console" ] + configs = + [ "//../../mini_chromium/mini_chromium/build/config:win_windowed" ] } else { remove_configs = [ "//third_party/mini_chromium/mini_chromium/build/config:win_console", From e29981e10c71b57bc987895a2cfec892b1aac750 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Tue, 5 Oct 2021 10:31:59 -0700 Subject: [PATCH 09/69] Fix an instance of -Wunused-but-set-variable. Bug: chromium:794619 Change-Id: I4db52a6d895535b79e75331c51017489f490b4c1 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3206094 Reviewed-by: Mark Mentovai Commit-Queue: Peter Kasting --- .../ios_handler/in_process_intermediate_dump_handler.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/ios_handler/in_process_intermediate_dump_handler.cc b/client/ios_handler/in_process_intermediate_dump_handler.cc index 9c1a31644b..7e04058a0f 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler.cc @@ -747,7 +747,9 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( writer, IntermediateDumpKey::kThreads); // Exception thread ID. +#if defined(ARCH_CPU_ARM64) uint64_t exception_thread_id = 0; +#endif thread_identifier_info identifier_info; mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; kern_return_t kr = @@ -756,7 +758,9 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( reinterpret_cast(&identifier_info), &count); if (kr == KERN_SUCCESS) { +#if defined(ARCH_CPU_ARM64) exception_thread_id = identifier_info.thread_id; +#endif } else { CRASHPAD_RAW_LOG_ERROR(kr, "thread_info::THREAD_IDENTIFIER_INFO"); } @@ -803,7 +807,9 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( } // Thread ID. +#if defined(ARCH_CPU_ARM64) uint64_t thread_id; +#endif thread_identifier_info identifier_info; count = THREAD_IDENTIFIER_INFO_COUNT; kr = thread_info(thread, @@ -811,7 +817,9 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( reinterpret_cast(&identifier_info), &count); if (kr == KERN_SUCCESS) { +#if defined(ARCH_CPU_ARM64) thread_id = identifier_info.thread_id; +#endif WriteProperty( writer, IntermediateDumpKey::kThreadID, &identifier_info.thread_id); WriteProperty(writer, From 413dedd90fbefd377417d7c5947a1d11c09220ae Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 7 Oct 2021 16:02:56 -0400 Subject: [PATCH 10/69] ios: Missing include. uint16_t needs stdint.h. Change-Id: Iafbbb6365d2cf180e61f62c5fbd9e7c35a58e827 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3212887 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- util/ios/ios_intermediate_dump_format.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/ios/ios_intermediate_dump_format.h b/util/ios/ios_intermediate_dump_format.h index 46d3f46798..5e36862e8d 100644 --- a/util/ios/ios_intermediate_dump_format.h +++ b/util/ios/ios_intermediate_dump_format.h @@ -15,6 +15,8 @@ #ifndef CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_FORMAT_H_ #define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_FORMAT_H_ +#include + namespace crashpad { namespace internal { From dd539703805b9c289f4990f42f710bd3a68c41f1 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Mon, 11 Oct 2021 10:58:21 -0700 Subject: [PATCH 11/69] Fix an instance of -Wunused-but-set-variable. Bug: chromium:1203071 Change-Id: I055432e2652ce6ca8a57a6f0f4f584c3e9c511bc Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3217911 Reviewed-by: Mark Mentovai Commit-Queue: Peter Kasting --- snapshot/linux/debug_rendezvous_test.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snapshot/linux/debug_rendezvous_test.cc b/snapshot/linux/debug_rendezvous_test.cc index c77e86263a..4754528e85 100644 --- a/snapshot/linux/debug_rendezvous_test.cc +++ b/snapshot/linux/debug_rendezvous_test.cc @@ -162,7 +162,9 @@ void TestAgainstTarget(PtraceConnection* connection) { ASSERT_GE(possible_mappings->Count(), 1u); std::unique_ptr module_reader; +#if !defined(OS_ANDROID) const MemoryMap::Mapping* module_mapping = nullptr; +#endif const MemoryMap::Mapping* mapping = nullptr; while ((mapping = possible_mappings->Next())) { auto parsed_module = std::make_unique(); @@ -172,7 +174,9 @@ void TestAgainstTarget(PtraceConnection* connection) { parsed_module->GetDynamicArrayAddress(&dynamic_address) && dynamic_address == module.dynamic_array) { module_reader = std::move(parsed_module); +#if !defined(OS_ANDROID) module_mapping = mapping; +#endif break; } } From 0a8985cd20d3d287a4a425c091448e926896513a Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Tue, 12 Oct 2021 15:55:03 -0700 Subject: [PATCH 12/69] linux,arm: support memory tagging 64-bit ARM's Top-Byte-Ignore enables features such as memory tagging. https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html Android 11 will start using memory tagging on some devices. https://source.android.com/devices/tech/debug/tagged-pointers Crashpad needs to remove the tags from pointers before comparing to addresses or using with system calls. Bug: crashpad:364 Change-Id: I67c6b9a4a86d090e1d139de727eb06d9e222cc25 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3078500 Reviewed-by: Mark Mentovai Commit-Queue: Joshua Peraza --- snapshot/linux/process_reader_linux.cc | 13 +++++++------ snapshot/linux/process_reader_linux.h | 2 +- snapshot/linux/process_reader_linux_test.cc | 9 ++++++--- test/linux/fake_ptrace_connection.cc | 2 +- test/linux/fake_ptrace_connection.h | 2 +- util/linux/direct_ptrace_connection.cc | 2 +- util/linux/direct_ptrace_connection.h | 4 ++-- util/linux/memory_map.cc | 8 +++++--- util/linux/memory_map.h | 1 + util/linux/ptrace_client.cc | 2 +- util/linux/ptrace_client.h | 4 ++-- util/linux/ptrace_connection.h | 4 ++-- util/process/process_memory_linux.cc | 17 +++++++++++++++-- util/process/process_memory_linux.h | 8 +++++++- 14 files changed, 52 insertions(+), 26 deletions(-) diff --git a/snapshot/linux/process_reader_linux.cc b/snapshot/linux/process_reader_linux.cc index ee246e8bcb..a9098ac803 100644 --- a/snapshot/linux/process_reader_linux.cc +++ b/snapshot/linux/process_reader_linux.cc @@ -125,7 +125,8 @@ void ProcessReaderLinux::Thread::InitializeStackFromSP( LOG(WARNING) << "no stack mapping"; return; } - LinuxVMAddress stack_region_start = stack_pointer; + LinuxVMAddress stack_region_start = + reader->Memory()->PointerToAddress(stack_pointer); // We've hit what looks like a guard page; skip to the end and check for a // mapped stack region. @@ -177,11 +178,11 @@ void ProcessReaderLinux::Thread::InitializeStackFromSP( // at the high-address end of the stack so we can try using that to shrink // the stack region. stack_region_size = stack_end - stack_region_address; - if (tid != reader->ProcessID() && - thread_info.thread_specific_data_address > stack_region_address && - thread_info.thread_specific_data_address < stack_end) { - stack_region_size = - thread_info.thread_specific_data_address - stack_region_address; + VMAddress tls_address = reader->Memory()->PointerToAddress( + thread_info.thread_specific_data_address); + if (tid != reader->ProcessID() && tls_address > stack_region_address && + tls_address < stack_end) { + stack_region_size = tls_address - stack_region_address; } } diff --git a/snapshot/linux/process_reader_linux.h b/snapshot/linux/process_reader_linux.h index 0eb1d40405..f44e15f5f5 100644 --- a/snapshot/linux/process_reader_linux.h +++ b/snapshot/linux/process_reader_linux.h @@ -123,7 +123,7 @@ class ProcessReaderLinux { pid_t ParentProcessID() const { return process_info_.ParentProcessID(); } //! \brief Return a memory reader for the target process. - const ProcessMemory* Memory() const { return connection_->Memory(); } + const ProcessMemoryLinux* Memory() const { return connection_->Memory(); } //! \brief Return a memory map of the target process. MemoryMap* GetMemoryMap() { return &memory_map_; } diff --git a/snapshot/linux/process_reader_linux_test.cc b/snapshot/linux/process_reader_linux_test.cc index 250f12dabb..f3791f85ba 100644 --- a/snapshot/linux/process_reader_linux_test.cc +++ b/snapshot/linux/process_reader_linux_test.cc @@ -291,9 +291,12 @@ void ExpectThreads(const ThreadMap& thread_map, #if !defined(ADDRESS_SANITIZER) // AddressSanitizer causes stack variables to be stored separately from the // call stack. - EXPECT_LE(thread.stack_region_address, iterator->second.stack_address); - EXPECT_GE(thread.stack_region_address + thread.stack_region_size, - iterator->second.stack_address); + EXPECT_LE( + thread.stack_region_address, + connection->Memory()->PointerToAddress(iterator->second.stack_address)); + EXPECT_GE( + thread.stack_region_address + thread.stack_region_size, + connection->Memory()->PointerToAddress(iterator->second.stack_address)); #endif // !defined(ADDRESS_SANITIZER) if (iterator->second.max_stack_size) { diff --git a/test/linux/fake_ptrace_connection.cc b/test/linux/fake_ptrace_connection.cc index 774a340a4d..33a8f08b69 100644 --- a/test/linux/fake_ptrace_connection.cc +++ b/test/linux/fake_ptrace_connection.cc @@ -80,7 +80,7 @@ bool FakePtraceConnection::ReadFileContents(const base::FilePath& path, return LoggingReadEntireFile(path, contents); } -ProcessMemory* FakePtraceConnection::Memory() { +ProcessMemoryLinux* FakePtraceConnection::Memory() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!memory_) { memory_ = std::make_unique(this); diff --git a/test/linux/fake_ptrace_connection.h b/test/linux/fake_ptrace_connection.h index bf09d95db9..f6ba7de3eb 100644 --- a/test/linux/fake_ptrace_connection.h +++ b/test/linux/fake_ptrace_connection.h @@ -63,7 +63,7 @@ class FakePtraceConnection : public PtraceConnection { //! \brief Attempts to create a ProcessMemory when called, calling //! ADD_FAILURE() and returning `nullptr` on failure. - ProcessMemory* Memory() override; + ProcessMemoryLinux* Memory() override; //! \todo Not yet implemented. bool Threads(std::vector* threads) override; diff --git a/util/linux/direct_ptrace_connection.cc b/util/linux/direct_ptrace_connection.cc index 5da0147587..3cc41c3f82 100644 --- a/util/linux/direct_ptrace_connection.cc +++ b/util/linux/direct_ptrace_connection.cc @@ -73,7 +73,7 @@ bool DirectPtraceConnection::ReadFileContents(const base::FilePath& path, return LoggingReadEntireFile(path, contents); } -ProcessMemory* DirectPtraceConnection::Memory() { +ProcessMemoryLinux* DirectPtraceConnection::Memory() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!memory_) { memory_ = std::make_unique(this); diff --git a/util/linux/direct_ptrace_connection.h b/util/linux/direct_ptrace_connection.h index a120889a59..391495ff74 100644 --- a/util/linux/direct_ptrace_connection.h +++ b/util/linux/direct_ptrace_connection.h @@ -58,13 +58,13 @@ class DirectPtraceConnection : public PtraceConnection { bool GetThreadInfo(pid_t tid, ThreadInfo* info) override; bool ReadFileContents(const base::FilePath& path, std::string* contents) override; - ProcessMemory* Memory() override; + ProcessMemoryLinux* Memory() override; bool Threads(std::vector* threads) override; ssize_t ReadUpTo(VMAddress, size_t size, void* buffer) override; private: std::vector> attachments_; - std::unique_ptr memory_; + std::unique_ptr memory_; pid_t pid_; Ptracer ptracer_; InitializationStateDcheck initialized_; diff --git a/util/linux/memory_map.cc b/util/linux/memory_map.cc index dabc114d91..e15a1c5e7d 100644 --- a/util/linux/memory_map.cc +++ b/util/linux/memory_map.cc @@ -240,7 +240,7 @@ MemoryMap::Mapping::Mapping() executable(false), shareable(false) {} -MemoryMap::MemoryMap() : mappings_(), initialized_() {} +MemoryMap::MemoryMap() : mappings_(), connection_(nullptr), initialized_() {} MemoryMap::~MemoryMap() {} @@ -256,6 +256,7 @@ bool MemoryMap::Mapping::Equals(const Mapping& other) const { bool MemoryMap::Initialize(PtraceConnection* connection) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); + connection_ = connection; // If the maps file is not read atomically, entries can be read multiple times // or missed entirely. The kernel reads entries from this file into a page @@ -268,8 +269,8 @@ bool MemoryMap::Initialize(PtraceConnection* connection) { do { std::string contents; char path[32]; - snprintf(path, sizeof(path), "/proc/%d/maps", connection->GetProcessID()); - if (!connection->ReadFileContents(base::FilePath(path), &contents)) { + snprintf(path, sizeof(path), "/proc/%d/maps", connection_->GetProcessID()); + if (!connection_->ReadFileContents(base::FilePath(path), &contents)) { return false; } @@ -298,6 +299,7 @@ bool MemoryMap::Initialize(PtraceConnection* connection) { const MemoryMap::Mapping* MemoryMap::FindMapping(LinuxVMAddress address) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); + address = connection_->Memory()->PointerToAddress(address); for (const auto& mapping : mappings_) { if (mapping.range.Base() <= address && mapping.range.End() > address) { diff --git a/util/linux/memory_map.h b/util/linux/memory_map.h index d43b7af429..f6f7cc840b 100644 --- a/util/linux/memory_map.h +++ b/util/linux/memory_map.h @@ -129,6 +129,7 @@ class MemoryMap { private: std::vector mappings_; + PtraceConnection* connection_; InitializationStateDcheck initialized_; }; diff --git a/util/linux/ptrace_client.cc b/util/linux/ptrace_client.cc index cb1a1a5d06..9a34722ae2 100644 --- a/util/linux/ptrace_client.cc +++ b/util/linux/ptrace_client.cc @@ -248,7 +248,7 @@ bool PtraceClient::ReadFileContents(const base::FilePath& path, return true; } -ProcessMemory* PtraceClient::Memory() { +ProcessMemoryLinux* PtraceClient::Memory() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!memory_) { memory_ = std::make_unique(this); diff --git a/util/linux/ptrace_client.h b/util/linux/ptrace_client.h index 299aafc993..cd40f6bd04 100644 --- a/util/linux/ptrace_client.h +++ b/util/linux/ptrace_client.h @@ -60,14 +60,14 @@ class PtraceClient : public PtraceConnection { bool GetThreadInfo(pid_t tid, ThreadInfo* info) override; bool ReadFileContents(const base::FilePath& path, std::string* contents) override; - ProcessMemory* Memory() override; + ProcessMemoryLinux* Memory() override; bool Threads(std::vector* threads) override; ssize_t ReadUpTo(VMAddress address, size_t size, void* buffer) override; private: bool SendFilePath(const char* path, size_t length); - std::unique_ptr memory_; + std::unique_ptr memory_; int sock_; pid_t pid_; bool is_64_bit_; diff --git a/util/linux/ptrace_connection.h b/util/linux/ptrace_connection.h index 9b31d52a45..15594f81fe 100644 --- a/util/linux/ptrace_connection.h +++ b/util/linux/ptrace_connection.h @@ -22,7 +22,7 @@ #include "base/files/file_path.h" #include "util/linux/thread_info.h" -#include "util/process/process_memory.h" +#include "util/process/process_memory_linux.h" namespace crashpad { @@ -64,7 +64,7 @@ class PtraceConnection { //! //! The caller does not take ownership of the reader. The reader is valid for //! the lifetime of the PtraceConnection that created it. - virtual ProcessMemory* Memory() = 0; + virtual ProcessMemoryLinux* Memory() = 0; //! \brief Determines the thread IDs of the threads in the connected process. //! diff --git a/util/process/process_memory_linux.cc b/util/process/process_memory_linux.cc index 56ac0ec836..b67b9c09d6 100644 --- a/util/process/process_memory_linux.cc +++ b/util/process/process_memory_linux.cc @@ -24,11 +24,20 @@ #include "base/logging.h" #include "base/posix/eintr_wrapper.h" +#include "build/build_config.h" +#include "util/file/filesystem.h" +#include "util/linux/ptrace_connection.h" namespace crashpad { ProcessMemoryLinux::ProcessMemoryLinux(PtraceConnection* connection) - : ProcessMemory(), mem_fd_() { + : ProcessMemory(), mem_fd_(), ignore_top_byte_(false) { +#if defined(ARCH_CPU_ARM_FAMILY) + if (connection->Is64Bit()) { + ignore_top_byte_ = true; + } +#endif // ARCH_CPU_ARM_FAMILY + char path[32]; snprintf(path, sizeof(path), "/proc/%d/mem", connection->GetProcessID()); mem_fd_.reset(HANDLE_EINTR(open(path, O_RDONLY | O_NOCTTY | O_CLOEXEC))); @@ -53,11 +62,15 @@ ProcessMemoryLinux::ProcessMemoryLinux(PtraceConnection* connection) ProcessMemoryLinux::~ProcessMemoryLinux() {} +VMAddress ProcessMemoryLinux::PointerToAddress(VMAddress address) const { + return ignore_top_byte_ ? address & 0x00ffffffffffffff : address; +} + ssize_t ProcessMemoryLinux::ReadUpTo(VMAddress address, size_t size, void* buffer) const { DCHECK_LE(size, size_t{std::numeric_limits::max()}); - return read_up_to_(address, size, buffer); + return read_up_to_(PointerToAddress(address), size, buffer); } } // namespace crashpad diff --git a/util/process/process_memory_linux.h b/util/process/process_memory_linux.h index 496cf2d545..f62f2b4f5b 100644 --- a/util/process/process_memory_linux.h +++ b/util/process/process_memory_linux.h @@ -21,12 +21,13 @@ #include #include "base/files/scoped_file.h" -#include "util/linux/ptrace_connection.h" #include "util/misc/address_types.h" #include "util/process/process_memory.h" namespace crashpad { +class PtraceConnection; + //! \brief Accesses the memory of another Linux process. class ProcessMemoryLinux final : public ProcessMemory { public: @@ -37,11 +38,16 @@ class ProcessMemoryLinux final : public ProcessMemory { ~ProcessMemoryLinux(); + //! \brief Returns the input pointer with any non-addressing bits, such as + //! tags removed. + VMAddress PointerToAddress(VMAddress address) const; + private: ssize_t ReadUpTo(VMAddress address, size_t size, void* buffer) const override; std::function read_up_to_; base::ScopedFD mem_fd_; + bool ignore_top_byte_; }; } // namespace crashpad From 07a6b707559004bac4b7d3ccb166f3aa87fec43b Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Wed, 13 Oct 2021 15:22:00 -0700 Subject: [PATCH 13/69] Disable cause-SIGFPE test on Arm processors The way that division operations behave have changed between Armv7 and Armv8. On the later one, divisions by zero will *not* yield an exception of any kind (for both a 32bit and 64bit app), for hardware integer divide operation. On Arm processors exceptions may also be a factor of: - if the hardware implementation supports it. - if the kernel has set the proper internal state registers/flags. - C library implementations (e.g. libgcc x clang_rt). Aside that, a division by zero is within the realm of UD (Undefined Behavior) in C/C++. Since there are two categories of tests (explicit raise x caused by instructions), it just makes sense to disable the second for Arm since there is no reliable way to cause a SIGFPE without an explicit raise() POSIX call. For x86, we keep the previous implementation idea but streamlined the code by deploying 'volatile' to ensure that the compiler won't optimize away the result of the division (i.e no need to call stat() and fstat()). Bug: chromium:919548, chromium:1184398 Change-Id: Ib0fd4bdf503dcd50149dccae0577c777488c0238 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3213431 Commit-Queue: Adenilson Cavalcanti Commit-Queue: Mark Mentovai Reviewed-by: Mark Mentovai --- util/posix/signals_test.cc | 40 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index d26c291955..09f49adfe9 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -46,9 +45,16 @@ bool CanCauseSignal(int sig) { return sig == SIGABRT || sig == SIGALRM || sig == SIGBUS || -#if !defined(ARCH_CPU_ARM64) +/* According to DDI0487D (Armv8 Architecture Reference Manual) the expected + * behavior for division by zero (Section 3.4.8) is: "... results in a + * zero being written to the destination register, without any + * indication that the division by zero occurred.". + * This applies to Armv8 (and not earlier) for both 32bit and 64bit app code. + */ +#if defined(ARCH_CPU_X86_FAMILY) sig == SIGFPE || -#endif // !defined(ARCH_CPU_ARM64) +#endif + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) sig == SIGILL || #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) @@ -115,27 +121,19 @@ void CauseSignal(int sig) { _exit(kUnexpectedExitStatus); } -#if !defined(ARCH_CPU_ARM64) - // ARM64 has hardware integer division instructions that don’t generate a - // trap for divide-by-zero, so this doesn’t produce SIGFPE. case SIGFPE: { - // Optimization makes this tricky, so get zero from a system call likely - // to succeed, and try to do something with the result. - struct stat stat_buf; - int zero = stat("/", &stat_buf); - if (zero == -1) { - // It’s important to check |== -1| and not |!= 0|. An optimizer is free - // to discard an |== 0| branch entirely, because division by zero is - // undefined behavior. - PLOG(ERROR) << "stat"; - _exit(kUnexpectedExitStatus); - } - - int quotient = 2 / zero; - fstat(quotient, &stat_buf); +/* Enabled only for x86, since a division by zero won't raise a signal + * on Armv8, please see comment at the top of file concerning the + * Arm architecture. + */ +#if defined(ARCH_CPU_X86_FAMILY) + volatile int a = 42; + volatile int b = 0; + a /= b; + ALLOW_UNUSED_LOCAL(a); +#endif break; } -#endif // ARCH_CPU_ARM64 #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) case SIGILL: { From 204abe16d225fc85779623063a8c4c85b707d577 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 14 Oct 2021 10:55:03 -0400 Subject: [PATCH 14/69] ios: Add iOS in-process handler for managing minidump generation. Manage the intermediate minidump generation, and own the crash report upload thread and database. Change-Id: I272d790a827cd13f6872e56f4675f366d13719c5 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3087721 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/BUILD.gn | 3 +- client/crashpad_client.h | 5 +- client/crashpad_client_ios.cc | 175 +++++++--- client/crashpad_client_ios_test.mm | 59 +++- client/ios_handler/in_process_handler.cc | 298 ++++++++++++++++++ client/ios_handler/in_process_handler.h | 199 ++++++++++++ handler/crash_report_upload_thread.cc | 3 +- ...xception_snapshot_ios_intermediate_dump.cc | 3 +- util/BUILD.gn | 5 +- util/mach/mach_extensions.h | 3 + 10 files changed, 689 insertions(+), 64 deletions(-) create mode 100644 client/ios_handler/in_process_handler.cc create mode 100644 client/ios_handler/in_process_handler.h diff --git a/client/BUILD.gn b/client/BUILD.gn index 5c18c6b0d7..ad2d71c7bd 100644 --- a/client/BUILD.gn +++ b/client/BUILD.gn @@ -35,6 +35,8 @@ crashpad_static_library("client") { "crashpad_client_ios.cc", "ios_handler/exception_processor.h", "ios_handler/exception_processor.mm", + "ios_handler/in_process_handler.cc", + "ios_handler/in_process_handler.h", "ios_handler/in_process_intermediate_dump_handler.cc", "ios_handler/in_process_intermediate_dump_handler.h", "simulate_crash_ios.h", @@ -84,7 +86,6 @@ crashpad_static_library("client") { cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union } - # TODO(justincohen): Temporary dependency to bring up the iOS client. if (crashpad_is_ios) { deps += [ "../handler:common", diff --git a/client/crashpad_client.h b/client/crashpad_client.h index c8016d25f4..468c83617a 100644 --- a/client/crashpad_client.h +++ b/client/crashpad_client.h @@ -465,7 +465,8 @@ class CrashpadClient { //! \param[in] database The path to a Crashpad database. //! \param[in] url The URL of an upload server. //! \param[in] annotations Process annotations to set in each crash report. - static void StartCrashpadInProcessHandler( + //! \return `true` on success, `false` on failure with a message logged. + static bool StartCrashpadInProcessHandler( const base::FilePath& database, const std::string& url, const std::map& annotations); @@ -503,7 +504,7 @@ class CrashpadClient { const std::map& annotations = {}); //! \brief Requests that the handler begin in-process uploading of any - //! pending reports. + //! pending reports. //! //! Once called the handler will start looking for pending reports to upload //! on another thread. This method does not block. diff --git a/client/crashpad_client_ios.cc b/client/crashpad_client_ios.cc index b32678d6e3..9a911dfdbf 100644 --- a/client/crashpad_client_ios.cc +++ b/client/crashpad_client_ios.cc @@ -23,6 +23,7 @@ #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" #include "client/ios_handler/exception_processor.h" +#include "client/ios_handler/in_process_handler.h" #include "util/ios/ios_system_data_collector.h" #include "util/mach/exc_server_variants.h" #include "util/mach/exception_ports.h" @@ -33,6 +34,19 @@ #include "util/posix/signals.h" #include "util/thread/thread.h" +namespace { + +bool IsBeingDebugged() { + kinfo_proc kern_proc_info; + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; + size_t len = sizeof(kern_proc_info); + if (sysctl(mib, base::size(mib), &kern_proc_info, &len, nullptr, 0) == 0) + return kern_proc_info.kp_proc.p_flag & P_TRACED; + return false; +} + +} // namespace + namespace crashpad { namespace { @@ -50,23 +64,33 @@ class CrashHandler : public Thread, return instance; } - void Initialize() { + bool Initialize(const base::FilePath& database, + const std::string& url, + const std::map& annotations) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - InstallMachExceptionHandler(); - CHECK(Signals::InstallHandler(SIGABRT, CatchSignal, 0, &old_action_)); + if (!in_process_handler_.Initialize(database, url, annotations) || + !InstallMachExceptionHandler() || + !Signals::InstallHandler(SIGABRT, CatchSignal, 0, &old_action_)) { + LOG(ERROR) << "Unable to initialize Crashpad."; + return false; + } INITIALIZATION_STATE_SET_VALID(initialized_); + return true; } void ProcessIntermediateDumps( - const std::map& annotations = {}) {} + const std::map& annotations) { + in_process_handler_.ProcessIntermediateDumps(annotations); + } void ProcessIntermediateDump( const base::FilePath& file, - const std::map& annotations = {}) {} + const std::map& annotations) { + in_process_handler_.ProcessIntermediateDump(file, annotations); + } - void DumpWithoutCrash(NativeCPUContext* context) { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - mach_exception_data_type_t code[2] = {}; + void DumpWithContext(NativeCPUContext* context) { + const mach_exception_data_type_t code[2] = {}; static constexpr int kSimulatedException = -1; HandleMachException(MACH_EXCEPTION_CODES, mach_thread_self(), @@ -78,33 +102,68 @@ class CrashHandler : public Thread, MACHINE_THREAD_STATE_COUNT); } + void DumpWithoutCrash(NativeCPUContext* context, bool process_dump) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + internal::InProcessHandler::ScopedAlternateWriter scoper( + &in_process_handler_); + if (scoper.Open()) { + DumpWithContext(context); + if (process_dump) { + in_process_handler_.ProcessIntermediateDump(scoper.path()); + } + } + } + + void DumpWithoutCrashAtPath(NativeCPUContext* context, + const base::FilePath& path) { + internal::InProcessHandler::ScopedAlternateWriter scoper( + &in_process_handler_); + if (scoper.OpenAtPath(path)) + DumpWithContext(context); + } + + void StartProcessingPendingReports() { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + in_process_handler_.StartProcessingPendingReports(); + } + private: CrashHandler() = default; - void InstallMachExceptionHandler() { + bool InstallMachExceptionHandler() { exception_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); - CHECK(exception_port_.is_valid()); + if (!exception_port_.is_valid()) { + return false; + } kern_return_t kr = mach_port_insert_right(mach_task_self(), exception_port_.get(), exception_port_.get(), MACH_MSG_TYPE_MAKE_SEND); - MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_insert_right"; + if (kr != KERN_SUCCESS) { + MACH_LOG(ERROR, kr) << "mach_port_insert_right"; + return false; + } // TODO: Use SwapExceptionPort instead and put back EXC_MASK_BREAKPOINT. - const exception_mask_t mask = + // Until then, remove |EXC_MASK_BREAKPOINT| while attached to a debugger. + exception_mask_t mask = ExcMaskAll() & - ~(EXC_MASK_EMULATION | EXC_MASK_SOFTWARE | EXC_MASK_BREAKPOINT | - EXC_MASK_RPC_ALERT | EXC_MASK_GUARD); + ~(EXC_MASK_EMULATION | EXC_MASK_SOFTWARE | EXC_MASK_RPC_ALERT | + EXC_MASK_GUARD | (IsBeingDebugged() ? EXC_MASK_BREAKPOINT : 0)); + ExceptionPorts exception_ports(ExceptionPorts::kTargetTypeTask, TASK_NULL); - exception_ports.GetExceptionPorts(mask, &original_handlers_); - exception_ports.SetExceptionPort( - mask, - exception_port_.get(), - EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, - MACHINE_THREAD_STATE); + if (!exception_ports.GetExceptionPorts(mask, &original_handlers_) || + !exception_ports.SetExceptionPort( + mask, + exception_port_.get(), + EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, + MACHINE_THREAD_STATE)) { + return false; + } Start(); + return true; } // Thread: @@ -175,28 +234,21 @@ class CrashHandler : public Thread, thread_state_flavor_t flavor, ConstThreadState old_state, mach_msg_type_number_t old_state_count) { - // TODO(justincohen): This is incomplete. - } - - // The signal handler installed at OS-level. - static void CatchSignal(int signo, siginfo_t* siginfo, void* context) { - Get()->HandleAndReraiseSignal( - signo, siginfo, reinterpret_cast(context)); - } - - void HandleAndReraiseSignal(int signo, - siginfo_t* siginfo, - ucontext_t* context) { - // TODO(justincohen): This is incomplete. - - // Always call system handler. - Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, &old_action_); + in_process_handler_.DumpExceptionFromMachException(system_data_, + behavior, + thread, + exception, + code, + code_count, + flavor, + old_state, + old_state_count); } void HandleUncaughtNSException(const uint64_t* frames, const size_t num_frames) override { - // TODO(justincohen): Call into in_process_handler. - + in_process_handler_.DumpExceptionFromNSExceptionFrames( + system_data_, frames, num_frames); // After uncaught exceptions are reported, the system immediately triggers a // call to std::terminate()/abort(). Remove the abort handler so a second // dump isn't generated. @@ -205,7 +257,17 @@ class CrashHandler : public Thread, void HandleUncaughtNSExceptionWithContext( NativeCPUContext* context) override { - // TODO(justincohen): Call into in_process_handler. + const mach_exception_data_type_t code[2] = {0, 0}; + in_process_handler_.DumpExceptionFromMachException( + system_data_, + MACH_EXCEPTION_CODES, + mach_thread_self(), + kMachExceptionFromNSException, + code, + base::size(code), + MACHINE_THREAD_STATE, + reinterpret_cast(context), + MACHINE_THREAD_STATE_COUNT); // After uncaught exceptions are reported, the system immediately triggers a // call to std::terminate()/abort(). Remove the abort handler so a second @@ -213,9 +275,25 @@ class CrashHandler : public Thread, CHECK(Signals::InstallDefaultHandler(SIGABRT)); } + // The signal handler installed at OS-level. + static void CatchSignal(int signo, siginfo_t* siginfo, void* context) { + Get()->HandleAndReraiseSignal( + signo, siginfo, reinterpret_cast(context)); + } + + void HandleAndReraiseSignal(int signo, + siginfo_t* siginfo, + ucontext_t* context) { + in_process_handler_.DumpExceptionFromSignal(system_data_, siginfo, context); + + // Always call system handler. + Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, &old_action_); + } + base::mac::ScopedMachReceiveRight exception_port_; ExceptionPorts::ExceptionHandlerVector original_handlers_; struct sigaction old_action_ = {}; + internal::InProcessHandler in_process_handler_; internal::IOSSystemDataCollector system_data_; InitializationStateDcheck initialized_; }; @@ -227,15 +305,14 @@ CrashpadClient::CrashpadClient() {} CrashpadClient::~CrashpadClient() {} // static -void CrashpadClient::StartCrashpadInProcessHandler( +bool CrashpadClient::StartCrashpadInProcessHandler( const base::FilePath& database, const std::string& url, const std::map& annotations) { - CrashHandler* crash_handler = CrashHandler::Get(); DCHECK(crash_handler); InstallObjcExceptionPreprocessor(crash_handler); - crash_handler->Initialize(); + return crash_handler->Initialize(database, url, annotations); } // static @@ -257,17 +334,16 @@ void CrashpadClient::ProcessIntermediateDump( // static void CrashpadClient::StartProcessingPendingReports() { - // TODO(justincohen): Start the CrashReportUploadThread. + CrashHandler* crash_handler = CrashHandler::Get(); + DCHECK(crash_handler); + crash_handler->StartProcessingPendingReports(); } // static void CrashpadClient::DumpWithoutCrash(NativeCPUContext* context) { CrashHandler* crash_handler = CrashHandler::Get(); DCHECK(crash_handler); - crash_handler->DumpWithoutCrash(context); - // TODO(justincohen): Change this to only process the dump from above, not all - // intermediate dump files. - crash_handler->ProcessIntermediateDumps(); + crash_handler->DumpWithoutCrash(context, /*process_dump=*/true); } // static @@ -275,7 +351,7 @@ void CrashpadClient::DumpWithoutCrashAndDeferProcessing( NativeCPUContext* context) { CrashHandler* crash_handler = CrashHandler::Get(); DCHECK(crash_handler); - crash_handler->DumpWithoutCrash(context); + crash_handler->DumpWithoutCrash(context, /*process_dump=*/false); } // static @@ -284,8 +360,7 @@ void CrashpadClient::DumpWithoutCrashAndDeferProcessingAtPath( const base::FilePath path) { CrashHandler* crash_handler = CrashHandler::Get(); DCHECK(crash_handler); - // TODO(justincohen): Change to DumpWithoutCrashAtPath(context, path). - crash_handler->DumpWithoutCrash(context); + crash_handler->DumpWithoutCrashAtPath(context, path); } } // namespace crashpad diff --git a/client/crashpad_client_ios_test.mm b/client/crashpad_client_ios_test.mm index 30fabae014..3c350e9fd5 100644 --- a/client/crashpad_client_ios_test.mm +++ b/client/crashpad_client_ios_test.mm @@ -18,6 +18,9 @@ #include +#include "base/strings/sys_string_conversions.h" +#include "client/crash_report_database.h" +#include "client/ios_handler/exception_processor.h" #include "client/simulate_crash.h" #include "gtest/gtest.h" #include "test/scoped_temp_dir.h" @@ -32,9 +35,53 @@ TEST_F(CrashpadIOSClient, DumpWithoutCrash) { CrashpadClient client; ScopedTempDir database_dir; - client.StartCrashpadInProcessHandler( - base::FilePath(database_dir.path()), "", {}); + ASSERT_TRUE(client.StartCrashpadInProcessHandler( + base::FilePath(database_dir.path()), "", {})); + std::unique_ptr database = + CrashReportDatabase::Initialize(database_dir.path()); + std::vector reports; + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 0u); CRASHPAD_SIMULATE_CRASH(); + reports.clear(); + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 1u); + + CRASHPAD_SIMULATE_CRASH_AND_DEFER_PROCESSING(); + reports.clear(); + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 1u); + client.ProcessIntermediateDumps(); + reports.clear(); + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 2u); + + ScopedTempDir crash_dir; + UUID uuid; + uuid.InitializeWithNew(); + CRASHPAD_SIMULATE_CRASH_AND_DEFER_PROCESSING_AT_PATH( + crash_dir.path().Append(uuid.ToString())); + reports.clear(); + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 2u); + + NSError* error = nil; + NSArray* paths = [[NSFileManager defaultManager] + contentsOfDirectoryAtPath:base::SysUTF8ToNSString( + crash_dir.path().value()) + error:&error]; + ASSERT_EQ([paths count], 1u); + client.ProcessIntermediateDump( + crash_dir.path().Append([paths[0] fileSystemRepresentation])); + reports.clear(); + EXPECT_EQ(database->GetPendingReports(&reports), + CrashReportDatabase::kNoError); + ASSERT_EQ(reports.size(), 3u); } // This test is covered by a similar XCUITest, but for development purposes it's @@ -44,8 +91,8 @@ TEST_F(CrashpadIOSClient, DISABLED_ThrowNSException) { CrashpadClient client; ScopedTempDir database_dir; - client.StartCrashpadInProcessHandler( - base::FilePath(database_dir.path()), "", {}); + ASSERT_TRUE(client.StartCrashpadInProcessHandler( + base::FilePath(database_dir.path()), "", {})); [NSException raise:@"GoogleTestNSException" format:@"ThrowException"]; } @@ -56,8 +103,8 @@ TEST_F(CrashpadIOSClient, DISABLED_ThrowException) { CrashpadClient client; ScopedTempDir database_dir; - client.StartCrashpadInProcessHandler( - base::FilePath(database_dir.path()), "", {}); + ASSERT_TRUE(client.StartCrashpadInProcessHandler( + base::FilePath(database_dir.path()), "", {})); std::vector empty_vector; empty_vector.at(42); } diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc new file mode 100644 index 0000000000..85fd422ece --- /dev/null +++ b/client/ios_handler/in_process_handler.cc @@ -0,0 +1,298 @@ +// Copyright 2021 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. + +#include "client/ios_handler/in_process_handler.h" + +#include +#include + +#include "base/logging.h" +#include "client/ios_handler/in_process_intermediate_dump_handler.h" +#include "client/settings.h" +#include "minidump/minidump_file_writer.h" +#include "util/file/directory_reader.h" +#include "util/file/filesystem.h" + +namespace { + +// Creates directory at |path|. +void CreateDirectory(const base::FilePath& path) { + if (mkdir(path.value().c_str(), 0755) == 0) { + return; + } + if (errno != EEXIST) { + PLOG(ERROR) << "mkdir " << path.value(); + } +} + +} // namespace + +namespace crashpad { +namespace internal { + +InProcessHandler::InProcessHandler() = default; + +InProcessHandler::~InProcessHandler() { + upload_thread_->Stop(); +} + +bool InProcessHandler::Initialize( + const base::FilePath& database, + const std::string& url, + const std::map& annotations) { + INITIALIZATION_STATE_SET_INITIALIZING(initialized_); + annotations_ = annotations; + database_ = CrashReportDatabase::Initialize(database); + + if (!url.empty()) { + // TODO(scottmg): options.rate_limit should be removed when we have a + // configurable database setting to control upload limiting. + // See https://crashpad.chromium.org/bug/23. + CrashReportUploadThread::Options upload_thread_options; + upload_thread_options.rate_limit = false; + upload_thread_options.upload_gzip = true; + upload_thread_options.watch_pending_reports = true; + upload_thread_options.identify_client_via_url = true; + + upload_thread_.reset(new CrashReportUploadThread( + database_.get(), url, upload_thread_options)); + } + + CreateDirectory(database); + static constexpr char kPendingSerializediOSDump[] = + "pending-serialized-ios-dump"; + base_dir_ = database.Append(kPendingSerializediOSDump); + CreateDirectory(base_dir_); + + if (!OpenNewFile()) + return false; + + INITIALIZATION_STATE_SET_VALID(initialized_); + return true; +} + +void InProcessHandler::DumpExceptionFromSignal( + const IOSSystemDataCollector& system_data, + siginfo_t* siginfo, + ucontext_t* context) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + { + ScopedReport report(writer_.get(), system_data); + InProcessIntermediateDumpHandler::WriteExceptionFromSignal( + writer_.get(), system_data, siginfo, context); + } + PostReportCleanup(); +} + +void InProcessHandler::DumpExceptionFromMachException( + const IOSSystemDataCollector& system_data, + exception_behavior_t behavior, + thread_t thread, + exception_type_t exception, + const mach_exception_data_type_t* code, + mach_msg_type_number_t code_count, + thread_state_flavor_t flavor, + ConstThreadState old_state, + mach_msg_type_number_t old_state_count) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + { + ScopedReport report(writer_.get(), system_data); + InProcessIntermediateDumpHandler::WriteExceptionFromMachException( + writer_.get(), + behavior, + thread, + exception, + code, + code_count, + flavor, + old_state, + old_state_count); + } + PostReportCleanup(); +} + +void InProcessHandler::DumpExceptionFromNSExceptionFrames( + const IOSSystemDataCollector& system_data, + const uint64_t* frames, + const size_t num_frames) { + { + ScopedReport report(writer_.get(), system_data, frames, num_frames); + InProcessIntermediateDumpHandler::WriteExceptionFromNSException( + writer_.get()); + } + PostReportCleanup(); +} + +void InProcessHandler::ProcessIntermediateDumps( + const std::map& extra_annotations) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + + std::map annotations(annotations_); + annotations.insert(extra_annotations.begin(), extra_annotations.end()); + + for (auto& file : PendingFiles()) + ProcessIntermediateDumpWithCompleteAnnotations(file, annotations); +} + +void InProcessHandler::ProcessIntermediateDump( + const base::FilePath& file, + const std::map& extra_annotations) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + + std::map annotations(annotations_); + annotations.insert(extra_annotations.begin(), extra_annotations.end()); + ProcessIntermediateDumpWithCompleteAnnotations(file, annotations); +} + +void InProcessHandler::StartProcessingPendingReports() { + if (!upload_thread_started_ && upload_thread_) { + upload_thread_->Start(); + upload_thread_started_ = true; + } +} + +void InProcessHandler::ProcessIntermediateDumpWithCompleteAnnotations( + const base::FilePath& file, + const std::map& annotations) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + + ProcessSnapshotIOSIntermediateDump process_snapshot; + if (process_snapshot.Initialize(file, annotations)) { + SaveSnapshot(process_snapshot); + } +} + +void InProcessHandler::SaveSnapshot( + ProcessSnapshotIOSIntermediateDump& process_snapshot) { + std::unique_ptr new_report; + CrashReportDatabase::OperationStatus database_status = + database_->PrepareNewCrashReport(&new_report); + if (database_status != CrashReportDatabase::kNoError) { + Metrics::ExceptionCaptureResult( + Metrics::CaptureResult::kPrepareNewCrashReportFailed); + } + process_snapshot.SetReportID(new_report->ReportID()); + + MinidumpFileWriter minidump; + minidump.InitializeFromSnapshot(&process_snapshot); + if (!minidump.WriteEverything(new_report->Writer())) { + Metrics::ExceptionCaptureResult( + Metrics::CaptureResult::kMinidumpWriteFailed); + } + UUID uuid; + database_status = + database_->FinishedWritingCrashReport(std::move(new_report), &uuid); + if (database_status != CrashReportDatabase::kNoError) { + Metrics::ExceptionCaptureResult( + Metrics::CaptureResult::kFinishedWritingCrashReportFailed); + } + + if (upload_thread_) { + upload_thread_->ReportPending(uuid); + } +} + +std::vector InProcessHandler::PendingFiles() { + DirectoryReader reader; + std::vector files; + if (!reader.Open(base_dir_)) { + return files; + } + base::FilePath file; + DirectoryReader::Result result; + while ((result = reader.NextFile(&file)) == + DirectoryReader::Result::kSuccess) { + file = base_dir_.Append(file); + if (file != current_file_) { + ScopedFileHandle fd(LoggingOpenFileForRead(file)); + if (LoggingLockFile(fd.get(), + FileLocking::kExclusive, + FileLockingBlocking::kNonBlocking) == + FileLockingResult::kSuccess) { + files.push_back(file); + } + } + } + return files; +} + +InProcessHandler::ScopedAlternateWriter::ScopedAlternateWriter( + InProcessHandler* handler) + : handler_(handler) {} + +bool InProcessHandler::ScopedAlternateWriter::Open() { + UUID uuid; + uuid.InitializeWithNew(); + const std::string uuid_string = uuid.ToString(); + return OpenAtPath(handler_->base_dir_.Append(uuid_string)); +} + +bool InProcessHandler::ScopedAlternateWriter::OpenAtPath( + const base::FilePath& path) { + path_ = path; + handler_->SetOpenNewFileAfterReport(false); + original_writer_ = handler_->GetWriter(); + auto writer = std::make_unique(); + if (!writer->Open(path_)) { + DLOG(ERROR) << "Unable to open alternate intermediate dump file: " + << path_.value(); + return false; + } + handler_->SetWriter(std::move(writer)); + return true; +} + +InProcessHandler::ScopedAlternateWriter::~ScopedAlternateWriter() { + handler_->SetWriter(std::move(original_writer_)); + handler_->SetOpenNewFileAfterReport(true); +} + +InProcessHandler::ScopedReport::ScopedReport( + IOSIntermediateDumpWriter* writer, + const IOSSystemDataCollector& system_data, + const uint64_t* frames, + const size_t num_frames) + : rootMap_(writer) { + InProcessIntermediateDumpHandler::WriteHeader(writer); + InProcessIntermediateDumpHandler::WriteProcessInfo(writer); + InProcessIntermediateDumpHandler::WriteSystemInfo(writer, system_data); + InProcessIntermediateDumpHandler::WriteThreadInfo(writer, frames, num_frames); + InProcessIntermediateDumpHandler::WriteModuleInfo(writer); +} + +bool InProcessHandler::OpenNewFile() { + UUID uuid; + uuid.InitializeWithNew(); + const std::string uuid_string = uuid.ToString(); + current_file_ = base_dir_.Append(uuid_string); + writer_ = std::make_unique(); + if (!writer_->Open(current_file_)) { + DLOG(ERROR) << "Unable to open intermediate dump file: " + << current_file_.value(); + return false; + } + return true; +} + +void InProcessHandler::PostReportCleanup() { + if (writer_) { + writer_->Close(); + writer_.reset(); + } + if (open_new_file_after_report_) + OpenNewFile(); +} + +} // namespace internal +} // namespace crashpad diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h new file mode 100644 index 0000000000..877ae19cbd --- /dev/null +++ b/client/ios_handler/in_process_handler.h @@ -0,0 +1,199 @@ +// Copyright 2021 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. + +#include + +#include +#include +#include + +#include "base/files/file_path.h" +#include "handler/mac/crash_report_exception_handler.h" +#include "snapshot/ios/process_snapshot_ios_intermediate_dump.h" +#include "util/ios/ios_intermediate_dump_writer.h" +#include "util/ios/ios_system_data_collector.h" +#include "util/misc/initialization_state_dcheck.h" + +namespace crashpad { +namespace internal { + +//! \brief Manage intermediate minidump generation, and own the crash report +//! upload thread and database. +class InProcessHandler { + public: + InProcessHandler(); + ~InProcessHandler(); + InProcessHandler(const InProcessHandler&) = delete; + InProcessHandler& operator=(const InProcessHandler&) = delete; + + //! \brief Initializes the in-process handler. + //! + //! This method must be called only once, and must be successfully called + //! before any other method in this class may be called. + //! + //! \param[in] database The path to a Crashpad database. + //! \param[in] url The URL of an upload server. + //! \param[in] annotations Process annotations to set in each crash report. + //! \return `true` if a handler to a pending intermediate dump could be + //! opened. + bool Initialize(const base::FilePath& database, + const std::string& url, + const std::map& annotations); + + //! \brief Generate an intermediate dump from a signal handler exception. + //! + //! \param[in] system_data An object containing various system data points. + //! \param[in] siginfo A pointer to a `siginfo_t` object received by a signal + //! handler. + //! \param[in] context A pointer to a `ucontext_t` object received by a + //! signal. + void DumpExceptionFromSignal(const IOSSystemDataCollector& system_data, + siginfo_t* siginfo, + ucontext_t* context); + + //! \brief Generate an intermediate dump from a mach exception. + //! + //! \param[in] system_data An object containing various system data points. + //! \param[in] behavior + //! \param[in] thread + //! \param[in] exception + //! \param[in] code + //! \param[in] code_count + //! \param[in,out] flavor + //! \param[in] old_state + //! \param[in] old_state_count + void DumpExceptionFromMachException(const IOSSystemDataCollector& system_data, + exception_behavior_t behavior, + thread_t thread, + exception_type_t exception, + const mach_exception_data_type_t* code, + mach_msg_type_number_t code_count, + thread_state_flavor_t flavor, + ConstThreadState old_state, + mach_msg_type_number_t old_state_count); + + //! \brief Generate an intermediate dump from an uncaught NSException. + //! + //! When the ObjcExceptionPreprocessor does not detect an NSException as it is + //! thrown, the last-chance uncaught exception handler passes a list of call + //! stack frame addresses. Record them in the intermediate dump so a minidump + //! with a 'fake' call stack is generated. + //! + //! \param[in] system_data An object containing various system data points. + //! \param[in] frames An array of call stack frame addresses. + //! \param[in] num_frames The number of frames in |frames|. + void DumpExceptionFromNSExceptionFrames( + const IOSSystemDataCollector& system_data, + const uint64_t* frames, + const size_t num_frames); + + //! \brief Requests that the handler convert all intermediate dumps into + //! minidumps and trigger an upload if possible. + //! + //! \param[in] annotations Process annotations to set in each crash report. + void ProcessIntermediateDumps( + const std::map& annotations); + + //! \brief Requests that the handler convert a specific intermediate dump into + //! a minidump and trigger an upload if possible. + //! + //! \param[in] path Path to the specific intermediate dump. + //! \param[in] annotations Process annotations to set in each crash report. + void ProcessIntermediateDump( + const base::FilePath& path, + const std::map& annotations = {}); + + //! \brief Requests that the handler begin in-process uploading of any + //! pending reports. + void StartProcessingPendingReports(); + + //! \brief Helper that swaps out the InProcessHandler's |writer_| with an + //! alternate writer so DumpWithContext does not interfere with the + //! |writer_| created on startup. This is useful for -DumpWithoutCrash, + //! which may write to an alternate location. + class ScopedAlternateWriter { + public: + ScopedAlternateWriter(InProcessHandler* handler); + ~ScopedAlternateWriter(); + ScopedAlternateWriter(const ScopedAlternateWriter&) = delete; + ScopedAlternateWriter& operator=(const ScopedAlternateWriter&) = delete; + //! \brief Open's an alternate dump writer in the same directory as the + //! default InProcessHandler's dump writer, so the file will be + //! processed with -ProcessIntermediateDumps() + bool Open(); + + //! \brief Open's an alternate dump writer in the client provided |path|. + //! The file will only be processed by calling + //! ProcessIntermediateDump(path) + bool OpenAtPath(const base::FilePath& path); + + //! \brief The path of the alternate dump writer. + const base::FilePath& path() { return path_; } + + private: + InProcessHandler* handler_; + std::unique_ptr original_writer_; + base::FilePath path_; + }; + + private: + //! \brief Helper to start and end intermediate reports. + class ScopedReport { + public: + ScopedReport(IOSIntermediateDumpWriter* writer, + const IOSSystemDataCollector& system_data, + const uint64_t* frames = nullptr, + const size_t num_frames = 0); + ~ScopedReport() {} + ScopedReport(const ScopedReport&) = delete; + ScopedReport& operator=(const ScopedReport&) = delete; + + private: + IOSIntermediateDumpWriter::ScopedRootMap rootMap_; + }; + + std::unique_ptr GetWriter() { + return std::move(writer_); + } + + void SetWriter(std::unique_ptr writer) { + writer_ = std::move(writer); + } + + void SetOpenNewFileAfterReport(bool open_new_file_after_report) { + open_new_file_after_report_ = open_new_file_after_report; + } + + void ProcessIntermediateDumpWithCompleteAnnotations( + const base::FilePath& file, + const std::map& annotations); + void SaveSnapshot(ProcessSnapshotIOSIntermediateDump& process_snapshot); + std::vector PendingFiles(); + bool OpenNewFile(); + void PostReportCleanup(); + + bool upload_thread_started_ = false; + bool open_new_file_after_report_ = true; + std::map annotations_; + base::FilePath base_dir_; + base::FilePath current_file_; + std::unique_ptr writer_; + std::unique_ptr alternate_mach_writer_; + std::unique_ptr upload_thread_; + std::unique_ptr database_; + InitializationStateDcheck initialized_; +}; + +} // namespace internal +} // namespace crashpad diff --git a/handler/crash_report_upload_thread.cc b/handler/crash_report_upload_thread.cc index b7e445fd9f..60f172b6c8 100644 --- a/handler/crash_report_upload_thread.cc +++ b/handler/crash_report_upload_thread.cc @@ -68,7 +68,8 @@ CrashReportUploadThread::~CrashReportUploadThread() { void CrashReportUploadThread::ReportPending(const UUID& report_uuid) { known_pending_report_uuids_.PushBack(report_uuid); - thread_.DoWorkNow(); + if (thread_.is_running()) + thread_.DoWorkNow(); } void CrashReportUploadThread::Start() { diff --git a/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc b/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc index cd6045100e..5ad02076c8 100644 --- a/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc @@ -200,8 +200,7 @@ bool ExceptionSnapshotIOSIntermediateDump::InitializeFromNSException( INITIALIZATION_STATE_SET_INITIALIZING(initialized_); DCHECK(exception_data); - exception_ = EXC_SOFTWARE; - exception_info_ = 0xDEADC0DE; /* uncaught NSException */ + exception_ = kMachExceptionFromNSException; if (!GetDataValueFromMap(exception_data, Key::kThreadID, &thread_id_)) { LOG(ERROR) << "Exceptions require a thread id."; diff --git a/util/BUILD.gn b/util/BUILD.gn index affa4e9e6f..3e16b374e8 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -397,6 +397,7 @@ crashpad_static_library("util") { "ios/raw_logging.h", "ios/scoped_vm_read.cc", "ios/scoped_vm_read.h", + "net/http_transport_mac.mm", ] } @@ -659,8 +660,8 @@ if (!crashpad_is_android && !crashpad_is_ios) { deps = [ ":util", - "../third_party/cpp-httplib", "$mini_chromium_source_parent:base", + "../third_party/cpp-httplib", "../third_party/zlib", "../tools:tool_support", ] @@ -867,12 +868,12 @@ source_set("util_test") { deps = [ ":util", + "$mini_chromium_source_parent:base", "../client", "../compat", "../test", "../third_party/googletest:googlemock", "../third_party/googletest:googletest", - "$mini_chromium_source_parent:base", "../third_party/zlib", ] diff --git a/util/mach/mach_extensions.h b/util/mach/mach_extensions.h index 9247ce947c..ebf36d3dac 100644 --- a/util/mach/mach_extensions.h +++ b/util/mach/mach_extensions.h @@ -47,6 +47,9 @@ constexpr exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES; //! \brief An exception type to use for simulated exceptions. constexpr exception_type_t kMachExceptionSimulated = 'CPsx'; +//! \brief An exception type to use for uncaught NSExceptions. +constexpr exception_type_t kMachExceptionFromNSException = 'CPnx'; + //! \brief A const version of `thread_state_t`. //! //! This is useful as the \a old_state parameter to exception handler functions. From 02d50376a7fb51c91139f93a9f1e28bd88f5e43b Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 14 Oct 2021 11:34:57 -0400 Subject: [PATCH 15/69] Correct formatting in util/posix/signals_test.cc Change-Id: I431f663a91bfce62b8d554ee980fa62da8551275 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3223541 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- util/posix/signals_test.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index 09f49adfe9..2bd55801f2 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -42,9 +42,7 @@ constexpr int kUnexpectedExitStatus = 3; // Keep synchronized with CauseSignal(). bool CanCauseSignal(int sig) { - return sig == SIGABRT || - sig == SIGALRM || - sig == SIGBUS || + return sig == SIGABRT || sig == SIGALRM || sig == SIGBUS || /* According to DDI0487D (Armv8 Architecture Reference Manual) the expected * behavior for division by zero (Section 3.4.8) is: "... results in a * zero being written to the destination register, without any @@ -58,8 +56,7 @@ bool CanCauseSignal(int sig) { #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) sig == SIGILL || #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - sig == SIGPIPE || - sig == SIGSEGV || + sig == SIGPIPE || sig == SIGSEGV || #if defined(OS_APPLE) sig == SIGSYS || #endif // OS_APPLE From 1ba15daa73ea82e012988261c7e5743e0b5a8821 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 14 Oct 2021 14:10:22 -0400 Subject: [PATCH 16/69] ios: Fix incorrect header include. Change-Id: I0c24eae67684f95297478420e60e362836ef8874 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3224139 Reviewed-by: Rohit Rao Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- client/ios_handler/in_process_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index 877ae19cbd..d825c29c50 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -19,7 +19,7 @@ #include #include "base/files/file_path.h" -#include "handler/mac/crash_report_exception_handler.h" +#include "handler/crash_report_upload_thread.h" #include "snapshot/ios/process_snapshot_ios_intermediate_dump.h" #include "util/ios/ios_intermediate_dump_writer.h" #include "util/ios/ios_system_data_collector.h" From ec7a457e86de8df2fade06d022e207908ec5b45a Mon Sep 17 00:00:00 2001 From: Amanda Tait Date: Thu, 30 Sep 2021 18:01:25 -0400 Subject: [PATCH 17/69] [fuchsia] Inject components from test pkg Make the `crashpad-test` package hermetic and describe a correct build graph by explicitly expressing dependency edges to components. Inject component dependencies from the hermetic package in integration tests. Bug: fuchsia:84248 Change-Id: I20915acf6171b532b2c94941f33dc8eb90fb6776 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3197800 Reviewed-by: Mark Mentovai Commit-Queue: Mark Mentovai --- BUILD.gn | 5 +++++ test/fuchsia_crashpad_tests.cmx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 666784af6a..c0f8bcbc0d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -80,6 +80,11 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { fuchsia_test_package("crashpad-test") { test_components = [ ":crashpad-test-component" ] + deps = [ + "//src/connectivity/network/dns:component-legacy", + "//src/connectivity/network/netstack:component-legacy", + ] + test_specs = { log_settings = { max_severity = "FATAL" diff --git a/test/fuchsia_crashpad_tests.cmx b/test/fuchsia_crashpad_tests.cmx index 48faf38397..0a8c137f35 100644 --- a/test/fuchsia_crashpad_tests.cmx +++ b/test/fuchsia_crashpad_tests.cmx @@ -2,8 +2,8 @@ "facets": { "fuchsia.test": { "injected-services": { - "fuchsia.net.name.Lookup": "fuchsia-pkg://fuchsia.com/dns-resolver#meta/dns-resolver.cmx", - "fuchsia.posix.socket.Provider": "fuchsia-pkg://fuchsia.com/netstack#meta/netstack.cmx" + "fuchsia.net.name.Lookup": "fuchsia-pkg://fuchsia.com/crashpad-test#meta/dns-resolver.cmx", + "fuchsia.posix.socket.Provider": "fuchsia-pkg://fuchsia.com/crashpad-test#meta/netstack.cmx" } } }, From c367128a856a7eb161f0db6a5a1dc5c8d9d16cd3 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 19 Oct 2021 13:53:37 -0400 Subject: [PATCH 18/69] ios: Don't use POSIX file locks for iOS intermediate dumps. Instead use a custom mechanism based on the filename. Rather than a filename of , instead name the file |[.locked]. A locked file will have the optional .locked extension. Files can be unlocked after writing an intermediate dump, or during initialization by looking for matching bundle-ids. Clients that call ProcessIntermediateDumps() will clean up any leftover locked intermediate dumps. Clients that never call ProcessIntermediateDumps, such as extensions that leave this up to the main application, will be cleaned up in a followup change. Bug: crashpad:31 Change-Id: Icd4aaa3b79351870fbe9b8463cfbdf7cff7d5f87 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3229429 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai Reviewed-by: Rohit Rao --- client/crashpad_client_ios.cc | 3 +- client/ios_handler/in_process_handler.cc | 47 ++++++++++++++----- client/ios_handler/in_process_handler.h | 5 +- util/ios/ios_intermediate_dump_writer.cc | 11 +---- util/ios/ios_intermediate_dump_writer_test.cc | 12 ----- util/ios/ios_system_data_collector.h | 2 + util/ios/ios_system_data_collector.mm | 2 + 7 files changed, 46 insertions(+), 36 deletions(-) diff --git a/client/crashpad_client_ios.cc b/client/crashpad_client_ios.cc index 9a911dfdbf..8c00d5d0ea 100644 --- a/client/crashpad_client_ios.cc +++ b/client/crashpad_client_ios.cc @@ -68,7 +68,8 @@ class CrashHandler : public Thread, const std::string& url, const std::map& annotations) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - if (!in_process_handler_.Initialize(database, url, annotations) || + if (!in_process_handler_.Initialize( + database, url, annotations, system_data_) || !InstallMachExceptionHandler() || !Signals::InstallHandler(SIGABRT, CatchSignal, 0, &old_action_)) { LOG(ERROR) << "Unable to initialize Crashpad."; diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 85fd422ece..d4c4af434f 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -36,6 +36,13 @@ void CreateDirectory(const base::FilePath& path) { } } +// The file extension used to indicate a file is locked. +constexpr char kLockedExtension[] = ".locked"; + +// The seperator used to break the bundle id (e.g. com.chromium.ios) from the +// uuid in the intermediate dump file name. +constexpr char kBundleSeperator[] = "@"; + } // namespace namespace crashpad { @@ -50,10 +57,13 @@ InProcessHandler::~InProcessHandler() { bool InProcessHandler::Initialize( const base::FilePath& database, const std::string& url, - const std::map& annotations) { + const std::map& annotations, + const IOSSystemDataCollector& system_data) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); annotations_ = annotations; database_ = CrashReportDatabase::Initialize(database); + bundle_identifier_and_seperator_ = + system_data.BundleIdentifier() + kBundleSeperator; if (!url.empty()) { // TODO(scottmg): options.rate_limit should be removed when we have a @@ -213,16 +223,22 @@ std::vector InProcessHandler::PendingFiles() { DirectoryReader::Result result; while ((result = reader.NextFile(&file)) == DirectoryReader::Result::kSuccess) { - file = base_dir_.Append(file); - if (file != current_file_) { - ScopedFileHandle fd(LoggingOpenFileForRead(file)); - if (LoggingLockFile(fd.get(), - FileLocking::kExclusive, - FileLockingBlocking::kNonBlocking) == - FileLockingResult::kSuccess) { - files.push_back(file); - } + // Don't try to process files marked as 'locked' from a different bundle id. + if (file.value().compare(0, + bundle_identifier_and_seperator_.size(), + bundle_identifier_and_seperator_) != 0 && + file.FinalExtension() == kLockedExtension) { + continue; } + + // Never process the current file. + file = base_dir_.Append(file); + if (file == current_file_) + continue; + + // Otherwise, include any other unlocked, or locked files matching + // |bundle_identifier_and_seperator_|. + files.push_back(file); } return files; } @@ -272,10 +288,17 @@ InProcessHandler::ScopedReport::ScopedReport( } bool InProcessHandler::OpenNewFile() { + if (!current_file_.empty()) { + // Remove .lock extension so this dump can be processed on next run by this + // client, or a client with a different bundle id that can access this dump. + base::FilePath new_path = current_file_.RemoveFinalExtension(); + MoveFileOrDirectory(current_file_, new_path); + } UUID uuid; uuid.InitializeWithNew(); - const std::string uuid_string = uuid.ToString(); - current_file_ = base_dir_.Append(uuid_string); + const std::string file_string = + bundle_identifier_and_seperator_ + uuid.ToString() + kLockedExtension; + current_file_ = base_dir_.Append(file_string); writer_ = std::make_unique(); if (!writer_->Open(current_file_)) { DLOG(ERROR) << "Unable to open intermediate dump file: " diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index d825c29c50..a9a3094be1 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -45,11 +45,13 @@ class InProcessHandler { //! \param[in] database The path to a Crashpad database. //! \param[in] url The URL of an upload server. //! \param[in] annotations Process annotations to set in each crash report. + //! \param[in] system_data An object containing various system data points. //! \return `true` if a handler to a pending intermediate dump could be //! opened. bool Initialize(const base::FilePath& database, const std::string& url, - const std::map& annotations); + const std::map& annotations, + const IOSSystemDataCollector& system_data); //! \brief Generate an intermediate dump from a signal handler exception. //! @@ -192,6 +194,7 @@ class InProcessHandler { std::unique_ptr alternate_mach_writer_; std::unique_ptr upload_thread_; std::unique_ptr database_; + std::string bundle_identifier_and_seperator_; InitializationStateDcheck initialized_; }; diff --git a/util/ios/ios_intermediate_dump_writer.cc b/util/ios/ios_intermediate_dump_writer.cc index eca33d380f..cd4d99d252 100644 --- a/util/ios/ios_intermediate_dump_writer.cc +++ b/util/ios/ios_intermediate_dump_writer.cc @@ -50,15 +50,6 @@ bool RawLoggingCloseFile(int fd) { return rv == 0; } -// Similar to LoggingLockFile but with CRASHPAD_RAW_LOG. -bool RawLoggingLockFileExclusiveNonBlocking(int fd) { - int rv = HANDLE_EINTR(flock(fd, LOCK_EX | LOCK_NB)); - if (rv != 0) { - CRASHPAD_RAW_LOG_ERROR(rv, "RawLoggingLockFileExclusiveNonBlocking"); - } - return rv == 0; -} - bool IOSIntermediateDumpWriter::Open(const base::FilePath& path) { // Set data protection class D (No protection). A file with this type of // protection can be read from or written to at any time. @@ -76,7 +67,7 @@ bool IOSIntermediateDumpWriter::Open(const base::FilePath& path) { return false; } - return RawLoggingLockFileExclusiveNonBlocking(fd_); + return true; } bool IOSIntermediateDumpWriter::Close() { diff --git a/util/ios/ios_intermediate_dump_writer_test.cc b/util/ios/ios_intermediate_dump_writer_test.cc index 6c6bcadf10..24f56efd23 100644 --- a/util/ios/ios_intermediate_dump_writer_test.cc +++ b/util/ios/ios_intermediate_dump_writer_test.cc @@ -54,18 +54,6 @@ class IOSIntermediateDumpWriterTest : public testing::Test { base::FilePath path_; }; -// Test file is locked. -TEST_F(IOSIntermediateDumpWriterTest, OpenLocked) { - EXPECT_TRUE(writer_->Open(path())); - - ScopedFileHandle handle(LoggingOpenFileForRead(path())); - EXPECT_TRUE(handle.is_valid()); - EXPECT_EQ(LoggingLockFile(handle.get(), - FileLocking::kExclusive, - FileLockingBlocking::kNonBlocking), - FileLockingResult::kWouldBlock); -} - TEST_F(IOSIntermediateDumpWriterTest, Close) { EXPECT_TRUE(writer_->Open(path())); EXPECT_TRUE(writer_->Close()); diff --git a/util/ios/ios_system_data_collector.h b/util/ios/ios_system_data_collector.h index cac0c8691b..ab25a68a01 100644 --- a/util/ios/ios_system_data_collector.h +++ b/util/ios/ios_system_data_collector.h @@ -32,6 +32,7 @@ class IOSSystemDataCollector { const std::string& MachineDescription() const { return machine_description_; } int ProcessorCount() const { return processor_count_; } const std::string& Build() const { return build_; } + const std::string& BundleIdentifier() const { return bundle_identifier_; } const std::string& CPUVendor() const { return cpu_vendor_; } bool HasDaylightSavingTime() const { return has_next_daylight_saving_time_; } bool IsDaylightSavingTime() const { return is_daylight_saving_time_; } @@ -66,6 +67,7 @@ class IOSSystemDataCollector { int minor_version_; int patch_version_; std::string build_; + std::string bundle_identifier_; std::string machine_description_; int orientation_; int processor_count_; diff --git a/util/ios/ios_system_data_collector.mm b/util/ios/ios_system_data_collector.mm index 4387ac9555..ed81849945 100644 --- a/util/ios/ios_system_data_collector.mm +++ b/util/ios/ios_system_data_collector.mm @@ -77,6 +77,8 @@ processor_count_ = base::saturated_cast([[NSProcessInfo processInfo] processorCount]); build_ = ReadStringSysctlByName("kern.osversion"); + bundle_identifier_ = + base::SysNSStringToUTF8([[NSBundle mainBundle] bundleIdentifier]); #if defined(ARCH_CPU_X86_64) cpu_vendor_ = ReadStringSysctlByName("machdep.cpu.vendor"); From 31d9206f059fe9c5299be52870d9fad595fb543d Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 19 Oct 2021 16:12:52 -0400 Subject: [PATCH 19/69] Correct new mini_chromium locations for external. Followup to crrev.com/c/3062424 to fix Keystone build. Change-Id: I0c6a7bb236a84e2e11f4a9292f8a95bc99a99277 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3231491 Commit-Queue: David Fang Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- build/crashpad_buildconfig.gni | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build/crashpad_buildconfig.gni b/build/crashpad_buildconfig.gni index a9a8a102cb..e6e51e855c 100644 --- a/build/crashpad_buildconfig.gni +++ b/build/crashpad_buildconfig.gni @@ -36,10 +36,7 @@ crashpad_is_standalone = crashpad_dependencies == "standalone" # This is the parent directory that contains the mini_chromium source dir. # This variable is not used when crashpad_is_in_chromium. -if (crashpad_is_external || crashpad_is_in_dart) { - # External and Dart SDK builds assume crashpad and mini_chromium are peers. - mini_chromium_source_parent = "../mini_chromium" -} else if (crashpad_is_in_fuchsia) { +if (crashpad_is_in_fuchsia) { mini_chromium_source_parent = "//third_party/crashpad/third_party/mini_chromium" } else { mini_chromium_source_parent = "../third_party/mini_chromium" @@ -50,7 +47,7 @@ _mini_chromium_source_root = "$mini_chromium_source_parent/mini_chromium" # This references the mini_chromium location for importing GN files. if (crashpad_is_external || crashpad_is_in_dart) { - mini_chromium_import_root = "../../$_mini_chromium_source_root" + mini_chromium_import_root = "../../../$_mini_chromium_source_root" } else if (crashpad_is_in_fuchsia) { mini_chromium_import_root = "//third_party/mini_chromium" } else { @@ -70,6 +67,7 @@ if (crashpad_is_in_chromium) { crashpad_is_clang = is_clang } else { import("$mini_chromium_import_root/build/compiler.gni") + import("$mini_chromium_import_root/build/platform.gni") crashpad_is_mac = mini_chromium_is_mac crashpad_is_ios = mini_chromium_is_ios From 164b41de765ae593a8a3fcfb718f9865438b91ff Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 21 Oct 2021 06:15:40 -0700 Subject: [PATCH 20/69] Fix an instance of -Wshadow. Bug: chromium:794619 Change-Id: I4561b1019d9aeee6c25d1d4083b977d0a05abdfc Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3236044 Reviewed-by: Mark Mentovai Commit-Queue: Peter Kasting --- client/crash_report_database_generic.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/crash_report_database_generic.cc b/client/crash_report_database_generic.cc index a433a905dc..046e82d80c 100644 --- a/client/crash_report_database_generic.cc +++ b/client/crash_report_database_generic.cc @@ -342,23 +342,23 @@ void CrashReportDatabase::UploadReport::InitializeAttachments() { if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { return; } - DirectoryReader reader; - if (!reader.Open(attachments_dir)) { + DirectoryReader directory_reader; + if (!directory_reader.Open(attachments_dir)) { return; } base::FilePath filename; DirectoryReader::Result dir_result; - while ((dir_result = reader.NextFile(&filename)) == + while ((dir_result = directory_reader.NextFile(&filename)) == DirectoryReader::Result::kSuccess) { const base::FilePath filepath(attachments_dir.Append(filename)); - std::unique_ptr reader(std::make_unique()); - if (!reader->Open(filepath)) { + std::unique_ptr file_reader(std::make_unique()); + if (!file_reader->Open(filepath)) { LOG(ERROR) << "attachment " << filepath.value() << " couldn't be opened, skipping"; continue; } - attachment_readers_.emplace_back(std::move(reader)); + attachment_readers_.emplace_back(std::move(file_reader)); attachment_map_[filename.value()] = attachment_readers_.back().get(); } } From 2c45d05875b54df823cdf50930f631c75fed050f Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Mon, 25 Oct 2021 07:23:09 -0700 Subject: [PATCH 21/69] More -Wshadow fixes. Bug: chromium:794619 Change-Id: I1987eb543d0b1a5f82eeb8504b6adde8ef6df600 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3238894 Commit-Queue: Peter Kasting Reviewed-by: Mark Mentovai --- .../in_process_intermediate_dump_handler.cc | 12 +++++------- snapshot/mac/process_reader_mac_test.cc | 3 +-- util/mach/exception_ports_test.cc | 13 ++++++------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/client/ios_handler/in_process_intermediate_dump_handler.cc b/client/ios_handler/in_process_intermediate_dump_handler.cc index 7e04058a0f..e2c77223e7 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler.cc @@ -778,7 +778,7 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( thread_t thread = threads[thread_index]; thread_basic_info basic_info; - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; + count = THREAD_BASIC_INFO_COUNT; kr = thread_info(thread, THREAD_BASIC_INFO, reinterpret_cast(&basic_info), @@ -810,7 +810,6 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( #if defined(ARCH_CPU_ARM64) uint64_t thread_id; #endif - thread_identifier_info identifier_info; count = THREAD_IDENTIFIER_INFO_COUNT; kr = thread_info(thread, THREAD_IDENTIFIER_INFO, @@ -859,11 +858,10 @@ void InProcessIntermediateDumpHandler::WriteThreadInfo( mach_msg_type_number_t debug_state_count = ARM_DEBUG_STATE64_COUNT; #endif - kern_return_t kr = - thread_get_state(thread, - kThreadStateFlavor, - reinterpret_cast(&thread_state), - &thread_state_count); + kr = thread_get_state(thread, + kThreadStateFlavor, + reinterpret_cast(&thread_state), + &thread_state_count); if (kr != KERN_SUCCESS) { CRASHPAD_RAW_LOG_ERROR(kr, "thread_get_state::kThreadStateFlavor"); } diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc index 2f3775847f..6b4e108b99 100644 --- a/snapshot/mac/process_reader_mac_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -504,8 +504,7 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { // Write an entry for everything in the thread pool. for (size_t thread_index = 0; thread_index < thread_count_; ++thread_index) { - uint64_t thread_id = - thread_pool.GetThreadInfo(thread_index, &expectation); + thread_id = thread_pool.GetThreadInfo(thread_index, &expectation); CheckedWriteFile(write_handle, &thread_id, sizeof(thread_id)); CheckedWriteFile(write_handle, diff --git a/util/mach/exception_ports_test.cc b/util/mach/exception_ports_test.cc index b29e125ebb..b818e60abd 100644 --- a/util/mach/exception_ports_test.cc +++ b/util/mach/exception_ports_test.cc @@ -555,13 +555,12 @@ class TestExceptionPorts : public MachMultiprocess, UniversalMachExcServer universal_mach_exc_server(this); constexpr mach_msg_timeout_t kTimeoutMs = 50; - kern_return_t kr = - MachMessageServer::Run(&universal_mach_exc_server, - local_port, - kMachMessageReceiveAuditTrailer, - MachMessageServer::kOneShot, - MachMessageServer::kReceiveLargeError, - kTimeoutMs); + kr = MachMessageServer::Run(&universal_mach_exc_server, + local_port, + kMachMessageReceiveAuditTrailer, + MachMessageServer::kOneShot, + MachMessageServer::kReceiveLargeError, + kTimeoutMs); EXPECT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "MachMessageServer::Run"); From 2d5a30fb171d2b28fee9bfa0a737d2f850588a90 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 25 Oct 2021 11:35:19 -0400 Subject: [PATCH 22/69] ios: Create a PruneIntermediateDumpsAndCrashReportsThread. This will prune the database on a daily basis, in accordance with the specified condition. This will also unlock any leftover intermediate dump files. Bug: crashpad:31 Change-Id: I229f8b8006b44d31062fbf73bb9d316d69ab2dcf Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3231618 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/BUILD.gn | 2 + client/ios_handler/in_process_handler.cc | 9 ++ client/ios_handler/in_process_handler.h | 2 + ...rmediate_dumps_and_crash_reports_thread.cc | 126 ++++++++++++++++++ ...ermediate_dumps_and_crash_reports_thread.h | 102 ++++++++++++++ util/ios/ios_system_data_collector.h | 2 + util/ios/ios_system_data_collector.mm | 1 + 7 files changed, 244 insertions(+) create mode 100644 client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.cc create mode 100644 client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h diff --git a/client/BUILD.gn b/client/BUILD.gn index ad2d71c7bd..b60e904473 100644 --- a/client/BUILD.gn +++ b/client/BUILD.gn @@ -39,6 +39,8 @@ crashpad_static_library("client") { "ios_handler/in_process_handler.h", "ios_handler/in_process_intermediate_dump_handler.cc", "ios_handler/in_process_intermediate_dump_handler.h", + "ios_handler/prune_intermediate_dumps_and_crash_reports_thread.cc", + "ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h", "simulate_crash_ios.h", ] } diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index d4c4af434f..353e24b22c 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -19,6 +19,7 @@ #include "base/logging.h" #include "client/ios_handler/in_process_intermediate_dump_handler.h" +#include "client/prune_crash_reports.h" #include "client/settings.h" #include "minidump/minidump_file_writer.h" #include "util/file/directory_reader.h" @@ -85,6 +86,14 @@ bool InProcessHandler::Initialize( base_dir_ = database.Append(kPendingSerializediOSDump); CreateDirectory(base_dir_); + prune_thread_.reset(new PruneIntermediateDumpsAndCrashReportsThread( + database_.get(), + PruneCondition::GetDefault(), + base_dir_, + bundle_identifier_and_seperator_, + system_data.IsExtension())); + prune_thread_->Start(); + if (!OpenNewFile()) return false; diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index a9a3094be1..1e6ebc4b2a 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -19,6 +19,7 @@ #include #include "base/files/file_path.h" +#include "client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h" #include "handler/crash_report_upload_thread.h" #include "snapshot/ios/process_snapshot_ios_intermediate_dump.h" #include "util/ios/ios_intermediate_dump_writer.h" @@ -193,6 +194,7 @@ class InProcessHandler { std::unique_ptr writer_; std::unique_ptr alternate_mach_writer_; std::unique_ptr upload_thread_; + std::unique_ptr prune_thread_; std::unique_ptr database_; std::string bundle_identifier_and_seperator_; InitializationStateDcheck initialized_; diff --git a/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.cc b/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.cc new file mode 100644 index 0000000000..d6cfe885d2 --- /dev/null +++ b/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.cc @@ -0,0 +1,126 @@ +// Copyright 2021 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. + +#include "client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h" + +#include + +#include "client/prune_crash_reports.h" +#include "util/file/directory_reader.h" +#include "util/file/filesystem.h" + +namespace crashpad { + +namespace { + +// The file extension used to indicate a file is locked. +constexpr char kLockedExtension[] = ".locked"; + +// If the client finds a locked file matching it's own bundle id, unlock it +// after 24 hours. +constexpr time_t matching_bundle_locked_ttl = 60 * 60 * 24; + +// Unlock any locked intermediate dump after 60 days. +constexpr time_t max_locked_ttl = 60 * 60 * 24 * 60; + +// The initial thread delay for applications. Delay the thread's file i/o to +// not interfere with application startup. +constexpr double app_delay = 60; + +// The initial thread delay for app extensions. Because iOS extensions are often +// very short lived, do not wait the full |app_delay|, and instead use a shorter +// time. +constexpr double extension_delay = 5; + + +//! \brief Unlocks old intermediate dumps. +//! +//! This function can unlock (remove the .locked extension) intermediate dumps +//! that are either too old to be useful, or are likely leftover dumps from +//! clean app exits. +//! +//! \param[in] pending_path The path to any locked intermediate dump files. +//! \param[in] bundle_identifier_and_seperator The identifier for this client, +//! used to determine when locked files are considered stale. +void UnlockOldIntermediateDumps(base::FilePath pending_path, + std::string bundle_identifier_and_seperator) { + DirectoryReader reader; + std::vector files; + if (!reader.Open(pending_path)) { + return; + } + base::FilePath file; + DirectoryReader::Result result; + while ((result = reader.NextFile(&file)) == + DirectoryReader::Result::kSuccess) { + if (file.FinalExtension() != kLockedExtension) + continue; + + const base::FilePath file_path(pending_path.Append(file)); + timespec file_time; + time_t now = time(nullptr); + if (!FileModificationTime(file_path, &file_time)) { + continue; + } + + if ((file.value().compare(0, + bundle_identifier_and_seperator.size(), + bundle_identifier_and_seperator) == 0 && + file_time.tv_sec <= now - matching_bundle_locked_ttl) || + (file_time.tv_sec <= now - max_locked_ttl)) { + base::FilePath new_path = file_path.RemoveFinalExtension(); + MoveFileOrDirectory(file_path, new_path); + continue; + } + } +} + +} // namespace + +PruneIntermediateDumpsAndCrashReportsThread:: + PruneIntermediateDumpsAndCrashReportsThread( + CrashReportDatabase* database, + std::unique_ptr condition, + base::FilePath pending_path, + std::string bundle_identifier_and_seperator, + bool is_extension) + : thread_(60 * 60 * 24, this), + condition_(std::move(condition)), + pending_path_(pending_path), + bundle_identifier_and_seperator_(bundle_identifier_and_seperator), + initial_work_delay_(is_extension ? extension_delay : app_delay), + database_(database) {} + +PruneIntermediateDumpsAndCrashReportsThread:: + ~PruneIntermediateDumpsAndCrashReportsThread() {} + +void PruneIntermediateDumpsAndCrashReportsThread::Start() { + thread_.Start(initial_work_delay_); +} + +void PruneIntermediateDumpsAndCrashReportsThread::Stop() { + thread_.Stop(); +} + +void PruneIntermediateDumpsAndCrashReportsThread::DoWork( + const WorkerThread* thread) { + database_->CleanDatabase(60 * 60 * 24 * 3); + PruneCrashReportDatabase(database_, condition_.get()); + if (!clean_old_intermediate_dumps_) { + clean_old_intermediate_dumps_ = true; + UnlockOldIntermediateDumps(pending_path_, bundle_identifier_and_seperator_); + } +} + +} // namespace crashpad diff --git a/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h b/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h new file mode 100644 index 0000000000..b2764234c3 --- /dev/null +++ b/client/ios_handler/prune_intermediate_dumps_and_crash_reports_thread.h @@ -0,0 +1,102 @@ +// Copyright 2021 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. + +#ifndef CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_ +#define CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_ + +#include + +#include "base/files/file_path.h" +#include "util/thread/stoppable.h" +#include "util/thread/worker_thread.h" + +namespace crashpad { + +class CrashReportDatabase; +class PruneCondition; + +//! \brief A thread that periodically prunes crash reports from the database +//! using the specified condition, and any leftover locked intermediate +//! dumps. +//! +//! After the thread is started, the database is pruned using the condition +//! every 24 hours. Upon calling Start(), the thread waits 5 seconds before +//! performing the initial prune operation. +//! +//! Locked intermediate dump files are unlocked only once, not periodically. +//! Locked dumps that match this bundle id can be unlocked if they are over a +//! day old. Otherwise, unlock dumps that are over 60 days old. +class PruneIntermediateDumpsAndCrashReportsThread + : public WorkerThread::Delegate, + public Stoppable { + public: + //! \brief Constructs a new object. + //! + //! \param[in] database The database to prune crash reports from. + //! \param[in] condition The condition used to evaluate crash reports for + //! pruning. + //! \param[in] pending_path The path to any locked intermediate dump files. + //! \param[in] bundle_identifier_and_seperator The identifier for this client, + //! used to determine when locked files are considered stale, with a + //! seperator at the end to allow for substring searches. + PruneIntermediateDumpsAndCrashReportsThread( + CrashReportDatabase* database, + std::unique_ptr condition, + base::FilePath pending_path, + std::string bundle_identifier_and_seperator, + bool is_extension); + + PruneIntermediateDumpsAndCrashReportsThread( + const PruneIntermediateDumpsAndCrashReportsThread&) = delete; + PruneIntermediateDumpsAndCrashReportsThread& operator=( + const PruneIntermediateDumpsAndCrashReportsThread&) = delete; + + ~PruneIntermediateDumpsAndCrashReportsThread(); + + // Stoppable: + + //! \brief Starts a dedicated pruning thread. + //! + //! The thread waits before running the initial prune, so as to not interfere + //! with any startup-related IO performed by the client. + //! + //! This method may only be be called on a newly-constructed object or after + //! a call to Stop(). + void Start() override; + + //! \brief Stops the pruning thread. + //! + //! This method must only be called after Start(). If Start() has been called, + //! this method must be called before destroying an object of this class. + //! + //! This method may be called from any thread other than the pruning thread. + //! It is expected to only be called from the same thread that called Start(). + void Stop() override; + + private: + // WorkerThread::Delegate: + void DoWork(const WorkerThread* thread) override; + + WorkerThread thread_; + std::unique_ptr condition_; + base::FilePath pending_path_; + std::string bundle_identifier_and_seperator_; + bool clean_old_intermediate_dumps_; + double initial_work_delay_; + CrashReportDatabase* database_; // weak +}; + +} // namespace crashpad + +#endif // CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_ diff --git a/util/ios/ios_system_data_collector.h b/util/ios/ios_system_data_collector.h index ab25a68a01..035f9d81e7 100644 --- a/util/ios/ios_system_data_collector.h +++ b/util/ios/ios_system_data_collector.h @@ -33,6 +33,7 @@ class IOSSystemDataCollector { int ProcessorCount() const { return processor_count_; } const std::string& Build() const { return build_; } const std::string& BundleIdentifier() const { return bundle_identifier_; } + bool IsExtension() const { return is_extension_; } const std::string& CPUVendor() const { return cpu_vendor_; } bool HasDaylightSavingTime() const { return has_next_daylight_saving_time_; } bool IsDaylightSavingTime() const { return is_daylight_saving_time_; } @@ -68,6 +69,7 @@ class IOSSystemDataCollector { int patch_version_; std::string build_; std::string bundle_identifier_; + bool is_extension_; std::string machine_description_; int orientation_; int processor_count_; diff --git a/util/ios/ios_system_data_collector.mm b/util/ios/ios_system_data_collector.mm index ed81849945..366be46481 100644 --- a/util/ios/ios_system_data_collector.mm +++ b/util/ios/ios_system_data_collector.mm @@ -79,6 +79,7 @@ build_ = ReadStringSysctlByName("kern.osversion"); bundle_identifier_ = base::SysNSStringToUTF8([[NSBundle mainBundle] bundleIdentifier]); + is_extension_ = [[NSBundle mainBundle].bundlePath hasSuffix:@"appex"]; #if defined(ARCH_CPU_X86_64) cpu_vendor_ = ReadStringSysctlByName("machdep.cpu.vendor"); From 0118cc44aa716382f90d582204197fac24bba080 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 26 Oct 2021 11:44:18 -0400 Subject: [PATCH 23/69] Roll mini_chromium to 461b416. 461b416: ios: Add ios_test_runner_xcuitest. Change-Id: Ibc070d38aeb2f6396c1f51e9f2b6aa0212ae1ded Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3245733 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index fc7a1e2a73..8ecd52e3b8 100644 --- a/DEPS +++ b/DEPS @@ -39,7 +39,7 @@ deps = { '7bde79cc274d06451bf65ae82c012a5d3e476b5a', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - '14b219d5d503e305a6d853e64de201659cfcbe2d', + '461b416dbe5f40a060ee08764b4986a949da6e6e', 'crashpad/third_party/libfuzzer/src': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' + 'fda403cf93ecb8792cb1d061564d89a6553ca020', From aaed581a53d6b26923a16accc2a7190aca606a4f Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 26 Oct 2021 09:48:40 -0400 Subject: [PATCH 24/69] Correct WorkDelegate::DoWork race condition with an atomic_bool. Bug:crashpad:380 Change-Id: Iae523f22366ca65816c42b499bd482056efb5bca Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3244729 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- util/thread/worker_thread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/thread/worker_thread.h b/util/thread/worker_thread.h index a07fd7d5e2..d43cc63e84 100644 --- a/util/thread/worker_thread.h +++ b/util/thread/worker_thread.h @@ -15,6 +15,7 @@ #ifndef CRASHPAD_UTIL_THREAD_WORKER_THREAD_H_ #define CRASHPAD_UTIL_THREAD_WORKER_THREAD_H_ +#include #include #include "util/synchronization/semaphore.h" @@ -95,7 +96,7 @@ class WorkerThread { Delegate* delegate_; // weak std::unique_ptr impl_; bool running_; - bool do_work_now_; + std::atomic_bool do_work_now_; }; } // namespace crashpad From 9747e05e7ac7343c761f523360184c3dfd2cc5eb Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 26 Oct 2021 11:13:09 -0400 Subject: [PATCH 25/69] ios: Move ios_xcuitest_test to ios_test_runner_xcuitest This template will allow these tests to run on the Chromium bots. Change-Id: I3d9ee46379eed104fb847a9a8c1d72462cd67af8 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3245731 Reviewed-by: Rohit Rao Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- test/ios/BUILD.gn | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/ios/BUILD.gn b/test/ios/BUILD.gn index 4ba4ec4f75..07a15e8d3f 100644 --- a/test/ios/BUILD.gn +++ b/test/ios/BUILD.gn @@ -15,6 +15,7 @@ import("../../build/crashpad_buildconfig.gni") if (crashpad_is_in_chromium) { + import("//build/config/ios/ios_test_runner_xcuitest.gni") import("//build/config/ios/rules.gni") } else if (crashpad_is_standalone) { import("//third_party/mini_chromium/mini_chromium/build/ios/rules.gni") @@ -38,10 +39,10 @@ source_set("google_test_runner") { sources = [ "cptest_google_test_runner.mm" ] configs += [ "../..:crashpad_config" ] deps = [ + "../$mini_chromium_source_parent:base", "../../build:ios_enable_arc", "../../build:ios_xctest", "../../test/ios:google_test_runner_shared_headers", - "../$mini_chromium_source_parent:base", ] frameworks = [ "UIKit.framework" ] } @@ -55,9 +56,9 @@ source_set("google_test_setup") { configs += [ "../..:crashpad_config" ] deps = [ ":google_test_runner_shared_headers", + "../$mini_chromium_source_parent:base", "../../build:ios_enable_arc", "../../third_party/googletest:googletest", - "../$mini_chromium_source_parent:base", ] frameworks = [ "UIKit.framework" ] } @@ -74,7 +75,8 @@ source_set("xcuitests") { ] } -ios_xcuitest_test("ios_crash_xcuitests_module") { +ios_test_runner_xcuitest("ios_crash_xcuitests_module") { xcode_test_application_name = "ios_crash_xcuitests" deps = [ ":xcuitests" ] + data_deps = [ "host:ios_crash_xcuitests" ] } From c647c0cb121299318b33ee3df2a16554a6eecd9e Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Wed, 27 Oct 2021 08:14:25 -0700 Subject: [PATCH 26/69] Use Python3 on all builders Bug: chromium:1256408 Change-Id: Id4af99414cc8c3cb9c43499bbd2508c0c233f559 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3247779 Reviewed-by: Mark Mentovai Commit-Queue: Joshua Peraza --- infra/config/generated/cr-buildbucket.cfg | 112 ++++++++++++++++++++++ infra/config/generated/project.cfg | 6 ++ infra/config/main.star | 5 +- 3 files changed, 122 insertions(+), 1 deletion(-) diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 6a0c463ab4..66c5e375bb 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -38,6 +38,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -63,6 +67,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -87,6 +95,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -111,6 +123,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -139,6 +155,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -167,6 +187,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -194,6 +218,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -221,6 +249,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -245,6 +277,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -269,6 +305,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -296,6 +336,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -323,6 +367,10 @@ buckets { } build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -347,6 +395,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -371,6 +423,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -419,6 +475,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -443,6 +503,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -466,6 +530,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -489,6 +557,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -516,6 +588,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -543,6 +619,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -569,6 +649,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -595,6 +679,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -618,6 +706,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -641,6 +733,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -667,6 +763,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -693,6 +793,10 @@ buckets { } build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -716,6 +820,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 @@ -739,6 +847,10 @@ buckets { execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } experiments { key: "luci.use_realms" value: 100 diff --git a/infra/config/generated/project.cfg b/infra/config/generated/project.cfg index b68f45b7fc..3a159bb1c9 100644 --- a/infra/config/generated/project.cfg +++ b/infra/config/generated/project.cfg @@ -6,3 +6,9 @@ name: "crashpad" access: "group:all" +lucicfg { + version: "1.29.1" + package_dir: ".." + config_dir: "generated" + entry_point: "main.star" +} diff --git a/infra/config/main.star b/infra/config/main.star index 4aaeb80a7d..965b18affe 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -18,7 +18,10 @@ lucicfg.check_version("1.28.0", "Please update depot_tools") # Enable LUCI Realms support and Launch 100% of Swarming tasks for builds in # "realms-aware mode". lucicfg.enable_experiment("crbug.com/1085650") -luci.builder.defaults.experiments.set({"luci.use_realms": 100}) +luci.builder.defaults.experiments.set({ + "luci.use_realms": 100, + "luci.recipes.use_python3": 100, +}) REPO_URL = "https://chromium.googlesource.com/crashpad/crashpad" REVIEW_URL = "https://chromium-review.googlesource.com/crashpad/crashpad" From 9c6a751e4b811414ce5563e7d24857721a736845 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 25 Oct 2021 12:36:42 -0400 Subject: [PATCH 27/69] ios: Record NSException.userInfo value. Add another annotation similar to name and reason for the NSException userInfo string value. Bug: crashpad:31 Change-Id: Ifeda599d7855c1061e5c0f1fb5fe45d568af65f7 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3238128 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- client/ios_handler/exception_processor.mm | 34 +++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/client/ios_handler/exception_processor.mm b/client/ios_handler/exception_processor.mm index d8c94e5430..c54dd58960 100644 --- a/client/ios_handler/exception_processor.mm +++ b/client/ios_handler/exception_processor.mm @@ -128,15 +128,34 @@ int LoggingUnwStep(unw_cursor_t* cursor) { objc_exception_preprocessor g_next_preprocessor; NSUncaughtExceptionHandler* g_next_uncaught_exception_handler; -static void SetNSExceptionAnnotations(id exception, +static void SetNSExceptionAnnotations(NSException* exception, std::string& name, std::string& reason) { - name = base::SysNSStringToUTF8([exception name]); - reason = base::SysNSStringToUTF8([exception reason]); - static crashpad::StringAnnotation<256> nameKey("exceptionName"); - nameKey.Set(name); - static crashpad::StringAnnotation<512> reasonKey("exceptionReason"); - reasonKey.Set(reason); + @try { + name = base::SysNSStringToUTF8(exception.name); + static crashpad::StringAnnotation<256> nameKey("exceptionName"); + nameKey.Set(name); + } @catch (id name_exception) { + LOG(ERROR) << "Unable to read uncaught Objective-C exception name."; + } + + @try { + reason = base::SysNSStringToUTF8(exception.reason); + static crashpad::StringAnnotation<512> reasonKey("exceptionReason"); + reasonKey.Set(reason); + } @catch (id reason_exception) { + LOG(ERROR) << "Unable to read uncaught Objective-C exception reason."; + } + + @try { + if (exception.userInfo) { + static crashpad::StringAnnotation<512> userInfoKey("exceptionUserInfo"); + userInfoKey.Set(base::SysNSStringToUTF8( + [NSString stringWithFormat:@"%@", exception.userInfo])); + } + } @catch (id user_info_exception) { + LOG(ERROR) << "Unable to read uncaught Objective-C exception user info."; + } } static void ObjcUncaughtExceptionHandler(NSException* exception) { @@ -147,7 +166,6 @@ static void ObjcUncaughtExceptionHandler(NSException* exception) { static crashpad::StringAnnotation<256> nameKey("UncaughtNSException"); nameKey.Set("true"); std::vector addresses; - NSArray* addressArray = [exception callStackReturnAddresses]; for (NSNumber* address in addressArray) addresses.push_back([address unsignedLongLongValue]); g_exception_delegate->HandleUncaughtNSException(&addresses[0], From 15c4663b8c31968a14e9b61a4ccd5e9d657e8325 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Wed, 27 Oct 2021 12:31:45 -0400 Subject: [PATCH 28/69] ios: Fail Crashpad initialization with invalid database path. Bug: crashpad:31 Change-Id: I1853af83a18675bee6dd99636f179db127e1ac47 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3247291 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- client/ios_handler/in_process_handler.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 353e24b22c..0b4c4b74db 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -28,13 +28,15 @@ namespace { // Creates directory at |path|. -void CreateDirectory(const base::FilePath& path) { +bool CreateDirectory(const base::FilePath& path) { if (mkdir(path.value().c_str(), 0755) == 0) { - return; + return true; } if (errno != EEXIST) { PLOG(ERROR) << "mkdir " << path.value(); + return false; } + return true; } // The file extension used to indicate a file is locked. @@ -63,6 +65,9 @@ bool InProcessHandler::Initialize( INITIALIZATION_STATE_SET_INITIALIZING(initialized_); annotations_ = annotations; database_ = CrashReportDatabase::Initialize(database); + if (!database_) { + return false; + } bundle_identifier_and_seperator_ = system_data.BundleIdentifier() + kBundleSeperator; @@ -80,11 +85,13 @@ bool InProcessHandler::Initialize( database_.get(), url, upload_thread_options)); } - CreateDirectory(database); + if (!CreateDirectory(database)) + return false; static constexpr char kPendingSerializediOSDump[] = "pending-serialized-ios-dump"; base_dir_ = database.Append(kPendingSerializediOSDump); - CreateDirectory(base_dir_); + if (!CreateDirectory(base_dir_)) + return false; prune_thread_.reset(new PruneIntermediateDumpsAndCrashReportsThread( database_.get(), From fad3bdcde058984722056aa01ec47b13e81aeb17 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 28 Oct 2021 17:02:27 -0400 Subject: [PATCH 29/69] ios: Update XCUITests to check various crash type exception codes. Bug: crashpad:31 Change-Id: I804def3be0050b3e6f15d7d77d0b70184c380673 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3087722 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- snapshot/BUILD.gn | 22 +- test/ios/BUILD.gn | 1 + test/ios/crash_type_xctest.mm | 296 +++++++++--------- test/ios/host/BUILD.gn | 16 +- test/ios/host/cptest_application_delegate.mm | 216 ++++++++++++- test/ios/host/cptest_crash_view_controller.mm | 1 - test/ios/host/cptest_shared_object.h | 34 +- 7 files changed, 404 insertions(+), 182 deletions(-) diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 8b26e14a5a..b0158194e7 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -244,10 +244,10 @@ crashpad_static_library("snapshot") { public_deps = [ ":context" ] deps = [ + "$mini_chromium_source_parent:base", "../client:common", "../compat", "../minidump:format", - "$mini_chromium_source_parent:base", "../util", ] @@ -318,8 +318,8 @@ static_library("test_support") { public_deps = [ ":snapshot" ] deps = [ - "../compat", "$mini_chromium_source_parent:base", + "../compat", "../util", ] @@ -429,13 +429,13 @@ source_set("snapshot_test") { deps = [ ":test_support", + "$mini_chromium_source_parent:base", "../client:common", "../compat", "../minidump:format", "../test", "../third_party/googletest:googlemock", "../third_party/googletest:googletest", - "$mini_chromium_source_parent:base", "../util", ] @@ -489,8 +489,8 @@ crashpad_loadable_module("crashpad_snapshot_test_module") { testonly = true sources = [ "crashpad_info_client_options_test_module.cc" ] deps = [ - "../client", "$mini_chromium_source_parent:base", + "../client", ] } @@ -533,7 +533,7 @@ if ((crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) && } } -if (crashpad_is_mac) { +if (crashpad_is_mac || crashpad_is_ios) { crashpad_loadable_module("crashpad_snapshot_test_module_crashy_initializer") { testonly = true sources = [ @@ -552,9 +552,9 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_annotations.cc" ] deps = [ + "$mini_chromium_source_parent:base", "../client", "../compat", - "$mini_chromium_source_parent:base", ] } @@ -562,9 +562,9 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_crashing_child.cc" ] deps = [ + "$mini_chromium_source_parent:base", "../client", "../compat", - "$mini_chromium_source_parent:base", "../util", ] } @@ -573,9 +573,9 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_dump_without_crashing.cc" ] deps = [ + "$mini_chromium_source_parent:base", "../client", "../compat", - "$mini_chromium_source_parent:base", "../util", ] } @@ -584,9 +584,9 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_extra_memory_ranges.cc" ] deps = [ + "$mini_chromium_source_parent:base", "../client", "../compat", - "$mini_chromium_source_parent:base", ] } @@ -594,9 +594,9 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_image_reader.cc" ] deps = [ + "$mini_chromium_source_parent:base", "../client", "../compat", - "$mini_chromium_source_parent:base", "../util", ] if (crashpad_is_in_chromium) { @@ -613,8 +613,8 @@ if (crashpad_is_win) { testonly = true sources = [ "win/crashpad_snapshot_test_image_reader_module.cc" ] deps = [ - "../client", "$mini_chromium_source_parent:base", + "../client", ] if (crashpad_is_in_chromium) { if (symbol_level == 0) { diff --git a/test/ios/BUILD.gn b/test/ios/BUILD.gn index 07a15e8d3f..d17e540cbd 100644 --- a/test/ios/BUILD.gn +++ b/test/ios/BUILD.gn @@ -72,6 +72,7 @@ source_set("xcuitests") { "../../build:ios_xctest", "../../test/ios/host:app_shared_sources", "../../third_party/edo", + "../../util", ] } diff --git a/test/ios/crash_type_xctest.mm b/test/ios/crash_type_xctest.mm index 00d89e7c90..b4b22cb520 100644 --- a/test/ios/crash_type_xctest.mm +++ b/test/ios/crash_type_xctest.mm @@ -13,38 +13,34 @@ // limitations under the License. #import - #include + #import "Service/Sources/EDOClientService.h" #import "test/ios/host/cptest_shared_object.h" +#include "util/mach/exception_types.h" +#include "util/mach/mach_extensions.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif @interface CPTestTestCase : XCTestCase { - XCUIApplication* _app; + XCUIApplication* app_; + CPTestSharedObject* rootObject_; } - @end @implementation CPTestTestCase -- (void)handleCrashUnderSymbol:(id)arg1 { - // For now, do nothing. In the future this can be something testable. -} - + (void)setUp { // Swizzle away the handleCrashUnderSymbol callback. Without this, any time // the host app is intentionally crashed, the test is immediately failed. SEL originalSelector = NSSelectorFromString(@"handleCrashUnderSymbol:"); SEL swizzledSelector = @selector(handleCrashUnderSymbol:); - Method originalMethod = class_getInstanceMethod( objc_getClass("XCUIApplicationImpl"), originalSelector); Method swizzledMethod = class_getInstanceMethod([self class], swizzledSelector); - method_exchangeImplementations(originalMethod, swizzledMethod); // Override EDO default error handler. Without this, the default EDO error @@ -54,188 +50,186 @@ + (void)setUp { }); } +// This gets called after tearDown, so there's no straightforward way to +// test that this is called. However, not swizzling this out will cause every +// crashing test to fail. +- (void)handleCrashUnderSymbol:(id)arg1 { +} + - (void)setUp { - _app = [[XCUIApplication alloc] init]; - [_app launch]; + app_ = [[XCUIApplication alloc] init]; + [app_ launch]; + rootObject_ = [EDOClientService rootObjectWithPort:12345]; + [rootObject_ clearPendingReports]; + XCTAssertEqual([rootObject_ pendingReportCount], 0); + XCTAssertTrue(app_.state == XCUIApplicationStateRunningForeground); +} + +- (void)verifyCrashReportException:(int)exception { + // Confirm the app is not running. + XCTAssertTrue([app_ waitForState:XCUIApplicationStateNotRunning timeout:15]); + XCTAssertTrue(app_.state == XCUIApplicationStateNotRunning); + + // Restart app to get the report signal. + [app_ launch]; + XCTAssertTrue(app_.state == XCUIApplicationStateRunningForeground); + rootObject_ = [EDOClientService rootObjectWithPort:12345]; + XCTAssertEqual([rootObject_ pendingReportCount], 1); + XCTAssertEqual([rootObject_ pendingReportException], exception); } - (void)testEDO { - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - NSString* result = [rootObject testEDO]; + NSString* result = [rootObject_ testEDO]; XCTAssertEqualObjects(result, @"crashpad"); } - (void)testSegv { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashSegv]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashSegv]; +#if defined(NDEBUG) +#if TARGET_OS_SIMULATOR + [self verifyCrashReportException:SIGINT]; +#else + [self verifyCrashReportException:SIGABRT]; +#endif +#else + [self verifyCrashReportException:SIGHUP]; +#endif } - (void)testKillAbort { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashKillAbort]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashKillAbort]; + [self verifyCrashReportException:SIGABRT]; } - (void)testTrap { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashTrap]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashTrap]; +#if TARGET_OS_SIMULATOR + [self verifyCrashReportException:SIGINT]; +#else + [self verifyCrashReportException:SIGABRT]; +#endif } - (void)testAbort { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashAbort]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashAbort]; + [self verifyCrashReportException:SIGABRT]; } - (void)testBadAccess { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashBadAccess]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashBadAccess]; +#if defined(NDEBUG) +#if TARGET_OS_SIMULATOR + [self verifyCrashReportException:SIGINT]; +#else + [self verifyCrashReportException:SIGABRT]; +#endif +#else + [self verifyCrashReportException:SIGHUP]; +#endif } - (void)testException { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashException]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashException]; + [self verifyCrashReportException:SIGABRT]; } - (void)testNSException { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashNSException]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); -} - -- (void)testCrashUnreocgnizedSelectorAfterDelay { - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); - - // Crash the app. - CPTestSharedObject* rootObject = [EDOClientService rootObjectWithPort:12345]; - [rootObject crashUnreocgnizedSelectorAfterDelay]; - - // Confirm the app is not running. - XCTAssertTrue([_app waitForState:XCUIApplicationStateNotRunning timeout:15]); - XCTAssertTrue(_app.state == XCUIApplicationStateNotRunning); - - // TODO: Query the app for crash data - [_app launch]; - XCTAssertTrue(_app.state == XCUIApplicationStateRunningForeground); + [rootObject_ crashNSException]; + [self verifyCrashReportException:crashpad::kMachExceptionFromNSException]; + NSDictionary* dict = [rootObject_ getAnnotations]; + NSString* userInfo = + [dict[@"objects"][0] valueForKeyPath:@"exceptionUserInfo"]; + XCTAssertTrue([userInfo containsString:@"Error Object= +#include +#include +#include +#include #include #include #include @@ -24,7 +27,15 @@ #import "Service/Sources/EDOHostNamingService.h" #import "Service/Sources/EDOHostService.h" +#import "Service/Sources/NSObject+EDOValueObject.h" +#include "base/strings/sys_string_conversions.h" +#include "client/annotation.h" +#include "client/annotation_list.h" +#include "client/crash_report_database.h" #include "client/crashpad_client.h" +#include "client/crashpad_info.h" +#include "client/simple_string_dictionary.h" +#include "snapshot/minidump/process_snapshot_minidump.h" #import "test/ios/host/cptest_crash_view_controller.h" #import "test/ios/host/cptest_shared_object.h" @@ -32,15 +43,58 @@ #error "This file requires ARC support." #endif -@implementation CPTestApplicationDelegate +using OperationStatus = crashpad::CrashReportDatabase::OperationStatus; +using Report = crashpad::CrashReportDatabase::Report; + +namespace { + +base::FilePath GetDatabaseDir() { + base::FilePath database_dir([NSFileManager.defaultManager + URLsForDirectory:NSDocumentDirectory + inDomains:NSUserDomainMask] + .lastObject.path.UTF8String); + return database_dir.Append("crashpad"); +} + +std::unique_ptr GetDatabase() { + base::FilePath database_dir = GetDatabaseDir(); + std::unique_ptr database = + crashpad::CrashReportDatabase::Initialize(database_dir); + return database; +} + +OperationStatus GetPendingReports(std::vector* pending_reports) { + std::unique_ptr database(GetDatabase()); + return database->GetPendingReports(pending_reports); +} + +[[clang::optnone]] void recurse(int counter) { + // Fill up the stack faster. + int arr[1024]; + arr[0] = counter; + if (counter > INT_MAX) + return; + recurse(++counter); +} + +} // namespace + +@interface CPTestApplicationDelegate () +- (void)processIntermediateDumps; +@end + +@implementation CPTestApplicationDelegate { + crashpad::CrashpadClient client_; +} @synthesize window = _window; - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { // Start up crashpad. - crashpad::CrashpadClient client; - client.StartCrashpadInProcessHandler(base::FilePath(), "", {}); + if (client_.StartCrashpadInProcessHandler(GetDatabaseDir(), "", {})) { + client_.ProcessIntermediateDumps(); + } self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window makeKeyAndVisible]; @@ -54,9 +108,14 @@ - (BOOL)application:(UIApplication*)application [EDOHostService serviceWithPort:12345 rootObject:[[CPTestSharedObject alloc] init] queue:dispatch_get_main_queue()]; + return YES; } +- (void)processIntermediateDumps { + client_.ProcessIntermediateDumps(); +} + @end @implementation CPTestSharedObject @@ -65,6 +124,85 @@ - (NSString*)testEDO { return @"crashpad"; } +- (void)processIntermediateDumps { + CPTestApplicationDelegate* delegate = + (CPTestApplicationDelegate*)UIApplication.sharedApplication.delegate; + [delegate processIntermediateDumps]; +} + +- (void)clearPendingReports { + std::unique_ptr database(GetDatabase()); + std::vector pending_reports; + database->GetPendingReports(&pending_reports); + for (auto report : pending_reports) { + database->DeleteReport(report.uuid); + } +} + +- (int)pendingReportCount { + std::vector pending_reports; + OperationStatus status = GetPendingReports(&pending_reports); + if (status != crashpad::CrashReportDatabase::kNoError) { + return -1; + } + return pending_reports.size(); +} + +- (int)pendingReportException { + std::vector pending_reports; + OperationStatus status = GetPendingReports(&pending_reports); + if (status != crashpad::CrashReportDatabase::kNoError || + pending_reports.size() != 1) { + return -1; + } + + auto reader = std::make_unique(); + reader->Open(pending_reports[0].file_path); + crashpad::ProcessSnapshotMinidump process_snapshot; + process_snapshot.Initialize(reader.get()); + return static_cast(process_snapshot.Exception()->Exception()); +} + +- (NSDictionary*)getAnnotations { + std::vector pending_reports; + OperationStatus status = GetPendingReports(&pending_reports); + if (status != crashpad::CrashReportDatabase::kNoError || + pending_reports.size() != 1) { + return @{}; + } + + auto reader = std::make_unique(); + reader->Open(pending_reports[0].file_path); + crashpad::ProcessSnapshotMinidump process_snapshot; + process_snapshot.Initialize(reader.get()); + + NSDictionary* dict = @{ + @"simplemap" : [@{} mutableCopy], + @"vector" : [@[] mutableCopy], + @"objects" : [@[] mutableCopy] + }; + for (const auto* module : process_snapshot.Modules()) { + for (const auto& kv : module->AnnotationsSimpleMap()) { + [dict[@"simplemap"] setValue:@(kv.second.c_str()) + forKey:@(kv.first.c_str())]; + } + for (const std::string& annotation : module->AnnotationsVector()) { + [dict[@"vector"] addObject:@(annotation.c_str())]; + } + for (const auto& annotation : module->AnnotationObjects()) { + if (annotation.type != + static_cast(crashpad::Annotation::Type::kString)) { + continue; + } + std::string value(reinterpret_cast(annotation.value.data()), + annotation.value.size()); + [dict[@"objects"] + addObject:@{@(annotation.name.c_str()) : @(value.c_str())}]; + } + } + return [dict passByValue]; +} + - (void)crashBadAccess { strcpy(nullptr, "bla"); } @@ -92,13 +230,25 @@ - (void)crashException { } - (void)crashNSException { - // EDO has its own sinkhole. + // EDO has its own sinkhole, so dispatch this away. dispatch_async(dispatch_get_main_queue(), ^{ - NSArray* empty_array = @[]; - [empty_array objectAtIndex:42]; + NSError* error = [NSError errorWithDomain:@"com.crashpad.xcuitests" + code:200 + userInfo:@{@"Error Object" : self}]; + + [[NSException exceptionWithName:NSInternalInconsistencyException + reason:@"Intentionally throwing error." + userInfo:@{NSUnderlyingErrorKey : error}] raise]; }); } +- (void)crashUnrecognizedSelectorAfterDelay { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + [self performSelector:@selector(does_not_exist) withObject:nil afterDelay:1]; +#pragma clang diagnostic pop +} + - (void)catchNSException { @try { NSArray* empty_array = @[]; @@ -108,19 +258,53 @@ - (void)catchNSException { } } -- (void)crashUnreocgnizedSelectorAfterDelay { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wundeclared-selector" - [self performSelector:@selector(does_not_exist) withObject:nil afterDelay:1]; -#pragma clang diagnostic pop +- (void)crashRecursion { + recurse(0); } -- (void)recurse { - [self recurse]; +- (void)crashWithCrashInfoMessage { + dlsym(nullptr, nullptr); } -- (void)crashRecursion { - [self recurse]; +- (void)crashWithDyldErrorString { + std::string crashy_initializer = + base::SysNSStringToUTF8([[NSBundle mainBundle] + pathForResource:@"crashpad_snapshot_test_module_crashy_initializer" + ofType:@"so"]); + dlopen(crashy_initializer.c_str(), RTLD_LAZY | RTLD_LOCAL); +} + +- (void)crashWithAnnotations { + // This is “leaked” to crashpad_info. + crashpad::SimpleStringDictionary* simple_annotations = + new crashpad::SimpleStringDictionary(); + simple_annotations->SetKeyValue("#TEST# pad", "break"); + simple_annotations->SetKeyValue("#TEST# key", "value"); + simple_annotations->SetKeyValue("#TEST# pad", "crash"); + simple_annotations->SetKeyValue("#TEST# x", "y"); + simple_annotations->SetKeyValue("#TEST# longer", "shorter"); + simple_annotations->SetKeyValue("#TEST# empty_value", ""); + + crashpad::CrashpadInfo* crashpad_info = + crashpad::CrashpadInfo::GetCrashpadInfo(); + + crashpad_info->set_simple_annotations(simple_annotations); + + crashpad::AnnotationList::Register(); // This is “leaked” to crashpad_info. + + static crashpad::StringAnnotation<32> test_annotation_one{"#TEST# one"}; + static crashpad::StringAnnotation<32> test_annotation_two{"#TEST# two"}; + static crashpad::StringAnnotation<32> test_annotation_three{ + "#TEST# same-name"}; + static crashpad::StringAnnotation<32> test_annotation_four{ + "#TEST# same-name"}; + + test_annotation_one.Set("moocow"); + test_annotation_two.Set("this will be cleared"); + test_annotation_three.Set("same-name 3"); + test_annotation_four.Set("same-name 4"); + test_annotation_two.Clear(); + abort(); } @end diff --git a/test/ios/host/cptest_crash_view_controller.mm b/test/ios/host/cptest_crash_view_controller.mm index c467722907..af69845ca9 100644 --- a/test/ios/host/cptest_crash_view_controller.mm +++ b/test/ios/host/cptest_crash_view_controller.mm @@ -58,7 +58,6 @@ - (void)throwUIGestureEnvironmentException { - (void)viewDidLoad { [super viewDidLoad]; - self.view.backgroundColor = UIColor.redColor; } diff --git a/test/ios/host/cptest_shared_object.h b/test/ios/host/cptest_shared_object.h index 70c814b07a..e75849b319 100644 --- a/test/ios/host/cptest_shared_object.h +++ b/test/ios/host/cptest_shared_object.h @@ -18,9 +18,30 @@ #import @interface CPTestSharedObject : NSObject + // Returns the string "crashpad" for testing EDO. - (NSString*)testEDO; +// Tell Crashpad to process intermediate dumps. +- (void)processIntermediateDumps; + +// Clear pending reports from Crashpad database. +- (void)clearPendingReports; + +// Returns the number of pending reports, or -1 if there's an error getting +// report. +- (int)pendingReportCount; + +// Returns exception code when there's a single pending report, or -1 if there's +// a different number of pending reports. +- (int)pendingReportException; + +// Return an NSDictionary with a dictionary named "simplemap", an array named +// "vector" and an array named "objects", representing the combination of all +// modules AnnotationsSimpleMap, AnnotationsVector and AnnotationObjects +// (strings only) respectively. +- (NSDictionary*)getAnnotations; + // Triggers an EXC_BAD_ACCESS exception and crash. - (void)crashBadAccess; @@ -43,13 +64,22 @@ - (void)crashNSException; // Trigger an unrecognized selector after delay. -- (void)crashUnreocgnizedSelectorAfterDelay; +- (void)crashUnrecognizedSelectorAfterDelay; -// Trigger a caught NSxception. +// Trigger a caught NSException, this will not crash - (void)catchNSException; // Trigger a crash with an infinite recursion. - (void)crashRecursion; + +// Trigger a crash dlsym that contains a crash_info message. +- (void)crashWithCrashInfoMessage; + +// Trigger an error that will to the dyld error string `_error_string` +- (void)crashWithDyldErrorString; + +// Trigger a crash after writing various annotations. +- (void)crashWithAnnotations; @end #endif // CRASHPAD_TEST_IOS_HOST_SHARED_OBJECT_H_ From d842c3c4c62ec9d3b8fc928ad025a2d314a110ff Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 28 Oct 2021 17:08:41 -0400 Subject: [PATCH 30/69] ios: Life of a crash report documentation. Bug: crashpad: 31 Change-Id: Ic67aa0450cc273bd4088c494ed2656365b700198 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3234451 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai Reviewed-by: Rohit Rao --- client/crashpad_client_ios.cc | 2 +- doc/ios_overview_design.md | 73 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/client/crashpad_client_ios.cc b/client/crashpad_client_ios.cc index 8c00d5d0ea..01d3484579 100644 --- a/client/crashpad_client_ios.cc +++ b/client/crashpad_client_ios.cc @@ -75,6 +75,7 @@ class CrashHandler : public Thread, LOG(ERROR) << "Unable to initialize Crashpad."; return false; } + InstallObjcExceptionPreprocessor(this); INITIALIZATION_STATE_SET_VALID(initialized_); return true; } @@ -312,7 +313,6 @@ bool CrashpadClient::StartCrashpadInProcessHandler( const std::map& annotations) { CrashHandler* crash_handler = CrashHandler::Get(); DCHECK(crash_handler); - InstallObjcExceptionPreprocessor(crash_handler); return crash_handler->Initialize(database, url, annotations); } diff --git a/doc/ios_overview_design.md b/doc/ios_overview_design.md index 1c4d6dd0e5..e3c1b7d1fc 100644 --- a/doc/ios_overview_design.md +++ b/doc/ios_overview_design.md @@ -69,6 +69,71 @@ arrays. Similar to JSON, maps can contain other maps, arrays and properties. +## The life of an iOS crash report + +Immediately upon calling StartCrashpadInProcessHandler, the iOS in-process +handler is installed. This will open a temporary file within the database +directory, in a subdirectory named `pending-serialized-ios-dump`. This file will +be used to write an intermediate dump in the event of a crash. This must happen +before installing the various types of crash handlers, as each depends on having +a valid handler with an intermediate dump ready to be written to. + +After the in-process handler is initialized, the Mach exception, POSIX signal +and Objective-C exception preprocessor handlers are installed. + +### Intermediate Dump File Locking + +It is expected that multiple Crashpad clients may share the same database +directory, and this directory may be inside an iOS app group directory. While +it's possible for each Crashpad client to write to its own private directory, +if a shared directory is used, it's possible for different applications to +upload a crash report from any application in a shared group. This might be +used, for example, by an application and its various app extensions, where each +client may generate a crash report but only the main application uploads +reports. Alternatively, a suite of applications may upload each other's crash +reports. Otherwise, the only opportunity to upload a report would be when a +specific app that crashed relaunches. + +To prevent multiple clients from processing a pending intermediate dump, files +must be locked. However, POSIX locks on app group files will trigger app +termination on app backgrounding, so a custom file locking protocol is used. +Locked temporary files are named `@.locked`. The `.locked` +extension is removed when the file is unlocked. The `bundle-id` is used to +determine which Crashpad clients can process leftover locked files. + +### Writing Crashes to Intermediate Dumps + +When an app encounters a crash (via a Mach exception, Objective-C exception, or +a POSIX signal), an intermediate dump is written to the temporary locked file, +the .locked extension is removed, and a new temporary locked file is opened. + +App terminations not handled by Crashpad will leave behind a temporary +locked file, to be cleaned up on next launch. These files are still processed, +because it is possible for the app to be terminated while writing an +intermediate dump, and if enough data is written this may still be valuable. + +Note: Generally iOS apps are single-process, so it's safe for the client to +consider any files matching its `bundle-id`, but there are edge-cases (such as +if a share-to app extension is opened at the same time in two different apps) so +old locked files won't be cleared until after 24 hours. Any locked file found +after 60 days is unlocked regardless of `bundle-id`. + +### Writing to Intermediate Dumps without a Crash + +Apps may also generate intermediate dumps without a crash, often used for +debugging. Chromium makes heavy use of this for detecting main thread hangs, +something that can appear as a crash for the user, but is uncatchable for crash +handlers like Crashpad. When an app requests this (via DumpWithoutCrash, +DumpWithoutCrashAndDeferProcessing), an intermediate dump is written to the +temporary locked file, the .locked extension is removed, and a new temporary +locked file is opened. + +Note: DumpWithoutCrashAndDeferProcessingAtPath writes an intermediate dump to +the requested location, not the previously opened temporary file. This is useful +because Chromium's main thread hang detection will throw away hang reports in +certain circumstances (if the app recovers, if a different crash report is +written, etc). + ## The Crashpad In-Process Client Other Crashpad platforms handle exceptions and upload minidumps out-of-process. @@ -81,6 +146,11 @@ intermediate dumps into pending minidumps and begin processing pending minidumps, possibly for upload, at suitable times following the next application restart. +Note: Applications are not required to call either of these methods. For +example, application extensions may choose to generate dumps but leave +processing and uploading to the main applications. Clients that share the +same database directory between apps can take advantage of processing and +uploading crash reports from different applications. ### `ProcessIntermediateDumps` For performance and stability reasons applications may choose the correct time @@ -96,6 +166,9 @@ the next call to `ProcessIntermediateDumps`. Conversely, stability concerns. In this case, intermediate dumps are automatically converted to minidumps and immediately eligible for uploading. +Applications can include annotations here as well. Chromium uses this for its +insta-crash logic, which detects if an app is crashing repeatedly on startup. + ### `StartProcessingPendingReports` For similar reasons, applications may choose the correct time to begin uploading pending reports, such as when ideal network conditions exist. By default, From defcda0c2c54814a9bf74a0e90f4fb433c41209c Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Sat, 30 Oct 2021 07:52:58 -0700 Subject: [PATCH 31/69] Fix an instance of -Wshadow. Bug: chromium:794619 Change-Id: I504c2931e19f7de4f9d65227fc55978622d0de6f Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3253960 Reviewed-by: Mark Mentovai Reviewed-by: Justin Cohen Commit-Queue: Peter Kasting --- snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc index 0bc9247b33..1796c76c9f 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc @@ -336,9 +336,8 @@ class ProcessSnapshotIOSIntermediateDumpTest : public testing::Test { stack_region_address += 10; EXPECT_TRUE( writer->AddProperty(Key::kStackRegionAddress, &stack_region_address)); - constexpr char memory_region[] = "stack_data"; EXPECT_TRUE( - writer->AddPropertyBytes(Key::kStackRegionData, memory_region, 10)); + writer->AddPropertyBytes(Key::kStackRegionData, "stack_data", 10)); { IOSIntermediateDumpWriter::ScopedArray memoryRegions( writer, Key::kThreadContextMemoryRegions); @@ -347,9 +346,8 @@ class ProcessSnapshotIOSIntermediateDumpTest : public testing::Test { const vm_address_t memory_region_address = 0; EXPECT_TRUE(writer->AddProperty( Key::kThreadContextMemoryRegionAddress, &memory_region_address)); - constexpr char memory_region[] = "string"; EXPECT_TRUE(writer->AddPropertyBytes( - Key::kThreadContextMemoryRegionData, memory_region, 6)); + Key::kThreadContextMemoryRegionData, "string", 6)); } } } From 020da53ac84de675c8adae5b512f4257adc9dfe3 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Tue, 2 Nov 2021 13:37:00 -0700 Subject: [PATCH 32/69] Bump Windows SDK to 10.0.19041.0 Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 Reviewed-by: Mark Mentovai Commit-Queue: Mark Mentovai --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 4 ++++ infra/config/main.star | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 8ecd52e3b8..8a6ee243c0 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 66c5e375bb..bf9f5e3d8f 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -387,6 +387,7 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" + properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Debug\"" @@ -415,6 +416,7 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" + properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Release\"" @@ -813,6 +815,7 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" + properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Debug\"" properties_j: "target_os:\"win\"" @@ -840,6 +843,7 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" + properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Release\"" properties_j: "target_os:\"win\"" diff --git a/infra/config/main.star b/infra/config/main.star index 965b18affe..0ef18f8f90 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -186,6 +186,13 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu + if platform == "win": + properties["$depot_tools/windows_sdk"] = { + "sdk_properties": { + "version": "uploaded:2021-04-28", + }, + } + if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 4bafdbc211e07b7318580606b6c2f9767897d870 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 4 Nov 2021 20:31:33 +0000 Subject: [PATCH 33/69] Revert "Bump Windows SDK to 10.0.19041.0" This reverts commit 020da53ac84de675c8adae5b512f4257adc9dfe3. Reason for revert: Speculative revert, as trybots are failing: https://ci.chromium.org/ui/p/crashpad/builders/try/crashpad_win_x64_rel/103/overview Original change's description: > Bump Windows SDK to 10.0.19041.0 > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > Reviewed-by: Mark Mentovai > Commit-Queue: Mark Mentovai Change-Id: Ibd534e55fd81279e4d0f4df0f387fdaaa2475845 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3259422 Bot-Commit: Rubber Stamper --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 4 ---- infra/config/main.star | 7 ------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/DEPS b/DEPS index 8a6ee243c0..8ecd52e3b8 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2021-04-28' + 'version': 'uploaded:2018-06-13' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index bf9f5e3d8f..66c5e375bb 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -387,7 +387,6 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Debug\"" @@ -416,7 +415,6 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Release\"" @@ -815,7 +813,6 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Debug\"" properties_j: "target_os:\"win\"" @@ -843,7 +840,6 @@ buckets { name: "crashpad/build" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$depot_tools/windows_sdk:{\"sdk_properties\":{\"version\":\"uploaded:2021-04-28\"}}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "config:\"Release\"" properties_j: "target_os:\"win\"" diff --git a/infra/config/main.star b/infra/config/main.star index 0ef18f8f90..965b18affe 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -186,13 +186,6 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu - if platform == "win": - properties["$depot_tools/windows_sdk"] = { - "sdk_properties": { - "version": "uploaded:2021-04-28", - }, - } - if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From b50484dbe0954c14506a6d780fdfd2575e9b982f Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Thu, 4 Nov 2021 16:54:59 -0400 Subject: [PATCH 34/69] infra: Enable bbagent and use_python3 Change-Id: Ibfe01bd8f327bae137bd948082dc09504d8a5cb8 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260456 Reviewed-by: Mark Mentovai Commit-Queue: Mark Mentovai --- infra/config/generated/cr-buildbucket.cfg | 716 +++++++++++++--------- infra/config/generated/project.cfg | 2 +- infra/config/main.star | 5 +- 3 files changed, 416 insertions(+), 307 deletions(-) diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 66c5e375bb..d34621cdf0 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -25,16 +25,25 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -42,10 +51,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_arm64_rel" @@ -54,16 +59,25 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -71,10 +85,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_x64_dbg" @@ -83,15 +93,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -99,10 +118,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_x64_rel" @@ -111,15 +126,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -127,10 +151,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_arm64_dbg" @@ -138,16 +158,25 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -159,10 +188,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_arm64_rel" @@ -170,16 +195,25 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -191,10 +225,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_x64_dbg" @@ -202,15 +232,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -222,10 +261,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_x64_rel" @@ -233,15 +268,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -253,10 +297,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_linux_x64_dbg" @@ -265,15 +305,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"linux\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "linux"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -281,10 +330,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_linux_x64_rel" @@ -293,15 +338,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"linux\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "linux"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -309,10 +363,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_mac_x64_dbg" @@ -320,15 +370,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"mac\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "mac"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_mac" @@ -340,10 +399,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_mac_x64_rel" @@ -351,15 +406,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"mac\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "mac"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_mac" @@ -371,10 +435,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_win_x64_dbg" @@ -383,15 +443,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Windows-10" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"win\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "win"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -399,10 +468,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_win_x64_rel" @@ -411,15 +476,24 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Windows-10" dimensions: "pool:luci.flex.ci" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$gatekeeper:{\"group\":\"client.crashpad\"}" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"win\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$gatekeeper": {' + ' "group": "client.crashpad"' + ' },' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "win"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -427,10 +501,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } } } @@ -463,15 +533,22 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -479,10 +556,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_arm64_rel" @@ -491,15 +564,22 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -507,10 +587,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_x64_dbg" @@ -519,14 +595,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -534,10 +617,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_fuchsia_x64_rel" @@ -546,14 +625,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"fuchsia\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "fuchsia"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -561,10 +647,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_arm64_dbg" @@ -572,15 +654,22 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -592,10 +681,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_arm64_rel" @@ -603,15 +688,22 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_cpu:\"arm64\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_cpu": "arm64",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -623,10 +715,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_x64_dbg" @@ -634,14 +722,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -653,10 +748,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_ios_x64_rel" @@ -664,14 +755,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"ios\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "ios"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_ios" @@ -683,10 +781,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_linux_x64_dbg" @@ -695,14 +789,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"linux\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "linux"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -710,10 +811,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_linux_x64_rel" @@ -722,14 +819,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Ubuntu-16.04" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"linux\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "linux"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -737,10 +841,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_mac_x64_dbg" @@ -748,14 +848,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"mac\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "mac"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_mac" @@ -767,10 +874,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_mac_x64_rel" @@ -778,14 +881,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Mac-10.15" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"mac\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "mac"' + '}' execution_timeout_secs: 10800 caches { name: "osx_sdk_mac" @@ -797,10 +907,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_win_x64_dbg" @@ -809,14 +915,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Windows-10" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Debug\"" - properties_j: "target_os:\"win\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Debug",' + ' "recipe": "crashpad/build",' + ' "target_os": "win"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -824,10 +937,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } builders { name: "crashpad_win_x64_rel" @@ -836,14 +945,21 @@ buckets { dimensions: "cpu:x86-64" dimensions: "os:Windows-10" dimensions: "pool:luci.flex.try" - recipe { - name: "crashpad/build" + exe { cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/main" - properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" - properties_j: "config:\"Release\"" - properties_j: "target_os:\"win\"" - } + cmd: "luciexe" + } + properties: + '{' + ' "$kitchen": {' + ' "devshell": true,' + ' "git_auth": true' + ' },' + ' "config": "Release",' + ' "recipe": "crashpad/build",' + ' "target_os": "win"' + '}' execution_timeout_secs: 10800 build_numbers: YES service_account: "crashpad-try-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -851,10 +967,6 @@ buckets { key: "luci.recipes.use_python3" value: 100 } - experiments { - key: "luci.use_realms" - value: 100 - } } } } diff --git a/infra/config/generated/project.cfg b/infra/config/generated/project.cfg index 3a159bb1c9..9dcccbfab2 100644 --- a/infra/config/generated/project.cfg +++ b/infra/config/generated/project.cfg @@ -7,7 +7,7 @@ name: "crashpad" access: "group:all" lucicfg { - version: "1.29.1" + version: "1.30.1" package_dir: ".." config_dir: "generated" entry_point: "main.star" diff --git a/infra/config/main.star b/infra/config/main.star index 965b18affe..f51ef23e1e 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -18,10 +18,6 @@ lucicfg.check_version("1.28.0", "Please update depot_tools") # Enable LUCI Realms support and Launch 100% of Swarming tasks for builds in # "realms-aware mode". lucicfg.enable_experiment("crbug.com/1085650") -luci.builder.defaults.experiments.set({ - "luci.use_realms": 100, - "luci.recipes.use_python3": 100, -}) REPO_URL = "https://chromium.googlesource.com/crashpad/crashpad" REVIEW_URL = "https://chromium-review.googlesource.com/crashpad/crashpad" @@ -146,6 +142,7 @@ def crashpad_recipe(): return luci.recipe( name = "crashpad/build", cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build", + use_python3=True, ) def crashpad_caches(platform): From 44f566832da48b25c09ee83d4221a9c57f359a82 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Thu, 4 Nov 2021 15:54:17 -0700 Subject: [PATCH 35/69] Reland "Bump Windows SDK to 10.0.19041.0" This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 Original change's description: > Bump Windows SDK to 10.0.19041.0 > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > Reviewed-by: Mark Mentovai > Commit-Queue: Mark Mentovai Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 Commit-Queue: Alex Gough Reviewed-by: Mark Mentovai --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 20 ++++++++++++++++++++ infra/config/main.star | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 8ecd52e3b8..8a6ee243c0 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index d34621cdf0..0eb8c621d8 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,6 +450,11 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "sdk_properties": {' + ' "version": "uploaded:2021-04-28"' + ' }' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -483,6 +488,11 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "sdk_properties": {' + ' "version": "uploaded:2021-04-28"' + ' }' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -922,6 +932,11 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "sdk_properties": {' + ' "version": "uploaded:2021-04-28"' + ' }' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -952,6 +967,11 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "sdk_properties": {' + ' "version": "uploaded:2021-04-28"' + ' }' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index f51ef23e1e..94f0621058 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,6 +183,13 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu + if platform == "win": + properties["$depot_tools/windows_sdk"] = { + "sdk_properties": { + "version": "uploaded:2021-04-28", + }, + } + if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 197d037cfd2af493e93ac6d661f50a179416cac0 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Thu, 4 Nov 2021 23:40:05 +0000 Subject: [PATCH 36/69] Revert "Reland "Bump Windows SDK to 10.0.19041.0"" Infra failures continue: https://ci.chromium.org/ui/p/crashpad/builders/try/crashpad_win_x64_rel/114/overview This reverts commit 44f566832da48b25c09ee83d4221a9c57f359a82. Reason for revert: Original change's description: > Reland "Bump Windows SDK to 10.0.19041.0" > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > Original change's description: > > Bump Windows SDK to 10.0.19041.0 > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > Reviewed-by: Mark Mentovai > > Commit-Queue: Mark Mentovai > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > Commit-Queue: Alex Gough > Reviewed-by: Mark Mentovai Change-Id: I4b0629bccdb7586146f1775d20bfdc7d66348d2c No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260756 Bot-Commit: Rubber Stamper Reviewed-by: Mark Mentovai Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 20 -------------------- infra/config/main.star | 7 ------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/DEPS b/DEPS index 8a6ee243c0..8ecd52e3b8 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2021-04-28' + 'version': 'uploaded:2018-06-13' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 0eb8c621d8..d34621cdf0 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,11 +450,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "sdk_properties": {' - ' "version": "uploaded:2021-04-28"' - ' }' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -488,11 +483,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "sdk_properties": {' - ' "version": "uploaded:2021-04-28"' - ' }' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -932,11 +922,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "sdk_properties": {' - ' "version": "uploaded:2021-04-28"' - ' }' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -967,11 +952,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "sdk_properties": {' - ' "version": "uploaded:2021-04-28"' - ' }' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index 94f0621058..f51ef23e1e 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,13 +183,6 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu - if platform == "win": - properties["$depot_tools/windows_sdk"] = { - "sdk_properties": { - "version": "uploaded:2021-04-28", - }, - } - if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 717b3c9e7bbe845576f2b8f18ba2ef53d5777ebd Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 4 Nov 2021 15:32:12 -0400 Subject: [PATCH 37/69] ios: Fix incorrect type in IOSIntermediateDumpReader::Parse. size_t is written to intermediate dump properties, but the parser was reading off_t. off_t can go negative, which is a bad thing to pass to a std::vector constructor. Bug: crashpad:31 Change-Id: I52ebda0b29ece50d6d1cbc9064a70b2e221a4df1 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3261749 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- util/ios/ios_intermediate_dump_reader.cc | 2 +- util/ios/ios_intermediate_dump_reader_test.cc | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/util/ios/ios_intermediate_dump_reader.cc b/util/ios/ios_intermediate_dump_reader.cc index b571662d87..853d92cd17 100644 --- a/util/ios/ios_intermediate_dump_reader.cc +++ b/util/ios/ios_intermediate_dump_reader.cc @@ -142,7 +142,7 @@ bool IOSIntermediateDumpReader::Parse(FileReaderInterface* reader, if (key == IntermediateDumpKey::kInvalid) return false; - off_t value_length; + size_t value_length; if (!reader->ReadExactly(&value_length, sizeof(value_length))) { return false; } diff --git a/util/ios/ios_intermediate_dump_reader_test.cc b/util/ios/ios_intermediate_dump_reader_test.cc index ae27f7d80a..6892120898 100644 --- a/util/ios/ios_intermediate_dump_reader_test.cc +++ b/util/ios/ios_intermediate_dump_reader_test.cc @@ -96,6 +96,32 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadHelloWorld) { EXPECT_TRUE(root_map->empty()); } +TEST_F(IOSIntermediateDumpReaderTest, FuzzTestCases) { + constexpr uint8_t fuzz1[] = {0x6, + 0x5, + 0x0, + 0xff, + 0xff, + 0xfd, + 0x1, + 0xff, + 0xff, + 0xff, + 0xff, + 0xff, + 0xfd, + 0x1, + 0x7, + 0x16}; + EXPECT_TRUE(LoggingWriteFile(fd(), &fuzz1, sizeof(fuzz1))); + internal::IOSIntermediateDumpReader reader; + EXPECT_TRUE(reader.Initialize(path())); + EXPECT_FALSE(IsRegularFile(path())); + + const auto root_map = reader.RootMap(); + EXPECT_TRUE(root_map->empty()); +} + TEST_F(IOSIntermediateDumpReaderTest, WriteBadPropertyDataLength) { internal::IOSIntermediateDumpReader reader; IOSIntermediateDumpWriter::CommandType command_type = From 3dc913b12b4853ef620495a74081dd15fca8dc5e Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Thu, 4 Nov 2021 17:19:16 -0700 Subject: [PATCH 38/69] Reland "Reland "Bump Windows SDK to 10.0.19041.0"" This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 The proper format for this sort of property is: properties["$depot_tools/windows_sdk"] = { "version": "uploaded:2021-04-28", } rather than the nested version we had before. Original change's description: > Reland "Bump Windows SDK to 10.0.19041.0" > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > Original change's description: > > Bump Windows SDK to 10.0.19041.0 > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > Reviewed-by: Mark Mentovai > > Commit-Queue: Mark Mentovai > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > Commit-Queue: Alex Gough > Reviewed-by: Mark Mentovai Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 Commit-Queue: Alex Gough Reviewed-by: Mark Mentovai --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ++++++++++++ infra/config/main.star | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 8ecd52e3b8..8a6ee243c0 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index d34621cdf0..80e52d73a4 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,6 +450,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -483,6 +486,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -922,6 +928,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -952,6 +961,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index f51ef23e1e..e0582e6d41 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,6 +183,11 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu + if platform == "win": + properties["$depot_tools/windows_sdk"] = { + "version": "uploaded:2021-04-28", + } + if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 5225da1232af1569e8650c77ee11f48ffd1184f3 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Fri, 5 Nov 2021 03:27:47 +0000 Subject: [PATCH 39/69] Revert "Reland "Reland "Bump Windows SDK to 10.0.19041.0""" This reverts commit 3dc913b12b4853ef620495a74081dd15fca8dc5e. Reason for revert: while the SDK is now being fetched, the step Read SetEnv.platform.json is now failing. https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8831436994854248129/+/u/read_SetEnv.x86.json/stdout Original change's description: > Reland "Reland "Bump Windows SDK to 10.0.19041.0"" > > This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 > > The proper format for this sort of property is: > > properties["$depot_tools/windows_sdk"] = { > "version": "uploaded:2021-04-28", > } > > rather than the nested version we had before. > > Original change's description: > > Reland "Bump Windows SDK to 10.0.19041.0" > > > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > > > Original change's description: > > > Bump Windows SDK to 10.0.19041.0 > > > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > > Reviewed-by: Mark Mentovai > > > Commit-Queue: Mark Mentovai > > > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > > Commit-Queue: Alex Gough > > Reviewed-by: Mark Mentovai > > Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 > Commit-Queue: Alex Gough > Reviewed-by: Mark Mentovai Change-Id: If7d29c2d95491eb7df23b21383deef7a85f9192f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260758 Bot-Commit: Rubber Stamper Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ------------ infra/config/main.star | 5 ----- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/DEPS b/DEPS index 8a6ee243c0..8ecd52e3b8 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2021-04-28' + 'version': 'uploaded:2018-06-13' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 80e52d73a4..d34621cdf0 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,9 +450,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -486,9 +483,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -928,9 +922,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -961,9 +952,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index e0582e6d41..f51ef23e1e 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,11 +183,6 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu - if platform == "win": - properties["$depot_tools/windows_sdk"] = { - "version": "uploaded:2021-04-28", - } - if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 4bf79bc2bfb1ae3098f792fb9f7ccb0d5a4e726c Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Fri, 5 Nov 2021 15:23:47 -0400 Subject: [PATCH 40/69] ios: Fix typo in checking thread_times values. Change-Id: I4199b5b149d7792dcfb8a3b8de571026b1e98521 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3264806 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- snapshot/BUILD.gn | 13 ++++++++++++- .../ios/process_snapshot_ios_intermediate_dump.cc | 4 ++-- ...process_snapshot_ios_intermediate_dump_test.cc | 10 ++++++++++ ...crash-1fa088dda0adb41459d063078a0f384a0bb8eefa | Bin 0 -> 565 bytes 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 snapshot/ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index b0158194e7..fc2246a586 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -444,7 +444,10 @@ source_set("snapshot_test") { } if (crashpad_is_ios) { - deps += [ "../minidump" ] + deps += [ + ":snapshot_test_ios_data", + "../minidump", + ] } data_deps = [ @@ -485,6 +488,14 @@ source_set("snapshot_test") { } } +bundle_data("snapshot_test_ios_data") { + testonly = true + + sources = [ "ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa" ] + + outputs = [ "{{bundle_resources_dir}}/crashpad_test_data/" + + "{{source_root_relative_dir}}/{{source_file_part}}" ] +} crashpad_loadable_module("crashpad_snapshot_test_module") { testonly = true sources = [ "crashpad_info_client_options_test_module.cc" ] diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc index 7f0220020d..619ea95829 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc @@ -77,9 +77,9 @@ bool ProcessSnapshotIOSIntermediateDump::Initialize( const IOSIntermediateDumpMap* thread_times = process_info->GetAsMap(Key::kTaskThreadTimes); if (thread_times) { - GetDataValueFromMap(basic_info, Key::kUserTime, &thread_times_user_time_); + GetDataValueFromMap(thread_times, Key::kUserTime, &thread_times_user_time_); GetDataValueFromMap( - basic_info, Key::kSystemTime, &thread_times_system_time_); + thread_times, Key::kSystemTime, &thread_times_system_time_); } GetDataValueFromMap(process_info, Key::kSnapshotTime, &snapshot_time_); diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc index 1796c76c9f..dc3ad272d4 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc @@ -25,6 +25,7 @@ #include "minidump/minidump_file_writer.h" #include "test/errors.h" #include "test/scoped_temp_dir.h" +#include "test/test_paths.h" #include "util/file/file_io.h" #include "util/file/filesystem.h" #include "util/file/string_file.h" @@ -630,6 +631,15 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FullReport) { ExpectSnapshot(process_snapshot); } +TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FuzzTestCases) { + base::FilePath fuzz_path = TestPaths::TestDataRoot().Append(FILE_PATH_LITERAL( + "snapshot/ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa")); + + crashpad::internal::ProcessSnapshotIOSIntermediateDump process_snapshot; + EXPECT_TRUE(process_snapshot.Initialize(fuzz_path, {})); + EXPECT_TRUE(LoggingRemoveFile(path())); +} + } // namespace } // namespace test } // namespace crashpad diff --git a/snapshot/ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa b/snapshot/ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa new file mode 100644 index 0000000000000000000000000000000000000000..6f062a744bc5e3733ee0f98c7df193169a052eab GIT binary patch literal 565 zcmZQ$Wn^GvfB;6u1^lc__ywTcO%APzP$r0CVqC`0x`LkrN$7qQ8w2Zd6roLtObkp+ zj2*(P{lZdErJ4T03c;DVr8$Wu`9%sEnE@I3d8vj*I>wr;lZ08Iiui#v>tr|=B+5Dg zl{-bvE3jFGZpZtTW+Uy@kxc&}A+VXJjpxhlLzSA8Uy?3b#TW=0d|vGqCr2z&>X! t7GDANmOKL_;$hx=F;#cx_j(2f4T!u>+kYTu0aWn7ElCBSZ|WJqssS8Ga0LJW literal 0 HcmV?d00001 From d4bdb997a6605125909efab3e0e11e7cdf41cb64 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Wed, 10 Nov 2021 13:04:10 -0500 Subject: [PATCH 41/69] ios: Store Crashpad client annotations in the intermediate dump. The iOS crashpad client was mistakenly setting the process annotations (typically things like version and product name) when converting the intermediate dump into a minidump. This is incorrect, as those annotations are determined at intermediate dump creation time. Instead, correctly write those annotations during intermediate dump creation. Passing extra annotations during intermediate dump to minidump is still supported. Bug: crashpad: 31 Change-Id: Ic5e29debdc123011d130f75a48345071575466d9 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3266127 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/ios_handler/in_process_handler.cc | 37 +++++++------------ client/ios_handler/in_process_handler.h | 4 +- .../in_process_intermediate_dump_handler.cc | 21 ++++++++++- .../in_process_intermediate_dump_handler.h | 7 +++- ..._process_intermediate_dump_handler_test.cc | 6 ++- .../process_snapshot_ios_intermediate_dump.cc | 15 ++++++++ test/ios/crash_type_xctest.mm | 27 ++++++++++++++ test/ios/host/cptest_application_delegate.mm | 33 ++++++++++++++++- test/ios/host/cptest_shared_object.h | 4 ++ 9 files changed, 122 insertions(+), 32 deletions(-) diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 0b4c4b74db..6e440beffd 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -114,7 +114,7 @@ void InProcessHandler::DumpExceptionFromSignal( ucontext_t* context) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); { - ScopedReport report(writer_.get(), system_data); + ScopedReport report(writer_.get(), system_data, annotations_); InProcessIntermediateDumpHandler::WriteExceptionFromSignal( writer_.get(), system_data, siginfo, context); } @@ -133,7 +133,7 @@ void InProcessHandler::DumpExceptionFromMachException( mach_msg_type_number_t old_state_count) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); { - ScopedReport report(writer_.get(), system_data); + ScopedReport report(writer_.get(), system_data, annotations_); InProcessIntermediateDumpHandler::WriteExceptionFromMachException( writer_.get(), behavior, @@ -153,7 +153,8 @@ void InProcessHandler::DumpExceptionFromNSExceptionFrames( const uint64_t* frames, const size_t num_frames) { { - ScopedReport report(writer_.get(), system_data, frames, num_frames); + ScopedReport report( + writer_.get(), system_data, annotations_, frames, num_frames); InProcessIntermediateDumpHandler::WriteExceptionFromNSException( writer_.get()); } @@ -161,24 +162,22 @@ void InProcessHandler::DumpExceptionFromNSExceptionFrames( } void InProcessHandler::ProcessIntermediateDumps( - const std::map& extra_annotations) { + const std::map& annotations) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); - std::map annotations(annotations_); - annotations.insert(extra_annotations.begin(), extra_annotations.end()); - for (auto& file : PendingFiles()) - ProcessIntermediateDumpWithCompleteAnnotations(file, annotations); + ProcessIntermediateDump(file, annotations); } void InProcessHandler::ProcessIntermediateDump( const base::FilePath& file, - const std::map& extra_annotations) { + const std::map& annotations) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); - std::map annotations(annotations_); - annotations.insert(extra_annotations.begin(), extra_annotations.end()); - ProcessIntermediateDumpWithCompleteAnnotations(file, annotations); + ProcessSnapshotIOSIntermediateDump process_snapshot; + if (process_snapshot.Initialize(file, annotations)) { + SaveSnapshot(process_snapshot); + } } void InProcessHandler::StartProcessingPendingReports() { @@ -188,17 +187,6 @@ void InProcessHandler::StartProcessingPendingReports() { } } -void InProcessHandler::ProcessIntermediateDumpWithCompleteAnnotations( - const base::FilePath& file, - const std::map& annotations) { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - - ProcessSnapshotIOSIntermediateDump process_snapshot; - if (process_snapshot.Initialize(file, annotations)) { - SaveSnapshot(process_snapshot); - } -} - void InProcessHandler::SaveSnapshot( ProcessSnapshotIOSIntermediateDump& process_snapshot) { std::unique_ptr new_report; @@ -293,11 +281,12 @@ InProcessHandler::ScopedAlternateWriter::~ScopedAlternateWriter() { InProcessHandler::ScopedReport::ScopedReport( IOSIntermediateDumpWriter* writer, const IOSSystemDataCollector& system_data, + const std::map& annotations, const uint64_t* frames, const size_t num_frames) : rootMap_(writer) { InProcessIntermediateDumpHandler::WriteHeader(writer); - InProcessIntermediateDumpHandler::WriteProcessInfo(writer); + InProcessIntermediateDumpHandler::WriteProcessInfo(writer, annotations); InProcessIntermediateDumpHandler::WriteSystemInfo(writer, system_data); InProcessIntermediateDumpHandler::WriteThreadInfo(writer, frames, num_frames); InProcessIntermediateDumpHandler::WriteModuleInfo(writer); diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index 1e6ebc4b2a..888337b959 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -156,6 +156,7 @@ class InProcessHandler { public: ScopedReport(IOSIntermediateDumpWriter* writer, const IOSSystemDataCollector& system_data, + const std::map& annotations, const uint64_t* frames = nullptr, const size_t num_frames = 0); ~ScopedReport() {} @@ -178,9 +179,6 @@ class InProcessHandler { open_new_file_after_report_ = open_new_file_after_report; } - void ProcessIntermediateDumpWithCompleteAnnotations( - const base::FilePath& file, - const std::map& annotations); void SaveSnapshot(ProcessSnapshotIOSIntermediateDump& process_snapshot); std::vector PendingFiles(); bool OpenNewFile(); diff --git a/client/ios_handler/in_process_intermediate_dump_handler.cc b/client/ios_handler/in_process_intermediate_dump_handler.cc index e2c77223e7..12dcf2b49f 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler.cc @@ -582,7 +582,8 @@ void InProcessIntermediateDumpHandler::WriteHeader( // static void InProcessIntermediateDumpHandler::WriteProcessInfo( - IOSIntermediateDumpWriter* writer) { + IOSIntermediateDumpWriter* writer, + const std::map& annotations) { IOSIntermediateDumpWriter::ScopedMap process_map( writer, IntermediateDumpKey::kProcessInfo); @@ -647,6 +648,24 @@ void InProcessIntermediateDumpHandler::WriteProcessInfo( } else { CRASHPAD_RAW_LOG("task_info task_basic_info"); } + + if (!annotations.empty()) { + IOSIntermediateDumpWriter::ScopedArray simple_annotations_array( + writer, IntermediateDumpKey::kAnnotationsSimpleMap); + for (const auto& annotation_pair : annotations) { + const std::string& key = annotation_pair.first; + const std::string& value = annotation_pair.second; + IOSIntermediateDumpWriter::ScopedArrayMap annotation_map(writer); + WriteProperty(writer, + IntermediateDumpKey::kAnnotationName, + key.c_str(), + key.length()); + WriteProperty(writer, + IntermediateDumpKey::kAnnotationValue, + value.c_str(), + value.length()); + } + } } // static diff --git a/client/ios_handler/in_process_intermediate_dump_handler.h b/client/ios_handler/in_process_intermediate_dump_handler.h index 6281563006..f6db28d510 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.h +++ b/client/ios_handler/in_process_intermediate_dump_handler.h @@ -20,6 +20,8 @@ #include #include +#include + #include "client/crashpad_info.h" #include "util/ios/ios_intermediate_dump_writer.h" #include "util/ios/ios_system_data_collector.h" @@ -46,7 +48,10 @@ class InProcessIntermediateDumpHandler final { //! \brief Write ProcessSnapshot data to the intermediate dump. //! //! \param[in] writer The dump writer - static void WriteProcessInfo(IOSIntermediateDumpWriter* writer); + //! \param[in] annotations The simple map annotations. + static void WriteProcessInfo( + IOSIntermediateDumpWriter* writer, + const std::map& annotations); //! \brief Write SystemSnapshot data to the intermediate dump. //! diff --git a/client/ios_handler/in_process_intermediate_dump_handler_test.cc b/client/ios_handler/in_process_intermediate_dump_handler_test.cc index 9616ce75e5..26c40c0b71 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler_test.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler_test.cc @@ -55,7 +55,8 @@ class InProcessIntermediateDumpHandlerTest : public testing::Test { void WriteReport() { internal::IOSIntermediateDumpWriter::ScopedRootMap rootMap(writer_.get()); InProcessIntermediateDumpHandler::WriteHeader(writer_.get()); - InProcessIntermediateDumpHandler::WriteProcessInfo(writer_.get()); + InProcessIntermediateDumpHandler::WriteProcessInfo( + writer_.get(), {{"before_dump", "pre"}}); InProcessIntermediateDumpHandler::WriteSystemInfo(writer_.get(), system_data_); InProcessIntermediateDumpHandler::WriteThreadInfo(writer_.get(), 0, 0); @@ -147,7 +148,8 @@ TEST_F(InProcessIntermediateDumpHandlerTest, TestAnnotations) { ASSERT_TRUE(process_snapshot.Initialize(path(), {{"after_dump", "post"}})); auto process_map = process_snapshot.AnnotationsSimpleMap(); - EXPECT_EQ(process_map.size(), 1u); + EXPECT_EQ(process_map.size(), 2u); + EXPECT_EQ(process_map["before_dump"], "pre"); EXPECT_EQ(process_map["after_dump"], "post"); std::map all_annotations_simple_map; diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc index 619ea95829..f4769ff657 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc @@ -84,6 +84,21 @@ bool ProcessSnapshotIOSIntermediateDump::Initialize( GetDataValueFromMap(process_info, Key::kSnapshotTime, &snapshot_time_); + const IOSIntermediateDumpList* simple_map_dump = + process_info->GetAsList(IntermediateDumpKey::kAnnotationsSimpleMap); + if (simple_map_dump) { + for (auto& annotation : *simple_map_dump) { + const IOSIntermediateDumpData* name_dump = + annotation->GetAsData(IntermediateDumpKey::kAnnotationName); + const IOSIntermediateDumpData* value_dump = + annotation->GetAsData(IntermediateDumpKey::kAnnotationValue); + if (name_dump && value_dump) { + annotations_simple_map_.insert( + make_pair(name_dump->GetString(), value_dump->GetString())); + } + } + } + const IOSIntermediateDumpMap* system_info = GetMapFromMap(root_map, Key::kSystemInfo); if (!system_info) { diff --git a/test/ios/crash_type_xctest.mm b/test/ios/crash_type_xctest.mm index b4b22cb520..c931796549 100644 --- a/test/ios/crash_type_xctest.mm +++ b/test/ios/crash_type_xctest.mm @@ -184,6 +184,33 @@ - (void)testRecursion { [self verifyCrashReportException:SIGHUP]; } +- (void)testClientAnnotations { + [rootObject_ crashKillAbort]; + + // Set app launch args to trigger different client annotations. + NSArray* old_args = app_.launchArguments; + app_.launchArguments = @[ @"--alternate-client-annotations" ]; + [self verifyCrashReportException:SIGABRT]; + app_.launchArguments = old_args; + + // Confirm the initial crash took the standard annotations. + NSDictionary* dict = [rootObject_ getProcessAnnotations]; + XCTAssertTrue([dict[@"crashpad"] isEqualToString:@"yes"]); + XCTAssertTrue([dict[@"plat"] isEqualToString:@"iOS"]); + XCTAssertTrue([dict[@"prod"] isEqualToString:@"xcuitest"]); + XCTAssertTrue([dict[@"ver"] isEqualToString:@"1"]); + + // Confirm passing alternate client annotation args works. + [rootObject_ clearPendingReports]; + [rootObject_ crashKillAbort]; + [self verifyCrashReportException:SIGABRT]; + dict = [rootObject_ getProcessAnnotations]; + XCTAssertTrue([dict[@"crashpad"] isEqualToString:@"no"]); + XCTAssertTrue([dict[@"plat"] isEqualToString:@"macOS"]); + XCTAssertTrue([dict[@"prod"] isEqualToString:@"some_app"]); + XCTAssertTrue([dict[@"ver"] isEqualToString:@"42"]); +} + - (void)testCrashWithCrashInfoMessage { if (@available(iOS 15.0, *)) { // Figure out how to test this on iOS15. diff --git a/test/ios/host/cptest_application_delegate.mm b/test/ios/host/cptest_application_delegate.mm index 6216257a6a..6ff8378ac4 100644 --- a/test/ios/host/cptest_application_delegate.mm +++ b/test/ios/host/cptest_application_delegate.mm @@ -92,7 +92,18 @@ @implementation CPTestApplicationDelegate { - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { // Start up crashpad. - if (client_.StartCrashpadInProcessHandler(GetDatabaseDir(), "", {})) { + std::map annotations = { + {"prod", "xcuitest"}, {"ver", "1"}, {"plat", "iOS"}, {"crashpad", "yes"}}; + + NSArray* arguments = [[NSProcessInfo processInfo] arguments]; + if ([arguments containsObject:@"--alternate-client-annotations"]) { + annotations = {{"prod", "some_app"}, + {"ver", "42"}, + {"plat", "macOS"}, + {"crashpad", "no"}}; + } + if (client_.StartCrashpadInProcessHandler( + GetDatabaseDir(), "", annotations)) { client_.ProcessIntermediateDumps(); } @@ -203,6 +214,26 @@ - (NSDictionary*)getAnnotations { return [dict passByValue]; } +- (NSDictionary*)getProcessAnnotations { + std::vector pending_reports; + OperationStatus status = GetPendingReports(&pending_reports); + if (status != crashpad::CrashReportDatabase::kNoError || + pending_reports.size() != 1) { + return @{}; + } + + auto reader = std::make_unique(); + reader->Open(pending_reports[0].file_path); + crashpad::ProcessSnapshotMinidump process_snapshot; + process_snapshot.Initialize(reader.get()); + NSDictionary* dict = [@{} mutableCopy]; + for (const auto& kv : process_snapshot.AnnotationsSimpleMap()) { + [dict setValue:@(kv.second.c_str()) forKey:@(kv.first.c_str())]; + } + + return [dict passByValue]; +} + - (void)crashBadAccess { strcpy(nullptr, "bla"); } diff --git a/test/ios/host/cptest_shared_object.h b/test/ios/host/cptest_shared_object.h index e75849b319..4a781933d3 100644 --- a/test/ios/host/cptest_shared_object.h +++ b/test/ios/host/cptest_shared_object.h @@ -42,6 +42,10 @@ // (strings only) respectively. - (NSDictionary*)getAnnotations; +// Return an NSDictionary representing the ProcessSnapshotMinidump +// AnnotationsSimpleMap. +- (NSDictionary*)getProcessAnnotations; + // Triggers an EXC_BAD_ACCESS exception and crash. - (void)crashBadAccess; From 8342e6bd613a5b2e44eca1d74288e3115ccef139 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 10 Nov 2021 15:56:37 -0500 Subject: [PATCH 42/69] mac/ios: Restore NSInputStream-backed HTTP transport reader. This effectively reverts f0ee5f0efee651ab82aa854761f107193b3db5de, but updates the subclass with the new required NSStream methods. Crashpad switched to using CFReadStream because NSInputStream required overriding two private methods of NSInputStream in order to use it with NSURLConnection. With Mac OS X 10.11 (the earliest that Chromium supports), this is no longer the case. On iOS, using the private CFReadStreamCreate() API is not permissible. Switch back to using a custom NSInputStream subclass instead. Bug: crashpad:382 Change-Id: I92b1260f49c6fa6c304475f7dc9b27ae1a5f35c4 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3271448 Commit-Queue: Robert Sesek Reviewed-by: Mark Mentovai --- third_party/apple_cf/APPLE_LICENSE | 335 ------------------------ third_party/apple_cf/BUILD.gn | 17 -- third_party/apple_cf/CFStreamAbstract.h | 212 --------------- third_party/apple_cf/README.crashpad | 15 -- util/BUILD.gn | 1 - util/net/http_transport_mac.mm | 214 +++++++-------- 6 files changed, 96 insertions(+), 698 deletions(-) delete mode 100644 third_party/apple_cf/APPLE_LICENSE delete mode 100644 third_party/apple_cf/BUILD.gn delete mode 100644 third_party/apple_cf/CFStreamAbstract.h delete mode 100644 third_party/apple_cf/README.crashpad diff --git a/third_party/apple_cf/APPLE_LICENSE b/third_party/apple_cf/APPLE_LICENSE deleted file mode 100644 index 71fe6fd79c..0000000000 --- a/third_party/apple_cf/APPLE_LICENSE +++ /dev/null @@ -1,335 +0,0 @@ -APPLE PUBLIC SOURCE LICENSE -Version 2.0 - August 6, 2003 - -Please read this License carefully before downloading this software. By -downloading or using this software, you are agreeing to be bound by the terms -of this License. If you do not or cannot agree to the terms of this License, -please do not download or use the software. - -Apple Note: In January 2007, Apple changed its corporate name from "Apple -Computer, Inc." to "Apple Inc." This change has been reflected below and -copyright years updated, but no other changes have been made to the APSL 2.0. - -1. General; Definitions. This License applies to any program or other -work which Apple Inc. ("Apple") makes publicly available and which contains a -notice placed by Apple identifying such program or work as "Original Code" and -stating that it is subject to the terms of this Apple Public Source License -version 2.0 ("License"). As used in this License: - -1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is the -grantor of rights, (i) claims of patents that are now or hereafter acquired, -owned by or assigned to Apple and (ii) that cover subject matter contained in -the Original Code, but only to the extent necessary to use, reproduce and/or -distribute the Original Code without infringement; and (b) in the case where -You are the grantor of rights, (i) claims of patents that are now or hereafter -acquired, owned by or assigned to You and (ii) that cover subject matter in -Your Modifications, taken alone or in combination with Original Code. - -1.2 "Contributor" means any person or entity that creates or contributes to -the creation of Modifications. - -1.3 "Covered Code" means the Original Code, Modifications, the combination -of Original Code and any Modifications, and/or any respective portions thereof. - -1.4 "Externally Deploy" means: (a) to sublicense, distribute or otherwise -make Covered Code available, directly or indirectly, to anyone other than You; -and/or (b) to use Covered Code, alone or as part of a Larger Work, in any way -to provide a service, including but not limited to delivery of content, through -electronic communication with a client other than You. - -1.5 "Larger Work" means a work which combines Covered Code or portions -thereof with code not governed by the terms of this License. - -1.6 "Modifications" mean any addition to, deletion from, and/or change to, -the substance and/or structure of the Original Code, any previous -Modifications, the combination of Original Code and any previous Modifications, -and/or any respective portions thereof. When code is released as a series of -files, a Modification is: (a) any addition to or deletion from the contents of -a file containing Covered Code; and/or (b) any new file or other representation -of computer program statements that contains any part of Covered Code. - -1.7 "Original Code" means (a) the Source Code of a program or other work as -originally made available by Apple under this License, including the Source -Code of any updates or upgrades to such programs or works made available by -Apple under this License, and that has been expressly identified by Apple as -such in the header file(s) of such work; and (b) the object code compiled from -such Source Code and originally made available by Apple under this License - -1.8 "Source Code" means the human readable form of a program or other work -that is suitable for making modifications to it, including all modules it -contains, plus any associated interface definition files, scripts used to -control compilation and installation of an executable (object code). - -1.9 "You" or "Your" means an individual or a legal entity exercising rights -under this License. For legal entities, "You" or "Your" includes any entity -which controls, is controlled by, or is under common control with, You, where -"control" means (a) the power, direct or indirect, to cause the direction or -management of such entity, whether by contract or otherwise, or (b) ownership -of fifty percent (50%) or more of the outstanding shares or beneficial -ownership of such entity. - -2. Permitted Uses; Conditions & Restrictions. Subject to the terms and -conditions of this License, Apple hereby grants You, effective on the date You -accept this License and download the Original Code, a world-wide, royalty-free, -non-exclusive license, to the extent of Apple's Applicable Patent Rights and -copyrights covering the Original Code, to do the following: - -2.1 Unmodified Code. You may use, reproduce, display, perform, internally -distribute within Your organization, and Externally Deploy verbatim, unmodified -copies of the Original Code, for commercial or non-commercial purposes, -provided that in each instance: - -(a) You must retain and reproduce in all copies of Original Code the -copyright and other proprietary notices and disclaimers of Apple as they appear -in the Original Code, and keep intact all notices in the Original Code that -refer to this License; and - -(b) You must include a copy of this License with every copy of Source Code -of Covered Code and documentation You distribute or Externally Deploy, and You -may not offer or impose any terms on such Source Code that alter or restrict -this License or the recipients' rights hereunder, except as permitted under -Section 6. - -2.2 Modified Code. You may modify Covered Code and use, reproduce, -display, perform, internally distribute within Your organization, and -Externally Deploy Your Modifications and Covered Code, for commercial or -non-commercial purposes, provided that in each instance You also meet all of -these conditions: - -(a) You must satisfy all the conditions of Section 2.1 with respect to the -Source Code of the Covered Code; - -(b) You must duplicate, to the extent it does not already exist, the notice -in Exhibit A in each file of the Source Code of all Your Modifications, and -cause the modified files to carry prominent notices stating that You changed -the files and the date of any change; and - -(c) If You Externally Deploy Your Modifications, You must make Source Code -of all Your Externally Deployed Modifications either available to those to whom -You have Externally Deployed Your Modifications, or publicly available. Source -Code of Your Externally Deployed Modifications must be released under the terms -set forth in this License, including the license grants set forth in Section 3 -below, for as long as you Externally Deploy the Covered Code or twelve (12) -months from the date of initial External Deployment, whichever is longer. You -should preferably distribute the Source Code of Your Externally Deployed -Modifications electronically (e.g. download from a web site). - -2.3 Distribution of Executable Versions. In addition, if You Externally -Deploy Covered Code (Original Code and/or Modifications) in object code, -executable form only, You must include a prominent notice, in the code itself -as well as in related documentation, stating that Source Code of the Covered -Code is available under the terms of this License with information on how and -where to obtain such Source Code. - -2.4 Third Party Rights. You expressly acknowledge and agree that although -Apple and each Contributor grants the licenses to their respective portions of -the Covered Code set forth herein, no assurances are provided by Apple or any -Contributor that the Covered Code does not infringe the patent or other -intellectual property rights of any other entity. Apple and each Contributor -disclaim any liability to You for claims brought by any other entity based on -infringement of intellectual property rights or otherwise. As a condition to -exercising the rights and licenses granted hereunder, You hereby assume sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow You to -distribute the Covered Code, it is Your responsibility to acquire that license -before distributing the Covered Code. - -3. Your Grants. In consideration of, and as a condition to, the licenses -granted to You under this License, You hereby grant to any person or entity -receiving or distributing Covered Code under this License a non-exclusive, -royalty-free, perpetual, irrevocable license, under Your Applicable Patent -Rights and other intellectual property rights (other than patent) owned or -controlled by You, to use, reproduce, display, perform, modify, sublicense, -distribute and Externally Deploy Your Modifications of the same scope and -extent as Apple's licenses under Sections 2.1 and 2.2 above. - -4. Larger Works. You may create a Larger Work by combining Covered Code -with other code not governed by the terms of this License and distribute the -Larger Work as a single product. In each such instance, You must make sure the -requirements of this License are fulfilled for the Covered Code or any portion -thereof. - -5. Limitations on Patent License. Except as expressly stated in Section -2, no other patent rights, express or implied, are granted by Apple herein. -Modifications and/or Larger Works may require additional patent licenses from -Apple which Apple may grant in its sole discretion. - -6. Additional Terms. You may choose to offer, and to charge a fee for, -warranty, support, indemnity or liability obligations and/or other rights -consistent with the scope of the license granted herein ("Additional Terms") to -one or more recipients of Covered Code. However, You may do so only on Your own -behalf and as Your sole responsibility, and not on behalf of Apple or any -Contributor. You must obtain the recipient's agreement that any such Additional -Terms are offered by You alone, and You hereby agree to indemnify, defend and -hold Apple and every Contributor harmless for any liability incurred by or -claims asserted against Apple or such Contributor by reason of any such -Additional Terms. - -7. Versions of the License. Apple may publish revised and/or new versions -of this License from time to time. Each version will be given a distinguishing -version number. Once Original Code has been published under a particular -version of this License, You may continue to use it under the terms of that -version. You may also choose to use such Original Code under the terms of any -subsequent version of this License published by Apple. No one other than Apple -has the right to modify the terms applicable to Covered Code created under this -License. - -8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in -part pre-release, untested, or not fully tested works. The Covered Code may -contain errors that could cause failures or loss of data, and may be incomplete -or contain inaccuracies. You expressly acknowledge and agree that use of the -Covered Code, or any portion thereof, is at Your sole and entire risk. THE -COVERED CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF -ANY KIND AND APPLE AND APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" -FOR THE PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM -ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY, OF -SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY, OF -QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. APPLE AND EACH -CONTRIBUTOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE -COVERED CODE, THAT THE FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR -REQUIREMENTS, THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR -ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO ORAL OR -WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE AUTHORIZED -REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. You acknowledge -that the Covered Code is not intended for use in the operation of nuclear -facilities, aircraft navigation, communication systems, or air traffic control -machines in which case the failure of the Covered Code could lead to death, -personal injury, or severe physical or environmental damage. - -9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO -EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL, -INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO THIS LICENSE OR -YOUR USE OR INABILITY TO USE THE COVERED CODE, OR ANY PORTION THEREOF, WHETHER -UNDER A THEORY OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCTS -LIABILITY OR OTHERWISE, EVEN IF APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL -PURPOSE OF ANY REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF -LIABILITY OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT -APPLY TO YOU. In no event shall Apple's total liability to You for all damages -(other than as may be required by applicable law) under this License exceed the -amount of fifty dollars ($50.00). - -10. Trademarks. This License does not grant any rights to use the -trademarks or trade names "Apple", "Mac", "Mac OS", "QuickTime", "QuickTime -Streaming Server" or any other trademarks, service marks, logos or trade names -belonging to Apple (collectively "Apple Marks") or to any trademark, service -mark, logo or trade name belonging to any Contributor. You agree not to use -any Apple Marks in or as part of the name of products derived from the Original -Code or to endorse or promote products derived from the Original Code other -than as expressly permitted by and in strict compliance at all times with -Apple's third party trademark usage guidelines which are posted at -http://www.apple.com/legal/guidelinesfor3rdparties.html. - -11. Ownership. Subject to the licenses granted under this License, each -Contributor retains all rights, title and interest in and to any Modifications -made by such Contributor. Apple retains all rights, title and interest in and -to the Original Code and any Modifications made by or on behalf of Apple -("Apple Modifications"), and such Apple Modifications will not be automatically -subject to this License. Apple may, at its sole discretion, choose to license -such Apple Modifications under this License, or on different terms from those -contained in this License or may choose not to license them at all. - -12. Termination. - -12.1 Termination. This License and the rights granted hereunder will -terminate: - -(a) automatically without notice from Apple if You fail to comply with any -term(s) of this License and fail to cure such breach within 30 days of becoming -aware of such breach; -(b) immediately in the event of the circumstances described in Section -13.5(b); or -(c) automatically without notice from Apple if You, at any time during the -term of this License, commence an action for patent infringement against Apple; -provided that Apple did not first commence an action for patent infringement -against You in that instance. - -12.2 Effect of Termination. Upon termination, You agree to immediately stop -any further use, reproduction, modification, sublicensing and distribution of -the Covered Code. All sublicenses to the Covered Code which have been properly -granted prior to termination shall survive any termination of this License. -Provisions which, by their nature, should remain in effect beyond the -termination of this License shall survive, including but not limited to -Sections 3, 5, 8, 9, 10, 11, 12.2 and 13. No party will be liable to any other -for compensation, indemnity or damages of any sort solely as a result of -terminating this License in accordance with its terms, and termination of this -License will be without prejudice to any other right or remedy of any party. - -13. Miscellaneous. - -13.1 Government End Users. The Covered Code is a "commercial item" as -defined in FAR 2.101. Government software and technical data rights in the -Covered Code include only those rights customarily provided to the public as -defined in this License. This customary commercial license in technical data -and software is provided in accordance with FAR 12.211 (Technical Data) and -12.212 (Computer Software) and, for Department of Defense purchases, DFAR -252.227-7015 (Technical Data -- Commercial Items) and 227.7202-3 (Rights in -Commercial Computer Software or Computer Software Documentation). Accordingly, -all U.S. Government End Users acquire Covered Code with only those rights set -forth herein. - -13.2 Relationship of Parties. This License will not be construed as -creating an agency, partnership, joint venture or any other form of legal -association between or among You, Apple or any Contributor, and You will not -represent to the contrary, whether expressly, by implication, appearance or -otherwise. - -13.3 Independent Development. Nothing in this License will impair Apple's -right to acquire, license, develop, have others develop for it, market and/or -distribute technology or products that perform the same or similar functions -as, or otherwise compete with, Modifications, Larger Works, technology or -products that You may develop, produce, market or distribute. - -13.4 Waiver; Construction. Failure by Apple or any Contributor to enforce -any provision of this License will not be deemed a waiver of future enforcement -of that or any other provision. Any law or regulation which provides that the -language of a contract shall be construed against the drafter will not apply to -this License. - -13.5 Severability. (a) If for any reason a court of competent jurisdiction -finds any provision of this License, or portion thereof, to be unenforceable, -that provision of the License will be enforced to the maximum extent -permissible so as to effect the economic benefits and intent of the parties, -and the remainder of this License will continue in full force and effect. (b) -Notwithstanding the foregoing, if applicable law prohibits or restricts You -from fully and/or specifically complying with Sections 2 and/or 3 or prevents -the enforceability of either of those Sections, this License will immediately -terminate and You must immediately discontinue any use of the Covered Code and -destroy all copies of it that are in your possession or control. - -13.6 Dispute Resolution. Any litigation or other dispute resolution between -You and Apple relating to this License shall take place in the Northern -District of California, and You and Apple hereby consent to the personal -jurisdiction of, and venue in, the state and federal courts within that -District with respect to this License. The application of the United Nations -Convention on Contracts for the International Sale of Goods is expressly -excluded. - -13.7 Entire Agreement; Governing Law. This License constitutes the entire -agreement between the parties with respect to the subject matter hereof. This -License shall be governed by the laws of the United States and the State of -California, except that body of California law concerning conflicts of law. - -Where You are located in the province of Quebec, Canada, the following clause -applies: The parties hereby confirm that they have requested that this License -and all related documents be drafted in English. Les parties ont exigé que le -présent contrat et tous les documents connexes soient rédigés en anglais. - -EXHIBIT A. - -"Portions Copyright (c) 1999-2007 Apple Inc. All Rights Reserved. - -This file contains Original Code and/or Modifications of Original Code as -defined in and that are subject to the Apple Public Source License Version 2.0 -(the 'License'). You may not use this file except in compliance with the -License. Please obtain a copy of the License at -http://www.opensource.apple.com/apsl/ and read it before using this file. - -The Original Code and all software distributed under the License are -distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS -OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT -LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the -specific language governing rights and limitations under the License." - diff --git a/third_party/apple_cf/BUILD.gn b/third_party/apple_cf/BUILD.gn deleted file mode 100644 index 9e37354d63..0000000000 --- a/third_party/apple_cf/BUILD.gn +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2019 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("apple_cf") { - sources = [ "CFStreamAbstract.h" ] -} diff --git a/third_party/apple_cf/CFStreamAbstract.h b/third_party/apple_cf/CFStreamAbstract.h deleted file mode 100644 index ac26664f18..0000000000 --- a/third_party/apple_cf/CFStreamAbstract.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStreamAbstract.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTREAMABSTRACT__) -#define __COREFOUNDATION_CFSTREAMABSTRACT__ 1 - -#include - -CF_EXTERN_C_BEGIN - -/* During a stream's lifetime, the open callback will be called once, followed by any number of openCompleted calls (until openCompleted returns TRUE). Then any number of read/canRead or write/canWrite calls, then a single close call. copyProperty can be called at any time. prepareAsynch will be called exactly once when the stream's client is first configured. - - Expected semantics: - - open reserves any system resources that are needed. The stream may start the process of opening, returning TRUE immediately and setting openComplete to FALSE. When the open completes, _CFStreamSignalEvent should be called passing kCFStreamOpenCompletedEvent. openComplete should be set to TRUE only if the open operation completed in its entirety. - - openCompleted will only be called after open has been called, but before any kCFStreamOpenCompletedEvent has been received. Return TRUE, setting error.code to 0, if the open operation has completed. Return TRUE, setting error to the correct error code and domain if the open operation completed, but failed. Return FALSE if the open operation is still in-progress. If your open ever fails to complete (i.e. sets openComplete to FALSE), you must be implement the openCompleted callback. - - read should read into the given buffer, returning the number of bytes successfully read. read must block until at least one byte is available, but should not block until the entire buffer is filled; zero should only be returned if end-of-stream is encountered. atEOF should be set to true if the EOF is encountered, false otherwise. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. - - getBuffer is an optimization to return an internal buffer of bytes read from the stream, and may return NULL. getBuffer itself may be NULL if the concrete implementation does not wish to provide an internal buffer. If implemented, it should set numBytesRead to the number of bytes available in the internal buffer (but should not exceed maxBytesToRead) and return a pointer to the base of the bytes. - - canRead will only be called once openCompleted reports that the stream has been successfully opened (or the initial open call succeeded). It should return whether there are bytes that can be read without blocking. - - write should write the bytes in the given buffer to the device, returning the number of bytes successfully written. write must block until at least one byte is written. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. - - close should close the device, releasing any reserved system resources. close cannot fail (it may be called to abort the stream), and may be called at any time after open has been called. It will only be called once. - - copyProperty should return the value for the given property, or NULL if none exists. Composite streams (streams built on top of other streams) should take care to call CFStreamCopyProperty on the base stream if they do not recognize the property given, to give the underlying stream a chance to respond. - - In all cases, errors returned by reference will be initialized to NULL by the caller, and if they are set to non-NULL, will - be released by the caller -*/ - -typedef struct { - CFIndex version; /* == 2 */ - - void *(*create)(CFReadStreamRef stream, void *info); - void (*finalize)(CFReadStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); - - Boolean (*open)(CFReadStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFErrorRef *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, CFErrorRef *error, void *info); - void (*close)(CFReadStreamRef stream, void *info); - - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - - void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacks; - -typedef struct { - CFIndex version; /* == 2 */ - - void *(*create)(CFWriteStreamRef stream, void *info); - void (*finalize)(CFWriteStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); - - Boolean (*open)(CFWriteStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFErrorRef *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, CFErrorRef *error, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - - void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacks; - -// Primitive creation mechanisms. -CF_EXPORT -CFReadStreamRef CFReadStreamCreate(CFAllocatorRef alloc, const CFReadStreamCallBacks *callbacks, void *info); -CF_EXPORT -CFWriteStreamRef CFWriteStreamCreate(CFAllocatorRef alloc, const CFWriteStreamCallBacks *callbacks, void *info); - -/* All the functions below can only be called when you are sure the stream in question was created via - CFReadStreamCreate() or CFWriteStreamCreate(), above. They are NOT safe for toll-free bridged objects, - so the caller must be sure the argument passed is not such an object. */ - -// To be called by the concrete stream implementation (the callbacks) when an event occurs. error may be NULL if event != kCFStreamEventErrorOccurred -// error should be a CFErrorRef if the callbacks are version 2 or later; otherwise it should be a (CFStreamError *). -CF_EXPORT -void CFReadStreamSignalEvent(CFReadStreamRef stream, CFStreamEventType event, const void *error); -CF_EXPORT -void CFWriteStreamSignalEvent(CFWriteStreamRef stream, CFStreamEventType event, const void *error); - -// These require that the stream allow the run loop to run once before delivering the event to its client. -// See the comment above CFRead/WriteStreamSignalEvent for interpretation of the error argument. -CF_EXPORT -void _CFReadStreamSignalEventDelayed(CFReadStreamRef stream, CFStreamEventType event, const void *error); -CF_EXPORT -void _CFWriteStreamSignalEventDelayed(CFWriteStreamRef stream, CFStreamEventType event, const void *error); - -CF_EXPORT -void _CFReadStreamClearEvent(CFReadStreamRef stream, CFStreamEventType event); -// Write variant not currently needed -//CF_EXPORT -//void _CFWriteStreamClearEvent(CFWriteStreamRef stream, CFStreamEventType event); - -// Convenience for concrete implementations to extract the info pointer given the stream. -CF_EXPORT -void *CFReadStreamGetInfoPointer(CFReadStreamRef stream); -CF_EXPORT -void *CFWriteStreamGetInfoPointer(CFWriteStreamRef stream); - -// Returns the client info pointer currently set on the stream. These should probably be made public one day. -CF_EXPORT -void *_CFReadStreamGetClient(CFReadStreamRef readStream); -CF_EXPORT -void *_CFWriteStreamGetClient(CFWriteStreamRef writeStream); - -// Returns an array of the runloops and modes on which the stream is currently scheduled -// Note that these are unretained mutable arrays - use the copy variant instead. -CF_EXPORT -CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream); -CF_EXPORT -CFArrayRef _CFWriteStreamGetRunLoopsAndModes(CFWriteStreamRef writeStream); - -// Returns an array of the runloops and modes on which the stream is currently scheduled -CF_EXPORT -CFArrayRef _CFReadStreamCopyRunLoopsAndModes(CFReadStreamRef readStream); -CF_EXPORT -CFArrayRef _CFWriteStreamCopyRunLoopsAndModes(CFWriteStreamRef writeStream); - -/* Deprecated versions; here for backwards compatibility. */ -typedef struct { - CFIndex version; /* == 1 */ - void *(*create)(CFReadStreamRef stream, void *info); - void (*finalize)(CFReadStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); - Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, void *info); - void (*close)(CFReadStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacksV1; - -typedef struct { - CFIndex version; /* == 1 */ - void *(*create)(CFWriteStreamRef stream, void *info); - void (*finalize)(CFWriteStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); - Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacksV1; - -typedef struct { - CFIndex version; /* == 0 */ - Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, void *info); - void (*close)(CFReadStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacksV0; - -typedef struct { - CFIndex version; /* == 0 */ - Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacksV0; - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTREAMABSTRACT__ */ diff --git a/third_party/apple_cf/README.crashpad b/third_party/apple_cf/README.crashpad deleted file mode 100644 index 20066484df..0000000000 --- a/third_party/apple_cf/README.crashpad +++ /dev/null @@ -1,15 +0,0 @@ -Name: Apple CF-Lite -Short Name: CF -URL: https://opensource.apple.com/source/CF/ -URL: https://opensource.apple.com/tarballs/CF/ -Version: 1153.18 (from OS X 10.10.3) -License: APSL 2.0 -License File: APPLE_LICENSE -Security Critical: no - -Description: -CF-Lite is an open-source version of the CoreFoundation framework. This -contains non-public but stable header files. - -Local Modifications: - - Only CFStreamAbstract.h is included. diff --git a/util/BUILD.gn b/util/BUILD.gn index 3e16b374e8..7983dfd84c 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -623,7 +623,6 @@ crashpad_static_library("util") { "Foundation.framework", "IOKit.framework", ] - deps += [ "../third_party/apple_cf:apple_cf" ] } if (crashpad_is_win) { diff --git a/util/net/http_transport_mac.mm b/util/net/http_transport_mac.mm index e1cfd2543f..50b9206880 100644 --- a/util/net/http_transport_mac.mm +++ b/util/net/http_transport_mac.mm @@ -14,7 +14,6 @@ #include "util/net/http_transport.h" -#include #import #include @@ -24,11 +23,104 @@ #include "base/strings/sys_string_conversions.h" #include "build/build_config.h" #include "package.h" -#include "third_party/apple_cf/CFStreamAbstract.h" #include "util/file/file_io.h" #include "util/misc/implicit_cast.h" #include "util/net/http_body.h" +// An implementation of NSInputStream that reads from a +// crashpad::HTTPBodyStream. +@interface CrashpadHTTPBodyStreamTransport : NSInputStream { + @private + NSStreamStatus _streamStatus; + id _delegate; + crashpad::HTTPBodyStream* _bodyStream; // weak +} +- (instancetype)initWithBodyStream:(crashpad::HTTPBodyStream*)bodyStream; +@end + +@implementation CrashpadHTTPBodyStreamTransport + +- (instancetype)initWithBodyStream:(crashpad::HTTPBodyStream*)bodyStream { + if ((self = [super init])) { + _streamStatus = NSStreamStatusNotOpen; + _bodyStream = bodyStream; + } + return self; +} + +// NSInputStream: + +- (BOOL)hasBytesAvailable { + // Per Apple's documentation: "May also return YES if a read must be attempted + // in order to determine the availability of bytes." + switch (_streamStatus) { + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + return NO; + default: + return YES; + } +} + +- (NSInteger)read:(uint8_t*)buffer maxLength:(NSUInteger)maxLen { + _streamStatus = NSStreamStatusReading; + + crashpad::FileOperationResult rv = + _bodyStream->GetBytesBuffer(buffer, maxLen); + + if (rv == 0) + _streamStatus = NSStreamStatusAtEnd; + else if (rv < 0) + _streamStatus = NSStreamStatusError; + else + _streamStatus = NSStreamStatusOpen; + + return rv; +} + +- (BOOL)getBuffer:(uint8_t**)buffer length:(NSUInteger*)length { + return NO; +} + +// NSStream: + +- (void)scheduleInRunLoop:(NSRunLoop*)runLoop forMode:(NSString*)mode { +} + +- (void)removeFromRunLoop:(NSRunLoop*)runLoop forMode:(NSString*)mode { +} + +- (void)open { + _streamStatus = NSStreamStatusOpen; +} + +- (void)close { + _streamStatus = NSStreamStatusClosed; +} + +- (NSStreamStatus)streamStatus { + return _streamStatus; +} + +- (id)delegate { + return _delegate; +} + +- (void)setDelegate:(id)delegate { + _delegate = delegate; +} + +- (id)propertyForKey:(NSStreamPropertyKey)key { + return nil; +} + +- (BOOL)setProperty:(id)property forKey:(NSStreamPropertyKey)key { + return NO; +} + +@end + namespace crashpad { namespace { @@ -105,120 +197,6 @@ return user_agent; } -// An implementation of CFReadStream. This implements the V0 callback -// scheme. -class HTTPBodyStreamCFReadStream { - public: - explicit HTTPBodyStreamCFReadStream(HTTPBodyStream* body_stream) - : body_stream_(body_stream) { - } - - HTTPBodyStreamCFReadStream(const HTTPBodyStreamCFReadStream&) = delete; - HTTPBodyStreamCFReadStream& operator=(const HTTPBodyStreamCFReadStream&) = - delete; - - // Creates a new NSInputStream, which the caller owns. - NSInputStream* CreateInputStream() { - CFStreamClientContext context = { - .version = 0, - .info = this, - .retain = nullptr, - .release = nullptr, - .copyDescription = nullptr - }; - constexpr CFReadStreamCallBacksV0 callbacks = { - .version = 0, - .open = &Open, - .openCompleted = &OpenCompleted, - .read = &Read, - .getBuffer = &GetBuffer, - .canRead = &CanRead, - .close = &Close, - .copyProperty = &CopyProperty, - .schedule = &Schedule, - .unschedule = &Unschedule - }; - CFReadStreamRef read_stream = CFReadStreamCreate(nullptr, - reinterpret_cast(&callbacks), &context); - return base::mac::CFToNSCast(read_stream); - } - - private: - static HTTPBodyStream* GetStream(void* info) { - return static_cast(info)->body_stream_; - } - - static Boolean Open(CFReadStreamRef stream, - CFStreamError* error, - Boolean* open_complete, - void* info) { - *open_complete = TRUE; - return TRUE; - } - - static Boolean OpenCompleted(CFReadStreamRef stream, - CFStreamError* error, - void* info) { - return TRUE; - } - - static CFIndex Read(CFReadStreamRef stream, - UInt8* buffer, - CFIndex buffer_length, - CFStreamError* error, - Boolean* at_eof, - void* info) { - if (buffer_length == 0) { - *at_eof = FALSE; - return 0; - } - - FileOperationResult bytes_read = - GetStream(info)->GetBytesBuffer(buffer, buffer_length); - if (bytes_read < 0) { - error->error = -1; - error->domain = kCFStreamErrorDomainCustom; - } else { - *at_eof = bytes_read == 0; - } - - return bytes_read; - } - - static const UInt8* GetBuffer(CFReadStreamRef stream, - CFIndex max_bytes_to_read, - CFIndex* num_bytes_read, - CFStreamError* error, - Boolean* at_eof, - void* info) { - return nullptr; - } - - static Boolean CanRead(CFReadStreamRef stream, void* info) { - return TRUE; - } - - static void Close(CFReadStreamRef stream, void* info) {} - - static CFTypeRef CopyProperty(CFReadStreamRef stream, - CFStringRef property_name, - void* info) { - return nullptr; - } - - static void Schedule(CFReadStreamRef stream, - CFRunLoopRef run_loop, - CFStringRef run_loop_mode, - void* info) {} - - static void Unschedule(CFReadStreamRef stream, - CFRunLoopRef run_loop, - CFStringRef run_loop_mode, - void* info) {} - - HTTPBodyStream* body_stream_; // weak -}; - class HTTPTransportMac final : public HTTPTransport { public: HTTPTransportMac(); @@ -261,9 +239,9 @@ static void Unschedule(CFReadStreamRef stream, forHTTPHeaderField:base::SysUTF8ToNSString(pair.first)]; } - HTTPBodyStreamCFReadStream body_stream_cf(body_stream()); base::scoped_nsobject input_stream( - body_stream_cf.CreateInputStream()); + [[CrashpadHTTPBodyStreamTransport alloc] + initWithBodyStream:body_stream()]); [request setHTTPBodyStream:input_stream.get()]; NSURLResponse* response = nil; From 6fd38ffedfb4e0a1651499e36e672f52f9417dc7 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Fri, 5 Nov 2021 14:34:13 -0400 Subject: [PATCH 43/69] ios: Add exception preprocessor sinkhole for CoreAutoLayout. Another set of iOS redacted sinkholes appear in CoreAutoLayout. However, this is often called by our code, so it's unsafe to simply handle an uncaught nsexception here. Instead, skip the frame and continue searching for either a handler that belongs to us, or another sinkhole. Bug: crashpad: 31 Change-Id: I20be2acef96f5ee6b7521144548e920e635f0dc7 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3261270 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/ios_handler/exception_processor.mm | 18 ++++++++++++++++++ test/ios/crash_type_xctest.mm | 10 ++++++++++ test/ios/host/cptest_application_delegate.mm | 12 ++++++++++++ test/ios/host/cptest_shared_object.h | 4 ++++ 4 files changed, 44 insertions(+) diff --git a/client/ios_handler/exception_processor.mm b/client/ios_handler/exception_processor.mm index c54dd58960..ce1f2682d3 100644 --- a/client/ios_handler/exception_processor.mm +++ b/client/ios_handler/exception_processor.mm @@ -377,6 +377,24 @@ id ObjcExceptionPreprocessor(id exception) { return HANDLE_UNCAUGHT_NSEXCEPTION(exception, sinkhole); } } + + // Another set of iOS redacted sinkholes appear in CoreAutoLayout. + // However, this is often called by client code, so it's unsafe to simply + // handle an uncaught nsexception here. Instead, skip the frame and + // continue searching for either a handler that belongs to us, or another + // sinkhole. See: + // -[NSISEngine + // performModifications:withUnsatisfiableConstraintsHandler:]: + // -[NSISEngine withBehaviors:performModifications:] + // +[NSLayoutConstraintParser + // constraintsWithVisualFormat:options:metrics:views:]: + static constexpr const char* kCoreAutoLayoutSinkhole = + "/System/Library/PrivateFrameworks/CoreAutoLayout.framework/" + "CoreAutoLayout"; + if (ModulePathMatchesSinkhole(dl_info.dli_fname, + kCoreAutoLayoutSinkhole)) { + continue; + } } // Some sinkholes are harder to find. _UIGestureEnvironmentUpdate diff --git a/test/ios/crash_type_xctest.mm b/test/ios/crash_type_xctest.mm index c931796549..529ca13ece 100644 --- a/test/ios/crash_type_xctest.mm +++ b/test/ios/crash_type_xctest.mm @@ -179,6 +179,16 @@ - (void)testCatchNSException { XCTAssertEqual([rootObject_ pendingReportCount], 0); } +- (void)testCrashCoreAutoLayoutSinkhole { + [rootObject_ crashCoreAutoLayoutSinkhole]; + [self verifyCrashReportException:crashpad::kMachExceptionFromNSException]; + NSDictionary* dict = [rootObject_ getAnnotations]; + XCTAssertTrue([[dict[@"objects"][0] valueForKeyPath:@"exceptionReason"] + containsString:@"Unable to activate constraint with anchors"]); + XCTAssertTrue([[dict[@"objects"][1] valueForKeyPath:@"exceptionName"] + isEqualToString:@"NSGenericException"]); +} + - (void)testRecursion { [rootObject_ crashRecursion]; [self verifyCrashReportException:SIGHUP]; diff --git a/test/ios/host/cptest_application_delegate.mm b/test/ios/host/cptest_application_delegate.mm index 6ff8378ac4..44a7d88ad8 100644 --- a/test/ios/host/cptest_application_delegate.mm +++ b/test/ios/host/cptest_application_delegate.mm @@ -289,6 +289,18 @@ - (void)catchNSException { } } +- (void)crashCoreAutoLayoutSinkhole { + // EDO has its own sinkhole, so dispatch this away. + dispatch_async(dispatch_get_main_queue(), ^{ + UIView* unattachedView = [[UIView alloc] init]; + UIWindow* window = [UIApplication sharedApplication].windows[0]; + [NSLayoutConstraint activateConstraints:@[ + [window.rootViewController.view.bottomAnchor + constraintEqualToAnchor:unattachedView.bottomAnchor], + ]]; + }); +} + - (void)crashRecursion { recurse(0); } diff --git a/test/ios/host/cptest_shared_object.h b/test/ios/host/cptest_shared_object.h index 4a781933d3..bcd755479d 100644 --- a/test/ios/host/cptest_shared_object.h +++ b/test/ios/host/cptest_shared_object.h @@ -73,6 +73,9 @@ // Trigger a caught NSException, this will not crash - (void)catchNSException; +// Trigger an NSException with sinkholes in CoreAutoLayout. +- (void)crashCoreAutoLayoutSinkhole; + // Trigger a crash with an infinite recursion. - (void)crashRecursion; @@ -84,6 +87,7 @@ // Trigger a crash after writing various annotations. - (void)crashWithAnnotations; + @end #endif // CRASHPAD_TEST_IOS_HOST_SHARED_OBJECT_H_ From afeb19f1d24f292c8a26e14f41ec240cf8b8821b Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Thu, 11 Nov 2021 06:32:46 -0500 Subject: [PATCH 44/69] ios: Limit intermediate dump processing to 20 files. Because the intermediate dump directory is expected to be shared, mitigate any spamming by limiting this to 20. Prioritize our bundle id intermediate dumps first. Bug: crashpad: 31 Change-Id: I2888431b8bd2d94f481d2f4ec6e032882dad9698 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3261747 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/BUILD.gn | 1 + client/ios_handler/in_process_handler.cc | 34 +++- client/ios_handler/in_process_handler.h | 4 + client/ios_handler/in_process_handler_test.cc | 150 ++++++++++++++++++ 4 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 client/ios_handler/in_process_handler_test.cc diff --git a/client/BUILD.gn b/client/BUILD.gn index b60e904473..1a83efa2bb 100644 --- a/client/BUILD.gn +++ b/client/BUILD.gn @@ -170,6 +170,7 @@ source_set("client_test") { sources += [ "crashpad_client_ios_test.mm", "ios_handler/exception_processor_test.mm", + "ios_handler/in_process_handler_test.cc", "ios_handler/in_process_intermediate_dump_handler_test.cc", ] } diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 6e440beffd..d57b5f292d 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -54,7 +54,10 @@ namespace internal { InProcessHandler::InProcessHandler() = default; InProcessHandler::~InProcessHandler() { - upload_thread_->Stop(); + if (upload_thread_started_ && upload_thread_) { + upload_thread_->Stop(); + } + prune_thread_->Stop(); } bool InProcessHandler::Initialize( @@ -225,13 +228,23 @@ std::vector InProcessHandler::PendingFiles() { } base::FilePath file; DirectoryReader::Result result; + + // Because the intermediate dump directory is expected to be shared, + // mitigate any spamming by limiting this to |kMaxPendingFiles|. + constexpr size_t kMaxPendingFiles = 20; + + // Track other application bundles separately, so they don't spam our + // intermediate dumps into never getting processed. + std::vector other_files; + while ((result = reader.NextFile(&file)) == DirectoryReader::Result::kSuccess) { // Don't try to process files marked as 'locked' from a different bundle id. - if (file.value().compare(0, + bool bundle_match = + file.value().compare(0, bundle_identifier_and_seperator_.size(), - bundle_identifier_and_seperator_) != 0 && - file.FinalExtension() == kLockedExtension) { + bundle_identifier_and_seperator_) == 0; + if (!bundle_match && file.FinalExtension() == kLockedExtension) { continue; } @@ -242,8 +255,19 @@ std::vector InProcessHandler::PendingFiles() { // Otherwise, include any other unlocked, or locked files matching // |bundle_identifier_and_seperator_|. - files.push_back(file); + if (bundle_match) { + files.push_back(file); + if (files.size() >= kMaxPendingFiles) + return files; + } else { + other_files.push_back(file); + } } + + auto end_iterator = + other_files.begin() + + std::min(kMaxPendingFiles - files.size(), other_files.size()); + files.insert(files.end(), other_files.begin(), end_iterator); return files; } diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index 888337b959..e586219adf 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -180,7 +180,11 @@ class InProcessHandler { } void SaveSnapshot(ProcessSnapshotIOSIntermediateDump& process_snapshot); + + // Process a maximum of 20 pending intermediate dumps. Dumps named with our + // bundle id get first priority to prevent spamming. std::vector PendingFiles(); + bool OpenNewFile(); void PostReportCleanup(); diff --git a/client/ios_handler/in_process_handler_test.cc b/client/ios_handler/in_process_handler_test.cc new file mode 100644 index 0000000000..13dd366d4b --- /dev/null +++ b/client/ios_handler/in_process_handler_test.cc @@ -0,0 +1,150 @@ +// Copyright 2021 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. + +#include "client/ios_handler/in_process_handler.h" + +#include "gtest/gtest.h" +#include "test/scoped_temp_dir.h" +#include "test/test_paths.h" +#include "util/file/directory_reader.h" +#include "util/file/filesystem.h" + +namespace crashpad { +namespace test { +namespace { + +bool CreateFile(const base::FilePath& file) { + ScopedFileHandle fd(LoggingOpenFileForWrite( + file, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly)); + EXPECT_TRUE(fd.is_valid()); + return fd.is_valid(); +} + +class InProcessHandlerTest : public testing::Test { + protected: + // testing::Test: + + void SetUp() override { + ASSERT_TRUE( + in_process_handler_.Initialize(temp_dir_.path(), "", {}, system_data_)); + pending_dir_ = temp_dir_.path().Append("pending-serialized-ios-dump"); + bundle_identifier_and_seperator_ = system_data_.BundleIdentifier() + "@"; + } + + const auto& path() const { return pending_dir_; } + auto& handler() { return in_process_handler_; } + + void CreateFiles(int files, int other_files) { + base::FilePath::StringType file_prepend = + FILE_PATH_LITERAL(bundle_identifier_and_seperator_); + base::FilePath::StringType file_name = FILE_PATH_LITERAL("file"); + for (int i = 0; i < files; i++) { + std::string i_str = std::to_string(i); + base::FilePath file(file_prepend + file_name + i_str); + CreateFile(path().Append(file)); + } + + for (int i = 0; i < other_files; i++) { + std::string i_str = std::to_string(i); + base::FilePath file(file_name + i_str); + CreateFile(path().Append(file)); + } + } + + void VerifyRemainingFileCount(int expected_files_count, + int expected_other_files_count) { + DirectoryReader reader; + ASSERT_TRUE(reader.Open(path())); + DirectoryReader::Result result; + base::FilePath filename; + int files_count = 0; + int other_files_count = 0; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + bool bundle_match = + filename.value().compare(0, + bundle_identifier_and_seperator_.size(), + bundle_identifier_and_seperator_) == 0; + if (bundle_match) { + files_count++; + } else { + other_files_count++; + } + } + EXPECT_EQ(expected_files_count, files_count); + EXPECT_EQ(expected_other_files_count, other_files_count); + } + + void ClearFiles() { + DirectoryReader reader; + ASSERT_TRUE(reader.Open(path())); + DirectoryReader::Result result; + base::FilePath filename; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + LoggingRemoveFile(path().Append(filename)); + } + } + + private: + ScopedTempDir temp_dir_; + base::FilePath pending_dir_; + std::string bundle_identifier_and_seperator_; + internal::IOSSystemDataCollector system_data_; + internal::InProcessHandler in_process_handler_; +}; + +TEST_F(InProcessHandlerTest, TestPendingFileLimit) { + // Clear this first to blow away the pending file held by InProcessHandler. + ClearFiles(); + + // Only process other app files. + CreateFiles(0, 20); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(0, 0); + ClearFiles(); + + // Only process our app files. + CreateFiles(20, 20); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(0, 20); + ClearFiles(); + + // Process all of our files and 10 remaining. + CreateFiles(10, 30); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(0, 20); + ClearFiles(); + + // Process 20 our files, leaving 10 remaining, and all other files remaining. + CreateFiles(30, 10); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(10, 10); + ClearFiles(); + + CreateFiles(0, 0); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(0, 0); + ClearFiles(); + + CreateFiles(10, 0); + handler().ProcessIntermediateDumps({}); + VerifyRemainingFileCount(0, 0); + ClearFiles(); + +} + +} // namespace +} // namespace test +} // namespace crashpad From d62cc6fdbdfe1813a59aa7bd7f9f1ed8ba15db2c Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Fri, 12 Nov 2021 18:55:21 +0100 Subject: [PATCH 45/69] Linux: capture memory pointed to by context This adds support for capturing memory snippets for addresses currently stored in registers to Linux/Android/CrOS. Modeled after the existing support on Windows. Bug: crashpad:30 Change-Id: Ib7cb523555a6e8e4d70145c205d67dcfbc9c7fcc Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3273712 Commit-Queue: Jakob Kummerow Reviewed-by: Joshua Peraza --- .gitignore | 1 + snapshot/BUILD.gn | 2 + .../linux/capture_memory_delegate_linux.cc | 77 +++++++++++++++++++ .../linux/capture_memory_delegate_linux.h | 70 +++++++++++++++++ snapshot/linux/exception_snapshot_linux.cc | 24 +++++- snapshot/linux/exception_snapshot_linux.h | 2 + snapshot/linux/process_snapshot_linux.cc | 17 +++- snapshot/linux/process_snapshot_linux.h | 4 + snapshot/linux/system_snapshot_linux_test.cc | 4 +- snapshot/linux/thread_snapshot_linux.cc | 22 +++++- snapshot/linux/thread_snapshot_linux.h | 7 +- tools/generate_dump.cc | 7 +- util/linux/memory_map.cc | 57 ++++++++++++++ util/linux/memory_map.h | 10 +++ 14 files changed, 294 insertions(+), 10 deletions(-) create mode 100644 snapshot/linux/capture_memory_delegate_linux.cc create mode 100644 snapshot/linux/capture_memory_delegate_linux.h diff --git a/.gitignore b/.gitignore index 27c9f8d813..b739477a52 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *.xcodeproj *~ .*.sw? +.cache .DS_Store .gdb_history .gdbinit diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index fc2246a586..225d3446f3 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -128,6 +128,8 @@ crashpad_static_library("snapshot") { if (crashpad_is_linux || crashpad_is_android) { sources += [ + "linux/capture_memory_delegate_linux.cc", + "linux/capture_memory_delegate_linux.h", "linux/cpu_context_linux.cc", "linux/cpu_context_linux.h", "linux/debug_rendezvous.cc", diff --git a/snapshot/linux/capture_memory_delegate_linux.cc b/snapshot/linux/capture_memory_delegate_linux.cc new file mode 100644 index 0000000000..4f1587400c --- /dev/null +++ b/snapshot/linux/capture_memory_delegate_linux.cc @@ -0,0 +1,77 @@ +// Copyright 2021 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. + +#include "snapshot/linux/capture_memory_delegate_linux.h" + +#include + +#include "base/numerics/safe_conversions.h" +#include "snapshot/memory_snapshot_generic.h" + +namespace crashpad { +namespace internal { + +CaptureMemoryDelegateLinux::CaptureMemoryDelegateLinux( + ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread* thread_opt, + std::vector>* snapshots, + uint32_t* budget_remaining) + : stack_(thread_opt ? thread_opt->stack_region_address : 0, + thread_opt ? thread_opt->stack_region_size : 0), + process_reader_(process_reader), + snapshots_(snapshots), + budget_remaining_(budget_remaining) {} + +bool CaptureMemoryDelegateLinux::Is64Bit() const { + return process_reader_->Is64Bit(); +} + +bool CaptureMemoryDelegateLinux::ReadMemory(uint64_t at, + uint64_t num_bytes, + void* into) const { + return process_reader_->Memory()->Read( + at, base::checked_cast(num_bytes), into); +} + +std::vector> +CaptureMemoryDelegateLinux::GetReadableRanges( + const CheckedRange& range) const { + return process_reader_->GetMemoryMap()->GetReadableRanges(range); +} + +void CaptureMemoryDelegateLinux::AddNewMemorySnapshot( + const CheckedRange& range) { + // Don't bother storing this memory if it points back into the stack. + if (stack_.ContainsRange(range)) + return; + if (range.size() == 0) + return; + if (budget_remaining_ && *budget_remaining_ == 0) + return; + snapshots_->push_back(std::make_unique()); + internal::MemorySnapshotGeneric* snapshot = snapshots_->back().get(); + snapshot->Initialize(process_reader_->Memory(), range.base(), range.size()); + if (budget_remaining_) { + if (!base::IsValueInRangeForNumericType(range.size())) { + *budget_remaining_ = 0; + } else { + int64_t temp = *budget_remaining_; + temp -= range.size(); + *budget_remaining_ = base::saturated_cast(temp); + } + } +} + +} // namespace internal +} // namespace crashpad diff --git a/snapshot/linux/capture_memory_delegate_linux.h b/snapshot/linux/capture_memory_delegate_linux.h new file mode 100644 index 0000000000..c0250b5561 --- /dev/null +++ b/snapshot/linux/capture_memory_delegate_linux.h @@ -0,0 +1,70 @@ +// Copyright 2021 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. + +#ifndef CRASHPAD_SNAPSHOT_LINUX_CAPTURE_MEMORY_DELEGATE_LINUX_H_ +#define CRASHPAD_SNAPSHOT_LINUX_CAPTURE_MEMORY_DELEGATE_LINUX_H_ + +#include "snapshot/capture_memory.h" + +#include + +#include +#include + +#include "snapshot/linux/process_reader_linux.h" +#include "util/numeric/checked_range.h" + +namespace crashpad { +namespace internal { + +class MemorySnapshotGeneric; + +class CaptureMemoryDelegateLinux : public CaptureMemory::Delegate { + public: + //! \brief A MemoryCaptureDelegate for Linux. + //! + //! \param[in] process_reader A ProcessReaderLinux for the target process. + //! \param[in] thread_opt The thread being inspected. Memory ranges + //! overlapping this thread's stack will be ignored on the assumption + //! that they're already captured elsewhere. May be nullptr. + //! \param[in] snapshots A vector of MemorySnapshotGeneric to which the + //! captured memory will be added. + //! \param[in] budget_remaining If non-null, a pointer to the remaining number + //! of bytes to capture. If this is `0`, no further memory will be + //! captured. + CaptureMemoryDelegateLinux( + ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread* thread_opt, + std::vector>* snapshots, + uint32_t* budget_remaining); + + // MemoryCaptureDelegate: + bool Is64Bit() const override; + bool ReadMemory(uint64_t at, uint64_t num_bytes, void* into) const override; + std::vector> GetReadableRanges( + const CheckedRange& range) const override; + void AddNewMemorySnapshot( + const CheckedRange& range) override; + + private: + CheckedRange stack_; + ProcessReaderLinux* process_reader_; // weak + std::vector>* snapshots_; // weak + uint32_t* budget_remaining_; +}; + +} // namespace internal +} // namespace crashpad + +#endif // CRASHPAD_SNAPSHOT_LINUX_CAPTURE_MEMORY_DELEGATE_LINUX_H_ diff --git a/snapshot/linux/exception_snapshot_linux.cc b/snapshot/linux/exception_snapshot_linux.cc index cd40b3b12d..42d0eb0b29 100644 --- a/snapshot/linux/exception_snapshot_linux.cc +++ b/snapshot/linux/exception_snapshot_linux.cc @@ -17,6 +17,7 @@ #include #include "base/logging.h" +#include "snapshot/linux/capture_memory_delegate_linux.h" #include "snapshot/linux/cpu_context_linux.h" #include "snapshot/linux/process_reader_linux.h" #include "snapshot/linux/signal_context.h" @@ -332,6 +333,18 @@ bool ExceptionSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, INITIALIZATION_STATE_SET_INITIALIZING(initialized_); thread_id_ = thread_id; + const ProcessReaderLinux::Thread* thread = nullptr; + for (const auto& loop_thread : process_reader->Threads()) { + if (thread_id == loop_thread.tid) { + thread = &loop_thread; + break; + } + } + if (!thread) { + // This is allowed until {ProcessReaderLinux::InitializeThreads()} is + // improved to support target threads in the same thread group. + LOG(WARNING) << "thread ID " << thread_id << " not found in process"; + } if (process_reader->Is64Bit()) { if (!ReadContext(process_reader, context_address) || @@ -345,6 +358,10 @@ bool ExceptionSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, } } + CaptureMemoryDelegateLinux capture_memory_delegate( + process_reader, thread, &extra_memory_, nullptr); + CaptureMemory::PointedToByContext(context_, &capture_memory_delegate); + INITIALIZATION_STATE_SET_VALID(initialized_); return true; } @@ -462,7 +479,12 @@ const std::vector& ExceptionSnapshotLinux::Codes() const { std::vector ExceptionSnapshotLinux::ExtraMemory() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return std::vector(); + std::vector result; + result.reserve(extra_memory_.size()); + for (const auto& em : extra_memory_) { + result.push_back(em.get()); + } + return result; } } // namespace internal diff --git a/snapshot/linux/exception_snapshot_linux.h b/snapshot/linux/exception_snapshot_linux.h index c722ac77ad..1719f0be76 100644 --- a/snapshot/linux/exception_snapshot_linux.h +++ b/snapshot/linux/exception_snapshot_linux.h @@ -25,6 +25,7 @@ #include "snapshot/exception_snapshot.h" #include "snapshot/linux/process_reader_linux.h" #include "snapshot/memory_snapshot.h" +#include "snapshot/memory_snapshot_generic.h" #include "util/linux/address_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -91,6 +92,7 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot { } context_union_; CPUContext context_; std::vector codes_; + std::vector> extra_memory_; uint64_t thread_id_; uint64_t exception_address_; uint32_t signal_number_; diff --git a/snapshot/linux/process_snapshot_linux.cc b/snapshot/linux/process_snapshot_linux.cc index 35f870ec76..53499b3654 100644 --- a/snapshot/linux/process_snapshot_linux.cc +++ b/snapshot/linux/process_snapshot_linux.cc @@ -41,6 +41,8 @@ bool ProcessSnapshotLinux::Initialize(PtraceConnection* connection) { system_.Initialize(&process_reader_, &snapshot_time_); + GetCrashpadOptionsInternal((&options_)); + InitializeThreads(); InitializeModules(); InitializeAnnotations(); @@ -100,7 +102,7 @@ bool ProcessSnapshotLinux::InitializeException( auto exc_thread_snapshot = std::make_unique(); - if (!exc_thread_snapshot->Initialize(&process_reader_, thread)) { + if (!exc_thread_snapshot->Initialize(&process_reader_, thread, nullptr)) { return false; } @@ -124,7 +126,11 @@ bool ProcessSnapshotLinux::InitializeException( void ProcessSnapshotLinux::GetCrashpadOptions( CrashpadInfoClientOptions* options) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); + *options = options_; +} +void ProcessSnapshotLinux::GetCrashpadOptionsInternal( + CrashpadInfoClientOptions* options) { CrashpadInfoClientOptions local_options; for (const auto& module : modules_) { @@ -262,10 +268,17 @@ const ProcessMemory* ProcessSnapshotLinux::Memory() const { void ProcessSnapshotLinux::InitializeThreads() { const std::vector& process_reader_threads = process_reader_.Threads(); + uint32_t* budget_remaining_pointer = nullptr; + uint32_t budget_remaining = options_.indirectly_referenced_memory_cap; + if (options_.gather_indirectly_referenced_memory == TriState::kEnabled) { + budget_remaining_pointer = &budget_remaining; + } for (const ProcessReaderLinux::Thread& process_reader_thread : process_reader_threads) { auto thread = std::make_unique(); - if (thread->Initialize(&process_reader_, process_reader_thread)) { + if (thread->Initialize(&process_reader_, + process_reader_thread, + budget_remaining_pointer)) { threads_.push_back(std::move(thread)); } } diff --git a/snapshot/linux/process_snapshot_linux.h b/snapshot/linux/process_snapshot_linux.h index 62517bbf5d..285ee5d09a 100644 --- a/snapshot/linux/process_snapshot_linux.h +++ b/snapshot/linux/process_snapshot_linux.h @@ -139,6 +139,9 @@ class ProcessSnapshotLinux final : public ProcessSnapshot { void InitializeModules(); void InitializeAnnotations(); + // Initializes options_ on behalf of Initialize(). + void GetCrashpadOptionsInternal(CrashpadInfoClientOptions* options); + std::map annotations_simple_map_; timeval snapshot_time_; UUID report_id_; @@ -149,6 +152,7 @@ class ProcessSnapshotLinux final : public ProcessSnapshot { internal::SystemSnapshotLinux system_; ProcessReaderLinux process_reader_; ProcessMemoryRange memory_range_; + CrashpadInfoClientOptions options_; InitializationStateDcheck initialized_; }; diff --git a/snapshot/linux/system_snapshot_linux_test.cc b/snapshot/linux/system_snapshot_linux_test.cc index f3013b54f6..f5d26a1e74 100644 --- a/snapshot/linux/system_snapshot_linux_test.cc +++ b/snapshot/linux/system_snapshot_linux_test.cc @@ -47,7 +47,9 @@ TEST(SystemSnapshotLinux, Basic) { uint64_t current_hz, max_hz; system.CPUFrequency(¤t_hz, &max_hz); - EXPECT_GE(max_hz, current_hz); + // For short-term loads, modern CPUs can boost single-core frequency beyond + // the advertised base clock. Let's assume this is no more than a factor 2. + EXPECT_GE(max_hz * 2, current_hz); int major, minor, bugfix; std::string build; diff --git a/snapshot/linux/thread_snapshot_linux.cc b/snapshot/linux/thread_snapshot_linux.cc index e3e2bebddb..f279e0adad 100644 --- a/snapshot/linux/thread_snapshot_linux.cc +++ b/snapshot/linux/thread_snapshot_linux.cc @@ -17,6 +17,7 @@ #include #include "base/logging.h" +#include "snapshot/linux/capture_memory_delegate_linux.h" #include "snapshot/linux/cpu_context_linux.h" #include "util/misc/reinterpret_bytes.h" @@ -138,8 +139,10 @@ ThreadSnapshotLinux::ThreadSnapshotLinux() ThreadSnapshotLinux::~ThreadSnapshotLinux() {} -bool ThreadSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, - const ProcessReaderLinux::Thread& thread) { +bool ThreadSnapshotLinux::Initialize( + ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread& thread, + uint32_t* gather_indirectly_referenced_memory_bytes_remaining) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); #if defined(ARCH_CPU_X86_FAMILY) @@ -205,6 +208,13 @@ bool ThreadSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, thread.static_priority, thread.sched_policy, thread.nice_value) : -1; + CaptureMemoryDelegateLinux capture_memory_delegate( + process_reader, + &thread, + &pointed_to_memory_, + gather_indirectly_referenced_memory_bytes_remaining); + CaptureMemory::PointedToByContext(context_, &capture_memory_delegate); + INITIALIZATION_STATE_SET_VALID(initialized_); return true; } @@ -240,7 +250,13 @@ uint64_t ThreadSnapshotLinux::ThreadSpecificDataAddress() const { } std::vector ThreadSnapshotLinux::ExtraMemory() const { - return std::vector(); + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + std::vector result; + result.reserve(pointed_to_memory_.size()); + for (const auto& pointed_to_memory : pointed_to_memory_) { + result.push_back(pointed_to_memory.get()); + } + return result; } } // namespace internal diff --git a/snapshot/linux/thread_snapshot_linux.h b/snapshot/linux/thread_snapshot_linux.h index 17a6668dad..40cd7e7f54 100644 --- a/snapshot/linux/thread_snapshot_linux.h +++ b/snapshot/linux/thread_snapshot_linux.h @@ -47,8 +47,10 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { //! //! \return `true` if the snapshot could be created, `false` otherwise with //! a message logged. - bool Initialize(ProcessReaderLinux* process_reader, - const ProcessReaderLinux::Thread& thread); + bool Initialize( + ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread& thread, + uint32_t* gather_indirectly_referenced_memory_bytes_remaining); // ThreadSnapshot: @@ -81,6 +83,7 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { pid_t thread_id_; int priority_; InitializationStateDcheck initialized_; + std::vector> pointed_to_memory_; }; } // namespace internal diff --git a/tools/generate_dump.cc b/tools/generate_dump.cc index e22f92a5f4..ab027b8795 100644 --- a/tools/generate_dump.cc +++ b/tools/generate_dump.cc @@ -49,6 +49,7 @@ #include "util/win/xp_compat.h" #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) #include "snapshot/linux/process_snapshot_linux.h" +#include "util/linux/direct_ptrace_connection.h" #endif // OS_APPLE namespace crashpad { @@ -198,8 +199,12 @@ int GenerateDumpMain(int argc, char* argv[]) { } #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) // TODO(jperaza): https://crashpad.chromium.org/bug/30. + DirectPtraceConnection task; + if (!task.Initialize(options.pid)) { + return EXIT_FAILURE; + } ProcessSnapshotLinux process_snapshot; - if (!process_snapshot.Initialize(nullptr)) { + if (!process_snapshot.Initialize(&task)) { return EXIT_FAILURE; } #endif // OS_APPLE diff --git a/util/linux/memory_map.cc b/util/linux/memory_map.cc index e15a1c5e7d..47eec973f2 100644 --- a/util/linux/memory_map.cc +++ b/util/linux/memory_map.cc @@ -227,6 +227,12 @@ class FullReverseIterator : public MemoryMap::Iterator { std::vector::const_reverse_iterator rend_; }; +// Faster than a CheckedRange, for temporary values. +struct FastRange { + VMAddress base; + VMSize size; +}; + } // namespace MemoryMap::Mapping::Mapping() @@ -321,6 +327,57 @@ const MemoryMap::Mapping* MemoryMap::FindMappingWithName( return nullptr; } +std::vector> MemoryMap::GetReadableRanges( + const CheckedRange& range) const { + using Range = CheckedRange; + + VMAddress range_base = range.base(); + VMAddress range_end = range.end(); + std::vector overlapping; + + // Find all readable ranges overlapping the target range, maintaining order. + for (const auto& mapping : mappings_) { + if (!mapping.readable) + continue; + if (mapping.range.End() < range_base) + continue; + if (mapping.range.Base() >= range_end) + continue; + // Special case: the "[vvar]" region is marked readable, but we can't + // access it. + if (mapping.inode == 0 && mapping.name == "[vvar]") + continue; + overlapping.push_back({mapping.range.Base(), mapping.range.Size()}); + } + if (overlapping.empty()) + return std::vector(); + + // For the first and last, trim to the boundary of the incoming range. + FastRange& front = overlapping.front(); + VMAddress original_front_base = front.base; + front.base = std::max(front.base, range_base); + front.size = (original_front_base + front.size) - front.base; + FastRange& back = overlapping.back(); + VMAddress back_end = back.base + back.size; + back.size = std::min(range_end, back_end) - back.base; + + // Coalesce, and convert to return type. + std::vector result; + result.push_back({overlapping[0].base, overlapping[0].size}); + DCHECK(result.back().IsValid()); + for (size_t i = 1; i < overlapping.size(); ++i) { + if (result.back().end() == overlapping[i].base) { + result.back().SetRange(result.back().base(), + result.back().size() + overlapping[i].size); + } else { + result.push_back({overlapping[i].base, overlapping[i].size}); + } + DCHECK(result.back().IsValid()); + } + + return result; +} + std::unique_ptr MemoryMap::FindFilePossibleMmapStarts( const Mapping& mapping) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); diff --git a/util/linux/memory_map.h b/util/linux/memory_map.h index f6f7cc840b..2a542ebb64 100644 --- a/util/linux/memory_map.h +++ b/util/linux/memory_map.h @@ -77,6 +77,16 @@ class MemoryMap { //! it was obtained from. const Mapping* FindMappingWithName(const std::string& name) const; + //! \brief Given a range to be read from the target process, returns a vector + //! of ranges, representing the readable portions of the original range. + //! + //! \param[in] range The range being identified. + //! + //! \return A vector of ranges corresponding to the portion of \a range that + //! is readable based on the memory map. + std::vector> GetReadableRanges( + const CheckedRange& range) const; + //! \brief An abstract base class for iterating over ordered sets of mappings //! in a MemoryMap. class Iterator { From c8d8dd9ccfc96ad193191a1563242527e49240bb Mon Sep 17 00:00:00 2001 From: Olivier Robin Date: Tue, 2 Nov 2021 10:50:42 +0100 Subject: [PATCH 46/69] Add attachment support for Mac/iOS crash report database Copy the crash_report_database_generic implementation. bug: crashpad: 31 Change-Id: I582620ec8b22fecc7568d220c410c397948dfcb1 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3045405 Commit-Queue: Olivier Robin Reviewed-by: Joshua Peraza --- client/crash_report_database.cc | 109 +++++++++++++++++ client/crash_report_database.h | 34 +++++- client/crash_report_database_generic.cc | 154 ++---------------------- client/crash_report_database_mac.mm | 117 +++++++++++++++--- client/crash_report_database_test.cc | 42 ++++--- client/crash_report_database_win.cc | 153 ++++++----------------- client/prune_crash_reports_test.cc | 1 + util/file/filesystem.h | 16 +++ util/file/filesystem_posix.cc | 35 ++++++ util/file/filesystem_test.cc | 59 +++++++++ util/file/filesystem_win.cc | 37 ++++++ 11 files changed, 458 insertions(+), 299 deletions(-) diff --git a/client/crash_report_database.cc b/client/crash_report_database.cc index 68393333df..5c8156e01e 100644 --- a/client/crash_report_database.cc +++ b/client/crash_report_database.cc @@ -14,10 +14,29 @@ #include "client/crash_report_database.h" +#include + +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" #include "build/build_config.h" +#include "util/file/directory_reader.h" +#include "util/file/filesystem.h" namespace crashpad { +namespace { +constexpr base::FilePath::CharType kAttachmentsDirectory[] = + FILE_PATH_LITERAL("attachments"); + +bool AttachmentNameIsOK(const std::string& name) { + for (const char c : name) { + if (c != '_' && c != '-' && c != '.' && !isalnum(c)) + return false; + } + return true; +} +} // namespace + CrashReportDatabase::Report::Report() : uuid(), file_path(), @@ -73,6 +92,60 @@ FileReaderInterface* CrashReportDatabase::NewReport::Reader() { return reader_.get(); } +FileWriter* CrashReportDatabase::NewReport::AddAttachment( + const std::string& name) { + if (!AttachmentNameIsOK(name)) { + LOG(ERROR) << "invalid name for attachment " << name; + return nullptr; + } + base::FilePath report_attachments_dir = database_->AttachmentsPath(uuid_); + if (!LoggingCreateDirectory( + report_attachments_dir, FilePermissions::kOwnerOnly, true)) { + return nullptr; + } +#if defined(OS_WIN) + const std::wstring name_string = base::UTF8ToWide(name); +#else + const std::string name_string = name; +#endif + base::FilePath attachment_path = report_attachments_dir.Append(name_string); + auto writer = std::make_unique(); + if (!writer->Open(attachment_path, + FileWriteMode::kCreateOrFail, + FilePermissions::kOwnerOnly)) { + return nullptr; + } + attachment_writers_.emplace_back(std::move(writer)); + attachment_removers_.emplace_back(ScopedRemoveFile(attachment_path)); + return attachment_writers_.back().get(); +} + +void CrashReportDatabase::UploadReport::InitializeAttachments() { + base::FilePath report_attachments_dir = database_->AttachmentsPath(uuid); + DirectoryReader dir_reader; + if (!dir_reader.Open(report_attachments_dir)) { + return; + } + + base::FilePath filename; + DirectoryReader::Result dir_result; + while ((dir_result = dir_reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath filepath(report_attachments_dir.Append(filename)); + std::unique_ptr file_reader(std::make_unique()); + if (!file_reader->Open(filepath)) { + continue; + } + attachment_readers_.emplace_back(std::move(file_reader)); +#if defined(OS_WIN) + const std::string name_string = base::WideToUTF8(filename.value()); +#else + const std::string name_string = filename.value(); +#endif + attachment_map_[name_string] = attachment_readers_.back().get(); + } +} + CrashReportDatabase::UploadReport::UploadReport() : Report(), reader_(std::make_unique()), @@ -103,4 +176,40 @@ CrashReportDatabase::OperationStatus CrashReportDatabase::RecordUploadComplete( return RecordUploadAttempt(report, true, id); } +base::FilePath CrashReportDatabase::AttachmentsPath(const UUID& uuid) { +#if defined(OS_WIN) + const std::wstring uuid_string = uuid.ToWString(); +#else + const std::string uuid_string = uuid.ToString(); +#endif + + return DatabasePath().Append(kAttachmentsDirectory).Append(uuid_string); +} + +base::FilePath CrashReportDatabase::AttachmentsRootPath() { + return DatabasePath().Append(kAttachmentsDirectory); +} + +void CrashReportDatabase::RemoveAttachmentsByUUID(const UUID& uuid) { + base::FilePath report_attachment_dir = AttachmentsPath(uuid); + if (!IsDirectory(report_attachment_dir, /*allow_symlinks=*/false)) { + return; + } + DirectoryReader reader; + if (!reader.Open(report_attachment_dir)) { + return; + } + + base::FilePath filename; + DirectoryReader::Result result; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath attachment_path( + report_attachment_dir.Append(filename)); + LoggingRemoveFile(attachment_path); + } + + LoggingRemoveDirectory(report_attachment_dir); +} + } // namespace crashpad diff --git a/client/crash_report_database.h b/client/crash_report_database.h index 19f1bf74db..fea49853a0 100644 --- a/client/crash_report_database.h +++ b/client/crash_report_database.h @@ -129,8 +129,6 @@ class CrashReportDatabase { //! \brief Adds an attachment to the report. //! - //! \note This function is not yet implemented on macOS. - //! //! \param[in] name The key and name for the attachment, which will be //! included in the http upload. The attachment will not appear in the //! minidump report. \a name should only use characters from the set @@ -174,8 +172,6 @@ class CrashReportDatabase { //! \brief Obtains a mapping of names to file readers for any attachments //! for the report. - //! - //! This is not implemented on macOS. std::map GetAttachments() const { return attachment_map_; } @@ -400,9 +396,11 @@ class CrashReportDatabase { virtual OperationStatus RequestUpload(const UUID& uuid) = 0; //! \brief Cleans the database of expired lockfiles, metadata without report - //! files, and report files without metadata. + //! files, report files without metadata, and attachments without report + //! files. //! - //! This method does nothing on the macOS implementations of the database. + //! As the macOS implementation does not use lock or metadata files, the + //! cleaning is limited to attachments without report files. //! //! \param[in] lockfile_ttl The number of seconds at which lockfiles or new //! report files are considered expired. @@ -412,6 +410,30 @@ class CrashReportDatabase { protected: CrashReportDatabase() {} + //! \brief The path to the database passed to Initialize. + //! + //! \return The filepath of the database; + virtual base::FilePath DatabasePath() = 0; + + //! \brief Build a filepath for the root attachments directory. + //! + //! \return The filepath to the attachments directory. + base::FilePath AttachmentsRootPath(); + + //! \brief Build a filepath for the directory for the report to hold + //! attachments. + //! + //! \param[in] uuid The unique identifier for the crash report record. + //! + //! \return The filepath to the report attachments directory. + base::FilePath AttachmentsPath(const UUID& uuid); + + //! \brief Attempts to remove any attachments associated with the given + //! report UUID. There may not be any, so failing is not an error. + //! + //! \param[in] uuid The unique identifier for the crash report record. + void RemoveAttachmentsByUUID(const UUID& uuid); + private: //! \brief Adjusts a crash report record’s metadata to account for an upload //! attempt, and updates the last upload attempt time as returned by diff --git a/client/crash_report_database_generic.cc b/client/crash_report_database_generic.cc index 046e82d80c..734a6c4800 100644 --- a/client/crash_report_database_generic.cc +++ b/client/crash_report_database_generic.cc @@ -45,14 +45,6 @@ UUID UUIDFromReportPath(const base::FilePath& path) { return uuid; } -bool AttachmentNameIsOK(const std::string& name) { - for (const char c : name) { - if (c != '_' && c != '-' && c != '.' && !isalnum(c)) - return false; - } - return true; -} - using OperationStatus = CrashReportDatabase::OperationStatus; constexpr base::FilePath::CharType kSettings[] = @@ -70,8 +62,6 @@ constexpr base::FilePath::CharType kPendingDirectory[] = FILE_PATH_LITERAL("pending"); constexpr base::FilePath::CharType kCompletedDirectory[] = FILE_PATH_LITERAL("completed"); -constexpr base::FilePath::CharType kAttachmentsDirectory[] = - FILE_PATH_LITERAL("attachments"); constexpr const base::FilePath::CharType* kReportDirectories[] = { kNewDirectory, @@ -164,35 +154,6 @@ class ScopedLockFile { private: ScopedRemoveFile lock_file_; }; - -off_t GetFileSize(const base::FilePath& filepath) { - struct stat statbuf; - if (stat(filepath.value().c_str(), &statbuf) == 0) { - return statbuf.st_size; - } - PLOG(ERROR) << "stat " << filepath.value(); - return 0; -} - -void AddAttachmentSize(const base::FilePath& attachments_dir, uint64_t* size) { - // Early return if the attachment directory does not exist. - if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { - return; - } - DirectoryReader reader; - if (!reader.Open(attachments_dir)) { - return; - } - base::FilePath attachment_filename; - DirectoryReader::Result result; - while ((result = reader.NextFile(&attachment_filename)) == - DirectoryReader::Result::kSuccess) { - const base::FilePath attachment_filepath( - attachments_dir.Append(attachment_filename)); - *size += GetFileSize(attachment_filepath); - } -} - } // namespace class CrashReportDatabaseGeneric : public CrashReportDatabase { @@ -225,9 +186,7 @@ class CrashReportDatabaseGeneric : public CrashReportDatabase { OperationStatus DeleteReport(const UUID& uuid) override; OperationStatus RequestUpload(const UUID& uuid) override; int CleanDatabase(time_t lockfile_ttl) override; - - // Build a filepath for the directory for the report to hold attachments. - base::FilePath AttachmentsPath(const UUID& uuid); + base::FilePath DatabasePath() override; private: struct LockfileUploadReport : public UploadReport { @@ -286,10 +245,6 @@ class CrashReportDatabaseGeneric : public CrashReportDatabase { // Cleans any attachments that have no associated report in any state. void CleanOrphanedAttachments(); - // Attempt to remove any attachments associated with the given report UUID. - // There may not be any, so failing is not an error. - void RemoveAttachmentsByUUID(const UUID& uuid); - // Reads the metadata for a report from path and returns it in report. bool ReadMetadata(const base::FilePath& path, Report* report); @@ -307,62 +262,6 @@ class CrashReportDatabaseGeneric : public CrashReportDatabase { InitializationStateDcheck initialized_; }; -FileWriter* CrashReportDatabase::NewReport::AddAttachment( - const std::string& name) { - if (!AttachmentNameIsOK(name)) { - LOG(ERROR) << "invalid name for attachment " << name; - return nullptr; - } - - base::FilePath attachments_dir = - static_cast(database_)->AttachmentsPath( - uuid_); - if (!LoggingCreateDirectory( - attachments_dir, FilePermissions::kOwnerOnly, true)) { - return nullptr; - } - - base::FilePath path = attachments_dir.Append(name); - - auto writer = std::make_unique(); - if (!writer->Open( - path, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly)) { - LOG(ERROR) << "could not open " << path.value(); - return nullptr; - } - attachment_writers_.emplace_back(std::move(writer)); - attachment_removers_.emplace_back(ScopedRemoveFile(path)); - return attachment_writers_.back().get(); -} - -void CrashReportDatabase::UploadReport::InitializeAttachments() { - base::FilePath attachments_dir = - static_cast(database_)->AttachmentsPath( - uuid); - if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { - return; - } - DirectoryReader directory_reader; - if (!directory_reader.Open(attachments_dir)) { - return; - } - - base::FilePath filename; - DirectoryReader::Result dir_result; - while ((dir_result = directory_reader.NextFile(&filename)) == - DirectoryReader::Result::kSuccess) { - const base::FilePath filepath(attachments_dir.Append(filename)); - std::unique_ptr file_reader(std::make_unique()); - if (!file_reader->Open(filepath)) { - LOG(ERROR) << "attachment " << filepath.value() - << " couldn't be opened, skipping"; - continue; - } - attachment_readers_.emplace_back(std::move(file_reader)); - attachment_map_[filename.value()] = attachment_readers_.back().get(); - } -} - CrashReportDatabaseGeneric::CrashReportDatabaseGeneric() = default; CrashReportDatabaseGeneric::~CrashReportDatabaseGeneric() = default; @@ -385,9 +284,8 @@ bool CrashReportDatabaseGeneric::Initialize(const base::FilePath& path, } } - if (!LoggingCreateDirectory(base_dir_.Append(kAttachmentsDirectory), - FilePermissions::kOwnerOnly, - true)) { + if (!LoggingCreateDirectory( + AttachmentsRootPath(), FilePermissions::kOwnerOnly, true)) { return false; } @@ -413,6 +311,10 @@ CrashReportDatabase::InitializeWithoutCreating(const base::FilePath& path) { return database->Initialize(path, false) ? std::move(database) : nullptr; } +base::FilePath CrashReportDatabaseGeneric::DatabasePath() { + return base_dir_; +} + Settings* CrashReportDatabaseGeneric::GetSettings() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return &settings_; @@ -699,7 +601,7 @@ base::FilePath CrashReportDatabaseGeneric::ReportPath(const UUID& uuid, DCHECK_NE(state, kSearchable); #if defined(OS_WIN) - const std::wstring uuid_string = uuid.ToString16(); + const std::wstring uuid_string = uuid.ToWString(); #else const std::string uuid_string = uuid.ToString(); #endif @@ -708,16 +610,6 @@ base::FilePath CrashReportDatabaseGeneric::ReportPath(const UUID& uuid, .Append(uuid_string + kCrashReportExtension); } -base::FilePath CrashReportDatabaseGeneric::AttachmentsPath(const UUID& uuid) { -#if defined(OS_WIN) - const std::wstring uuid_string = uuid.ToString16(); -#else - const std::string uuid_string = uuid.ToString(); -#endif - - return base_dir_.Append(kAttachmentsDirectory).Append(uuid_string); -} - OperationStatus CrashReportDatabaseGeneric::LocateAndLockReport( const UUID& uuid, ReportState desired_state, @@ -878,7 +770,7 @@ int CrashReportDatabaseGeneric::CleanReportsInState(ReportState state, } void CrashReportDatabaseGeneric::CleanOrphanedAttachments() { - base::FilePath root_attachments_dir(base_dir_.Append(kAttachmentsDirectory)); + base::FilePath root_attachments_dir(AttachmentsRootPath()); DirectoryReader reader; if (!reader.Open(root_attachments_dir)) { return; @@ -888,8 +780,9 @@ void CrashReportDatabaseGeneric::CleanOrphanedAttachments() { DirectoryReader::Result result; while ((result = reader.NextFile(&filename)) == DirectoryReader::Result::kSuccess) { - const base::FilePath path(root_attachments_dir.Append(filename)); - if (IsDirectory(path, false)) { + const base::FilePath report_attachment_dir( + root_attachments_dir.Append(filename)); + if (IsDirectory(report_attachment_dir, false)) { UUID uuid; if (!uuid.InitializeFromString(filename.value())) { LOG(ERROR) << "unexpected attachment dir name " << filename.value(); @@ -919,27 +812,6 @@ void CrashReportDatabaseGeneric::CleanOrphanedAttachments() { } } -void CrashReportDatabaseGeneric::RemoveAttachmentsByUUID(const UUID& uuid) { - base::FilePath attachments_dir = AttachmentsPath(uuid); - if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { - return; - } - DirectoryReader reader; - if (!reader.Open(attachments_dir)) { - return; - } - - base::FilePath filename; - DirectoryReader::Result result; - while ((result = reader.NextFile(&filename)) == - DirectoryReader::Result::kSuccess) { - const base::FilePath filepath(attachments_dir.Append(filename)); - LoggingRemoveFile(filepath); - } - - LoggingRemoveDirectory(attachments_dir); -} - bool CrashReportDatabaseGeneric::ReadMetadata(const base::FilePath& path, Report* report) { const base::FilePath metadata_path( @@ -974,7 +846,7 @@ bool CrashReportDatabaseGeneric::ReadMetadata(const base::FilePath& path, // Seed the total size with the main report size and then add the sizes of any // potential attachments. uint64_t total_size = GetFileSize(path); - AddAttachmentSize(AttachmentsPath(uuid), &total_size); + total_size += GetDirectorySize(AttachmentsPath(uuid)); report->uuid = uuid; report->upload_attempts = metadata.upload_attempts; diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm index 839cfc8f30..ce0ab186ed 100644 --- a/client/crash_report_database_mac.mm +++ b/client/crash_report_database_mac.mm @@ -35,7 +35,9 @@ #include "base/strings/stringprintf.h" #include "base/strings/sys_string_conversions.h" #include "client/settings.h" +#include "util/file/directory_reader.h" #include "util/file/file_io.h" +#include "util/file/filesystem.h" #include "util/mac/xattr.h" #include "util/misc/initialization_state_dcheck.h" #include "util/misc/metrics.h" @@ -153,6 +155,8 @@ OperationStatus SkipReportUpload(const UUID& uuid, Metrics::CrashSkippedReason reason) override; OperationStatus DeleteReport(const UUID& uuid) override; OperationStatus RequestUpload(const UUID& uuid) override; + int CleanDatabase(time_t lockfile_ttl) override; + base::FilePath DatabasePath() override; private: // CrashReportDatabase: @@ -244,21 +248,15 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, const base::FilePath& report_path, base::FilePath* out_path); + // Cleans any attachments that have no associated report in any state. + void CleanOrphanedAttachments(); + base::FilePath base_dir_; Settings settings_; bool xattr_new_names_; InitializationStateDcheck initialized_; }; -FileWriter* CrashReportDatabase::NewReport::AddAttachment( - const std::string& name) { - // Attachments aren't implemented in the Mac database yet. - return nullptr; -} - -void CrashReportDatabase::UploadReport::InitializeAttachments() { - // Attachments aren't implemented in the Mac database yet. -} CrashReportDatabaseMac::CrashReportDatabaseMac(const base::FilePath& path) : CrashReportDatabase(), @@ -288,6 +286,10 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return false; } + if (!CreateOrEnsureDirectoryExists(AttachmentsRootPath())) { + return false; + } + if (!settings_.Initialize(base_dir_.Append(kSettings))) return false; @@ -315,6 +317,10 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return true; } +base::FilePath CrashReportDatabaseMac::DatabasePath() { + return base_dir_; +} + Settings* CrashReportDatabaseMac::GetSettings() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return &settings_; @@ -381,6 +387,14 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, } ignore_result(report->file_remover_.release()); + // Close all the attachments and disarm their removers too. + for (auto& writer : report->attachment_writers_) { + writer->Close(); + } + for (auto& remover : report->attachment_removers_) { + ignore_result(remover.release()); + } + Metrics::CrashReportPending(Metrics::PendingReportReason::kNewlyCreated); Metrics::CrashReportSize(size); @@ -444,7 +458,7 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, if (!ReadReportMetadataLocked(upload_report->file_path, upload_report.get())) return kDatabaseError; - if (!upload_report->reader_->Open(upload_report->file_path)) { + if (!upload_report->Initialize(upload_report->file_path, this)) { return kFileSystemError; } @@ -544,6 +558,8 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return kFileSystemError; } + RemoveAttachmentsByUUID(uuid); + return kNoError; } @@ -628,6 +644,34 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return kNoError; } +int CrashReportDatabaseMac::CleanDatabase(time_t lockfile_ttl) { + int removed = 0; + time_t now = time(nullptr); + + DirectoryReader reader; + const base::FilePath new_dir(base_dir_.Append(kWriteDirectory)); + if (reader.Open(new_dir)) { + base::FilePath filename; + DirectoryReader::Result result; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath filepath(new_dir.Append(filename)); + timespec filetime; + if (!FileModificationTime(filepath, &filetime)) { + continue; + } + if (filetime.tv_sec <= now - lockfile_ttl) { + if (LoggingRemoveFile(filepath)) { + ++removed; + } + } + } + } + + CleanOrphanedAttachments(); + return removed; +} + // static base::ScopedFD CrashReportDatabaseMac::ObtainReportLock( const base::FilePath& path) { @@ -685,13 +729,11 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return false; } - // There are no attachments on Mac so the total size is the main report size. - struct stat statbuf; - if (stat(path.value().c_str(), &statbuf) != 0) { - PLOG(ERROR) << "stat " << path.value(); - return false; - } - report->total_size = statbuf.st_size; + // Seed the total size with the main report size and then add the sizes of any + // potential attachments. + uint64_t total_size = GetFileSize(path); + total_size += GetDirectorySize(AttachmentsPath(report->uuid)); + report->total_size = total_size; return true; } @@ -758,6 +800,47 @@ OperationStatus ReportsInDirectory(const base::FilePath& path, return kNoError; } +void CrashReportDatabaseMac::CleanOrphanedAttachments() { + base::FilePath root_attachments_dir(AttachmentsRootPath()); + DirectoryReader reader; + if (!reader.Open(root_attachments_dir)) { + return; + } + + base::FilePath filename; + DirectoryReader::Result result; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath report_attachment_dir( + root_attachments_dir.Append(filename)); + if (IsDirectory(report_attachment_dir, false)) { + UUID uuid; + if (!uuid.InitializeFromString(filename.value())) { + LOG(ERROR) << "unexpected attachment dir name " << filename.value(); + continue; + } + + // Check to see if the report is being created in "new". + base::FilePath new_dir_path = + base_dir_.Append(kWriteDirectory) + .Append(uuid.ToString() + "." + kCrashReportFileExtension); + if (IsRegularFile(new_dir_path)) { + continue; + } + + // Check to see if the report is in "pending" or "completed". + base::FilePath local_path = + LocateCrashReport(uuid, kReportStatePending | kReportStateCompleted); + if (!local_path.empty()) { + continue; + } + + // Couldn't find a report, assume these attachments are orphaned. + RemoveAttachmentsByUUID(uuid); + } + } +} + std::unique_ptr InitializeInternal( const base::FilePath& path, bool may_create) { diff --git a/client/crash_report_database_test.cc b/client/crash_report_database_test.cc index 9d3f1fc9b9..357702b069 100644 --- a/client/crash_report_database_test.cc +++ b/client/crash_report_database_test.cc @@ -675,10 +675,6 @@ TEST_F(CrashReportDatabaseTest, RequestUpload) { } TEST_F(CrashReportDatabaseTest, Attachments) { -#if defined(OS_APPLE) || defined(OS_WIN) - // Attachments aren't supported on Mac and Windows yet. - GTEST_SKIP(); -#else std::unique_ptr new_report; ASSERT_EQ(db()->PrepareNewCrashReport(&new_report), CrashReportDatabase::kNoError); @@ -717,16 +713,9 @@ TEST_F(CrashReportDatabaseTest, Attachments) { char result_buffer[sizeof(test_data)]; result_attachments["some_file"]->Read(result_buffer, sizeof(result_buffer)); EXPECT_EQ(memcmp(test_data, result_buffer, sizeof(test_data)), 0); -#endif } TEST_F(CrashReportDatabaseTest, OrphanedAttachments) { -#if defined(OS_APPLE) || defined(OS_WIN) - // Attachments aren't supported on Mac and Windows yet. - GTEST_SKIP(); -#else - // TODO: This is using paths that are specific to the generic implementation - // and will need to be generalized for Mac and Windows. std::unique_ptr new_report; ASSERT_EQ(db()->PrepareNewCrashReport(&new_report), CrashReportDatabase::kNoError); @@ -748,25 +737,43 @@ TEST_F(CrashReportDatabaseTest, OrphanedAttachments) { ASSERT_TRUE(LoggingRemoveFile(report.file_path)); +#if !defined(OS_APPLE) && !defined(OS_WIN) + // CrashReportDatabaseMac stores metadata in xattrs and does not have .meta + // files. + // CrashReportDatabaseWin stores metadata in a global metadata file and not + // per report. ASSERT_TRUE(LoggingRemoveFile(base::FilePath( report.file_path.RemoveFinalExtension().value() + ".meta"))); +#endif ASSERT_EQ(db()->LookUpCrashReport(uuid, &report), CrashReportDatabase::kReportNotFound); +#if defined(OS_WIN) + const std::wstring uuid_string = uuid.ToWString(); +#else + const std::string uuid_string = uuid.ToString(); +#endif base::FilePath report_attachments_dir( - path().Append("attachments").Append(uuid.ToString())); - base::FilePath file_path1(report_attachments_dir.Append("file1")); - base::FilePath file_path2(report_attachments_dir.Append("file2")); + path().Append(FILE_PATH_LITERAL("attachments")).Append(uuid_string)); + base::FilePath file_path1( + report_attachments_dir.Append(FILE_PATH_LITERAL("file1"))); + base::FilePath file_path2( + report_attachments_dir.Append(FILE_PATH_LITERAL("file2"))); EXPECT_TRUE(FileExists(file_path1)); EXPECT_TRUE(FileExists(file_path1)); +#if defined(OS_WIN) + // On Windows, reports removed from metadata are counted, even if the file + // is not on the disk. + EXPECT_EQ(db()->CleanDatabase(0), 1); +#else EXPECT_EQ(db()->CleanDatabase(0), 0); +#endif EXPECT_FALSE(FileExists(file_path1)); EXPECT_FALSE(FileExists(file_path2)); EXPECT_FALSE(FileExists(report_attachments_dir)); -#endif } // This test uses knowledge of the database format to break it, so it only @@ -860,10 +867,6 @@ TEST_F(CrashReportDatabaseTest, TotalSize_MainReportOnly) { } TEST_F(CrashReportDatabaseTest, GetReportSize_RightSizeWithAttachments) { -#if defined(OS_APPLE) || defined(OS_WIN) - // Attachments aren't supported on Mac and Windows yet. - return; -#else std::unique_ptr new_report; ASSERT_EQ(db()->PrepareNewCrashReport(&new_report), CrashReportDatabase::kNoError); @@ -895,7 +898,6 @@ TEST_F(CrashReportDatabaseTest, GetReportSize_RightSizeWithAttachments) { EXPECT_EQ(report.total_size, sizeof(main_report_data) + sizeof(attachment_1_data) + sizeof(attachment_2_data)); -#endif } } // namespace diff --git a/client/crash_report_database_win.cc b/client/crash_report_database_win.cc index b8ecadb788..33d729bba3 100644 --- a/client/crash_report_database_win.cc +++ b/client/crash_report_database_win.cc @@ -48,8 +48,6 @@ constexpr wchar_t kCrashReportFileExtension[] = L"dmp"; constexpr uint32_t kMetadataFileHeaderMagic = 'CPAD'; constexpr uint32_t kMetadataFileVersion = 1; -constexpr base::FilePath::CharType kAttachmentsDirectory[] = L"attachments"; - using OperationStatus = CrashReportDatabase::OperationStatus; // Helpers --------------------------------------------------------------------- @@ -216,8 +214,10 @@ class Metadata { //! handle. ~Metadata(); - static std::unique_ptr Create(const base::FilePath& metadata_file, - const base::FilePath& report_dir); + static std::unique_ptr Create( + const base::FilePath& metadata_file, + const base::FilePath& report_dir, + const base::FilePath& attachments_dir); //! \brief Adds a new report to the set. //! @@ -280,7 +280,9 @@ class Metadata { int CleanDatabase(); private: - Metadata(FileHandle handle, const base::FilePath& report_dir); + Metadata(FileHandle handle, + const base::FilePath& report_dir, + const base::FilePath& attachments_dir); bool Rewind(); @@ -298,6 +300,7 @@ class Metadata { ScopedFileHandle handle_; const base::FilePath report_dir_; + const base::FilePath attachments_dir_; bool dirty_; //! \brief `true` when a Write() is required on destruction. std::vector reports_; }; @@ -312,8 +315,10 @@ Metadata::~Metadata() { } // static -std::unique_ptr Metadata::Create(const base::FilePath& metadata_file, - const base::FilePath& report_dir) { +std::unique_ptr Metadata::Create( + const base::FilePath& metadata_file, + const base::FilePath& report_dir, + const base::FilePath& attachments_dir) { // It is important that dwShareMode be non-zero so that concurrent access to // this file results in a successful open. This allows us to get to LockFileEx // which then blocks to guard access. @@ -338,7 +343,8 @@ std::unique_ptr Metadata::Create(const base::FilePath& metadata_file, return std::unique_ptr(); } - std::unique_ptr metadata(new Metadata(handle, report_dir)); + std::unique_ptr metadata( + new Metadata(handle, report_dir, attachments_dir)); // If Read() fails, for whatever reason (corruption, etc.) metadata will not // have been modified and will be in a clean empty state. We continue on and // return an empty database to hopefully recover. This means that existing @@ -427,9 +433,14 @@ int Metadata::CleanDatabase() { return removed; } -Metadata::Metadata(FileHandle handle, const base::FilePath& report_dir) - : handle_(handle), report_dir_(report_dir), dirty_(false), reports_() { -} +Metadata::Metadata(FileHandle handle, + const base::FilePath& report_dir, + const base::FilePath& attachments_dir) + : handle_(handle), + report_dir_(report_dir), + attachments_dir_(attachments_dir), + dirty_(false), + reports_() {} bool Metadata::Rewind() { FileOffset result = LoggingSeekFile(handle_.get(), 0, SEEK_SET); @@ -488,15 +499,10 @@ void Metadata::Read() { } ReportDisk report_disk(record, report_dir_, string_table); - // There are no attachments on Windows so the total size is the main - // report size. - struct _stati64 statbuf; - if (_wstat64(report_disk.file_path.value().c_str(), &statbuf) == 0) { - report_disk.total_size = statbuf.st_size; - } else { - LOG(ERROR) << "failed to stat report"; - } - + report_disk.total_size = GetFileSize(report_disk.file_path); + base::FilePath report_attachment_dir = + attachments_dir_.Append(report_disk.uuid.ToWString()); + report_disk.total_size += GetDirectorySize(report_attachment_dir); reports.push_back(report_disk); } } @@ -643,12 +649,7 @@ class CrashReportDatabaseWin : public CrashReportDatabase { OperationStatus DeleteReport(const UUID& uuid) override; OperationStatus RequestUpload(const UUID& uuid) override; int CleanDatabase(time_t lockfile_ttl) override; - - // Build a filepath for the root attachments directory. - base::FilePath AttachmentsRootPath(); - - // Build a filepath for the directory for the report to hold attachments. - base::FilePath AttachmentsPath(const UUID& uuid); + base::FilePath DatabasePath() override; private: // CrashReportDatabase: @@ -659,10 +660,6 @@ class CrashReportDatabaseWin : public CrashReportDatabase { // Cleans any attachments that have no associated report. void CleanOrphanedAttachments(); - // Attempt to remove any attachments associated with the given report UUID. - // There may not be any, so failing is not an error. - void RemoveAttachmentsByUUID(const UUID& uuid); - std::unique_ptr AcquireMetadata(); base::FilePath base_dir_; @@ -670,68 +667,6 @@ class CrashReportDatabaseWin : public CrashReportDatabase { InitializationStateDcheck initialized_; }; -base::FilePath CrashReportDatabaseWin::AttachmentsRootPath() { - return base_dir_.Append(kAttachmentsDirectory); -} - -base::FilePath CrashReportDatabaseWin::AttachmentsPath(const UUID& uuid) { - const std::wstring uuid_string = uuid.ToWString(); - return base_dir_.Append(kAttachmentsDirectory).Append(uuid_string); -} - -FileWriter* CrashReportDatabase::NewReport::AddAttachment( - const std::string& name) { - auto database_win = static_cast(database_); - base::FilePath attachments_root_dir = database_win->AttachmentsRootPath(); - base::FilePath attachments_dir = database_win->AttachmentsPath(uuid_); - if (!LoggingCreateDirectory( - attachments_root_dir, FilePermissions::kOwnerOnly, true) || - !LoggingCreateDirectory( - attachments_dir, FilePermissions::kOwnerOnly, true)) { - return nullptr; - } - - base::FilePath path = attachments_dir.Append(base::UTF8ToWide(name)); - - auto writer = std::make_unique(); - if (!writer->Open( - path, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly)) { - LOG(ERROR) << "could not open " << path.value().c_str(); - return nullptr; - } - attachment_writers_.emplace_back(std::move(writer)); - attachment_removers_.emplace_back(ScopedRemoveFile(path)); - return attachment_writers_.back().get(); -} - -void CrashReportDatabase::UploadReport::InitializeAttachments() { - base::FilePath attachments_dir = - static_cast(database_)->AttachmentsPath(uuid); - if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { - return; - } - DirectoryReader dir_reader; - if (!dir_reader.Open(attachments_dir)) { - return; - } - - base::FilePath filename; - DirectoryReader::Result dir_result; - while ((dir_result = dir_reader.NextFile(&filename)) == - DirectoryReader::Result::kSuccess) { - const base::FilePath filepath(attachments_dir.Append(filename)); - std::unique_ptr file_reader(std::make_unique()); - if (!file_reader->Open(filepath)) { - LOG(ERROR) << "attachment " << filepath.value().c_str() - << " couldn't be opened, skipping"; - continue; - } - attachment_readers_.emplace_back(std::move(file_reader)); - attachment_map_[base::WideToUTF8(filename.value())] = - attachment_readers_.back().get(); - } -} - CrashReportDatabaseWin::CrashReportDatabaseWin(const base::FilePath& path) : CrashReportDatabase(), base_dir_(path), settings_(), initialized_() {} @@ -753,6 +688,9 @@ bool CrashReportDatabaseWin::Initialize(bool may_create) { if (!CreateDirectoryIfNecessary(base_dir_.Append(kReportsDirectory))) return false; + if (!CreateDirectoryIfNecessary(AttachmentsRootPath())) + return false; + if (!settings_.Initialize(base_dir_.Append(kSettings))) return false; @@ -760,6 +698,10 @@ bool CrashReportDatabaseWin::Initialize(bool may_create) { return true; } +base::FilePath CrashReportDatabaseWin::DatabasePath() { + return base_dir_; +} + Settings* CrashReportDatabaseWin::GetSettings() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return &settings_; @@ -934,27 +876,6 @@ OperationStatus CrashReportDatabaseWin::DeleteReport(const UUID& uuid) { return kNoError; } -void CrashReportDatabaseWin::RemoveAttachmentsByUUID(const UUID& uuid) { - base::FilePath attachments_dir = AttachmentsPath(uuid); - if (!IsDirectory(attachments_dir, /*allow_symlinks=*/false)) { - return; - } - DirectoryReader reader; - if (!reader.Open(attachments_dir)) { - return; - } - - base::FilePath filename; - DirectoryReader::Result result; - while ((result = reader.NextFile(&filename)) == - DirectoryReader::Result::kSuccess) { - const base::FilePath filepath(attachments_dir.Append(filename)); - LoggingRemoveFile(filepath); - } - - LoggingRemoveDirectory(attachments_dir); -} - OperationStatus CrashReportDatabaseWin::SkipReportUpload( const UUID& uuid, Metrics::CrashSkippedReason reason) { @@ -977,7 +898,9 @@ OperationStatus CrashReportDatabaseWin::SkipReportUpload( std::unique_ptr CrashReportDatabaseWin::AcquireMetadata() { base::FilePath metadata_file = base_dir_.Append(kMetadataFileName); - return Metadata::Create(metadata_file, base_dir_.Append(kReportsDirectory)); + return Metadata::Create(metadata_file, + base_dir_.Append(kReportsDirectory), + AttachmentsRootPath()); } std::unique_ptr InitializeInternal( @@ -1073,7 +996,7 @@ int CrashReportDatabaseWin::CleanDatabase(time_t lockfile_ttl) { } void CrashReportDatabaseWin::CleanOrphanedAttachments() { - base::FilePath root_attachments_dir(base_dir_.Append(kAttachmentsDirectory)); + base::FilePath root_attachments_dir = AttachmentsRootPath(); DirectoryReader reader; if (!reader.Open(root_attachments_dir)) { return; diff --git a/client/prune_crash_reports_test.cc b/client/prune_crash_reports_test.cc index b989d2f615..cce26aa053 100644 --- a/client/prune_crash_reports_test.cc +++ b/client/prune_crash_reports_test.cc @@ -69,6 +69,7 @@ class MockDatabase : public CrashReportDatabase { (override)); MOCK_METHOD(OperationStatus, DeleteReport, (const UUID&), (override)); MOCK_METHOD(OperationStatus, RequestUpload, (const UUID&), (override)); + MOCK_METHOD(base::FilePath, DatabasePath, (), (override)); // Google Mock doesn't support mocking methods with non-copyable types such as // unique_ptr. diff --git a/util/file/filesystem.h b/util/file/filesystem.h index e12f127148..e2affcc654 100644 --- a/util/file/filesystem.h +++ b/util/file/filesystem.h @@ -111,6 +111,22 @@ bool LoggingRemoveFile(const base::FilePath& path); //! \return `true` if the directory was removed. Otherwise, `false`. bool LoggingRemoveDirectory(const base::FilePath& path); +//! \brief Returns the size of the file at |filepath|. +//! The function will ignore symlinks (not follow them, not add them to +//! the returned size). +//! +//! \return The size of the file pointed by |filepath|. +uint64_t GetFileSize(const base::FilePath& filepath); + +//! \brief Returns the recursive sum of the size of the files in |dirPath|. +//! The function will ignore symlinks (not follow them, not add them to +//! the returned size). +//! +//! \param[in] dirPath The path to the directory +//! +//! \return The sum of the size of the files in |dirPath|. +uint64_t GetDirectorySize(const base::FilePath& dirPath); + } // namespace crashpad #endif // CRASHPAD_UTIL_FILE_FILESYSTEM_H_ diff --git a/util/file/filesystem_posix.cc b/util/file/filesystem_posix.cc index 60799eb4b3..c413397447 100644 --- a/util/file/filesystem_posix.cc +++ b/util/file/filesystem_posix.cc @@ -22,6 +22,7 @@ #include "base/logging.h" #include "build/build_config.h" +#include "util/file/directory_reader.h" namespace crashpad { @@ -112,4 +113,38 @@ bool LoggingRemoveDirectory(const base::FilePath& path) { return true; } +uint64_t GetFileSize(const base::FilePath& filepath) { + if (!IsRegularFile(filepath)) { + return 0; + } + struct stat statbuf; + if (stat(filepath.value().c_str(), &statbuf) == 0) { + return statbuf.st_size; + } + PLOG(ERROR) << "stat " << filepath.value().c_str(); + return 0; +} + +uint64_t GetDirectorySize(const base::FilePath& dirpath) { + if (!IsDirectory(dirpath, /*allow_symlinks=*/false)) { + return 0; + } + DirectoryReader reader; + if (!reader.Open(dirpath)) { + return 0; + } + base::FilePath filename; + DirectoryReader::Result result; + uint64_t size = 0; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath filepath(dirpath.Append(filename)); + if (IsDirectory(filepath, /*allow_symlinks=*/false)) { + size += GetDirectorySize(filepath); + } else { + size += GetFileSize(filepath); + } + } + return size; +} } // namespace crashpad diff --git a/util/file/filesystem_test.cc b/util/file/filesystem_test.cc index 30cd0d128e..9338cdcc12 100644 --- a/util/file/filesystem_test.cc +++ b/util/file/filesystem_test.cc @@ -21,12 +21,15 @@ #include "test/errors.h" #include "test/filesystem.h" #include "test/scoped_temp_dir.h" +#include "util/file/file_writer.h" #include "util/misc/time.h" namespace crashpad { namespace test { namespace { +constexpr char kTestFileContent[] = "file_content"; + bool CurrentTime(timespec* now) { #if defined(OS_APPLE) timeval now_tv; @@ -471,6 +474,62 @@ TEST(Filesystem, RemoveDirectory_SymbolicLinks) { #endif // !OS_FUCHSIA +TEST(Filesystem, GetFileSize) { + ScopedTempDir temp_dir; + base::FilePath filepath(temp_dir.path().Append(FILE_PATH_LITERAL("file"))); + FileWriter writer; + bool is_created = writer.Open( + filepath, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly); + ASSERT_TRUE(is_created); + writer.Write(kTestFileContent, sizeof(kTestFileContent)); + writer.Close(); + uint64_t filesize = GetFileSize(filepath); + EXPECT_EQ(filesize, sizeof(kTestFileContent)); + +#if !defined(OS_FUCHSIA) + // Create a link to a file. + base::FilePath link(temp_dir.path().Append(FILE_PATH_LITERAL("link"))); + ASSERT_TRUE(CreateSymbolicLink(filepath, link)); + uint64_t filesize_link = GetFileSize(link); + EXPECT_EQ(filesize_link, 0u); +#endif // !OS_FUCHSIA +} + +TEST(Filesystem, GetDirectorySize) { + ScopedTempDir temp_dir; + base::FilePath dir(temp_dir.path().Append(FILE_PATH_LITERAL("dir"))); + ASSERT_TRUE( + LoggingCreateDirectory(dir, FilePermissions::kWorldReadable, false)); + base::FilePath filepath1(temp_dir.path().Append(FILE_PATH_LITERAL("file"))); + FileWriter writer1; + bool is_created1 = writer1.Open( + filepath1, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly); + ASSERT_TRUE(is_created1); + writer1.Write(kTestFileContent, sizeof(kTestFileContent)); + writer1.Close(); + + base::FilePath filepath2(dir.Append(FILE_PATH_LITERAL("file"))); + FileWriter writer2; + bool is_created2 = writer2.Open( + filepath2, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly); + ASSERT_TRUE(is_created2); + writer2.Write(kTestFileContent, sizeof(kTestFileContent)); + writer2.Close(); + +#if !defined(OS_FUCHSIA) + // Create a link to a file. + base::FilePath link(dir.Append(FILE_PATH_LITERAL("link"))); + ASSERT_TRUE(CreateSymbolicLink(filepath2, link)); + + // Create a link to a dir. + base::FilePath linkdir(temp_dir.path().Append(FILE_PATH_LITERAL("link"))); + ASSERT_TRUE(CreateSymbolicLink(dir, linkdir)); +#endif // !OS_FUCHSIA + + uint64_t filesize = GetDirectorySize(temp_dir.path()); + EXPECT_EQ(filesize, 2 * sizeof(kTestFileContent)); +} + } // namespace } // namespace test } // namespace crashpad diff --git a/util/file/filesystem_win.cc b/util/file/filesystem_win.cc index d0270fc6bf..8edb295691 100644 --- a/util/file/filesystem_win.cc +++ b/util/file/filesystem_win.cc @@ -19,6 +19,7 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" +#include "util/file/directory_reader.h" #include "util/misc/time.h" namespace crashpad { @@ -159,4 +160,40 @@ bool LoggingRemoveDirectory(const base::FilePath& path) { return LoggingRemoveDirectoryImpl(path); } +uint64_t GetFileSize(const base::FilePath& filepath) { + struct _stati64 statbuf; + if (!IsRegularFile(filepath)) { + return 0; + } + int ret_value = _wstat64(filepath.value().c_str(), &statbuf); + if (ret_value == 0) { + return statbuf.st_size; + } + PLOG(ERROR) << "stat " << filepath.value().c_str(); + return 0; +} + +uint64_t GetDirectorySize(const base::FilePath& dirpath) { + if (!IsDirectory(dirpath, /*allow_symlinks=*/false)) { + return 0; + } + DirectoryReader reader; + if (!reader.Open(dirpath)) { + return 0; + } + base::FilePath filename; + DirectoryReader::Result result; + uint64_t size = 0; + while ((result = reader.NextFile(&filename)) == + DirectoryReader::Result::kSuccess) { + const base::FilePath filepath(dirpath.Append(filename)); + if (IsDirectory(filepath, /*allow_symlinks=*/false)) { + size += GetDirectorySize(filepath); + } else { + size += GetFileSize(filepath); + } + } + return size; +} + } // namespace crashpad From 04431eccfe878570b1c74a5b376d96b4c9c7e0e8 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 12 Nov 2021 17:31:20 -0800 Subject: [PATCH 47/69] Reraise signals via rt_tgsigqueueinfo(2) on Linux. Previously we would rely on implicit re-raising to deliver signals to the underlying handler on POSIX systems if the signal is detected as being re-raisable via WillSignalReraiseAutonomously(). This detection mechanism is imperfect, as it will misclassify signals delivered as a result of kill(2) when passing a signal number usually used for synchronous signals, but now also asynchronous MTE tag check faults, which are delivered as SIGSEGV signals on Linux. As a result, these signals would not be re-raised and therefore would be discarded. Although we could, for example, teach WillSignalReraiseAutonomously() about MTE faults, the signal would still be re-raised via raise(3) and therefore we would lose the information in siginfo. We can avoid discarding these signals on Linux while at the same time preserving the siginfo by making use of the syscall rt_tgsigqueueinfo(2) which delivers a signal together with a user-provided siginfo. The problem still exists on non-Linux POSIX systems because this syscall is Linux-specific. Change-Id: I6df58d9371e29f75e19b4f899b723d4047f12936 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3278691 Commit-Queue: Peter Collingbourne Reviewed-by: Mark Mentovai --- util/posix/signals.cc | 21 +++++ util/posix/signals_test.cc | 164 ++++++++++++++++++++++++++----------- 2 files changed, 136 insertions(+), 49 deletions(-) diff --git a/util/posix/signals.cc b/util/posix/signals.cc index b90e8f659b..1c31f09b6a 100644 --- a/util/posix/signals.cc +++ b/util/posix/signals.cc @@ -22,6 +22,10 @@ #include "base/cxx17_backports.h" #include "base/logging.h" +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) +#include +#endif + namespace crashpad { namespace { @@ -280,6 +284,23 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( _exit(kFailureExitCode); } + // If we can raise a signal with siginfo on this platform, do so. This ensures + // that we preserve the siginfo information for asynchronous signals (i.e. + // signals that do not re-raise autonomously), such as signals delivered via + // kill() and asynchronous hardware faults such as SEGV_MTEAERR, which would + // otherwise be lost when re-raising the signal via raise(). +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + int retval = syscall(SYS_rt_tgsigqueueinfo, + getpid(), + syscall(SYS_gettid), + siginfo->si_signo, + siginfo); + if (retval != 0) { + _exit(kFailureExitCode); + } + return; +#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + // Explicitly re-raise the signal if it will not re-raise itself. Because // signal handlers normally execute with their signal blocked, this raise() // cannot immediately deliver the signal. Delivery is deferred until the diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index 2bd55801f2..cb29ff50b3 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -34,15 +34,48 @@ #include "test/scoped_temp_dir.h" #include "util/posix/scoped_mmap.h" +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) +#include +#include + +#if defined(ARCH_CPU_ARM64) +#ifndef HWCAP2_MTE +#define HWCAP2_MTE (1 << 18) +#endif +#ifndef SEGV_MTEAERR +#define SEGV_MTEAERR 8 +#endif +#ifndef PROT_MTE +#define PROT_MTE 0x20 +#endif +#ifndef PR_SET_TAGGED_ADDR_CTRL +#define PR_SET_TAGGED_ADDR_CTRL 55 +#endif +#ifndef PR_TAGGED_ADDR_ENABLE +#define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#endif +#ifndef PR_MTE_TCF_ASYNC +#define PR_MTE_TCF_ASYNC (1UL << 2) +#endif +#endif // defined(ARCH_CPU_ARM64) +#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + namespace crashpad { namespace test { namespace { constexpr int kUnexpectedExitStatus = 3; +struct TestableSignal { + int sig, code; +}; + // Keep synchronized with CauseSignal(). -bool CanCauseSignal(int sig) { - return sig == SIGABRT || sig == SIGALRM || sig == SIGBUS || +std::vector TestableSignals() { + std::vector signals; + signals.push_back({SIGABRT, 0}); + signals.push_back({SIGALRM, 0}); + signals.push_back({SIGBUS, 0}); /* According to DDI0487D (Armv8 Architecture Reference Manual) the expected * behavior for division by zero (Section 3.4.8) is: "... results in a * zero being written to the destination register, without any @@ -50,24 +83,30 @@ bool CanCauseSignal(int sig) { * This applies to Armv8 (and not earlier) for both 32bit and 64bit app code. */ #if defined(ARCH_CPU_X86_FAMILY) - sig == SIGFPE || + signals.push_back({SIGFPE, 0}); #endif - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - sig == SIGILL || + signals.push_back({SIGILL, 0}); #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - sig == SIGPIPE || sig == SIGSEGV || + signals.push_back({SIGPIPE, 0}); + signals.push_back({SIGSEGV, 0}); +#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ + defined(ARCH_CPU_ARM64) + if (getauxval(AT_HWCAP2) & HWCAP2_MTE) { + signals.push_back({SIGSEGV, SEGV_MTEAERR}); + } +#endif #if defined(OS_APPLE) - sig == SIGSYS || + signals.push_back({SIGSYS, 0}); #endif // OS_APPLE #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - sig == SIGTRAP || + signals.push_back({SIGTRAP, 0}); #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - false; + return signals; } -// Keep synchronized with CanCauseSignal(). -void CauseSignal(int sig) { +// Keep synchronized with TestableSignals(). +void CauseSignal(int sig, int code) { switch (sig) { case SIGABRT: { abort(); @@ -164,8 +203,37 @@ void CauseSignal(int sig) { } case SIGSEGV: { - volatile int* i = nullptr; - *i = 0; + switch (code) { + case 0: { + volatile int* i = nullptr; + *i = 0; + break; + } +#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ + defined(ARCH_CPU_ARM64) + case SEGV_MTEAERR: { + ScopedMmap mapping; + if (!mapping.ResetMmap(nullptr, + getpagesize(), + PROT_READ | PROT_WRITE | PROT_MTE, + MAP_PRIVATE | MAP_ANON, + -1, + 0)) { + _exit(kUnexpectedExitStatus); + } + if (prctl(PR_SET_TAGGED_ADDR_CTRL, + PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC, + 0, + 0, + 0) != 0) { + _exit(kUnexpectedExitStatus); + } + mapping.addr_as()[1ULL << 56] = 0; + break; + } +#endif // (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && + // defined(ARCH_CPU_ARM64) + } break; } @@ -218,9 +286,10 @@ class SignalsTest : public Multiprocess { }; static constexpr int kExitingHandlerExitStatus = 2; - SignalsTest(TestType test_type, SignalSource signal_source, int sig) + SignalsTest(TestType test_type, SignalSource signal_source, int sig, int code) : Multiprocess(), sig_(sig), + code_(code), test_type_(test_type), signal_source_(signal_source) {} @@ -299,7 +368,7 @@ class SignalsTest : public Multiprocess { switch (signal_source_) { case SignalSource::kCause: - CauseSignal(sig_); + CauseSignal(sig_, code_); break; case SignalSource::kRaise: raise(sig_); @@ -310,6 +379,7 @@ class SignalsTest : public Multiprocess { } int sig_; + int code_; TestType test_type_; SignalSource signal_source_; static Signals::OldActions old_actions_; @@ -352,32 +422,28 @@ TEST(Signals, WillSignalReraiseAutonomously) { } TEST(Signals, Cause_DefaultHandler) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kCause, - sig); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); + s.sig, + s.code); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); test.Run(); } } TEST(Signals, Cause_HandlerExits) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kCause, - sig); + s.sig, + s.code); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -385,32 +451,28 @@ TEST(Signals, Cause_HandlerExits) { } TEST(Signals, Cause_HandlerReraisesToDefault) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kCause, - sig); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); + s.sig, + s.code); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); test.Run(); } } TEST(Signals, Cause_HandlerReraisesToPrevious) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kCause, - sig); + s.sig, + s.code); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -427,7 +489,8 @@ TEST(Signals, Raise_DefaultHandler) { SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -443,7 +506,8 @@ TEST(Signals, Raise_HandlerExits) { SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -475,7 +539,8 @@ TEST(Signals, Raise_HandlerReraisesToDefault) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -506,7 +571,8 @@ TEST(Signals, Raise_HandlerReraisesToPrevious) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); From bede7bb29ee66a647cb188d761fe06d24084e878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Tue, 16 Nov 2021 12:58:15 -0800 Subject: [PATCH 48/69] Rename "base/macros.h" => "base/ignore_result.h" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This pulls in "base/ignore_result.h" from mini_chromium through DEPS and updates existing uses of "base/macros.h" to use "base/ignore_result.h". Bug: chromium:1010217 Change-Id: I283e2bcfb2775de420d7e767b3b4a639dbba9e20 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286105 Reviewed-by: Mark Mentovai Commit-Queue: Peter Boström --- DEPS | 2 +- client/crash_report_database_generic.cc | 2 +- client/crash_report_database_mac.mm | 2 +- client/crash_report_database_win.cc | 2 +- client/crashpad_client_mac.cc | 2 +- test/mac/mach_multiprocess.cc | 2 +- util/mach/child_port_handshake.h | 2 +- util/mach/mach_message_test.cc | 2 +- util/posix/close_stdio.cc | 2 +- util/stream/file_encoder.cc | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 8ecd52e3b8..c1edb80c15 100644 --- a/DEPS +++ b/DEPS @@ -39,7 +39,7 @@ deps = { '7bde79cc274d06451bf65ae82c012a5d3e476b5a', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - '461b416dbe5f40a060ee08764b4986a949da6e6e', + '0e22eed71eec97dacbe80822a14c5cd0b580d793', 'crashpad/third_party/libfuzzer/src': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' + 'fda403cf93ecb8792cb1d061564d89a6553ca020', diff --git a/client/crash_report_database_generic.cc b/client/crash_report_database_generic.cc index 734a6c4800..f5dfa891b0 100644 --- a/client/crash_report_database_generic.cc +++ b/client/crash_report_database_generic.cc @@ -20,8 +20,8 @@ #include +#include "base/ignore_result.h" #include "base/logging.h" -#include "base/macros.h" #include "build/build_config.h" #include "client/settings.h" #include "util/file/directory_reader.h" diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm index ce0ab186ed..d1c0a3ed2e 100644 --- a/client/crash_report_database_mac.mm +++ b/client/crash_report_database_mac.mm @@ -26,9 +26,9 @@ #include #include "base/cxx17_backports.h" +#include "base/ignore_result.h" #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" -#include "base/macros.h" #include "base/posix/eintr_wrapper.h" #include "base/scoped_generic.h" #include "base/strings/string_piece.h" diff --git a/client/crash_report_database_win.cc b/client/crash_report_database_win.cc index 33d729bba3..65feaa4cf4 100644 --- a/client/crash_report_database_win.cc +++ b/client/crash_report_database_win.cc @@ -23,8 +23,8 @@ #include +#include "base/ignore_result.h" #include "base/logging.h" -#include "base/macros.h" #include "base/numerics/safe_math.h" #include "base/strings/utf_string_conversions.h" #include "client/settings.h" diff --git a/client/crashpad_client_mac.cc b/client/crashpad_client_mac.cc index f4256f0cd3..b4a365d020 100644 --- a/client/crashpad_client_mac.cc +++ b/client/crashpad_client_mac.cc @@ -23,9 +23,9 @@ #include #include +#include "base/ignore_result.h" #include "base/logging.h" #include "base/mac/mach_logging.h" -#include "base/macros.h" #include "base/strings/stringprintf.h" #include "util/mac/mac_util.h" #include "util/mach/bootstrap.h" diff --git a/test/mac/mach_multiprocess.cc b/test/mac/mach_multiprocess.cc index 35df0611ab..91a06e3acc 100644 --- a/test/mac/mach_multiprocess.cc +++ b/test/mac/mach_multiprocess.cc @@ -21,8 +21,8 @@ #include #include "base/auto_reset.h" +#include "base/ignore_result.h" #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "test/errors.h" #include "test/mac/mach_errors.h" diff --git a/util/mach/child_port_handshake.h b/util/mach/child_port_handshake.h index 0399f9b80b..c61f734ed0 100644 --- a/util/mach/child_port_handshake.h +++ b/util/mach/child_port_handshake.h @@ -20,7 +20,7 @@ #include #include "base/files/scoped_file.h" -#include "base/macros.h" +#include "base/ignore_result.h" #include "util/mach/child_port_types.h" namespace crashpad { diff --git a/util/mach/mach_message_test.cc b/util/mach/mach_message_test.cc index 5af954e4e2..0bee04b335 100644 --- a/util/mach/mach_message_test.cc +++ b/util/mach/mach_message_test.cc @@ -16,8 +16,8 @@ #include +#include "base/ignore_result.h" #include "base/mac/scoped_mach_port.h" -#include "base/macros.h" #include "gtest/gtest.h" #include "test/mac/mach_errors.h" #include "util/mach/mach_extensions.h" diff --git a/util/posix/close_stdio.cc b/util/posix/close_stdio.cc index 812aad5721..a8efc81c19 100644 --- a/util/posix/close_stdio.cc +++ b/util/posix/close_stdio.cc @@ -20,7 +20,7 @@ #include "base/check.h" #include "base/files/scoped_file.h" -#include "base/macros.h" +#include "base/ignore_result.h" #include "base/posix/eintr_wrapper.h" namespace crashpad { diff --git a/util/stream/file_encoder.cc b/util/stream/file_encoder.cc index e375cef7f8..5cebbfcc52 100644 --- a/util/stream/file_encoder.cc +++ b/util/stream/file_encoder.cc @@ -16,7 +16,7 @@ #include -#include "base/macros.h" +#include "base/ignore_result.h" #include "util/file/file_io.h" #include "util/file/file_reader.h" #include "util/file/scoped_remove_file.h" From 08978c7b75319ba8ffc4e6d43915e5cdb506a856 Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Fri, 12 Nov 2021 23:22:38 +0100 Subject: [PATCH 49/69] Linux: Add a test for "extra memory" / code-around-pc And implement ExtraMemory() for ProcessSnapshotMinidump for this purpose. Bug: crashpad:10,crashpad:30 Change-Id: I889c42c7e91358336671ae8d00154af820725e7b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3279301 Reviewed-by: Joshua Peraza Commit-Queue: Jakob Kummerow --- client/crashpad_client_linux_test.cc | 22 ++++++++ .../minidump/process_snapshot_minidump.cc | 56 +++++++++++++++++-- snapshot/minidump/process_snapshot_minidump.h | 5 ++ 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/client/crashpad_client_linux_test.cc b/client/crashpad_client_linux_test.cc index a17589add0..a3ddc31c8a 100644 --- a/client/crashpad_client_linux_test.cc +++ b/client/crashpad_client_linux_test.cc @@ -147,6 +147,26 @@ void ValidateAttachment(const CrashReportDatabase::UploadReport* report) { 0); } +void ValidateExtraMemory(const ProcessSnapshotMinidump& minidump) { + // Verify that if we have an exception, then the code around the instruction + // pointer is included in the extra memory. + const ExceptionSnapshot* exception = minidump.Exception(); + if (exception == nullptr) + return; + uint64_t pc = exception->Context()->InstructionPointer(); + std::vector snippets = minidump.ExtraMemory(); + bool pc_found = false; + for (const MemorySnapshot* snippet : snippets) { + uint64_t start = snippet->Address(); + uint64_t end = start + snippet->Size(); + if (pc >= start && pc < end) { + pc_found = true; + break; + } + } + EXPECT_TRUE(pc_found); +} + void ValidateDump(const CrashReportDatabase::UploadReport* report) { ProcessSnapshotMinidump minidump_snapshot; ASSERT_TRUE(minidump_snapshot.Initialize(report->Reader())); @@ -164,6 +184,8 @@ void ValidateDump(const CrashReportDatabase::UploadReport* report) { #endif ValidateAttachment(report); + ValidateExtraMemory(minidump_snapshot); + for (const ModuleSnapshot* module : minidump_snapshot.Modules()) { for (const AnnotationSnapshot& annotation : module->AnnotationObjects()) { if (static_cast(annotation.type) != diff --git a/snapshot/minidump/process_snapshot_minidump.cc b/snapshot/minidump/process_snapshot_minidump.cc index 4f85b77cfd..db7e595546 100644 --- a/snapshot/minidump/process_snapshot_minidump.cc +++ b/snapshot/minidump/process_snapshot_minidump.cc @@ -117,8 +117,9 @@ bool ProcessSnapshotMinidump::Initialize(FileReaderInterface* file_reader) { if (!InitializeCrashpadInfo() || !InitializeMiscInfo() || !InitializeModules() || !InitializeSystemSnapshot() || - !InitializeMemoryInfo() || !InitializeThreads() || - !InitializeCustomMinidumpStreams() || !InitializeExceptionSnapshot()) { + !InitializeMemoryInfo() || !InitializeExtraMemory() || + !InitializeThreads() || !InitializeCustomMinidumpStreams() || + !InitializeExceptionSnapshot()) { return false; } @@ -234,8 +235,11 @@ std::vector ProcessSnapshotMinidump::Handles() const { std::vector ProcessSnapshotMinidump::ExtraMemory() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); - NOTREACHED(); // https://crashpad.chromium.org/bug/10 - return std::vector(); + std::vector chunks; + for (const auto& chunk : extra_memory_) { + chunks.push_back(chunk.get()); + } + return chunks; } const ProcessMemory* ProcessSnapshotMinidump::Memory() const { @@ -502,6 +506,50 @@ bool ProcessSnapshotMinidump::InitializeMemoryInfo() { return true; } +bool ProcessSnapshotMinidump::InitializeExtraMemory() { + const auto& stream_it = stream_map_.find(kMinidumpStreamTypeMemoryList); + if (stream_it == stream_map_.end()) { + return true; + } + + if (stream_it->second->DataSize < sizeof(MINIDUMP_MEMORY_LIST)) { + LOG(ERROR) << "memory_list size mismatch"; + return false; + } + + if (!file_reader_->SeekSet(stream_it->second->Rva)) { + return false; + } + + // MSVC won't let us stack-allocate a MINIDUMP_MEMORY_LIST because of its + // trailing zero-element array. Luckily we're only interested in its other + // field anyway: a uint32_t indicating the number of memory descriptors that + // follow. + static_assert( + sizeof(MINIDUMP_MEMORY_LIST) == 4, + "MINIDUMP_MEMORY_LIST's only actual field should be an uint32_t"); + uint32_t num_ranges; + if (!file_reader_->ReadExactly(&num_ranges, sizeof(num_ranges))) { + return false; + } + + // We have to manually keep track of the locations of the entries in the + // contiguous list of MINIDUMP_MEMORY_DESCRIPTORs, because the Initialize() + // function jumps around the file to find the contents of each snapshot. + FileOffset location = file_reader_->SeekGet(); + for (uint32_t i = 0; i < num_ranges; i++) { + extra_memory_.emplace_back( + std::make_unique()); + if (!extra_memory_.back()->Initialize(file_reader_, + static_cast(location))) { + return false; + } + location += sizeof(MINIDUMP_MEMORY_DESCRIPTOR); + } + + return true; +} + bool ProcessSnapshotMinidump::InitializeThreads() { const auto& stream_it = stream_map_.find(kMinidumpStreamTypeThreadList); if (stream_it == stream_map_.end()) { diff --git a/snapshot/minidump/process_snapshot_minidump.h b/snapshot/minidump/process_snapshot_minidump.h index f76956d219..18fbc7c367 100644 --- a/snapshot/minidump/process_snapshot_minidump.h +++ b/snapshot/minidump/process_snapshot_minidump.h @@ -116,6 +116,10 @@ class ProcessSnapshotMinidump final : public ProcessSnapshot { // Initialize(). bool InitializeMemoryInfo(); + // Initializes data carried in a MINIDUMP_MEMORY_LIST stream on behalf of + // Initialize(). + bool InitializeExtraMemory(); + // Initializes data carried in a MINIDUMP_SYSTEM_INFO stream on behalf of // Initialize(). bool InitializeSystemSnapshot(); @@ -147,6 +151,7 @@ class ProcessSnapshotMinidump final : public ProcessSnapshot { std::vector> mem_regions_; std::vector mem_regions_exposed_; + std::vector> extra_memory_; std::vector> custom_streams_; MinidumpCrashpadInfo crashpad_info_; internal::SystemSnapshotMinidump system_snapshot_; From ab9a87fb5463e5d1579e16bacb1f79d0dd71119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Tue, 16 Nov 2021 15:20:14 -0800 Subject: [PATCH 50/69] Fix dead-code warning in util/posix/signals.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This unblocks a roll of crashpad into chromium. Bug: None Change-Id: I54fc53e0b53b8a7c7ff8e28c4657b46587bfad8d Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3287226 Commit-Queue: Peter Boström Reviewed-by: Mark Mentovai --- util/posix/signals.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/util/posix/signals.cc b/util/posix/signals.cc index 1c31f09b6a..5df5a08dba 100644 --- a/util/posix/signals.cc +++ b/util/posix/signals.cc @@ -298,9 +298,7 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( if (retval != 0) { _exit(kFailureExitCode); } - return; -#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) - +#else // Explicitly re-raise the signal if it will not re-raise itself. Because // signal handlers normally execute with their signal blocked, this raise() // cannot immediately deliver the signal. Delivery is deferred until the @@ -310,6 +308,7 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( if (!WillSignalReraiseAutonomously(siginfo) && raise(sig) != 0) { _exit(kFailureExitCode); } +#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) } // static From e5e47bc277532ae109a444cbb3646977c93fc077 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Tue, 16 Nov 2021 13:48:50 -0800 Subject: [PATCH 51/69] Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0""" This is a reland of 3dc913b12b4853ef620495a74081dd15fca8dc5e Previous attempt failed as the recipe helper in depot tools did not understand the new cipd win sdk layout and failed at the 'SetEnv.target.json' step. https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8831436994854248129/+/u/read_SetEnv.x86.json/stdout This should be addressed once https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3283800 is rolled into the bot infrastructure. > This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 > > The proper format for this sort of property is: > > properties["$depot_tools/windows_sdk"] = { > "version": "uploaded:2021-04-28", > } > > rather than the nested version we had before. > > Original change's description: > > Reland "Bump Windows SDK to 10.0.19041.0" > > > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > > > Original change's description: > > > Bump Windows SDK to 10.0.19041.0 > > > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > > Reviewed-by: Mark Mentovai > > > Commit-Queue: Mark Mentovai > > > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > > Commit-Queue: Alex Gough > > Reviewed-by: Mark Mentovai > > Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 > Commit-Queue: Alex Gough > Reviewed-by: Mark Mentovai > Bug: crashpad: Bug: 1250098 Change-Id: Ia3fa460e7054c85456bca37478b03c60906b36a9 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286783 Reviewed-by: Mark Mentovai Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ++++++++++++ infra/config/main.star | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index c1edb80c15..2ead5cc8d7 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index d34621cdf0..80e52d73a4 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,6 +450,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -483,6 +486,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -922,6 +928,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -952,6 +961,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index f51ef23e1e..e0582e6d41 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,6 +183,11 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu + if platform == "win": + properties["$depot_tools/windows_sdk"] = { + "version": "uploaded:2021-04-28", + } + if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 801e7e7021296356eb9ad02d8e8f465256d69641 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Wed, 17 Nov 2021 20:22:43 +0000 Subject: [PATCH 52/69] Revert "Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0"""" This reverts commit e5e47bc277532ae109a444cbb3646977c93fc077. Reason for revert: depot_tools winapi recipe needs another minor change. https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8830288168302335601/+/u/read_SetEnv_json/stdout?format=raw https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8830288168302335601/+/u/read_SetEnv_json/stdout?format=raw Original change's description: > Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0""" > > This is a reland of 3dc913b12b4853ef620495a74081dd15fca8dc5e > > Previous attempt failed as the recipe helper in depot tools did not > understand the new cipd win sdk layout and failed at the > 'SetEnv.target.json' step. > https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8831436994854248129/+/u/read_SetEnv.x86.json/stdout > > This should be addressed once > https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3283800 > is rolled into the bot infrastructure. > > > This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 > > > > The proper format for this sort of property is: > > > > properties["$depot_tools/windows_sdk"] = { > > "version": "uploaded:2021-04-28", > > } > > > > rather than the nested version we had before. > > > > Original change's description: > > > Reland "Bump Windows SDK to 10.0.19041.0" > > > > > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > > > > > Original change's description: > > > > Bump Windows SDK to 10.0.19041.0 > > > > > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > > > Reviewed-by: Mark Mentovai > > > > Commit-Queue: Mark Mentovai > > > > > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > > > Commit-Queue: Alex Gough > > > Reviewed-by: Mark Mentovai > > > > Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 > > Commit-Queue: Alex Gough > > Reviewed-by: Mark Mentovai > > Bug: crashpad: > > Bug: 1250098 > Change-Id: Ia3fa460e7054c85456bca37478b03c60906b36a9 > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286783 > Reviewed-by: Mark Mentovai > Commit-Queue: Alex Gough Bug: 1250098 Change-Id: If183131c20b15ec87a956fccee2dcbcf0c551091 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3290110 Bot-Commit: Rubber Stamper Reviewed-by: Mark Mentovai Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ------------ infra/config/main.star | 5 ----- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/DEPS b/DEPS index 2ead5cc8d7..c1edb80c15 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2021-04-28' + 'version': 'uploaded:2018-06-13' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 80e52d73a4..d34621cdf0 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,9 +450,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -486,9 +483,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -928,9 +922,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -961,9 +952,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index e0582e6d41..f51ef23e1e 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,11 +183,6 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu - if platform == "win": - properties["$depot_tools/windows_sdk"] = { - "version": "uploaded:2021-04-28", - } - if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 6383b8d2a71bc5825bb0d294fab59985fa460d9d Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Tue, 16 Nov 2021 13:48:50 -0800 Subject: [PATCH 53/69] Reland "Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0"""" https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3290913 should now correctly locate the new json environments that this SDK cipd package introduces (I have manually downloaded old and new packages and verified). This is a reland of e5e47bc277532ae109a444cbb3646977c93fc077 Original change's description: > Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0""" > > This is a reland of 3dc913b12b4853ef620495a74081dd15fca8dc5e > > Previous attempt failed as the recipe helper in depot tools did not > understand the new cipd win sdk layout and failed at the > 'SetEnv.target.json' step. > https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8831436994854248129/+/u/read_SetEnv.x86.json/stdout > > This should be addressed once > https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3283800 > is rolled into the bot infrastructure. > > > This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 > > > > The proper format for this sort of property is: > > > > properties["$depot_tools/windows_sdk"] = { > > "version": "uploaded:2021-04-28", > > } > > > > rather than the nested version we had before. > > > > Original change's description: > > > Reland "Bump Windows SDK to 10.0.19041.0" > > > > > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > > > > > Original change's description: > > > > Bump Windows SDK to 10.0.19041.0 > > > > > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > > > Reviewed-by: Mark Mentovai > > > > Commit-Queue: Mark Mentovai > > > > > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > > > Commit-Queue: Alex Gough > > > Reviewed-by: Mark Mentovai > > > > Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 > > Commit-Queue: Alex Gough > > Reviewed-by: Mark Mentovai > > Bug: crashpad: > > Bug: 1250098 > Change-Id: Ia3fa460e7054c85456bca37478b03c60906b36a9 > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286783 > Reviewed-by: Mark Mentovai > Commit-Queue: Alex Gough Bug: 1250098 Change-Id: I6f278db20c440b5dd9952281411723706aa0af2b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3292209 Reviewed-by: Mark Mentovai Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ++++++++++++ infra/config/main.star | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index c1edb80c15..2ead5cc8d7 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index d34621cdf0..80e52d73a4 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,6 +450,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -483,6 +486,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -922,6 +928,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -952,6 +961,9 @@ buckets { } properties: '{' + ' "$depot_tools/windows_sdk": {' + ' "version": "uploaded:2021-04-28"' + ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index f51ef23e1e..e0582e6d41 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,6 +183,11 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu + if platform == "win": + properties["$depot_tools/windows_sdk"] = { + "version": "uploaded:2021-04-28", + } + if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 70e4327a73cabe81d863fc01a6059d347736b5b4 Mon Sep 17 00:00:00 2001 From: Alex Gough Date: Fri, 19 Nov 2021 00:59:12 +0000 Subject: [PATCH 54/69] Revert "Reland "Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0""""" This reverts commit 6383b8d2a71bc5825bb0d294fab59985fa460d9d. Reason for revert: https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8830178135765256705/+/u/RECIPE_CRASH__Uncaught_exception_/logging Seem like later stages are not ready for the json, or we need to massage a path somewhere. Will investigate. Original change's description: > Reland "Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0"""" > > https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3290913 > should now correctly locate the new json environments that this SDK cipd > package introduces (I have manually downloaded old and new packages > and verified). > > This is a reland of e5e47bc277532ae109a444cbb3646977c93fc077 > > Original change's description: > > Reland "Reland "Reland "Bump Windows SDK to 10.0.19041.0""" > > > > This is a reland of 3dc913b12b4853ef620495a74081dd15fca8dc5e > > > > Previous attempt failed as the recipe helper in depot tools did not > > understand the new cipd win sdk layout and failed at the > > 'SetEnv.target.json' step. > > https://logs.chromium.org/logs/crashpad/buildbucket/cr-buildbucket/8831436994854248129/+/u/read_SetEnv.x86.json/stdout > > > > This should be addressed once > > https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3283800 > > is rolled into the bot infrastructure. > > > > > This is a reland of 44f566832da48b25c09ee83d4221a9c57f359a82 > > > > > > The proper format for this sort of property is: > > > > > > properties["$depot_tools/windows_sdk"] = { > > > "version": "uploaded:2021-04-28", > > > } > > > > > > rather than the nested version we had before. > > > > > > Original change's description: > > > > Reland "Bump Windows SDK to 10.0.19041.0" > > > > > > > > This is a reland of 020da53ac84de675c8adae5b512f4257adc9dfe3 > > > > > > > > Original change's description: > > > > > Bump Windows SDK to 10.0.19041.0 > > > > > > > > > > Change-Id: Id0c308a838a8b94ce7d24369ffd168a10730a30a > > > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3256822 > > > > > Reviewed-by: Mark Mentovai > > > > > Commit-Queue: Mark Mentovai > > > > > > > > Change-Id: I9e8d14415c12c28b6a230b689d3b791a086d7a06 > > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260604 > > > > Commit-Queue: Alex Gough > > > > Reviewed-by: Mark Mentovai > > > > > > Change-Id: Iafb40bd8799dbfea9308f19e3c6e7568bcba82df > > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3260757 > > > Commit-Queue: Alex Gough > > > Reviewed-by: Mark Mentovai > > > Bug: crashpad: > > > > Bug: 1250098 > > Change-Id: Ia3fa460e7054c85456bca37478b03c60906b36a9 > > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286783 > > Reviewed-by: Mark Mentovai > > Commit-Queue: Alex Gough > > Bug: 1250098 > Change-Id: I6f278db20c440b5dd9952281411723706aa0af2b > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3292209 > Reviewed-by: Mark Mentovai > Commit-Queue: Alex Gough Bug: 1250098 Change-Id: I58ca7c64541832cc00690729b907b210eb583895 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3292345 Bot-Commit: Rubber Stamper Commit-Queue: Alex Gough --- DEPS | 2 +- infra/config/generated/cr-buildbucket.cfg | 12 ------------ infra/config/main.star | 5 ----- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/DEPS b/DEPS index 2ead5cc8d7..c1edb80c15 100644 --- a/DEPS +++ b/DEPS @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2021-04-28' + 'version': 'uploaded:2018-06-13' }, ], 'condition': 'checkout_win and pull_win_toolchain', diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 80e52d73a4..d34621cdf0 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg @@ -450,9 +450,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -486,9 +483,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$gatekeeper": {' ' "group": "client.crashpad"' ' },' @@ -928,9 +922,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' @@ -961,9 +952,6 @@ buckets { } properties: '{' - ' "$depot_tools/windows_sdk": {' - ' "version": "uploaded:2021-04-28"' - ' },' ' "$kitchen": {' ' "devshell": true,' ' "git_auth": true' diff --git a/infra/config/main.star b/infra/config/main.star index e0582e6d41..f51ef23e1e 100755 --- a/infra/config/main.star +++ b/infra/config/main.star @@ -183,11 +183,6 @@ def crashpad_properties(platform, cpu, config, bucket): if cpu != "x64": properties["target_cpu"] = cpu - if platform == "win": - properties["$depot_tools/windows_sdk"] = { - "version": "uploaded:2021-04-28", - } - if bucket == "ci": properties["$gatekeeper"] = { "group": "client.crashpad", From 92f6c212421219456c21190ce2e35357220a2016 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Fri, 19 Nov 2021 14:12:08 -0500 Subject: [PATCH 55/69] Retry UploadReport on http upload failures. This implements a per-report retry rate limit (as opposed to per upload rate limit in ShouldRateLimitUpload). When a report upload ends in a retry state, an in-memory only timestamp is stored with the next possible retry time. This timestamp is a backoff from the main thread work interval, doubling on each attemt. Because this is only stored in memory, on restart reports in the retry state will always be tried once, and then fall back into the next backoff. This continues until 5 retry attempts are reached. Change-Id: Ibde8855a8a9f0743f0b0bd4d5e3de8a45c64bcb6 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3087723 Reviewed-by: Mark Mentovai Reviewed-by: Robert Sesek Commit-Queue: Justin Cohen --- handler/crash_report_upload_thread.cc | 128 ++++++++++++++++++-------- handler/crash_report_upload_thread.h | 36 ++++++++ util/misc/metrics.h | 4 + util/misc/uuid.cc | 4 + util/misc/uuid.h | 1 + util/misc/uuid_test.cc | 16 ++++ 6 files changed, 149 insertions(+), 40 deletions(-) diff --git a/handler/crash_report_upload_thread.cc b/handler/crash_report_upload_thread.cc index 60f172b6c8..3872e1142f 100644 --- a/handler/crash_report_upload_thread.cc +++ b/handler/crash_report_upload_thread.cc @@ -46,6 +46,21 @@ namespace crashpad { +namespace { + +// The number of seconds to wait between checking for pending reports. +const int kRetryWorkIntervalSeconds = 15 * 60; + +#if defined(OS_IOS) +// The number of times to attempt to upload a pending report, repeated on +// failure. Attempts will happen once per launch, once per call to +// ReportPending(), and, if Options.watch_pending_reports is true, once every +// kRetryWorkIntervalSeconds. Currently iOS only. +const int kRetryAttempts = 5; +#endif + +} // namespace + CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database, const std::string& url, const Options& options) @@ -55,7 +70,7 @@ CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database, // absence of a signal from the handler thread. This allows for failed // uploads to be retried periodically, and for pending reports written by // other processes to be recognized. - thread_(options.watch_pending_reports ? 15 * 60.0 + thread_(options.watch_pending_reports ? kRetryWorkIntervalSeconds : WorkerThread::kIndefiniteWait, this), known_pending_report_uuids_(), @@ -154,45 +169,13 @@ void CrashReportUploadThread::ProcessPendingReport( return; } - // This currently implements very simplistic rate-limiting, compatible with - // the Breakpad client, where the strategy is to permit one upload attempt per - // hour, and retire reports that would exceed this limit or for which the - // upload fails on the first attempt. - // - // If upload was requested explicitly (i.e. by user action), we do not - // throttle the upload. - // - // TODO(mark): Provide a proper rate-limiting strategy and allow for failed - // upload attempts to be retried. - if (!report.upload_explicitly_requested && options_.rate_limit) { - time_t last_upload_attempt_time; - if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) { - time_t now = time(nullptr); - if (now >= last_upload_attempt_time) { - // If the most recent upload attempt occurred within the past hour, - // don’t attempt to upload the new report. If it happened longer ago, - // attempt to upload the report. - constexpr int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour - if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) { - database_->SkipReportUpload( - report.uuid, Metrics::CrashSkippedReason::kUploadThrottled); - return; - } - } else { - // The most recent upload attempt purportedly occurred in the future. If - // it “happened” at least one day in the future, assume that the last - // upload attempt time is bogus, and attempt to upload the report. If - // the most recent upload time is in the future but within one day, - // accept it and don’t attempt to upload the report. - constexpr int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day - if (last_upload_attempt_time - now < kBackwardsClockTolerance) { - database_->SkipReportUpload( - report.uuid, Metrics::CrashSkippedReason::kUnexpectedTime); - return; - } - } - } - } + if (ShouldRateLimitUpload(report)) + return; + +#if defined(OS_IOS) + if (ShouldRateLimitRetry(report)) + return; +#endif std::unique_ptr upload_report; CrashReportDatabase::OperationStatus status = @@ -234,6 +217,19 @@ void CrashReportUploadThread::ProcessPendingReport( report.uuid, Metrics::CrashSkippedReason::kPrepareForUploadFailed); break; case UploadResult::kRetry: +#if defined(OS_IOS) + if (upload_report->upload_attempts > kRetryAttempts) { + upload_report.reset(); + database_->SkipReportUpload(report.uuid, + Metrics::CrashSkippedReason::kUploadFailed); + } else { + Metrics::CrashUploadSkipped( + Metrics::CrashSkippedReason::kUploadFailedButCanRetry); + retry_uuid_time_map_[report.uuid] = + time(nullptr) + + (1 << upload_report->upload_attempts) * kRetryWorkIntervalSeconds; + } +#else upload_report.reset(); // TODO(mark): Deal with retries properly: don’t call SkipReportUplaod() @@ -241,6 +237,7 @@ void CrashReportUploadThread::ProcessPendingReport( // too many times. database_->SkipReportUpload(report.uuid, Metrics::CrashSkippedReason::kUploadFailed); +#endif break; } } @@ -344,4 +341,55 @@ void CrashReportUploadThread::DoWork(const WorkerThread* thread) { ProcessPendingReports(); } +bool CrashReportUploadThread::ShouldRateLimitUpload( + const CrashReportDatabase::Report& report) { + if (report.upload_explicitly_requested || !options_.rate_limit) + return false; + + Settings* const settings = database_->GetSettings(); + time_t last_upload_attempt_time; + if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) { + time_t now = time(nullptr); + if (now >= last_upload_attempt_time) { + // If the most recent upload attempt occurred within the past hour, + // don’t attempt to upload the new report. If it happened longer ago, + // attempt to upload the report. + constexpr int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour + if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) { + database_->SkipReportUpload( + report.uuid, Metrics::CrashSkippedReason::kUploadThrottled); + return true; + } + } else { + // The most recent upload attempt purportedly occurred in the future. If + // it “happened” at least one day in the future, assume that the last + // upload attempt time is bogus, and attempt to upload the report. If + // the most recent upload time is in the future but within one day, + // accept it and don’t attempt to upload the report. + constexpr int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day + if (last_upload_attempt_time - now < kBackwardsClockTolerance) { + database_->SkipReportUpload( + report.uuid, Metrics::CrashSkippedReason::kUnexpectedTime); + return true; + } + } + } + return false; +} + +#if defined(OS_IOS) +bool CrashReportUploadThread::ShouldRateLimitRetry( + const CrashReportDatabase::Report& report) { + if (retry_uuid_time_map_.find(report.uuid) != retry_uuid_time_map_.end()) { + time_t now = time(nullptr); + if (now < retry_uuid_time_map_[report.uuid]) { + return true; + } else { + retry_uuid_time_map_.erase(report.uuid); + } + } + return false; +} +#endif + } // namespace crashpad diff --git a/handler/crash_report_upload_thread.h b/handler/crash_report_upload_thread.h index 1a88a087b5..7649ae0db4 100644 --- a/handler/crash_report_upload_thread.h +++ b/handler/crash_report_upload_thread.h @@ -17,6 +17,7 @@ #include #include +#include #include "client/crash_report_database.h" #include "util/misc/uuid.h" @@ -170,10 +171,45 @@ class CrashReportUploadThread : public WorkerThread::Delegate, //! been called on any thread, as well as periodically on a timer. void DoWork(const WorkerThread* thread) override; + //! \brief Rate-limit uploads. + //! + //! \param[in] report The crash report to process. + //! + //! This currently implements very simplistic rate-limiting, compatible with + //! the Breakpad client, where the strategy is to permit one upload attempt + //! per hour, and retire reports that would exceed this limit or for which the + //! upload fails on the first attempt. + //! If upload was requested explicitly (i.e. by user action), do not throttle + //! the upload. + //! + //! TODO(mark): Provide a proper rate-limiting strategy and allow for failed + //! upload attempts to be retried. + bool ShouldRateLimitUpload(const CrashReportDatabase::Report& report); + +#if defined(OS_IOS) + //! \brief Rate-limit report retries. + //! + //! \param[in] report The crash report to process. + //! + //! This implements a per-report retry rate limit (as opposed to per upload + //! rate limit in ShouldRateLimitUpload). When a report upload ends in a retry + //! state, an in-memory only timestamp is stored in |retry_uuid_time_map_| + //! with the next possible retry time. This timestamp is a backoff from the + //! main thread work interval, doubling on each attemt. Because this is only + //! stored in memory, on restart reports in the retry state will always be + //! tried once, and then fall back into the next backoff. This continues until + //! kRetryAttempts is reached. + bool ShouldRateLimitRetry(const CrashReportDatabase::Report& report); +#endif + const Options options_; const std::string url_; WorkerThread thread_; ThreadSafeVector known_pending_report_uuids_; +#if defined(OS_IOS) + // This is not thread-safe, and only used by the worker thread. + std::map retry_uuid_time_map_; +#endif CrashReportDatabase* database_; // weak }; diff --git a/util/misc/metrics.h b/util/misc/metrics.h index 63c673a337..dcd37a6aaa 100644 --- a/util/misc/metrics.h +++ b/util/misc/metrics.h @@ -89,6 +89,10 @@ class Metrics { //! and uploading it to the crash server. kPrepareForUploadFailed = 5, + //! \brief The upload of the crash failed during communication with the + //! server, but the upload can be retried later. + kUploadFailedButCanRetry = 6, + //! \brief The number of values in this enumeration; not a valid value. kMaxValue }; diff --git a/util/misc/uuid.cc b/util/misc/uuid.cc index 32ffea5259..4ed3831175 100644 --- a/util/misc/uuid.cc +++ b/util/misc/uuid.cc @@ -43,6 +43,10 @@ bool UUID::operator==(const UUID& that) const { return memcmp(this, &that, sizeof(*this)) == 0; } +bool UUID::operator<(const UUID& that) const { + return memcmp(this, &that, sizeof(*this)) < 0; +} + void UUID::InitializeToZero() { memset(this, 0, sizeof(*this)); } diff --git a/util/misc/uuid.h b/util/misc/uuid.h index 291baa9f28..7e504a2253 100644 --- a/util/misc/uuid.h +++ b/util/misc/uuid.h @@ -39,6 +39,7 @@ namespace crashpad { struct UUID { bool operator==(const UUID& that) const; bool operator!=(const UUID& that) const { return !operator==(that); } + bool operator<(const UUID& that) const; //! \brief Initializes the %UUID to zero. void InitializeToZero(); diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc index 936e76bf24..28d7ce4bd6 100644 --- a/util/misc/uuid_test.cc +++ b/util/misc/uuid_test.cc @@ -85,24 +85,40 @@ TEST(UUID, UUID) { EXPECT_EQ(uuid_2, uuid); EXPECT_FALSE(uuid != uuid_2); + // Test operator< operator + UUID uuid_3{}; + UUID uuid_4; + uuid_4.InitializeFromString("11111111-1111-1111-1111-111111111111"); + UUID uuid_5; + uuid_5.InitializeFromString("22222222-2222-2222-2222-222222222222"); + + EXPECT_LT(uuid_3, uuid_4); + EXPECT_LT(uuid_3, uuid_5); + EXPECT_LT(uuid_4, uuid_5); + // Make sure that operator== and operator!= check the entire UUID. ++uuid.data_1; EXPECT_NE(uuid, uuid_2); + EXPECT_LT(uuid_2, uuid); --uuid.data_1; ++uuid.data_2; EXPECT_NE(uuid, uuid_2); + EXPECT_LT(uuid_2, uuid); --uuid.data_2; ++uuid.data_3; EXPECT_NE(uuid, uuid_2); + EXPECT_LT(uuid_2, uuid); --uuid.data_3; for (size_t index = 0; index < base::size(uuid.data_4); ++index) { ++uuid.data_4[index]; EXPECT_NE(uuid, uuid_2); + EXPECT_LT(uuid_2, uuid); --uuid.data_4[index]; } for (size_t index = 0; index < base::size(uuid.data_5); ++index) { ++uuid.data_5[index]; EXPECT_NE(uuid, uuid_2); + EXPECT_LT(uuid_2, uuid); --uuid.data_5[index]; } From c8edcf1bb8c89d94e99b85e2942e0a81a8572828 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 19 Nov 2021 13:01:52 -0500 Subject: [PATCH 56/69] Split util/net files into a separate static_library target. Only the handler uses util/net. After 8342e6bd613a5b2e44eca1d74288e3115ccef139, the introduction of an Objective-C class caused Chromium to emit duplicate class defintion warnings in the component build. Bug: chromium:1270609 Change-Id: I2770528347aef406bb21a79d295f702498f7b37e Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3290276 Commit-Queue: Robert Sesek Reviewed-by: Mark Mentovai --- handler/BUILD.gn | 1 + tools/BUILD.gn | 1 + util/BUILD.gn | 95 ++++++++++++++++++++++++++++++------------------ 3 files changed, 61 insertions(+), 36 deletions(-) diff --git a/handler/BUILD.gn b/handler/BUILD.gn index f66da69a4c..e7a4966127 100644 --- a/handler/BUILD.gn +++ b/handler/BUILD.gn @@ -112,6 +112,7 @@ static_library("common") { "../client:common", "../snapshot", "../util", + "../util:net", ] if (crashpad_is_win) { cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union diff --git a/tools/BUILD.gn b/tools/BUILD.gn index 91e20a03df..4069e070c5 100644 --- a/tools/BUILD.gn +++ b/tools/BUILD.gn @@ -48,6 +48,7 @@ if (!crashpad_is_ios) { "../compat", "$mini_chromium_source_parent:base", "../util", + "../util:net", ] } } diff --git a/util/BUILD.gn b/util/BUILD.gn index 7983dfd84c..a376c0c92a 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -217,17 +217,6 @@ crashpad_static_library("util") { "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/url.cc", - "net/url.h", "numeric/checked_address_range.cc", "numeric/checked_address_range.h", "numeric/checked_range.h", @@ -369,7 +358,6 @@ crashpad_static_library("util") { "mach/scoped_task_suspend.h", "mach/task_for_pid.cc", "mach/task_for_pid.h", - "net/http_transport_mac.mm", "posix/process_info_mac.cc", "process/process_memory_mac.cc", "process/process_memory_mac.h", @@ -397,34 +385,11 @@ crashpad_static_library("util") { "ios/raw_logging.h", "ios/scoped_vm_read.cc", "ios/scoped_vm_read.h", - "net/http_transport_mac.mm", ] } deps = [] - if (crashpad_http_transport_impl == "socket") { - sources += [ "net/http_transport_socket.cc" ] - if (crashpad_use_boringssl_for_http_transport_socket) { - defines += [ "CRASHPAD_USE_BORINGSSL" ] - - if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { - deps += [ "//third_party/boringssl" ] - } else { - libs = [ - "crypto", - "ssl", - ] - } - } - } else if (crashpad_http_transport_impl == "libcurl") { - sources += [ "net/http_transport_libcurl.cc" ] - if (crashpad_is_in_fuchsia) { - # Host Linux builds in Fuchsia don't have libcurl in a sysroot. - deps += [ "//third_party/curl:libcurl" ] - } - } - if (crashpad_is_android) { sources += [ "linux/initial_signal_dispositions.cc", @@ -488,7 +453,6 @@ crashpad_static_library("util") { "misc/clock_win.cc", "misc/paths_win.cc", "misc/time_win.cc", - "net/http_transport_win.cc", "process/process_memory_win.cc", "process/process_memory_win.h", "synchronization/semaphore_win.cc", @@ -652,12 +616,70 @@ crashpad_static_library("util") { } } +# net is split into a separate target from util so that client code does +# not have to depend on it. +crashpad_static_library("net") { + sources = [ + "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/url.cc", + "net/url.h", + ] + + deps = [ + ":util", + "$mini_chromium_source_parent:base", + ] + + if (crashpad_is_mac && !crashpad_is_in_fuchsia) { + sources += [ "net/http_transport_mac.mm" ] + } + + if (crashpad_is_ios) { + sources += [ "net/http_transport_mac.mm" ] + } + + if (crashpad_is_win) { + sources += [ "net/http_transport_win.cc" ] + } + + if (crashpad_http_transport_impl == "socket") { + sources += [ "net/http_transport_socket.cc" ] + if (crashpad_use_boringssl_for_http_transport_socket) { + defines += [ "CRASHPAD_USE_BORINGSSL" ] + + if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { + deps += [ "//third_party/boringssl" ] + } else { + libs = [ + "crypto", + "ssl", + ] + } + } + } else if (crashpad_http_transport_impl == "libcurl") { + sources += [ "net/http_transport_libcurl.cc" ] + if (crashpad_is_in_fuchsia) { + # Host Linux builds in Fuchsia don't have libcurl in a sysroot. + deps += [ "//third_party/curl:libcurl" ] + } + } +} + if (!crashpad_is_android && !crashpad_is_ios) { crashpad_executable("http_transport_test_server") { testonly = true sources = [ "net/http_transport_test_server.cc" ] deps = [ + ":net", ":util", "$mini_chromium_source_parent:base", "../third_party/cpp-httplib", @@ -866,6 +888,7 @@ source_set("util_test") { ] deps = [ + ":net", ":util", "$mini_chromium_source_parent:base", "../client", From 10e82d53189403e3abee94331d8bf3bd22c33bbc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 19 Nov 2021 16:04:11 -0500 Subject: [PATCH 57/69] mac: Make crashpad build with the 12.0 SDK The size of dyld_all_image_infos didn't change, but the last 128 bit of `reserved` moved out of `reserved` and got names. On 64-bit, that's straightforward -- just move two uint64s out of the array into fields. On 32-bit, it's fairly awkward: It's 4 of the uintptr_t `reserved` array, which means `UIntPtr, reserved, [4]` would have to diverge between 32-bit and 64-bit, and also shared_cache_fs_obj_id would straddle the `end_v14` boundary. Since macOS 12.0 doesn't support 32-bit builds, just punt on this for 32-bit. (This might possibly mean that crashpad-on-apple-watch might not compile, but that's a build configuration that doesn't exist.) See comment 9 and 6 on the bug. Bug: crashpad:375, chromium:1265179 Change-Id: I221af20c59c30a8176d5685d3f5e84aaf3de9afe Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3253742 Commit-Queue: Nico Weber Auto-Submit: Nico Weber Reviewed-by: Mark Mentovai Message-Id: Merged from chromium 83a01b8e2cd2d4d96b0e298d012bb3a2bd93c64f Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3293642 Commit-Queue: Robert Sesek --- compat/mac/AvailabilityVersions.h | 6 ++++++ snapshot/mac/process_types/custom.cc | 1 + snapshot/mac/process_types/dyld_images.proctype | 8 ++++++-- snapshot/mac/process_types_test.cc | 12 ++++++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/compat/mac/AvailabilityVersions.h b/compat/mac/AvailabilityVersions.h index 0bedb3d2c0..b9bb74ec7e 100644 --- a/compat/mac/AvailabilityVersions.h +++ b/compat/mac/AvailabilityVersions.h @@ -87,4 +87,10 @@ #define __MAC_11_0 110000 #endif +// 12.0 SDK + +#ifndef __MAC_12_0 +#define __MAC_12_0 120000 +#endif + #endif // CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_ diff --git a/snapshot/mac/process_types/custom.cc b/snapshot/mac/process_types/custom.cc index d80a984bf9..06c13001d0 100644 --- a/snapshot/mac/process_types/custom.cc +++ b/snapshot/mac/process_types/custom.cc @@ -147,6 +147,7 @@ size_t dyld_all_image_infos::ExpectedSizeForVersion( std::numeric_limits::max(), // 15, see below offsetof(dyld_all_image_infos, end_v16), // 16 sizeof(dyld_all_image_infos), // 17 + sizeof(dyld_all_image_infos), // 18 }; if (version >= base::size(kSizeForVersion)) { diff --git a/snapshot/mac/process_types/dyld_images.proctype b/snapshot/mac/process_types/dyld_images.proctype index 589ad097a0..5c57a26f0a 100644 --- a/snapshot/mac/process_types/dyld_images.proctype +++ b/snapshot/mac/process_types/dyld_images.proctype @@ -127,12 +127,16 @@ PROCESS_TYPE_STRUCT_BEGIN(dyld_all_image_infos) // preceding the padding in the 32-bit structure that would natively be // addressed at index 4 of |reserved|. Treat reserved_4_32 as only available // in version 16 of the structure. + // In the 12.0 SDK, 2 of the trailing UIntPtrs on 64-bit and + // 4 of them on 32-bit were replaced by two uint64_ts. On 32-bit, that + // awkwardly straddles end_v14. Since macOS 12.0 is 64-bit only, the proctype + // version of this struct only has these uint64_ts in the 64-bit version. PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, reserved, [4]) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_4_64) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_5) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_6) - PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_7) - PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_8) + PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, shared_cache_fs_id) + PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, shared_cache_fs_obj_id) PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_v14) PROCESS_TYPE_STRUCT_MEMBER(Reserved32_32Only, reserved_4_32) diff --git a/snapshot/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc index e0c3c9cb37..90f5c1f679 100644 --- a/snapshot/mac/process_types_test.cc +++ b/snapshot/mac/process_types_test.cc @@ -356,8 +356,16 @@ TEST(ProcessTypes, DyldImagesSelf) { self_image_infos->reserved[4]); EXPECT_EQ(proctype_image_infos.reserved_5, self_image_infos->reserved[5]); EXPECT_EQ(proctype_image_infos.reserved_6, self_image_infos->reserved[6]); - EXPECT_EQ(proctype_image_infos.reserved_7, self_image_infos->reserved[7]); - EXPECT_EQ(proctype_image_infos.reserved_8, self_image_infos->reserved[8]); +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 + uint64_t shared_cache_fs_id = self_image_infos->sharedCacheFSID; + uint64_t shared_cache_fs_obj_id = self_image_infos->sharedCacheFSObjID; +#else + uint64_t shared_cache_fs_id = self_image_infos->reserved[7]; + uint64_t shared_cache_fs_obj_id = self_image_infos->reserved[8]; +#endif + EXPECT_EQ(proctype_image_infos.shared_cache_fs_id, shared_cache_fs_id); + EXPECT_EQ(proctype_image_infos.shared_cache_fs_obj_id, + shared_cache_fs_obj_id); #endif } #endif From 4b86b277735e43f178bc04bdfedcffe2fdbdf0f8 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Sat, 20 Nov 2021 23:03:45 -0500 Subject: [PATCH 58/69] ios: Add IOSIntermediateDumpInterface. Change IOSIntermediateDumpReader to take a new interface that can be backed by a FilePath (as it is now) or a StringFile byte array, which can be useful for tests, especially with fuzzing. Change-Id: I02a25cfb7cd204975d1bcce80201bd10944f3f2e Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3270755 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/ios_handler/in_process_handler.cc | 2 +- client/ios_handler/in_process_handler_test.cc | 1 - ..._process_intermediate_dump_handler_test.cc | 15 +++-- .../process_snapshot_ios_intermediate_dump.cc | 24 ++++++- .../process_snapshot_ios_intermediate_dump.h | 24 +++++-- ...ess_snapshot_ios_intermediate_dump_test.cc | 23 +++---- util/BUILD.gn | 2 + util/ios/ios_intermediate_dump_interface.cc | 60 +++++++++++++++++ util/ios/ios_intermediate_dump_interface.h | 67 +++++++++++++++++++ util/ios/ios_intermediate_dump_reader.cc | 28 ++++---- util/ios/ios_intermediate_dump_reader.h | 16 +++-- util/ios/ios_intermediate_dump_reader_test.cc | 29 ++++---- 12 files changed, 229 insertions(+), 62 deletions(-) create mode 100644 util/ios/ios_intermediate_dump_interface.cc create mode 100644 util/ios/ios_intermediate_dump_interface.h diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index d57b5f292d..285218fd72 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -178,7 +178,7 @@ void InProcessHandler::ProcessIntermediateDump( INITIALIZATION_STATE_DCHECK_VALID(initialized_); ProcessSnapshotIOSIntermediateDump process_snapshot; - if (process_snapshot.Initialize(file, annotations)) { + if (process_snapshot.InitializeWithFilePath(file, annotations)) { SaveSnapshot(process_snapshot); } } diff --git a/client/ios_handler/in_process_handler_test.cc b/client/ios_handler/in_process_handler_test.cc index 13dd366d4b..d7dfc05304 100644 --- a/client/ios_handler/in_process_handler_test.cc +++ b/client/ios_handler/in_process_handler_test.cc @@ -142,7 +142,6 @@ TEST_F(InProcessHandlerTest, TestPendingFileLimit) { handler().ProcessIntermediateDumps({}); VerifyRemainingFileCount(0, 0); ClearFiles(); - } } // namespace diff --git a/client/ios_handler/in_process_intermediate_dump_handler_test.cc b/client/ios_handler/in_process_intermediate_dump_handler_test.cc index 26c40c0b71..b79f93f67b 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler_test.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler_test.cc @@ -93,7 +93,7 @@ class InProcessIntermediateDumpHandlerTest : public testing::Test { TEST_F(InProcessIntermediateDumpHandlerTest, TestSystem) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); // Snpahot const SystemSnapshot* system = process_snapshot.System(); @@ -145,7 +145,8 @@ TEST_F(InProcessIntermediateDumpHandlerTest, TestAnnotations) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {{"after_dump", "post"}})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath( + path(), {{"after_dump", "post"}})); auto process_map = process_snapshot.AnnotationsSimpleMap(); EXPECT_EQ(process_map.size(), 2u); @@ -199,7 +200,7 @@ TEST_F(InProcessIntermediateDumpHandlerTest, TestAnnotations) { TEST_F(InProcessIntermediateDumpHandlerTest, TestThreads) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); const auto& threads = process_snapshot.Threads(); ASSERT_GT(threads.size(), 0u); @@ -217,26 +218,26 @@ TEST_F(InProcessIntermediateDumpHandlerTest, TestThreads) { TEST_F(InProcessIntermediateDumpHandlerTest, TestProcess) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); EXPECT_EQ(process_snapshot.ProcessID(), getpid()); } TEST_F(InProcessIntermediateDumpHandlerTest, TestMachException) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); } TEST_F(InProcessIntermediateDumpHandlerTest, TestSignalException) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); } TEST_F(InProcessIntermediateDumpHandlerTest, TestNSException) { WriteReport(); internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), {})); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), {})); } } // namespace diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc index f4769ff657..3f9414d956 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc @@ -36,14 +36,24 @@ namespace internal { using Key = internal::IntermediateDumpKey; -bool ProcessSnapshotIOSIntermediateDump::Initialize( +bool ProcessSnapshotIOSIntermediateDump::InitializeWithFilePath( const base::FilePath& dump_path, const std::map& annotations) { + IOSIntermediateDumpFilePath dump_interface; + if (!dump_interface.Initialize(dump_path)) + return false; + + return InitializeWithFileInterface(dump_interface, annotations); +} + +bool ProcessSnapshotIOSIntermediateDump::InitializeWithFileInterface( + const IOSIntermediateDumpInterface& dump_interface, + const std::map& annotations) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); annotations_simple_map_ = annotations; - if (!reader_.Initialize(dump_path)) { + if (!reader_.Initialize(dump_interface)) { return false; } @@ -165,6 +175,16 @@ bool ProcessSnapshotIOSIntermediateDump::Initialize( return true; } +void ProcessSnapshotIOSIntermediateDump::SetClientID(const UUID& client_id) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + client_id_ = client_id; +} + +void ProcessSnapshotIOSIntermediateDump::SetReportID(const UUID& report_id) { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + report_id_ = report_id; +} + pid_t ProcessSnapshotIOSIntermediateDump::ProcessID() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return p_pid_; diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.h b/snapshot/ios/process_snapshot_ios_intermediate_dump.h index 61312f0741..fb05cdaaa0 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.h +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.h @@ -46,24 +46,38 @@ class ProcessSnapshotIOSIntermediateDump final : public ProcessSnapshot { //! \brief Initializes the object. //! - //! \param[in] dump_path A class containing various system data points. + //! \param[in] dump_path The intermediate dump to read. + //! \param[in] annotations Process annotations to set in each crash report. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(const base::FilePath& dump_path, - const std::map& annotations); + bool InitializeWithFilePath( + const base::FilePath& dump_path, + const std::map& annotations); + + //! \brief Initializes the object. + //! + //! \param[in] dump_interface An interface corresponding to an intermediate + //! dump file. + //! \param[in] annotations Process annotations to set in each crash report. + //! + //! \return `true` if the snapshot could be created, `false` otherwise with + //! an appropriate message logged. + bool InitializeWithFileInterface( + const IOSIntermediateDumpInterface& dump_interface, + const std::map& annotations); //! On iOS, the client ID is under the control of the snapshot producer, //! which may call this method to set the client ID. If this is not done, //! ClientID() will return an identifier consisting entirely of zeroes. - void SetClientID(const UUID& client_id) { client_id_ = client_id; } + void SetClientID(const UUID& client_id); //! \brief Sets the value to be returned by ReportID(). //! //! On iOS, the crash report ID is under the control of the snapshot //! producer, which may call this method to set the report ID. If this is not //! done, ReportID() will return an identifier consisting entirely of zeroes. - void SetReportID(const UUID& report_id) { report_id_ = report_id; } + void SetReportID(const UUID& report_id); // ProcessSnapshot: pid_t ProcessID() const override; diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc index dc3ad272d4..910c124d25 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc @@ -456,14 +456,14 @@ class ProcessSnapshotIOSIntermediateDumpTest : public testing::Test { TEST_F(ProcessSnapshotIOSIntermediateDumpTest, InitializeNoFile) { const base::FilePath file; ProcessSnapshotIOSIntermediateDump process_snapshot; - EXPECT_FALSE(process_snapshot.Initialize(file, annotations())); + EXPECT_FALSE(process_snapshot.InitializeWithFilePath(file, annotations())); EXPECT_TRUE(LoggingRemoveFile(path())); EXPECT_FALSE(IsRegularFile(path())); } TEST_F(ProcessSnapshotIOSIntermediateDumpTest, InitializeEmpty) { ProcessSnapshotIOSIntermediateDump process_snapshot; - EXPECT_FALSE(process_snapshot.Initialize(path(), annotations())); + EXPECT_FALSE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); } @@ -476,7 +476,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, InitializeMinimumDump) { { IOSIntermediateDumpWriter::ScopedMap map(writer(), Key::kProcessInfo); } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); } @@ -489,7 +489,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, MissingSystemDump) { { IOSIntermediateDumpWriter::ScopedMap map(writer(), Key::kProcessInfo); } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_FALSE(process_snapshot.Initialize(path(), annotations())); + ASSERT_FALSE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); } @@ -501,7 +501,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, MissingProcessDump) { { IOSIntermediateDumpWriter::ScopedMap map(writer(), Key::kSystemInfo); } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_FALSE(process_snapshot.Initialize(path(), annotations())); + ASSERT_FALSE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); } @@ -526,7 +526,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, EmptySignalDump) { } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); } @@ -552,7 +552,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, EmptyMachDump) { } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); } @@ -578,7 +578,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, EmptyExceptionDump) { } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); } @@ -608,7 +608,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, EmptyUncaughtNSExceptionDump) { } } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); } @@ -625,7 +625,7 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FullReport) { WriteMachException(writer()); } ProcessSnapshotIOSIntermediateDump process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(path(), annotations())); + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); EXPECT_FALSE(IsRegularFile(path())); EXPECT_TRUE(DumpSnapshot(process_snapshot)); ExpectSnapshot(process_snapshot); @@ -634,9 +634,8 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FullReport) { TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FuzzTestCases) { base::FilePath fuzz_path = TestPaths::TestDataRoot().Append(FILE_PATH_LITERAL( "snapshot/ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa")); - crashpad::internal::ProcessSnapshotIOSIntermediateDump process_snapshot; - EXPECT_TRUE(process_snapshot.Initialize(fuzz_path, {})); + EXPECT_TRUE(process_snapshot.InitializeWithFilePath(fuzz_path, {})); EXPECT_TRUE(LoggingRemoveFile(path())); } diff --git a/util/BUILD.gn b/util/BUILD.gn index a376c0c92a..7b70440887 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -369,6 +369,8 @@ crashpad_static_library("util") { "ios/ios_intermediate_dump_data.cc", "ios/ios_intermediate_dump_data.h", "ios/ios_intermediate_dump_format.h", + "ios/ios_intermediate_dump_interface.cc", + "ios/ios_intermediate_dump_interface.h", "ios/ios_intermediate_dump_list.cc", "ios/ios_intermediate_dump_list.h", "ios/ios_intermediate_dump_map.cc", diff --git a/util/ios/ios_intermediate_dump_interface.cc b/util/ios/ios_intermediate_dump_interface.cc new file mode 100644 index 0000000000..bc583c4b13 --- /dev/null +++ b/util/ios/ios_intermediate_dump_interface.cc @@ -0,0 +1,60 @@ +// Copyright 2021 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. + +#include "util/ios/ios_intermediate_dump_interface.h" + +#include "util/file/scoped_remove_file.h" + +namespace crashpad { +namespace internal { + +bool IOSIntermediateDumpFilePath::Initialize(const base::FilePath& path) { + INITIALIZATION_STATE_SET_INITIALIZING(initialized_); + ScopedRemoveFile file_remover(path); + handle_.reset(LoggingOpenFileForRead(path)); + if (!handle_.is_valid()) + return false; + + reader_ = std::make_unique(handle_.get()); + INITIALIZATION_STATE_SET_VALID(initialized_); + return true; +} + +FileReaderInterface* IOSIntermediateDumpFilePath::FileReader() const { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + return reader_.get(); +} + +FileOffset IOSIntermediateDumpFilePath::Size() const { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + return LoggingFileSizeByHandle(handle_.get()); +} + +IOSIntermediateDumpByteArray::IOSIntermediateDumpByteArray(const void* data, + size_t size) { + string_file_ = std::make_unique(); + string_file_->SetString( + std::string(reinterpret_cast(data), size)); +} + +FileReaderInterface* IOSIntermediateDumpByteArray::FileReader() const { + return string_file_.get(); +} + +FileOffset IOSIntermediateDumpByteArray::Size() const { + return string_file_->string().size(); +} + +} // namespace internal +} // namespace crashpad diff --git a/util/ios/ios_intermediate_dump_interface.h b/util/ios/ios_intermediate_dump_interface.h new file mode 100644 index 0000000000..6d14d2f9e7 --- /dev/null +++ b/util/ios/ios_intermediate_dump_interface.h @@ -0,0 +1,67 @@ +// Copyright 2021 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. + +#ifndef CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_INTERFACE_H_ +#define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_INTERFACE_H_ + +#include "base/files/file_path.h" +#include "util/file/file_reader.h" +#include "util/file/filesystem.h" +#include "util/file/string_file.h" +#include "util/misc/initialization_state_dcheck.h" + +namespace crashpad { +namespace internal { + +//! \brief The base class for reading data into an IOSIntermediateDumpReader. +class IOSIntermediateDumpInterface { + public: + virtual FileReaderInterface* FileReader() const = 0; + virtual FileOffset Size() const = 0; +}; + +//! \brief An intermediate dump backed by a FilePath. FilePath is unlinked +//! immediately upon initialization to ensure files are only processed once +//! in the event a crash is introduced by this intermediate dump. +class IOSIntermediateDumpFilePath : public IOSIntermediateDumpInterface { + public: + bool Initialize(const base::FilePath& path); + + // IOSIntermediateDumpInterface: + FileReaderInterface* FileReader() const override; + FileOffset Size() const override; + + private: + ScopedFileHandle handle_; + std::unique_ptr reader_; + InitializationStateDcheck initialized_; +}; + +//! \brief An intermediate dump backed by a byte array. +class IOSIntermediateDumpByteArray : public IOSIntermediateDumpInterface { + public: + IOSIntermediateDumpByteArray(const void* data, size_t size); + + // IOSIntermediateDumpInterface + FileReaderInterface* FileReader() const override; + FileOffset Size() const override; + + private: + std::unique_ptr string_file_; +}; + +} // namespace internal +} // namespace crashpad + +#endif // CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_INTERFACE_H_ diff --git a/util/ios/ios_intermediate_dump_reader.cc b/util/ios/ios_intermediate_dump_reader.cc index 853d92cd17..0b41eab5cd 100644 --- a/util/ios/ios_intermediate_dump_reader.cc +++ b/util/ios/ios_intermediate_dump_reader.cc @@ -29,31 +29,35 @@ namespace crashpad { namespace internal { -bool IOSIntermediateDumpReader::Initialize(const base::FilePath& path) { - ScopedFileHandle handle(LoggingOpenFileForRead(path)); - auto reader = std::make_unique(handle.get()); +bool IOSIntermediateDumpReader::Initialize( + const IOSIntermediateDumpInterface& dump_interface) { + INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - // In the event a crash is introduced by this intermediate dump, don't ever - // read a file twice. To ensure this doesn't happen, immediately unlink. - LoggingRemoveFile(path); - - // Don't initialize invalid or empty files. - FileOffset size = LoggingFileSizeByHandle(handle.get()); - if (!handle.is_valid() || size == 0) { + // Don't initialize empty files. + FileOffset size = dump_interface.Size(); + if (size == 0) { return false; } - if (!Parse(reader.get(), size)) { + if (!Parse(dump_interface.FileReader(), size)) { LOG(ERROR) << "Intermediate dump parsing failed"; + // Intentially do not return false here, as it may be possible to extract a + // useful minidump out of a partial intermediate dump. } + INITIALIZATION_STATE_SET_VALID(initialized_); return true; } +const IOSIntermediateDumpMap* IOSIntermediateDumpReader::RootMap() { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + return &intermediate_dump_; +} + bool IOSIntermediateDumpReader::Parse(FileReaderInterface* reader, FileOffset file_size) { std::stack stack; - stack.push(&minidump_); + stack.push(&intermediate_dump_); using Command = IOSIntermediateDumpWriter::CommandType; using Type = IOSIntermediateDumpObject::Type; diff --git a/util/ios/ios_intermediate_dump_reader.h b/util/ios/ios_intermediate_dump_reader.h index e1c42172a2..513d52277e 100644 --- a/util/ios/ios_intermediate_dump_reader.h +++ b/util/ios/ios_intermediate_dump_reader.h @@ -15,9 +15,9 @@ #ifndef CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_ #define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_ -#include "base/files/file_path.h" -#include "util/file/file_reader.h" +#include "util/ios/ios_intermediate_dump_interface.h" #include "util/ios/ios_intermediate_dump_map.h" +#include "util/misc/initialization_state_dcheck.h" namespace crashpad { namespace internal { @@ -31,26 +31,28 @@ class IOSIntermediateDumpReader { IOSIntermediateDumpReader& operator=(const IOSIntermediateDumpReader&) = delete; - //! \brief Open and parses \a path, ignoring empty files. + //! \brief Open and parses \a dump_interface. //! //! Will attempt to parse the binary file, similar to a JSON file, using the //! same format used by IOSIntermediateDumpWriter, resulting in an //! IOSIntermediateDumpMap //! - //! \param[in] path The intermediate dump to read. + //! \param[in] dump_interface An interface corresponding to an intermediate + //! dump file. //! //! \return On success, returns `true`, otherwise returns `false`. Clients may //! still attempt to parse RootMap, as partial minidumps may still be //! usable. - bool Initialize(const base::FilePath& path); + bool Initialize(const IOSIntermediateDumpInterface& dump_interface); //! \brief Returns an IOSIntermediateDumpMap corresponding to the root of the //! intermediate dump. - const IOSIntermediateDumpMap* RootMap() { return &minidump_; } + const IOSIntermediateDumpMap* RootMap(); private: bool Parse(FileReaderInterface* reader, FileOffset file_size); - IOSIntermediateDumpMap minidump_; + IOSIntermediateDumpMap intermediate_dump_; + InitializationStateDcheck initialized_; }; } // namespace internal diff --git a/util/ios/ios_intermediate_dump_reader_test.cc b/util/ios/ios_intermediate_dump_reader_test.cc index 6892120898..a223b441e7 100644 --- a/util/ios/ios_intermediate_dump_reader_test.cc +++ b/util/ios/ios_intermediate_dump_reader_test.cc @@ -48,6 +48,7 @@ class IOSIntermediateDumpReaderTest : public testing::Test { writer_ = std::make_unique(); ASSERT_TRUE(writer_->Open(path_)); ASSERT_TRUE(IsRegularFile(path_)); + dump_interface_.Initialize(path_); } void TearDown() override { @@ -59,6 +60,7 @@ class IOSIntermediateDumpReaderTest : public testing::Test { int fd() { return fd_.get(); } const base::FilePath& path() const { return path_; } + const auto& dump_interface() const { return dump_interface_; } std::unique_ptr writer_; @@ -66,22 +68,20 @@ class IOSIntermediateDumpReaderTest : public testing::Test { base::ScopedFD fd_; ScopedTempDir temp_dir_; base::FilePath path_; + internal::IOSIntermediateDumpFilePath dump_interface_; }; TEST_F(IOSIntermediateDumpReaderTest, ReadNoFile) { internal::IOSIntermediateDumpReader reader; - EXPECT_FALSE(reader.Initialize(base::FilePath())); - EXPECT_TRUE(LoggingRemoveFile(path())); + internal::IOSIntermediateDumpFilePath dump_interface; + EXPECT_FALSE(dump_interface.Initialize(base::FilePath())); EXPECT_FALSE(IsRegularFile(path())); } TEST_F(IOSIntermediateDumpReaderTest, ReadEmptyFile) { internal::IOSIntermediateDumpReader reader; - EXPECT_FALSE(reader.Initialize(path())); + EXPECT_FALSE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); - - const auto root_map = reader.RootMap(); - EXPECT_TRUE(root_map->empty()); } TEST_F(IOSIntermediateDumpReaderTest, ReadHelloWorld) { @@ -89,7 +89,7 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadHelloWorld) { EXPECT_TRUE( LoggingWriteFile(fd(), hello_world.c_str(), hello_world.length())); internal::IOSIntermediateDumpReader reader; - EXPECT_TRUE(reader.Initialize(path())); + EXPECT_TRUE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -113,11 +113,10 @@ TEST_F(IOSIntermediateDumpReaderTest, FuzzTestCases) { 0x1, 0x7, 0x16}; - EXPECT_TRUE(LoggingWriteFile(fd(), &fuzz1, sizeof(fuzz1))); - internal::IOSIntermediateDumpReader reader; - EXPECT_TRUE(reader.Initialize(path())); - EXPECT_FALSE(IsRegularFile(path())); + internal::IOSIntermediateDumpByteArray dump_interface(fuzz1, sizeof(fuzz1)); + internal::IOSIntermediateDumpReader reader; + EXPECT_TRUE(reader.Initialize(dump_interface)); const auto root_map = reader.RootMap(); EXPECT_TRUE(root_map->empty()); } @@ -136,7 +135,7 @@ TEST_F(IOSIntermediateDumpReaderTest, WriteBadPropertyDataLength) { size_t value_length = 999999; EXPECT_TRUE(LoggingWriteFile(fd(), &value_length, sizeof(size_t))); EXPECT_TRUE(LoggingWriteFile(fd(), &value, sizeof(value))); - EXPECT_TRUE(reader.Initialize(path())); + EXPECT_TRUE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -159,7 +158,7 @@ TEST_F(IOSIntermediateDumpReaderTest, InvalidArrayInArray) { writer_->AddProperty(Key::kVersion, &version); } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(path())); + EXPECT_TRUE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -181,7 +180,7 @@ TEST_F(IOSIntermediateDumpReaderTest, InvalidPropertyInArray) { writer_->AddProperty(Key::kVersion, &version); } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(path())); + EXPECT_TRUE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -218,7 +217,7 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadValidData) { } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(path())); + EXPECT_TRUE(reader.Initialize(dump_interface())); EXPECT_FALSE(IsRegularFile(path())); auto root_map = reader.RootMap(); From 3a7e935a8687e579537861cc23209f30c00155f3 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 22 Nov 2021 15:18:15 -0500 Subject: [PATCH 59/69] ios: Handle partial intermediate dumps and exception contexts. Testing in beta has shown a few examples of a cropped intermediate dump still providing useful information, but due to the order intermediate dump data is written, could be improved. - Change the order of writing data to the intermediate dump by increasing the priority of the Exception block from: Header / Process / System / Threads/ Modules / Exception to Header / Process / System / Exception / Threads / Modules - Annotate minidump reports generated from incomplete intermediate dumps with the key 'crashpad_intermediate_dump_incomplete'. - Handle partial exception contexts rather than throwing them away. Change-Id: I543c1d3135c42e5b8e339e498ea0c86002f37ea3 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3294862 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/ios_handler/in_process_handler.cc | 15 ++++-- client/ios_handler/in_process_handler.h | 5 +- ...xception_snapshot_ios_intermediate_dump.cc | 50 ++++++++++--------- .../process_snapshot_ios_intermediate_dump.cc | 6 ++- ...ess_snapshot_ios_intermediate_dump_test.cc | 29 ++++++++++- util/ios/ios_intermediate_dump_reader.cc | 11 ++-- util/ios/ios_intermediate_dump_reader.h | 18 ++++++- util/ios/ios_intermediate_dump_reader_test.cc | 15 +++--- 8 files changed, 107 insertions(+), 42 deletions(-) diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 285218fd72..6798734896 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -308,12 +308,21 @@ InProcessHandler::ScopedReport::ScopedReport( const std::map& annotations, const uint64_t* frames, const size_t num_frames) - : rootMap_(writer) { + : writer_(writer), + frames_(frames), + num_frames_(num_frames), + rootMap_(writer) { InProcessIntermediateDumpHandler::WriteHeader(writer); InProcessIntermediateDumpHandler::WriteProcessInfo(writer, annotations); InProcessIntermediateDumpHandler::WriteSystemInfo(writer, system_data); - InProcessIntermediateDumpHandler::WriteThreadInfo(writer, frames, num_frames); - InProcessIntermediateDumpHandler::WriteModuleInfo(writer); +} + +InProcessHandler::ScopedReport::~ScopedReport() { + // Write threads and modules last (after the exception itself is written by + // DumpExceptionFrom*.) + InProcessIntermediateDumpHandler::WriteThreadInfo( + writer_, frames_, num_frames_); + InProcessIntermediateDumpHandler::WriteModuleInfo(writer_); } bool InProcessHandler::OpenNewFile() { diff --git a/client/ios_handler/in_process_handler.h b/client/ios_handler/in_process_handler.h index e586219adf..d94f19e7e6 100644 --- a/client/ios_handler/in_process_handler.h +++ b/client/ios_handler/in_process_handler.h @@ -159,11 +159,14 @@ class InProcessHandler { const std::map& annotations, const uint64_t* frames = nullptr, const size_t num_frames = 0); - ~ScopedReport() {} + ~ScopedReport(); ScopedReport(const ScopedReport&) = delete; ScopedReport& operator=(const ScopedReport&) = delete; private: + IOSIntermediateDumpWriter* writer_; + const uint64_t* frames_; + const size_t num_frames_; IOSIntermediateDumpWriter::ScopedRootMap rootMap_; }; diff --git a/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc b/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc index 5ad02076c8..c4d99e77a6 100644 --- a/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/exception_snapshot_ios_intermediate_dump.cc @@ -293,36 +293,40 @@ void ExceptionSnapshotIOSIntermediateDump::LoadContextFromThread( const IOSIntermediateDumpData* state_dump = GetDataFromMap(exception_data, Key::kState); if (state_dump) { - const std::vector& bytes = state_dump->bytes(); + std::vector bytes = state_dump->bytes(); size_t actual_length = bytes.size(); size_t expected_length = ThreadStateLengthForFlavor(flavor); - // TODO(justincohen): Consider zero-ing out bytes if actual_length is - // shorter than expected_length, and tolerating actual_length longer than - // expected_length. - if (expected_length == actual_length) { - const ConstThreadState state = - reinterpret_cast(bytes.data()); - mach_msg_type_number_t state_count = bytes.size() / sizeof(uint32_t); + if (actual_length < expected_length) { + // Zero out bytes if actual_length is shorter than expected_length. + bytes.resize(expected_length, 0); + actual_length = bytes.size(); + LOG(WARNING) << "Exception context length " << actual_length + << " shorter than expected length " << expected_length; + } + const ConstThreadState state = + reinterpret_cast(bytes.data()); + // Tolerating actual_length longer than expected_length by setting + // state_count based on expected_length, not bytes.size(). + mach_msg_type_number_t state_count = expected_length / sizeof(uint32_t); #if defined(ARCH_CPU_X86_64) - InitializeCPUContextX86_64(&context_x86_64_, - flavor, - state, - state_count, - &thread_state, - &float_state, - &debug_state); + InitializeCPUContextX86_64(&context_x86_64_, + flavor, + state, + state_count, + &thread_state, + &float_state, + &debug_state); #elif defined(ARCH_CPU_ARM64) - InitializeCPUContextARM64(&context_arm64_, - flavor, - state, - state_count, - &thread_state, - &float_state, - &debug_state); + InitializeCPUContextARM64(&context_arm64_, + flavor, + state, + state_count, + &thread_state, + &float_state, + &debug_state); #else #error Port to your CPU architecture #endif - } } } diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc index 3f9414d956..bf973a3ab8 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc @@ -53,8 +53,12 @@ bool ProcessSnapshotIOSIntermediateDump::InitializeWithFileInterface( annotations_simple_map_ = annotations; - if (!reader_.Initialize(dump_interface)) { + IOSIntermediateDumpReaderInitializeResult result = + reader_.Initialize(dump_interface); + if (result == IOSIntermediateDumpReaderInitializeResult::kFailure) { return false; + } else if (result == IOSIntermediateDumpReaderInitializeResult::kIncomplete) { + annotations_simple_map_["crashpad_intermediate_dump_incomplete"] = "yes"; } const IOSIntermediateDumpMap* root_map = reader_.RootMap(); diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc index 910c124d25..84f6a7b014 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc @@ -273,7 +273,8 @@ class ProcessSnapshotIOSIntermediateDumpTest : public testing::Test { } } - void WriteMachException(IOSIntermediateDumpWriter* writer) { + void WriteMachException(IOSIntermediateDumpWriter* writer, + bool short_context = false) { IOSIntermediateDumpWriter::ScopedMap machExceptionMap(writer, Key::kMachException); exception_type_t exception = 5; @@ -298,6 +299,10 @@ class ProcessSnapshotIOSIntermediateDumpTest : public testing::Test { EXPECT_TRUE(writer->AddProperty(Key::kException, &exception)); EXPECT_TRUE(writer->AddProperty(Key::kCodes, code, code_count)); EXPECT_TRUE(writer->AddProperty(Key::kFlavor, &flavor)); + + if (short_context) { + state_length -= 10; + } EXPECT_TRUE(writer->AddPropertyBytes( Key::kState, reinterpret_cast(&state), state_length)); uint64_t thread_id = 1; @@ -613,6 +618,24 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, EmptyUncaughtNSExceptionDump) { EXPECT_TRUE(DumpSnapshot(process_snapshot)); } +TEST_F(ProcessSnapshotIOSIntermediateDumpTest, ShortContext) { + { + IOSIntermediateDumpWriter::ScopedRootMap rootMap(writer()); + uint8_t version = 1; + EXPECT_TRUE(writer()->AddProperty(Key::kVersion, &version)); + WriteSystemInfo(writer()); + WriteProcessInfo(writer()); + WriteThreads(writer()); + WriteModules(writer()); + WriteMachException(writer(), true /* short_context=true*/); + } + ProcessSnapshotIOSIntermediateDump process_snapshot; + ASSERT_TRUE(process_snapshot.InitializeWithFilePath(path(), annotations())); + EXPECT_FALSE(IsRegularFile(path())); + EXPECT_TRUE(DumpSnapshot(process_snapshot)); + ExpectSnapshot(process_snapshot); +} + TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FullReport) { { IOSIntermediateDumpWriter::ScopedRootMap rootMap(writer()); @@ -637,6 +660,10 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FuzzTestCases) { crashpad::internal::ProcessSnapshotIOSIntermediateDump process_snapshot; EXPECT_TRUE(process_snapshot.InitializeWithFilePath(fuzz_path, {})); EXPECT_TRUE(LoggingRemoveFile(path())); + + auto map = process_snapshot.AnnotationsSimpleMap(); + ASSERT_TRUE(map.find("crashpad_intermediate_dump_incomplete") != map.end()); + EXPECT_EQ(map["crashpad_intermediate_dump_incomplete"], "yes"); } } // namespace diff --git a/util/ios/ios_intermediate_dump_reader.cc b/util/ios/ios_intermediate_dump_reader.cc index 0b41eab5cd..022133bce7 100644 --- a/util/ios/ios_intermediate_dump_reader.cc +++ b/util/ios/ios_intermediate_dump_reader.cc @@ -29,24 +29,25 @@ namespace crashpad { namespace internal { -bool IOSIntermediateDumpReader::Initialize( +IOSIntermediateDumpReaderInitializeResult IOSIntermediateDumpReader::Initialize( const IOSIntermediateDumpInterface& dump_interface) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); // Don't initialize empty files. FileOffset size = dump_interface.Size(); if (size == 0) { - return false; + return IOSIntermediateDumpReaderInitializeResult::kFailure; } + IOSIntermediateDumpReaderInitializeResult result = + IOSIntermediateDumpReaderInitializeResult::kSuccess; if (!Parse(dump_interface.FileReader(), size)) { LOG(ERROR) << "Intermediate dump parsing failed"; - // Intentially do not return false here, as it may be possible to extract a - // useful minidump out of a partial intermediate dump. + result = IOSIntermediateDumpReaderInitializeResult::kIncomplete; } INITIALIZATION_STATE_SET_VALID(initialized_); - return true; + return result; } const IOSIntermediateDumpMap* IOSIntermediateDumpReader::RootMap() { diff --git a/util/ios/ios_intermediate_dump_reader.h b/util/ios/ios_intermediate_dump_reader.h index 513d52277e..fced1f2797 100644 --- a/util/ios/ios_intermediate_dump_reader.h +++ b/util/ios/ios_intermediate_dump_reader.h @@ -22,6 +22,21 @@ namespace crashpad { namespace internal { +//! \brief The return value for IOSIntermediateDumpReader::Initialize. +enum class IOSIntermediateDumpReaderInitializeResult : int { + //! \brief The intermediate dump was read successfully, initialization + //! succeeded. + kSuccess, + + //! \brief The intermediate dump could be loaded, but parsing was incomplete. + //! An attempt to parse the RootMap should still be made, as there may + //! still be valuable information to put into a minidump. + kIncomplete, + + //! \brief The intermediate dump could not be loaded, initialization failed. + kFailure, +}; + //! \brief Open and parse iOS intermediate dumps. class IOSIntermediateDumpReader { public: @@ -43,7 +58,8 @@ class IOSIntermediateDumpReader { //! \return On success, returns `true`, otherwise returns `false`. Clients may //! still attempt to parse RootMap, as partial minidumps may still be //! usable. - bool Initialize(const IOSIntermediateDumpInterface& dump_interface); + IOSIntermediateDumpReaderInitializeResult Initialize( + const IOSIntermediateDumpInterface& dump_interface); //! \brief Returns an IOSIntermediateDumpMap corresponding to the root of the //! intermediate dump. diff --git a/util/ios/ios_intermediate_dump_reader_test.cc b/util/ios/ios_intermediate_dump_reader_test.cc index a223b441e7..a66d6c3d46 100644 --- a/util/ios/ios_intermediate_dump_reader_test.cc +++ b/util/ios/ios_intermediate_dump_reader_test.cc @@ -33,6 +33,7 @@ namespace test { namespace { using Key = internal::IntermediateDumpKey; +using Result = internal::IOSIntermediateDumpReaderInitializeResult; using internal::IOSIntermediateDumpWriter; class IOSIntermediateDumpReaderTest : public testing::Test { @@ -80,7 +81,7 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadNoFile) { TEST_F(IOSIntermediateDumpReaderTest, ReadEmptyFile) { internal::IOSIntermediateDumpReader reader; - EXPECT_FALSE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kFailure); EXPECT_FALSE(IsRegularFile(path())); } @@ -89,7 +90,7 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadHelloWorld) { EXPECT_TRUE( LoggingWriteFile(fd(), hello_world.c_str(), hello_world.length())); internal::IOSIntermediateDumpReader reader; - EXPECT_TRUE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kIncomplete); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -116,7 +117,7 @@ TEST_F(IOSIntermediateDumpReaderTest, FuzzTestCases) { internal::IOSIntermediateDumpByteArray dump_interface(fuzz1, sizeof(fuzz1)); internal::IOSIntermediateDumpReader reader; - EXPECT_TRUE(reader.Initialize(dump_interface)); + EXPECT_EQ(reader.Initialize(dump_interface), Result::kIncomplete); const auto root_map = reader.RootMap(); EXPECT_TRUE(root_map->empty()); } @@ -135,7 +136,7 @@ TEST_F(IOSIntermediateDumpReaderTest, WriteBadPropertyDataLength) { size_t value_length = 999999; EXPECT_TRUE(LoggingWriteFile(fd(), &value_length, sizeof(size_t))); EXPECT_TRUE(LoggingWriteFile(fd(), &value, sizeof(value))); - EXPECT_TRUE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kIncomplete); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -158,7 +159,7 @@ TEST_F(IOSIntermediateDumpReaderTest, InvalidArrayInArray) { writer_->AddProperty(Key::kVersion, &version); } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kIncomplete); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -180,7 +181,7 @@ TEST_F(IOSIntermediateDumpReaderTest, InvalidPropertyInArray) { writer_->AddProperty(Key::kVersion, &version); } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kIncomplete); EXPECT_FALSE(IsRegularFile(path())); const auto root_map = reader.RootMap(); @@ -217,7 +218,7 @@ TEST_F(IOSIntermediateDumpReaderTest, ReadValidData) { } EXPECT_TRUE(writer_->Close()); - EXPECT_TRUE(reader.Initialize(dump_interface())); + EXPECT_EQ(reader.Initialize(dump_interface()), Result::kSuccess); EXPECT_FALSE(IsRegularFile(path())); auto root_map = reader.RootMap(); From 54f2581bf1ef2d1023bd7f19b4ed5393a5f64a54 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Sun, 21 Nov 2021 00:46:19 -0500 Subject: [PATCH 60/69] ios: Set client id in minidump. Change-Id: Ie19e0388cf388533b82625a27f7a7a1c2abdaecb Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3294662 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- client/ios_handler/in_process_handler.cc | 6 ++++++ snapshot/ios/process_snapshot_ios_intermediate_dump.cc | 1 + 2 files changed, 7 insertions(+) diff --git a/client/ios_handler/in_process_handler.cc b/client/ios_handler/in_process_handler.cc index 6798734896..6058e3b3f1 100644 --- a/client/ios_handler/in_process_handler.cc +++ b/client/ios_handler/in_process_handler.cc @@ -201,6 +201,12 @@ void InProcessHandler::SaveSnapshot( } process_snapshot.SetReportID(new_report->ReportID()); + UUID client_id; + Settings* const settings = database_->GetSettings(); + if (settings && settings->GetClientID(&client_id)) { + process_snapshot.SetClientID(client_id); + } + MinidumpFileWriter minidump; minidump.InitializeFromSnapshot(&process_snapshot); if (!minidump.WriteEverything(new_report->Writer())) { diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc index bf973a3ab8..9a63ea1d4b 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump.cc @@ -52,6 +52,7 @@ bool ProcessSnapshotIOSIntermediateDump::InitializeWithFileInterface( INITIALIZATION_STATE_SET_INITIALIZING(initialized_); annotations_simple_map_ = annotations; + client_id_.InitializeToZero(); IOSIntermediateDumpReaderInitializeResult result = reader_.Initialize(dump_interface); From c7ce2e3ec14d6e001aced344e7fbeedefd42a3cc Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 23 Nov 2021 13:59:19 -0500 Subject: [PATCH 61/69] ios: Tighten up UIGestureEnvironment exception detection. iOS 15.1 reordered private APIs before public APIs when looking at the unw_get_proc_info() frame_info.start_ip, so doing a min/max within UIGestureEnvironment would fail on devices. However, this API is always called by UIWindow sendEvent, which is not a private API. Do the same check, but instead look back 2 frames, and check to see if we are within UIWindow. Both APIs are still marked , but the detection should still work. Also cleans up some tests fixtures when running in release. Change-Id: I762615e9cb44389800cf3291af52a7568c3825d5 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3299008 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- client/ios_handler/exception_processor.mm | 23 ++++++++++++----------- test/ios/crash_type_xctest.mm | 16 +++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/client/ios_handler/exception_processor.mm b/client/ios_handler/exception_processor.mm index ce1f2682d3..1c0503411f 100644 --- a/client/ios_handler/exception_processor.mm +++ b/client/ios_handler/exception_processor.mm @@ -403,20 +403,22 @@ id ObjcExceptionPreprocessor(id exception) { // internally and also has has non-sinkhole handlers. While all the // calling methods in UIKit are marked starting in iOS14, it's // currently true that all callers to _UIGestureEnvironmentUpdate are within - // UIGestureEnvironment. That means a very hacky way to detect this are to - // check if the calling method IMP is within the range of all - // UIGestureEnvironment methods. + // UIWindow sendEvent -> UIGestureEnvironment. That means a very hacky way + // to detect this is to check if the calling (2x) method IMP is within the + // range of all UIWindow methods. static constexpr const char kUIKitCorePath[] = "/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore"; if (ModulePathMatchesSinkhole(dl_info.dli_fname, kUIKitCorePath)) { unw_proc_info_t caller_frame_info; if (LoggingUnwStep(&cursor) > 0 && + unw_get_proc_info(&cursor, &caller_frame_info) == UNW_ESUCCESS && + LoggingUnwStep(&cursor) > 0 && unw_get_proc_info(&cursor, &caller_frame_info) == UNW_ESUCCESS) { - auto uigestureimp_lambda = [](IMP* max) { + auto uiwindowimp_lambda = [](IMP* max) { IMP min = *max = bit_cast(nullptr); unsigned int method_count = 0; std::unique_ptr method_list( - class_copyMethodList(NSClassFromString(@"UIGestureEnvironment"), + class_copyMethodList(NSClassFromString(@"UIWindow"), &method_count)); if (method_count > 0) { min = *max = method_getImplementation(method_list[0]); @@ -431,15 +433,14 @@ id ObjcExceptionPreprocessor(id exception) { return min; }; - static IMP gesture_environment_max_imp; - static IMP gesture_environment_min_imp = - uigestureimp_lambda(&gesture_environment_max_imp); + static IMP uiwindow_max_imp; + static IMP uiwindow_min_imp = uiwindowimp_lambda(&uiwindow_max_imp); - if (gesture_environment_min_imp && gesture_environment_max_imp && + if (uiwindow_min_imp && uiwindow_max_imp && caller_frame_info.start_ip >= - reinterpret_cast(gesture_environment_min_imp) && + reinterpret_cast(uiwindow_min_imp) && caller_frame_info.start_ip <= - reinterpret_cast(gesture_environment_max_imp)) { + reinterpret_cast(uiwindow_max_imp)) { return HANDLE_UNCAUGHT_NSEXCEPTION(exception, "_UIGestureEnvironmentUpdate"); } diff --git a/test/ios/crash_type_xctest.mm b/test/ios/crash_type_xctest.mm index 529ca13ece..2dcfac786f 100644 --- a/test/ios/crash_type_xctest.mm +++ b/test/ios/crash_type_xctest.mm @@ -85,12 +85,8 @@ - (void)testEDO { - (void)testSegv { [rootObject_ crashSegv]; -#if defined(NDEBUG) -#if TARGET_OS_SIMULATOR +#if defined(NDEBUG) && TARGET_OS_SIMULATOR [self verifyCrashReportException:SIGINT]; -#else - [self verifyCrashReportException:SIGABRT]; -#endif #else [self verifyCrashReportException:SIGHUP]; #endif @@ -117,12 +113,8 @@ - (void)testAbort { - (void)testBadAccess { [rootObject_ crashBadAccess]; -#if defined(NDEBUG) -#if TARGET_OS_SIMULATOR +#if defined(NDEBUG) && TARGET_OS_SIMULATOR [self verifyCrashReportException:SIGINT]; -#else - [self verifyCrashReportException:SIGABRT]; -#endif #else [self verifyCrashReportException:SIGHUP]; #endif @@ -221,6 +213,7 @@ - (void)testClientAnnotations { XCTAssertTrue([dict[@"ver"] isEqualToString:@"42"]); } +#if TARGET_OS_SIMULATOR - (void)testCrashWithCrashInfoMessage { if (@available(iOS 15.0, *)) { // Figure out how to test this on iOS15. @@ -232,9 +225,10 @@ - (void)testCrashWithCrashInfoMessage { NSString* dyldMessage = dict[@"vector"][0]; XCTAssertTrue([dyldMessage isEqualToString:@"dyld: in dlsym()"]); } +#endif // TODO(justincohen): Codesign crashy_initializer.so so it can run on devices. -#if !TARGET_OS_SIMULATOR +#if TARGET_OS_SIMULATOR - (void)testCrashWithDyldErrorString { if (@available(iOS 15.0, *)) { // iOS 15 uses dyld4, which doesn't use CRSetCrashLogMessage2 From bc138fc01c8cbcefaa5b6e04e2fe6fc075b39101 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 22 Nov 2021 22:21:55 -0500 Subject: [PATCH 62/69] Initialize process snapshot client ids to zero. Change-Id: If6e1902d62e6364114a75d8ebc4d260e4239d58b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3296266 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- handler/linux/crash_report_exception_handler.cc | 8 ++------ handler/mac/crash_report_exception_handler.cc | 9 ++------- handler/win/crash_report_exception_handler.cc | 8 ++------ snapshot/fuchsia/process_snapshot_fuchsia.cc | 1 + snapshot/linux/process_snapshot_linux.cc | 1 + snapshot/mac/process_snapshot_mac.cc | 1 + snapshot/win/process_snapshot_win.cc | 2 +- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/handler/linux/crash_report_exception_handler.cc b/handler/linux/crash_report_exception_handler.cc index 4d37582b7f..84f9534fed 100644 --- a/handler/linux/crash_report_exception_handler.cc +++ b/handler/linux/crash_report_exception_handler.cc @@ -184,13 +184,9 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection( UUID client_id; Settings* const settings = database_->GetSettings(); - if (settings) { - // If GetSettings() or GetClientID() fails, something else will log a - // message and client_id will be left at its default value, all zeroes, - // which is appropriate. - settings->GetClientID(&client_id); + if (settings && settings->GetClientID(&client_id)) { + process_snapshot->SetClientID(client_id); } - process_snapshot->SetClientID(client_id); return write_minidump_to_database_ ? WriteMinidumpToDatabase(process_snapshot.get(), diff --git a/handler/mac/crash_report_exception_handler.cc b/handler/mac/crash_report_exception_handler.cc index cccf1e94ed..ad3bac149a 100644 --- a/handler/mac/crash_report_exception_handler.cc +++ b/handler/mac/crash_report_exception_handler.cc @@ -147,14 +147,9 @@ kern_return_t CrashReportExceptionHandler::CatchMachException( UUID client_id; Settings* const settings = database_->GetSettings(); - if (settings) { - // If GetSettings() or GetClientID() fails, something else will log a - // message and client_id will be left at its default value, all zeroes, - // which is appropriate. - settings->GetClientID(&client_id); + if (settings && settings->GetClientID(&client_id)) { + process_snapshot.SetClientID(client_id); } - - process_snapshot.SetClientID(client_id); process_snapshot.SetAnnotationsSimpleMap(*process_annotations_); std::unique_ptr new_report; diff --git a/handler/win/crash_report_exception_handler.cc b/handler/win/crash_report_exception_handler.cc index d78d9e6e30..2098a574e8 100644 --- a/handler/win/crash_report_exception_handler.cc +++ b/handler/win/crash_report_exception_handler.cc @@ -82,14 +82,10 @@ unsigned int CrashReportExceptionHandler::ExceptionHandlerServerException( if (client_options.crashpad_handler_behavior != TriState::kDisabled) { UUID client_id; Settings* const settings = database_->GetSettings(); - if (settings) { - // If GetSettings() or GetClientID() fails, something else will log a - // message and client_id will be left at its default value, all zeroes, - // which is appropriate. - settings->GetClientID(&client_id); + if (settings && settings->GetClientID(&client_id)) { + process_snapshot.SetClientID(client_id); } - process_snapshot.SetClientID(client_id); process_snapshot.SetAnnotationsSimpleMap(*process_annotations_); std::unique_ptr new_report; diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.cc b/snapshot/fuchsia/process_snapshot_fuchsia.cc index d36335c5d5..8ebdae5cc3 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.cc +++ b/snapshot/fuchsia/process_snapshot_fuchsia.cc @@ -36,6 +36,7 @@ bool ProcessSnapshotFuchsia::Initialize(const zx::process& process) { return false; } + client_id_.InitializeToZero(); system_.Initialize(&snapshot_time_); InitializeThreads(); diff --git a/snapshot/linux/process_snapshot_linux.cc b/snapshot/linux/process_snapshot_linux.cc index 53499b3654..6233134795 100644 --- a/snapshot/linux/process_snapshot_linux.cc +++ b/snapshot/linux/process_snapshot_linux.cc @@ -39,6 +39,7 @@ bool ProcessSnapshotLinux::Initialize(PtraceConnection* connection) { return false; } + client_id_.InitializeToZero(); system_.Initialize(&process_reader_, &snapshot_time_); GetCrashpadOptionsInternal((&options_)); diff --git a/snapshot/mac/process_snapshot_mac.cc b/snapshot/mac/process_snapshot_mac.cc index 528e92133b..2a0884b981 100644 --- a/snapshot/mac/process_snapshot_mac.cc +++ b/snapshot/mac/process_snapshot_mac.cc @@ -50,6 +50,7 @@ bool ProcessSnapshotMac::Initialize(task_t task) { return false; } + client_id_.InitializeToZero(); system_.Initialize(&process_reader_, &snapshot_time_); InitializeThreads(); diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc index 21df191a5d..b60ea38ea1 100644 --- a/snapshot/win/process_snapshot_win.cc +++ b/snapshot/win/process_snapshot_win.cc @@ -81,7 +81,7 @@ bool ProcessSnapshotWin::Initialize( } } - + client_id_.InitializeToZero(); system_.Initialize(&process_reader_); if (process_reader_.Is64Bit()) { From c537245de8918fea19af117cab0f2bee2f1b6f6a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 24 Nov 2021 13:45:20 -0800 Subject: [PATCH 63/69] Revert "Reraise signals via rt_tgsigqueueinfo(2) on Linux." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Causes test failures on older versions of Android (e.g. Marshmallow). Also reverts follow-up CL "Fix dead-code warning in util/posix/signals.cc". This reverts commits ab9a87fb5463e5d1579e16bacb1f79d0dd71119b and 04431eccfe878570b1c74a5b376d96b4c9c7e0e8. Bug: 1272877 Change-Id: Id9ef420516c932147b6c8b67d9f4daf9d31d9b03 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3300986 Reviewed-by: Peter Boström Commit-Queue: Peter Collingbourne --- util/posix/signals.cc | 20 ----- util/posix/signals_test.cc | 164 +++++++++++-------------------------- 2 files changed, 49 insertions(+), 135 deletions(-) diff --git a/util/posix/signals.cc b/util/posix/signals.cc index 5df5a08dba..b90e8f659b 100644 --- a/util/posix/signals.cc +++ b/util/posix/signals.cc @@ -22,10 +22,6 @@ #include "base/cxx17_backports.h" #include "base/logging.h" -#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) -#include -#endif - namespace crashpad { namespace { @@ -284,21 +280,6 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( _exit(kFailureExitCode); } - // If we can raise a signal with siginfo on this platform, do so. This ensures - // that we preserve the siginfo information for asynchronous signals (i.e. - // signals that do not re-raise autonomously), such as signals delivered via - // kill() and asynchronous hardware faults such as SEGV_MTEAERR, which would - // otherwise be lost when re-raising the signal via raise(). -#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) - int retval = syscall(SYS_rt_tgsigqueueinfo, - getpid(), - syscall(SYS_gettid), - siginfo->si_signo, - siginfo); - if (retval != 0) { - _exit(kFailureExitCode); - } -#else // Explicitly re-raise the signal if it will not re-raise itself. Because // signal handlers normally execute with their signal blocked, this raise() // cannot immediately deliver the signal. Delivery is deferred until the @@ -308,7 +289,6 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( if (!WillSignalReraiseAutonomously(siginfo) && raise(sig) != 0) { _exit(kFailureExitCode); } -#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) } // static diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index cb29ff50b3..2bd55801f2 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -34,48 +34,15 @@ #include "test/scoped_temp_dir.h" #include "util/posix/scoped_mmap.h" -#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) -#include -#include - -#if defined(ARCH_CPU_ARM64) -#ifndef HWCAP2_MTE -#define HWCAP2_MTE (1 << 18) -#endif -#ifndef SEGV_MTEAERR -#define SEGV_MTEAERR 8 -#endif -#ifndef PROT_MTE -#define PROT_MTE 0x20 -#endif -#ifndef PR_SET_TAGGED_ADDR_CTRL -#define PR_SET_TAGGED_ADDR_CTRL 55 -#endif -#ifndef PR_TAGGED_ADDR_ENABLE -#define PR_TAGGED_ADDR_ENABLE (1UL << 0) -#endif -#ifndef PR_MTE_TCF_ASYNC -#define PR_MTE_TCF_ASYNC (1UL << 2) -#endif -#endif // defined(ARCH_CPU_ARM64) -#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) - namespace crashpad { namespace test { namespace { constexpr int kUnexpectedExitStatus = 3; -struct TestableSignal { - int sig, code; -}; - // Keep synchronized with CauseSignal(). -std::vector TestableSignals() { - std::vector signals; - signals.push_back({SIGABRT, 0}); - signals.push_back({SIGALRM, 0}); - signals.push_back({SIGBUS, 0}); +bool CanCauseSignal(int sig) { + return sig == SIGABRT || sig == SIGALRM || sig == SIGBUS || /* According to DDI0487D (Armv8 Architecture Reference Manual) the expected * behavior for division by zero (Section 3.4.8) is: "... results in a * zero being written to the destination register, without any @@ -83,30 +50,24 @@ std::vector TestableSignals() { * This applies to Armv8 (and not earlier) for both 32bit and 64bit app code. */ #if defined(ARCH_CPU_X86_FAMILY) - signals.push_back({SIGFPE, 0}); + sig == SIGFPE || #endif + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - signals.push_back({SIGILL, 0}); + sig == SIGILL || #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - signals.push_back({SIGPIPE, 0}); - signals.push_back({SIGSEGV, 0}); -#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ - defined(ARCH_CPU_ARM64) - if (getauxval(AT_HWCAP2) & HWCAP2_MTE) { - signals.push_back({SIGSEGV, SEGV_MTEAERR}); - } -#endif + sig == SIGPIPE || sig == SIGSEGV || #if defined(OS_APPLE) - signals.push_back({SIGSYS, 0}); + sig == SIGSYS || #endif // OS_APPLE #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - signals.push_back({SIGTRAP, 0}); + sig == SIGTRAP || #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - return signals; + false; } -// Keep synchronized with TestableSignals(). -void CauseSignal(int sig, int code) { +// Keep synchronized with CanCauseSignal(). +void CauseSignal(int sig) { switch (sig) { case SIGABRT: { abort(); @@ -203,37 +164,8 @@ void CauseSignal(int sig, int code) { } case SIGSEGV: { - switch (code) { - case 0: { - volatile int* i = nullptr; - *i = 0; - break; - } -#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ - defined(ARCH_CPU_ARM64) - case SEGV_MTEAERR: { - ScopedMmap mapping; - if (!mapping.ResetMmap(nullptr, - getpagesize(), - PROT_READ | PROT_WRITE | PROT_MTE, - MAP_PRIVATE | MAP_ANON, - -1, - 0)) { - _exit(kUnexpectedExitStatus); - } - if (prctl(PR_SET_TAGGED_ADDR_CTRL, - PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC, - 0, - 0, - 0) != 0) { - _exit(kUnexpectedExitStatus); - } - mapping.addr_as()[1ULL << 56] = 0; - break; - } -#endif // (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && - // defined(ARCH_CPU_ARM64) - } + volatile int* i = nullptr; + *i = 0; break; } @@ -286,10 +218,9 @@ class SignalsTest : public Multiprocess { }; static constexpr int kExitingHandlerExitStatus = 2; - SignalsTest(TestType test_type, SignalSource signal_source, int sig, int code) + SignalsTest(TestType test_type, SignalSource signal_source, int sig) : Multiprocess(), sig_(sig), - code_(code), test_type_(test_type), signal_source_(signal_source) {} @@ -368,7 +299,7 @@ class SignalsTest : public Multiprocess { switch (signal_source_) { case SignalSource::kCause: - CauseSignal(sig_, code_); + CauseSignal(sig_); break; case SignalSource::kRaise: raise(sig_); @@ -379,7 +310,6 @@ class SignalsTest : public Multiprocess { } int sig_; - int code_; TestType test_type_; SignalSource signal_source_; static Signals::OldActions old_actions_; @@ -422,28 +352,32 @@ TEST(Signals, WillSignalReraiseAutonomously) { } TEST(Signals, Cause_DefaultHandler) { - for (TestableSignal s : TestableSignals()) { - SCOPED_TRACE(base::StringPrintf( - "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); + for (int sig = 1; sig < NSIG; ++sig) { + SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); + + if (!CanCauseSignal(sig)) { + continue; + } SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kCause, - s.sig, - s.code); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); + sig); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } } TEST(Signals, Cause_HandlerExits) { - for (TestableSignal s : TestableSignals()) { - SCOPED_TRACE(base::StringPrintf( - "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); + for (int sig = 1; sig < NSIG; ++sig) { + SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); + + if (!CanCauseSignal(sig)) { + continue; + } SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kCause, - s.sig, - s.code); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -451,28 +385,32 @@ TEST(Signals, Cause_HandlerExits) { } TEST(Signals, Cause_HandlerReraisesToDefault) { - for (TestableSignal s : TestableSignals()) { - SCOPED_TRACE(base::StringPrintf( - "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); + for (int sig = 1; sig < NSIG; ++sig) { + SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); + + if (!CanCauseSignal(sig)) { + continue; + } SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kCause, - s.sig, - s.code); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); + sig); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } } TEST(Signals, Cause_HandlerReraisesToPrevious) { - for (TestableSignal s : TestableSignals()) { - SCOPED_TRACE(base::StringPrintf( - "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); + for (int sig = 1; sig < NSIG; ++sig) { + SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); + + if (!CanCauseSignal(sig)) { + continue; + } SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kCause, - s.sig, - s.code); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -489,8 +427,7 @@ TEST(Signals, Raise_DefaultHandler) { SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kRaise, - sig, - 0); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -506,8 +443,7 @@ TEST(Signals, Raise_HandlerExits) { SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kRaise, - sig, - 0); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -539,8 +475,7 @@ TEST(Signals, Raise_HandlerReraisesToDefault) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kRaise, - sig, - 0); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -571,8 +506,7 @@ TEST(Signals, Raise_HandlerReraisesToPrevious) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kRaise, - sig, - 0); + sig); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); From 0fdeeecba65fc8356ed507001bb63788f970879f Mon Sep 17 00:00:00 2001 From: Richard Townsend Date: Mon, 22 Nov 2021 12:08:35 +0000 Subject: [PATCH 64/69] fix: link Chromium's libunwind when using sanitizers Following https://crev.com/d3d85ce0b330b11f73f0495b7b99cea0d04d8c63, the compiler now does not build an unwind library into the ASAN runtime, nor is one available from the NDK in r23. Restoring Chrome's standard dependencies (libcxx, libunwind) prevents a link error. Bug: 1271628 Change-Id: I62d1c066bd7037276d78e2533dd5e4c3cf14f8c7 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3298826 Reviewed-by: Mark Mentovai Commit-Queue: Richard Townsend --- handler/BUILD.gn | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handler/BUILD.gn b/handler/BUILD.gn index e7a4966127..0fe4760db7 100644 --- a/handler/BUILD.gn +++ b/handler/BUILD.gn @@ -214,7 +214,11 @@ if (crashpad_is_android) { libs = [ "log" ] if (crashpad_is_in_chromium) { - no_default_deps = true + # Chromium's sanitizer runtime libraries do not include an unwinder, + # so add Chromium's standard dependencies to link against the in-tree + # libunwind. + import("//build/config/sanitizers/sanitizers.gni") + no_default_deps = !using_sanitizer remove_configs = [ "//build/config/android:default_orderfile_instrumentation" ] } From 0d26b02c374a7d8c5a4f8dc7a6336bbb76922df2 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 24 Nov 2021 14:49:32 -0800 Subject: [PATCH 65/69] Reraise signals via rt_tgsigqueueinfo(2) on Linux (try 2). Previously we would rely on implicit re-raising to deliver signals to the underlying handler on POSIX systems if the signal is detected as being re-raisable via WillSignalReraiseAutonomously(). This detection mechanism is imperfect, as it will misclassify signals delivered as a result of kill(2) when passing a signal number usually used for synchronous signals, but now also asynchronous MTE tag check faults, which are delivered as SIGSEGV signals on Linux. As a result, these signals would not be re-raised and therefore would be discarded. Although we could, for example, teach WillSignalReraiseAutonomously() about MTE faults, the signal would still be re-raised via raise(3) and therefore we would lose the information in siginfo. We can avoid discarding these signals on Linux while at the same time preserving the siginfo by making use of the syscall rt_tgsigqueueinfo(2) which delivers a signal together with a user-provided siginfo. The problem still exists on non-Linux POSIX systems because this syscall is Linux-specific. With kernel versions prior to 3.9, the kernel will reject the rt_tgsigqueueinfo() syscall with EPERM. If that happens, follow the non-Linux code path. Change-Id: Ia410fbd651a756945c9402e361edfd5c520453d6 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3300991 Reviewed-by: Mark Mentovai Commit-Queue: Peter Collingbourne --- util/posix/signals.cc | 29 +++++++ util/posix/signals_test.cc | 164 ++++++++++++++++++++++++++----------- 2 files changed, 144 insertions(+), 49 deletions(-) diff --git a/util/posix/signals.cc b/util/posix/signals.cc index b90e8f659b..cd8b87d868 100644 --- a/util/posix/signals.cc +++ b/util/posix/signals.cc @@ -22,6 +22,10 @@ #include "base/cxx17_backports.h" #include "base/logging.h" +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) +#include +#endif + namespace crashpad { namespace { @@ -280,6 +284,31 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( _exit(kFailureExitCode); } + // If we can raise a signal with siginfo on this platform, do so. This ensures + // that we preserve the siginfo information for asynchronous signals (i.e. + // signals that do not re-raise autonomously), such as signals delivered via + // kill() and asynchronous hardware faults such as SEGV_MTEAERR, which would + // otherwise be lost when re-raising the signal via raise(). +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + int retval = syscall(SYS_rt_tgsigqueueinfo, + getpid(), + syscall(SYS_gettid), + siginfo->si_signo, + siginfo); + if (retval == 0) { + return; + } + + // Kernels without commit 66dd34ad31e5 ("signal: allow to send any siginfo to + // itself"), which was first released in kernel version 3.9, did not permit a + // process to send arbitrary signals to itself, and will reject the + // rt_tgsigqueueinfo syscall with EPERM. If that happens, follow the non-Linux + // code path. Any other errno is unexpected and will cause us to exit. + if (errno != EPERM) { + _exit(kFailureExitCode); + } +#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + // Explicitly re-raise the signal if it will not re-raise itself. Because // signal handlers normally execute with their signal blocked, this raise() // cannot immediately deliver the signal. Delivery is deferred until the diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index 2bd55801f2..cb29ff50b3 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -34,15 +34,48 @@ #include "test/scoped_temp_dir.h" #include "util/posix/scoped_mmap.h" +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) +#include +#include + +#if defined(ARCH_CPU_ARM64) +#ifndef HWCAP2_MTE +#define HWCAP2_MTE (1 << 18) +#endif +#ifndef SEGV_MTEAERR +#define SEGV_MTEAERR 8 +#endif +#ifndef PROT_MTE +#define PROT_MTE 0x20 +#endif +#ifndef PR_SET_TAGGED_ADDR_CTRL +#define PR_SET_TAGGED_ADDR_CTRL 55 +#endif +#ifndef PR_TAGGED_ADDR_ENABLE +#define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#endif +#ifndef PR_MTE_TCF_ASYNC +#define PR_MTE_TCF_ASYNC (1UL << 2) +#endif +#endif // defined(ARCH_CPU_ARM64) +#endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) + namespace crashpad { namespace test { namespace { constexpr int kUnexpectedExitStatus = 3; +struct TestableSignal { + int sig, code; +}; + // Keep synchronized with CauseSignal(). -bool CanCauseSignal(int sig) { - return sig == SIGABRT || sig == SIGALRM || sig == SIGBUS || +std::vector TestableSignals() { + std::vector signals; + signals.push_back({SIGABRT, 0}); + signals.push_back({SIGALRM, 0}); + signals.push_back({SIGBUS, 0}); /* According to DDI0487D (Armv8 Architecture Reference Manual) the expected * behavior for division by zero (Section 3.4.8) is: "... results in a * zero being written to the destination register, without any @@ -50,24 +83,30 @@ bool CanCauseSignal(int sig) { * This applies to Armv8 (and not earlier) for both 32bit and 64bit app code. */ #if defined(ARCH_CPU_X86_FAMILY) - sig == SIGFPE || + signals.push_back({SIGFPE, 0}); #endif - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - sig == SIGILL || + signals.push_back({SIGILL, 0}); #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL) - sig == SIGPIPE || sig == SIGSEGV || + signals.push_back({SIGPIPE, 0}); + signals.push_back({SIGSEGV, 0}); +#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ + defined(ARCH_CPU_ARM64) + if (getauxval(AT_HWCAP2) & HWCAP2_MTE) { + signals.push_back({SIGSEGV, SEGV_MTEAERR}); + } +#endif #if defined(OS_APPLE) - sig == SIGSYS || + signals.push_back({SIGSYS, 0}); #endif // OS_APPLE #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - sig == SIGTRAP || + signals.push_back({SIGTRAP, 0}); #endif // defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) - false; + return signals; } -// Keep synchronized with CanCauseSignal(). -void CauseSignal(int sig) { +// Keep synchronized with TestableSignals(). +void CauseSignal(int sig, int code) { switch (sig) { case SIGABRT: { abort(); @@ -164,8 +203,37 @@ void CauseSignal(int sig) { } case SIGSEGV: { - volatile int* i = nullptr; - *i = 0; + switch (code) { + case 0: { + volatile int* i = nullptr; + *i = 0; + break; + } +#if (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && \ + defined(ARCH_CPU_ARM64) + case SEGV_MTEAERR: { + ScopedMmap mapping; + if (!mapping.ResetMmap(nullptr, + getpagesize(), + PROT_READ | PROT_WRITE | PROT_MTE, + MAP_PRIVATE | MAP_ANON, + -1, + 0)) { + _exit(kUnexpectedExitStatus); + } + if (prctl(PR_SET_TAGGED_ADDR_CTRL, + PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC, + 0, + 0, + 0) != 0) { + _exit(kUnexpectedExitStatus); + } + mapping.addr_as()[1ULL << 56] = 0; + break; + } +#endif // (defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS)) && + // defined(ARCH_CPU_ARM64) + } break; } @@ -218,9 +286,10 @@ class SignalsTest : public Multiprocess { }; static constexpr int kExitingHandlerExitStatus = 2; - SignalsTest(TestType test_type, SignalSource signal_source, int sig) + SignalsTest(TestType test_type, SignalSource signal_source, int sig, int code) : Multiprocess(), sig_(sig), + code_(code), test_type_(test_type), signal_source_(signal_source) {} @@ -299,7 +368,7 @@ class SignalsTest : public Multiprocess { switch (signal_source_) { case SignalSource::kCause: - CauseSignal(sig_); + CauseSignal(sig_, code_); break; case SignalSource::kRaise: raise(sig_); @@ -310,6 +379,7 @@ class SignalsTest : public Multiprocess { } int sig_; + int code_; TestType test_type_; SignalSource signal_source_; static Signals::OldActions old_actions_; @@ -352,32 +422,28 @@ TEST(Signals, WillSignalReraiseAutonomously) { } TEST(Signals, Cause_DefaultHandler) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kCause, - sig); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); + s.sig, + s.code); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); test.Run(); } } TEST(Signals, Cause_HandlerExits) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kCause, - sig); + s.sig, + s.code); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -385,32 +451,28 @@ TEST(Signals, Cause_HandlerExits) { } TEST(Signals, Cause_HandlerReraisesToDefault) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kCause, - sig); - test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); + s.sig, + s.code); + test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, s.sig); test.Run(); } } TEST(Signals, Cause_HandlerReraisesToPrevious) { - for (int sig = 1; sig < NSIG; ++sig) { - SCOPED_TRACE(base::StringPrintf("sig %d (%s)", sig, strsignal(sig))); - - if (!CanCauseSignal(sig)) { - continue; - } + for (TestableSignal s : TestableSignals()) { + SCOPED_TRACE(base::StringPrintf( + "sig %d (%s), code %d", s.sig, strsignal(s.sig), s.code)); SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kCause, - sig); + s.sig, + s.code); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -427,7 +489,8 @@ TEST(Signals, Raise_DefaultHandler) { SignalsTest test(SignalsTest::TestType::kDefaultHandler, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -443,7 +506,8 @@ TEST(Signals, Raise_HandlerExits) { SignalsTest test(SignalsTest::TestType::kHandlerExits, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); @@ -475,7 +539,8 @@ TEST(Signals, Raise_HandlerReraisesToDefault) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToDefault, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationSignal, sig); test.Run(); } @@ -506,7 +571,8 @@ TEST(Signals, Raise_HandlerReraisesToPrevious) { SignalsTest test(SignalsTest::TestType::kHandlerReraisesToPrevious, SignalsTest::SignalSource::kRaise, - sig); + sig, + 0); test.SetExpectedChildTermination(Multiprocess::kTerminationNormal, SignalsTest::kExitingHandlerExitStatus); test.Run(); From 281ba70a13ae31ab2ac71db4859ebe8d75261a3b Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 26 Nov 2021 12:39:24 -0500 Subject: [PATCH 66/69] Fix build with /std:c++17 on 32-bit Windows Bug: chromium:1274168 Change-Id: I31c300f5cb078e90f25c5752c821f756dedd8591 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3304552 Reviewed-by: Mark Mentovai Commit-Queue: Nico Weber --- util/misc/no_cfi_icall.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/util/misc/no_cfi_icall.h b/util/misc/no_cfi_icall.h index 817dca64c7..80e584ebd5 100644 --- a/util/misc/no_cfi_icall.h +++ b/util/misc/no_cfi_icall.h @@ -96,7 +96,19 @@ struct FunctorTraits { return std::forward(function)(std::forward(args)...); } }; -#endif + +#if defined(OS_WIN) && defined(ARCH_CPU_X86) +template +struct FunctorTraits { + template + DISABLE_CFI_ICALL static R Invoke(R(__stdcall* function)(Args...), + RunArgs&&... args) { + return function(std::forward(args)...); + } +}; +#endif // OS_WIN && ARCH_CPU_X86 + +#endif // __cplusplus >= 201703L } // namespace From 0453ea168685ca0272dde3bd5117956d0b7a97f3 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 29 Nov 2021 15:01:00 -0500 Subject: [PATCH 67/69] ios: Handle empty stack in GenerateStackMemoryFromFrames. This fixes a _LIBCPP_ASSERT vector[] index out of bounds error, caught by fuzzer. Bug: 1274178 Change-Id: I95f3fbe450209a24ccc0229741ea752990e18ed6 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3307697 Commit-Queue: Justin Cohen Reviewed-by: Mark Mentovai --- snapshot/BUILD.gn | 5 ++++- ...ocess_snapshot_ios_intermediate_dump_test.cc | 8 ++++++++ snapshot/ios/testdata/crash-5726011582644224 | Bin 0 -> 71017 bytes .../thread_snapshot_ios_intermediate_dump.cc | 9 +++++---- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 snapshot/ios/testdata/crash-5726011582644224 diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 225d3446f3..e3ad7f67e7 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -493,7 +493,10 @@ source_set("snapshot_test") { bundle_data("snapshot_test_ios_data") { testonly = true - sources = [ "ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa" ] + sources = [ + "ios/testdata/crash-1fa088dda0adb41459d063078a0f384a0bb8eefa", + "ios/testdata/crash-5726011582644224", + ] outputs = [ "{{bundle_resources_dir}}/crashpad_test_data/" + "{{source_root_relative_dir}}/{{source_file_part}}" ] diff --git a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc index 84f6a7b014..5f56082eb1 100644 --- a/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc +++ b/snapshot/ios/process_snapshot_ios_intermediate_dump_test.cc @@ -664,6 +664,14 @@ TEST_F(ProcessSnapshotIOSIntermediateDumpTest, FuzzTestCases) { auto map = process_snapshot.AnnotationsSimpleMap(); ASSERT_TRUE(map.find("crashpad_intermediate_dump_incomplete") != map.end()); EXPECT_EQ(map["crashpad_intermediate_dump_incomplete"], "yes"); + + fuzz_path = TestPaths::TestDataRoot().Append( + FILE_PATH_LITERAL("snapshot/ios/testdata/crash-5726011582644224")); + crashpad::internal::ProcessSnapshotIOSIntermediateDump process_snapshot2; + EXPECT_TRUE(process_snapshot2.InitializeWithFilePath(fuzz_path, {})); + map = process_snapshot2.AnnotationsSimpleMap(); + ASSERT_TRUE(map.find("crashpad_intermediate_dump_incomplete") != map.end()); + EXPECT_EQ(map["crashpad_intermediate_dump_incomplete"], "yes"); } } // namespace diff --git a/snapshot/ios/testdata/crash-5726011582644224 b/snapshot/ios/testdata/crash-5726011582644224 new file mode 100644 index 0000000000000000000000000000000000000000..c2ebe211bf3d13ec9a6dcdf610300cb497113d65 GIT binary patch literal 71017 zcmeHQ30zdw_rC*-8zLyVq=jSd3oSEGYe2M$I)BG_BM! zGBrypvRrXNb1SW|#9uBcm1UYKYKx}H|GsVJy!$Rcs-M4d=0ETAfp_2C-ka|^_uO;u zJ?GvAav72#?vlw$1Ldm%gZM{_YPy;UCQe4ks3}g8uMG6#lYX2aL-JRhk0*5a@ik{b zGheXH+{SEv+3G;~+Q3G9S>YysT@vLZTSMjy+uQ&VIomJwK|VgRS;6uJ!EO24^l2H2 z41J;9pthMTif;OJoyn*TkLVTIUA`z-`07BMS^k{!ktr%K5kD>rZotUTE-}me7W&#+%-7sn zCZE(=K!bU;+$MgU+*){Rz$1OxpCm7KMpY-*1Tb-OYwNZAceh6z^9a9VR)}WTuTLY? zjZa7Ixo080nok$<`8E_Xa(DAR+`WO1_*p0~)F+hM_V|qnwfKEPexf=d8She8LZ{#TS!S@pv9WISAEsf-Ngz3LHY^l!u>`5_X^KFpW@o9@GQJfcs5_1 z!^w^ZG`m>Yz{?L+K#v))k*4?Ien%pIFNx%yw}0=dpOHht??o*T((x}5WX_~!T!irL zLboS;%U`_<67;W>7leUVI56n_v%-P-0)dte=7G6lr?c${7Y`78PSAFk%|BR*cp{{Ua4AOAiD|18AU@a1#%_GjNGloRgNd^>-t zoJ;46J8w<+&|A2}6!_nnhy(Y-2OK8bsqE7QK8!p;{N35#ll67taB<+Q%q6_50=I9b zeG2sm@j`uxLm~}KekK3=r}SLH{?5vKlq}wp*MzcnK`)pVah8>H_gt9D=2P*%|6=I9 z?DH4fIeEs&L*`B?|8Ub8@4_j|9+grU8RnnHaH)! zyyffL`b1MUe+6G&$WGobZsO#q5brMp@SVXXrz?log8Kv5`nvPDlXMb_btbwx$K}U3 zz7;b3P4}{wg4pjRUw7+viIW$YG;W-Lknp>!dAxR9NMhUBbppSGojE*E4Of4T@XY7` zg705(I`?Wb-(&Ilk?_plyYcY~oLkP8@I$b_5#HDBC+>Zf#QVyG=Q`deq~8ii=Hv$V zRj5rD?sq7J?-K5OeD)dc_XpK-@6`$Uxw~vA|IAm1HuHQU#0&QlKHrNC`1fCF^{ARD zB;W2Y$T)=hv(?BB`1{Cr_zPV;LW3L1EBuAtF(mxJOPZ>ILDQcM&AV~=aF%>0r~sEA z+z`pPISVs`DIb}<-2W_FH9}!=X0t)BQQPz;qcv=d#+0Y+tu~v(5=?j;Wwcqt617EI zgUPJ5gr(!LT)xRtXbs~=b7>j9&3sf?sy^4EwiJWh2_}oyIRFexx0v$v2CX%0q}^!K z7vcaOAojNE3oYEU>wP1&R+HVLab+E8GTFj1imf(nq4PD#7ImR^lF2f`iVIq_Lo8~u zPOq`{&KKfE(ekY>NOH=$F?=N7<&4T|Ek#~cNJHLN*0cdYK6}v(#id#O+fT__|Mjl# z#)pfLSE^7`JW!?}f69}P&(uz~5vVg!5b>ZJti%C`|3cyQn)_H-M0}3tFkF28>GZk! zD<>n)E?fO%eo5!A{w+cqRiHgSo{e^fR%5s5ZN&g>Aqt|6T6G}!TS4J(M@tfIS<~My z0JPuU7k~WhFa4&K?7H=;rG?!gLOTfg{(gaqcDZ};w%uw8Gw5@fzsGxr_s%QE0SIRL z7h?!8kG7Nw3niy40oL{R5wY&Q4dYYtE2H`^K6&Do=9fc)MPOpYhGTg|5fnSz7EDdg zo-{bCyO5ILI0eoeuD=IxBHuDUz?%&w9$z%A|DX+T{(8FIxHex76T?}7%KWHsR=6#k zT<6z2Udo_~r%48_q9Cf^emO)GwU+}#U%qdFI`7kgPcImI?w%>j4)hQsig0EsqC4Fd zQOuy~T)h-eWhatD4^i;U;Tk-tmx;Nwq4L0pw;i#0i$1))I8U?ov>4Mmxs;A61GF%- z5~gaML%csVrF++Ect94Lav#(5j+0WSrZq{OBNXZ=IG{w_eimvH^YV-lA%~R#>o1&d z5H)AxVlib9O7`WreLTzFPL27BdvQCVF{fMfMQWQCD9(u{jlB@7_`}skb%E9b^a>&c z_K0QkdlNmPKSjN$ppf8ONP=mP4VbznZoul*&*g;FBpmsGB*C}z9`WuQv>@bNA>rG_ z-EzBgD5{PkGsOk8gJF5{uVaHF4BLm<7PNh%+d)xdRj5!A&P`EYaT{hY_ncvn%FC>jVR{=g z+W;h`GY-P8itI$dzK%BF9m{GFpqrZDdng#dzC5Kz;IY*M_B}s4eT-?|hE^ij%l4x~ z!A{r-j*)(Qs&=woV={s-=VQQkJ3G2_cY<&Ti6(~-a@@oNQ+|#Jp&~7(<@2xd-n&o(7^&OO1P(>Wk1_D7rt%gv!40v^9Ib!kxnPhCp?=UW z-}NY0zIy+0UzCIE;qwd6B8y-%l9hkX<*(t(v-$D+nf$)vaKOyH4~PEaW#)fZ@|C0P z_Y0XTn0V%@p457#JHkKk!sgw;)SUd2^rUDb43KKhol!7FjKxZ*eTRWpGAtNxt{`M-dS7 z2hZeyKfLXnZ*6yZI~U{$BPWHN#UK@0VTY+$E5N-p)_ku8X z1$CBf2g2CW(;1KL<(*+hLlWMr0O1ZGjQuT~c{+k{ClKxo!d*bPD+pub8D~A+LAVD9 z_XOcyARG$9y+K$B!r>qs0m6|W90kICKzINM4+P;sAUqg^lRDro@ko8#$K$ z@GPs=VhwxDZnf!+8k0_I3}fu+!!#DPRcBV`xdJA;4V(4n+6zMUX2yvdBg=brvsk2z z$VeKQnax$6l9b^lkc0``f=zyhtM$fAokgq8OVDXG6R>RsYYEJumOL_Uc+%*!k;CpB zZa!d@|LEd9FPyT*3@Zs~H&*$*?2KrYAG6{r-WZK*ip+=w3-EIP&$(w5CM9EPJ+2to zp+nEOS0pDV$M;K!=@Xie5FZ^Hl^C8B8lRXP6PnOh*)K7nPgGJ&OmbMB+NNfGGcZI9 zzr@>(c?K=y`mmVjguc;nQGG-E#YD%4Mn%MjhsG!Mi3$zJ32{*|$w`s%5n+0hHJfFv z?8zFt-i9q>tgM>}B_1~0pgru^3N+g}vD4MeZ-;&|6xwz3dLROv0V$)jKyx3cpz4*M^LbI(nn|&89z^CC+IpFK8qg#92H?42W ztqD)H*fiPKM({OL1{e)7B)~5!_y3Tu4070A?3Pr&5P{sBvxW5~2i#1vf3M*95f}zx zF#zqcnyxrKFW~aPs3rTC4{i7~>MMd)p$hJD3qtEO>pA9L&=NLHzzU8vx&o$5>@&n! zabFr?fHja}_ZGzA0dOV^unx*!?2+gj-hAPYBmK_4XV@#kS!{rXt8(I8?I}1Xo3OBF z9RmT_u1JWu*+g1qmr_jL(y>O3FVb#a?9b?v+ip-8pO`0wxVnigC~fqW67 zpk(oSll}=Gb)XD-y-ELDhkpR3*P9gYz3^Y|p8(+GR1dE=>77H=-MmS?KA`B2`haqy z3g_6)>jR1b@%n)N38kR!fgbeQ18NwIhN_s?neVToE_H}=I_?4FopBKMzu%b;w=k!? zIp@~18dBIZbZR`l(P_1C(;!zQ1l}=$^fdp3GNq*CW}m?%USrvZaFeE;84s^&aWJau z26>Al`Ss-SqUod(75b3ANz)G=27C%$zs%5D*p(l^@-P~LpPta4m_hxJ0=|P=E(PEt z^rH+c0$dzD*)*fPZ(`Xd^%0wG=$j(&F~Ya#p2H{H8hkKQol=N*R!B*MfO9brYsW5f z_RfzoTb&cbf+Cqa6|D?Zb$#xOW&5MGWxl^=sWN?iNW9lJqOJ^_cWb;UQpS{TOVt}E z=#2#c`V3brgukq70m14=DXcDCEI_CST$DNT^*amqjEYEEbp2;d%Y;vskkDhp60qLo z6!6t<4LxA>hwN&L?Qv%M3PA3Pgou~^i`;^54h8WtY@&lNlHu_pCJ->2Mz0)}_QN2} z`^T1AwkKWtRD^nv!)K3Z_1ua2Sx-Tooi3D$br=niFMF93HSrWtQ-ck+D9Fp~aD6u; z{+_t5!^7Lm-l$ic*%v)Wggh=ilfDU;$B6b3S{q|81DKtUfp|O8yAZNv6b0{eZbe_z zjf%KD?&O;lO<#-N{LYY@$EIF7bzFos-i)uT301c2V#(+>OJZP($~w`2ZA2oaJ3uMX z0|cP74f)dP42)8sZgOemFw;8JuiMnEvWp?QrV@djLf1|9xGkt=i*}-2%K$6I)%+}} z@6q->lWue+t%2l9$QEK4Ki%5a-{+7<+H$99L zco%0Q)~@4CYD*qvSV>EU#4x9IB#3dCLX1+$@G=DHq3vW*hj*)L28Yj@x_@TF=+c4! z5izP|I5V|hyzbV-06KS;QP1qhomp(wrsUzB{Pg*HY@-QO5_$$m36*?2L5a>34Mo9O z4vI9CeUK8hhDkjGy2UJ;I^;s`kSXoNdsSh$KcQ2?)26rZUg{Zkvl-h>0wTB~A@HSU zQj+Oyin6qqp0~9#UI0(J+=dOf|386sm!0tu(63H0RC}{t40cZO+i+p@V^UW`PtmJ7lHRViZH2U z;riEj(#`p?wV(&4~SWW9pTn37N+v));H)jPGf4 zm)v<5dH8@k?9gwwkPdFNWJnAoBj+yXQ`&`!qQ{GL%U92iX)$g?^q?8@1MXjZ^wC42 zc7Z9`gg$ZeGe=}Ml|s@v{dAKadumy-QYf>?k~ByLMF$PhCITsKqTbFRX|g4yp-qj*eYtyn_F#uf@ z4{>*N8b>gE3I%s12aky1H^HIQ<5@l8rk?9pIql~8wqpzKk;xx-ZV$;8-9(=``--dA zO>vhB{eR3X+ zI}qO3i8i|O7z?rC+C05F(_}K_nkEClVKhWt6-|z@UZ6L zN`M5&c`}B?YlBLGL&Nzs7$C-(m6)?8kPWH+h}#WuZ$v_ps!;vorgI+07@G~a`2iW#6tzd8EBlFn~$RE~SD z<(S)zhg!s5WlD$7a=MUlZ@CVHOiG$~4R#c^JHxY@*08uRHVH!R=t)}M45V;<1x1k$ zhW6S|D6e%MqUw{nYDwcMeOGr;h&UcYUfPh_m0ogdjt7u48$FINF*bf0cFGd6yCeeYjunf=R-ZdF;T*G2dv6>7tNg5=BavnK}|0$&z)JQs8!shkoMlU7o=^FFsQrrEt_jO+*R&VOIdG$0h#H%$E z>N0|oq(L%N+eqiL7b#?@VCKBA4Bz3;*&s6yqSi3x#Th@}e>Aqus-dsXTCw_)WG&@O zdTa1B8^CzARm+kAsP@h{2zyW_srr0PfxU$Dgp#N}m=Z2^vw8O7LgVWZjh`>tv%Tt? ze79H-ArwuYL_5RK5MQ1&sLe_NxHE&G5<1Nw z=kJ|z?@#tlvA-={b@j()#|xe#i7=l&ZSQIB-JH`E)7iqg91shkS1cu=r`dhy)Ti)w zcwQey{oJi-XtB5AiwKv(2DUBKYgx`+FbPg}aNA30&@( z8DgtdkKLK|wqmKRYh@3z8~upl$y`&P#fPD(@xwQo^}jvKI-!;I(mb;W)(RxE)7J%e zyDhAGja`HF^4@V$NX>)Dd9hOzNEO^RC{R%NB*G3dYf`ScrnB zPRzB;y_~;m*wZAcS@d4-klUkbDl9Y^6D-AMY@flNf&+zXr3Bm^6mTmj;D-DFM)1?N z+?!o?ZNLxZL0Q|Lm6f+A!43I=+P8h=0pObPb`h3r>>n(_wqzj5xEm?hI;7b8=0nD{ zwH&`_+@)CMypby!o}4(7SaGgE`Ek_n0MJ_XoPDX`)hzx&F6 zzVgP$QC;V+?eM@$?ee>kO#2=kST{Y;2FO|5eQD~D2SM$~{iJBnDkQqDUz6Q%FR6>~ z-qu|!AGB)5u{rIEn+@nBf>!15*-hWy#O--DPj5A=Z5o}FXKR8;U_YSnteG1;6Ek;y zO?ttV;#tq$6EpmWzQ4V+vOvAMPn>w>4uji^zEb>wy9)&7*gh$+C7nrNH&KAC;C?&- zEU^TTa=Z1zBQHgj&xrlB_phPj9}saZ&MQ8-jag7&Pq=b>#j6l2UKHIRX9U@QZKfcb z!yzkDyiP*@=HG9$>unGyZ+bPg0 zD9{dss=?Rkx03zZ_iyx0r|;J+C|V>LDd4k4X(I)SZ=W;@75{`U8{z5#XN^72H-HU%RxBC-aqh=5@mmUln=utaT< z_HPh1fZwGqFk#*e@lDKpjx`K#hiuaq;z0duuE(CyMlEg)W`o+sZ0;K-jFkRYBo%A` zxM4iAvdV?Bt@^@j;VZIrCM#vlN`VZ-(#kf<*q-J<_9GnIzttg8m6H~8b$Z^*C3CtT zZ9|THu~7?cHIO7Rye_ZFc3mh)}de!Ye^7W<6&%v|(2mF1&q_(VE zb2v44HlcHGt4|-tmV+;^uiQChp6Kg?P?P5Lsll#X-T&$9Z90oqOP|f-d~kk+=;KwW$+z^6_q3xjK2MpS<#d>wQce_xSti@J5adYI5-F0V~(V_2_XZ`MHy% ztayvw6S}E!3|1_7K(jUZI;{aON>HFxEhLqUBa}W-!L?Q(1qf&t9jLljR}_2itbp*m z+^SRle-K(XwLoN{EyRZ{Vs9FgQOd71(@0ROD4?bXu&9ba6$yZuFg1G zxU;$8H4@Y(>HNCeZAGivqS5J#w7nywkeYu^B18a988&k>P7qR`#!v*ze>$Mmwwck> zpWWOgZ0Cw^3Q0&cbVzr)Eu@nR4G}avRiBdE`+iDcQDrj;i#Emw(YiKjSan)CY<|P= z6FY7X3RoCec}0w;19kK?JPm4Nfu1rMS2i$$;Lp<(JQW-tLH@+!H-P8KL$~~%S)}}| zS3=92K zBe<-5IiY?be-59&T@aVwOgszkA@9!L!~f39wGG)ULcH)EvfLIvKTKELZjTgGhWj#j z3H1oiFdwXI44)sSv-R+q9F-rEg{WbL617FqG-*BVN44 zIureTV)yx}BTXh-7-4emb)EhD{LTpIfvvgAOBUEFx*}n__PWmg0iQzN{gB4+0Ch%& zQZ`zK(GdBvmsyoUzRT&z6;F|qP9YrHzytjVTdn@PCwIl#@ZPbP378DReXEJ?_Q8090(1uyf~^4AEL`Y6Hd9S`|g^7XC2> zRu* z>H@8W9Y44{3Mr|u>#MwyPMGr@q8u@xppZhe-`kE$)^8kdM9*3`ZKM3{O-0!vQeeF6 z*zfJ8hmiuyZKK{;P}gB@v}8yOa~kQXa+pGlQf}@5h#TTqy`m29R@Dp+pEY&=%!bjW z1py*rRLhW_e!kCjwyeSKzwq$)Jsj2(he_av(?|TC zbBr?{0I?gC0l=A#fsKQBmuw}wVw!VYWdzHSLWwr?k#@%n%vpG61t@TwaS(dt&s_-_6GD+Oj#ex>B32h! z((ivR;B5b9k&mxvKH4;6R2kttr)so&Gwm+8VnzcGR4*hE3)_YuP}8?@!-q-DBom((P6qagrey1F_Dj z<@OJ8&2!D8FuH?d$hsv?SnSMK^Ao{<|dB`Sjter%9YK37MH{OMw6f&&Q_WT3873O&(+&ZA%vydU(@jQ7!^JxEyHffS8KF@rJZq*pUr*A zeYwt2gh^$6crVC#Tfgx2*s9rM&t%J61nva2zYS z3Z@Ox%v$4+)T9i6w-5#4R&9$V*!wgE?g|oaOCkPJ94XS>v-W50nb;_%(UcJjSECHn SON4ol3(&exception_stack_memory_[0]), - exception_stack_memory_.size()); + vm_address_t stack_memory_addr = + !exception_stack_memory_.empty() + ? reinterpret_cast(&exception_stack_memory_[0]) + : 0; + stack_.Initialize(0, stack_memory_addr, exception_stack_memory_.size()); } else { stack_.Initialize(0, 0, 0); } From 3b8a7cf594da2e3454fb230f98a60808837da217 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 30 Nov 2021 21:05:27 -0500 Subject: [PATCH 68/69] ios: Use _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS for backwards compatibility. _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is needed to bring back std::unexpected, which is removed in C++17, but still needed for libc++abi for backward compatibility. Bug: 1274565 Change-Id: I5b5687ef7a49e90bf6937ade8b02ff4484690e09 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3307905 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- client/ios_handler/exception_processor.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/ios_handler/exception_processor.mm b/client/ios_handler/exception_processor.mm index 1c0503411f..33981326f1 100644 --- a/client/ios_handler/exception_processor.mm +++ b/client/ios_handler/exception_processor.mm @@ -12,6 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +// std::unexpected_handler is deprecated starting in C++11, and removed in +// C++17. But macOS versions we run on still ship it. This define makes +// std::unexpected_handler reappear. If that define ever stops working, +// we hopefully no longer run on macOS versions that still have it. +// (...or we'll have to define it in this file instead of getting it from +// ). This define must before all includes. +#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS + #include "client/ios_handler/exception_processor.h" #include From fe19de6e1d003d04fb65de9a94d57bc37e1b770b Mon Sep 17 00:00:00 2001 From: Salome Thirot Date: Tue, 30 Nov 2021 10:38:31 +0000 Subject: [PATCH 69/69] arm64: Add Armv8.5-A BTI support to assembly files. Change-Id: Ic9c2d252829a39b0331e436df16effe7d0607996 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3241142 Commit-Queue: Jonathan Wright Reviewed-by: Joshua Peraza --- client/crashpad_info_note.S | 1 + snapshot/crashpad_info_size_test_note.S | 1 + snapshot/elf/elf_image_reader_test_note.S | 1 + util/misc/arm64_bti_note.S | 46 +++++++++++++++++++++++ util/misc/capture_context_linux.S | 3 ++ 5 files changed, 52 insertions(+) create mode 100644 util/misc/arm64_bti_note.S diff --git a/client/crashpad_info_note.S b/client/crashpad_info_note.S index b13d8642e7..ef3d68ccb4 100644 --- a/client/crashpad_info_note.S +++ b/client/crashpad_info_note.S @@ -17,6 +17,7 @@ // that symbol to be in the dynamic symbol table. #include "util/misc/elf_note_types.h" +#include "util/misc/arm64_bti_note.S" // namespace crashpad { // CrashpadInfo g_crashpad_info; diff --git a/snapshot/crashpad_info_size_test_note.S b/snapshot/crashpad_info_size_test_note.S index 16b5d499d7..8b1a0bd842 100644 --- a/snapshot/crashpad_info_size_test_note.S +++ b/snapshot/crashpad_info_size_test_note.S @@ -17,6 +17,7 @@ // that symbol to be in the dynamic symbol table. #include "util/misc/elf_note_types.h" +#include "util/misc/arm64_bti_note.S" // namespace crashpad { // CrashpadInfo g_test_crashpad_info; diff --git a/snapshot/elf/elf_image_reader_test_note.S b/snapshot/elf/elf_image_reader_test_note.S index 9ab0338977..08f1829fe4 100644 --- a/snapshot/elf/elf_image_reader_test_note.S +++ b/snapshot/elf/elf_image_reader_test_note.S @@ -13,6 +13,7 @@ // limitations under the License. #include "util/misc/elf_note_types.h" +#include "util/misc/arm64_bti_note.S" #define NOTE_ALIGN 4 .section .note.crashpad.test,"a",%note diff --git a/util/misc/arm64_bti_note.S b/util/misc/arm64_bti_note.S new file mode 100644 index 0000000000..987493be81 --- /dev/null +++ b/util/misc/arm64_bti_note.S @@ -0,0 +1,46 @@ +// Copyright 2021 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. + +#ifndef CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S +#define CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S + +/* Support macros for the Armv8.5-A Branch Target Identification feature which + * requires emitting a .note.gnu.property section with the appropriate + * architecture-dependent feature bits set. + * Read more: "ELF for the Arm® 64-bit Architecture" + */ +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI + .pushsection .note.gnu.property, "a" + .balign 4 + .long 0x4 /* size of field "GNU" */ + .long 0x10 /* note descriptor size */ + .long 0x5 /* type of note descriptor: NT_GNU_PROPERTY_TYPE_0 */ + .asciz "GNU" + .long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ + .long 0x4 + .long GNU_PROPERTY_AARCH64_BTI + .long 0x0 + .popsection +#define CRASHPAD_AARCH64_VALID_JUMP_CALL_TARGET bti jc +#define CRASHPAD_AARCH64_VALID_CALL_TARGET bti c +#define CRASHPAD_AARCH64_VALID_JUMP_TARGET bti j +#undef GNU_PROPERTY_AARCH64_BTI +#else +#define CRASHPAD_AARCH64_VALID_JUMP_CALL_TARGET +#define CRASHPAD_AARCH64_VALID_CALL_TARGET +#define CRASHPAD_AARCH64_VALID_JUMP_TARGET +#endif + +#endif /* CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S */ diff --git a/util/misc/capture_context_linux.S b/util/misc/capture_context_linux.S index 52215ee5d0..0ee561f534 100644 --- a/util/misc/capture_context_linux.S +++ b/util/misc/capture_context_linux.S @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "util/misc/arm64_bti_note.S" + // namespace crashpad { // void CaptureContext(ucontext_t* context); // } // namespace crashpad @@ -38,6 +40,7 @@ CAPTURECONTEXT_SYMBOL: CAPTURECONTEXT_SYMBOL2: + CRASHPAD_AARCH64_VALID_CALL_TARGET #if defined(__i386__)