From 15c4fff902ea0943787a0dc8e1db31a5d6486059 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 6 Dec 2017 10:08:11 -0800 Subject: [PATCH] Get crashpad_client_test and crashpad_handler_test building Stubs a variety of classes (CrashReportExceptionHandler, ExceptionHandlerServer, HTTPTransport, CrashReportDatabase). Bug: crashpad:196 Change-Id: I4772f90d0d2ad07cc2f3c2ef119e92fde5c7acef Reviewed-on: https://chromium-review.googlesource.com/809940 Reviewed-by: Mark Mentovai Commit-Queue: Scott Graham --- build/run_tests.py | 10 +-- client/BUILD.gn | 7 ++ client/crash_report_database_fuchsia.cc | 35 ++++++++++ client/crashpad_client_fuchsia.cc | 38 +++++++++++ handler/BUILD.gn | 10 +++ .../fuchsia/crash_report_exception_handler.cc | 27 ++++++++ .../fuchsia/crash_report_exception_handler.h | 65 +++++++++++++++++++ handler/fuchsia/exception_handler_server.cc | 29 +++++++++ handler/fuchsia/exception_handler_server.h | 44 +++++++++++++ handler/handler_main.cc | 15 +++++ handler/main.cc | 4 +- util/BUILD.gn | 5 +- util/net/http_transport_fuchsia.cc | 26 ++++++++ 13 files changed, 304 insertions(+), 11 deletions(-) create mode 100644 client/crash_report_database_fuchsia.cc create mode 100644 client/crashpad_client_fuchsia.cc create mode 100644 handler/fuchsia/crash_report_exception_handler.cc create mode 100644 handler/fuchsia/crash_report_exception_handler.h create mode 100644 handler/fuchsia/exception_handler_server.cc create mode 100644 handler/fuchsia/exception_handler_server.h create mode 100644 util/net/http_transport_fuchsia.cc diff --git a/build/run_tests.py b/build/run_tests.py index 5dbf5d2f..18cc9f53 100755 --- a/build/run_tests.py +++ b/build/run_tests.py @@ -173,20 +173,14 @@ def main(args): is_fuchsia = _BinaryDirLooksLikeFuchsiaBuild(binary_dir) tests = [ + 'crashpad_client_test', + 'crashpad_handler_test', 'crashpad_minidump_test', 'crashpad_snapshot_test', 'crashpad_test_test', 'crashpad_util_test', ] - if not is_fuchsia: - tests.extend([ - # TODO(scottmg): Move the rest of these to the common section once they - # are building and running successfully. - 'crashpad_client_test', - 'crashpad_handler_test', - ]) - if is_fuchsia: zircon_nodename = os.environ.get('ZIRCON_NODENAME') if not zircon_nodename: diff --git a/client/BUILD.gn b/client/BUILD.gn index 5361dda2..bdff4cf8 100644 --- a/client/BUILD.gn +++ b/client/BUILD.gn @@ -53,6 +53,13 @@ static_library("client") { ] } + if (is_fuchsia) { + sources += [ + "crash_report_database_fuchsia.cc", + "crashpad_client_fuchsia.cc", + ] + } + public_configs = [ "..:crashpad_config" ] deps = [ diff --git a/client/crash_report_database_fuchsia.cc b/client/crash_report_database_fuchsia.cc new file mode 100644 index 00000000..0a7157c8 --- /dev/null +++ b/client/crash_report_database_fuchsia.cc @@ -0,0 +1,35 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "client/crash_report_database.h" + +#include "base/logging.h" + +namespace crashpad { + +// static +std::unique_ptr CrashReportDatabase::Initialize( + const base::FilePath& path) { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 + return std::unique_ptr(); +} + +// static +std::unique_ptr +CrashReportDatabase::InitializeWithoutCreating(const base::FilePath& path) { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 + return std::unique_ptr(); +} + +} // namespace crashpad diff --git a/client/crashpad_client_fuchsia.cc b/client/crashpad_client_fuchsia.cc new file mode 100644 index 00000000..ea179b85 --- /dev/null +++ b/client/crashpad_client_fuchsia.cc @@ -0,0 +1,38 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "client/crashpad_client.h" + +#include "base/logging.h" + +namespace crashpad { + +CrashpadClient::CrashpadClient() {} + +CrashpadClient::~CrashpadClient() {} + +bool CrashpadClient::StartHandler( + const base::FilePath& handler, + const base::FilePath& database, + const base::FilePath& metrics_dir, + const std::string& url, + const std::map& annotations, + const std::vector& arguments, + bool restartable, + bool asynchronous_start) { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 + return false; +} + +} // namespace crashpad diff --git a/handler/BUILD.gn b/handler/BUILD.gn index 05f554b7..496f256e 100644 --- a/handler/BUILD.gn +++ b/handler/BUILD.gn @@ -46,6 +46,15 @@ static_library("handler") { ] } + if (is_fuchsia) { + sources += [ + "fuchsia/crash_report_exception_handler.cc", + "fuchsia/crash_report_exception_handler.h", + "fuchsia/exception_handler_server.cc", + "fuchsia/exception_handler_server.h", + ] + } + public_configs = [ "..:crashpad_config" ] deps = [ @@ -75,6 +84,7 @@ source_set("handler_test") { "../client", "../compat", "../snapshot", + "../snapshot:test_support", "../test", "../util", "//base", diff --git a/handler/fuchsia/crash_report_exception_handler.cc b/handler/fuchsia/crash_report_exception_handler.cc new file mode 100644 index 00000000..a7f61994 --- /dev/null +++ b/handler/fuchsia/crash_report_exception_handler.cc @@ -0,0 +1,27 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "handler/fuchsia/crash_report_exception_handler.h" + +namespace crashpad { + +CrashReportExceptionHandler::CrashReportExceptionHandler( + CrashReportDatabase* database, + CrashReportUploadThread* upload_thread, + const std::map* process_annotations, + const UserStreamDataSources* user_stream_data_sources) {} + +CrashReportExceptionHandler::~CrashReportExceptionHandler() {} + +} // namespace crashpad diff --git a/handler/fuchsia/crash_report_exception_handler.h b/handler/fuchsia/crash_report_exception_handler.h new file mode 100644 index 00000000..c987a5dc --- /dev/null +++ b/handler/fuchsia/crash_report_exception_handler.h @@ -0,0 +1,65 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_HANDLER_FUCHSIA_CRASH_REPORT_EXCEPTION_HANDLER_H_ +#define CRASHPAD_HANDLER_FUCHSIA_CRASH_REPORT_EXCEPTION_HANDLER_H_ + +#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" + +namespace crashpad { + +//! \brief An exception handler that writes crash reports for exception messages +//! to a CrashReportDatabase. This class is not yet implemented. +class CrashReportExceptionHandler { + public: + //! \brief Creates a new object that will store crash reports in \a database. + //! + //! \param[in] database The database to store crash reports in. Weak. + //! \param[in] upload_thread The upload thread to notify when a new crash + //! report is written into \a database. + //! \param[in] process_annotations A map of annotations to insert as + //! process-level annotations into each crash report that is written. Do + //! not confuse this with module-level annotations, which are under the + //! control of the crashing process, and are used to implement Chrome's + //! "crash keys." Process-level annotations are those that are beyond the + //! control of the crashing process, which must reliably be set even if + //! the process crashes before it’s able to establish its own annotations. + //! To interoperate with Breakpad servers, the recommended practice is to + //! specify values for the `"prod"` and `"ver"` keys as process + //! annotations. + //! \param[in] user_stream_data_sources Data sources to be used to extend + //! crash reports. For each crash report that is written, the data sources + //! are called in turn. These data sources may contribute additional + //! minidump streams. `nullptr` if not required. + CrashReportExceptionHandler( + CrashReportDatabase* database, + CrashReportUploadThread* upload_thread, + const std::map* process_annotations, + const UserStreamDataSources* user_stream_data_sources); + + ~CrashReportExceptionHandler(); + + private: + DISALLOW_COPY_AND_ASSIGN(CrashReportExceptionHandler); +}; + +} // namespace crashpad + +#endif // CRASHPAD_HANDLER_FUCHSIA_CRASH_REPORT_EXCEPTION_HANDLER_H_ diff --git a/handler/fuchsia/exception_handler_server.cc b/handler/fuchsia/exception_handler_server.cc new file mode 100644 index 00000000..d1dfcdf0 --- /dev/null +++ b/handler/fuchsia/exception_handler_server.cc @@ -0,0 +1,29 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "handler/fuchsia/exception_handler_server.h" + +#include "base/logging.h" + +namespace crashpad { + +ExceptionHandlerServer::ExceptionHandlerServer() {} + +ExceptionHandlerServer::~ExceptionHandlerServer() {} + +void ExceptionHandlerServer::Run(CrashReportExceptionHandler* handler) { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 +} + +} // namespace crashpad diff --git a/handler/fuchsia/exception_handler_server.h b/handler/fuchsia/exception_handler_server.h new file mode 100644 index 00000000..b998ba9c --- /dev/null +++ b/handler/fuchsia/exception_handler_server.h @@ -0,0 +1,44 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_HANDLER_FUCHSIA_EXCEPTION_HANDLER_SERVER_H_ +#define CRASHPAD_HANDLER_FUCHSIA_EXCEPTION_HANDLER_SERVER_H_ + +#include "base/macros.h" + +namespace crashpad { + +class CrashReportExceptionHandler; + +//! \brief Runs the main exception-handling server in Crashpad's handler +//! process. This class is not yet implemented. +class ExceptionHandlerServer { + public: + //! \brief Constructs an ExceptionHandlerServer object. + ExceptionHandlerServer(); + ~ExceptionHandlerServer(); + + //! \brief Runs the exception-handling server. + //! + //! \param[in] handler The handler to which the exceptions are delegated when + //! they are caught in Run(). Ownership is not transferred. + void Run(CrashReportExceptionHandler* handler); + + private: + DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); +}; + +} // namespace crashpad + +#endif // CRASHPAD_HANDLER_FUCHSIA_EXCEPTION_HANDLER_SERVER_H_ diff --git a/handler/handler_main.cc b/handler/handler_main.cc index 2e46f86a..f175fddf 100644 --- a/handler/handler_main.cc +++ b/handler/handler_main.cc @@ -74,6 +74,9 @@ #include "util/win/handle.h" #include "util/win/initial_client_data.h" #include "util/win/session_end_watcher.h" +#elif defined(OS_FUCHSIA) +#include "handler/fuchsia/crash_report_exception_handler.h" +#include "handler/fuchsia/exception_handler_server.h" #endif // OS_MACOSX namespace crashpad { @@ -345,6 +348,16 @@ void InstallCrashHandler() { ALLOW_UNUSED_LOCAL(terminate_handler); } +#elif defined(OS_FUCHSIA) + +void InstallCrashHandler() { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 +} + +void ReinstallCrashHandler() { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 +} + #endif // OS_MACOSX void MonitorSelf(const Options& options) { @@ -727,6 +740,8 @@ int HandlerMain(int argc, if (!options.pipe_name.empty()) { exception_handler_server.SetPipeName(base::UTF8ToUTF16(options.pipe_name)); } +#elif defined(OS_FUCHSIA) + ExceptionHandlerServer exception_handler_server; #endif // OS_MACOSX base::GlobalHistogramAllocator* histogram_allocator = nullptr; diff --git a/handler/main.cc b/handler/main.cc index c0a04f40..3ae73ecd 100644 --- a/handler/main.cc +++ b/handler/main.cc @@ -21,7 +21,7 @@ #include #endif -#if defined(OS_MACOSX) +#if defined(OS_POSIX) int main(int argc, char* argv[]) { return crashpad::HandlerMain(argc, argv, nullptr); @@ -50,4 +50,4 @@ int wmain(int argc, wchar_t* argv[]) { return crashpad::ToolSupport::Wmain(argc, argv, HandlerMainAdaptor); } -#endif // OS_MACOSX +#endif // OS_POSIX diff --git a/util/BUILD.gn b/util/BUILD.gn index 11a6849b..9adc5d63 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -310,7 +310,10 @@ static_library("util") { } if (is_fuchsia) { - sources += [ "misc/paths_fuchsia.cc" ] + sources += [ + "misc/paths_fuchsia.cc", + "net/http_transport_fuchsia.cc", + ] } public_configs = [ "..:crashpad_config" ] diff --git a/util/net/http_transport_fuchsia.cc b/util/net/http_transport_fuchsia.cc new file mode 100644 index 00000000..1c08c1f1 --- /dev/null +++ b/util/net/http_transport_fuchsia.cc @@ -0,0 +1,26 @@ +// Copyright 2017 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "util/net/http_transport.h" + +#include "base/logging.h" + +namespace crashpad { + +std::unique_ptr HTTPTransport::Create() { + NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 + return std::unique_ptr(); +} + +} // namespace crashpad