2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2018 The Crashpad Authors
|
2018-02-16 09:13:35 -08:00
|
|
|
|
//
|
|
|
|
|
// 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_LINUX_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
|
#define CRASHPAD_HANDLER_LINUX_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "client/crash_report_database.h"
|
|
|
|
|
#include "handler/crash_report_upload_thread.h"
|
|
|
|
|
#include "handler/linux/exception_handler_server.h"
|
|
|
|
|
#include "handler/user_stream_data_source.h"
|
2018-06-12 08:30:36 -07:00
|
|
|
|
#include "util/linux/exception_handler_protocol.h"
|
2018-02-16 09:13:35 -08:00
|
|
|
|
#include "util/linux/ptrace_connection.h"
|
|
|
|
|
#include "util/misc/address_types.h"
|
2018-10-10 10:26:26 -07:00
|
|
|
|
#include "util/misc/uuid.h"
|
2018-02-16 09:13:35 -08:00
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
|
2020-01-28 12:02:55 -08:00
|
|
|
|
class ProcessSnapshotLinux;
|
|
|
|
|
class ProcessSnapshotSanitized;
|
|
|
|
|
|
2018-02-16 09:13:35 -08:00
|
|
|
|
//! \brief An exception handler that writes crash reports for exceptions
|
|
|
|
|
//! to a CrashReportDatabase.
|
|
|
|
|
class CrashReportExceptionHandler : public ExceptionHandlerServer::Delegate {
|
|
|
|
|
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. Report upload is skipped if this
|
|
|
|
|
//! value is `nullptr`.
|
|
|
|
|
//! \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.
|
2020-06-24 09:03:47 +02:00
|
|
|
|
//! \param[in] attachments A vector of file paths that should be captured with
|
|
|
|
|
//! each report at the time of the crash.
|
2020-01-28 12:02:55 -08:00
|
|
|
|
//! \param[in] write_minidump_to_database Whether the minidump shall be
|
|
|
|
|
//! written to database.
|
|
|
|
|
//! \param[in] write_minidump_to_log Whether the minidump shall be written to
|
|
|
|
|
//! log.
|
2018-02-16 09:13:35 -08:00
|
|
|
|
//! \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<std::string, std::string>* process_annotations,
|
2020-06-24 09:03:47 +02:00
|
|
|
|
const std::vector<base::FilePath>* attachments,
|
2020-01-28 12:02:55 -08:00
|
|
|
|
bool write_minidump_to_database,
|
|
|
|
|
bool write_minidump_to_log,
|
2018-02-16 09:13:35 -08:00
|
|
|
|
const UserStreamDataSources* user_stream_data_sources);
|
|
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
|
CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete;
|
|
|
|
|
CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) =
|
|
|
|
|
delete;
|
|
|
|
|
|
2019-08-30 11:51:47 -07:00
|
|
|
|
~CrashReportExceptionHandler() override;
|
2018-02-16 09:13:35 -08:00
|
|
|
|
|
|
|
|
|
// ExceptionHandlerServer::Delegate:
|
|
|
|
|
|
|
|
|
|
bool HandleException(pid_t client_process_id,
|
2019-08-19 15:43:02 -07:00
|
|
|
|
uid_t client_uid,
|
2019-04-23 09:59:29 -07:00
|
|
|
|
const ExceptionHandlerProtocol::ClientInformation& info,
|
2019-04-16 11:01:27 -07:00
|
|
|
|
VMAddress requesting_thread_stack_address = 0,
|
|
|
|
|
pid_t* requesting_thread_id = nullptr,
|
2018-10-10 10:26:26 -07:00
|
|
|
|
UUID* local_report_id = nullptr) override;
|
2018-02-16 09:13:35 -08:00
|
|
|
|
|
2019-04-23 09:59:29 -07:00
|
|
|
|
bool HandleExceptionWithBroker(
|
|
|
|
|
pid_t client_process_id,
|
2019-08-19 15:43:02 -07:00
|
|
|
|
uid_t client_uid,
|
2019-04-23 09:59:29 -07:00
|
|
|
|
const ExceptionHandlerProtocol::ClientInformation& info,
|
|
|
|
|
int broker_sock,
|
|
|
|
|
UUID* local_report_id = nullptr) override;
|
2018-02-16 09:13:35 -08:00
|
|
|
|
|
|
|
|
|
private:
|
2019-04-23 09:59:29 -07:00
|
|
|
|
bool HandleExceptionWithConnection(
|
|
|
|
|
PtraceConnection* connection,
|
|
|
|
|
const ExceptionHandlerProtocol::ClientInformation& info,
|
2019-08-19 15:43:02 -07:00
|
|
|
|
uid_t client_uid,
|
2019-04-23 09:59:29 -07:00
|
|
|
|
VMAddress requesting_thread_stack_address,
|
|
|
|
|
pid_t* requesting_thread_id,
|
|
|
|
|
UUID* local_report_id = nullptr);
|
2018-02-16 09:13:35 -08:00
|
|
|
|
|
2020-01-28 12:02:55 -08:00
|
|
|
|
bool WriteMinidumpToDatabase(ProcessSnapshotLinux* process_snapshot,
|
|
|
|
|
ProcessSnapshotSanitized* sanitized_snapshot,
|
|
|
|
|
bool write_minidump_to_log,
|
|
|
|
|
UUID* local_report_id);
|
|
|
|
|
bool WriteMinidumpToLog(ProcessSnapshotLinux* process_snapshot,
|
|
|
|
|
ProcessSnapshotSanitized* sanitized_snapshot);
|
|
|
|
|
|
2018-02-16 09:13:35 -08:00
|
|
|
|
CrashReportDatabase* database_; // weak
|
|
|
|
|
CrashReportUploadThread* upload_thread_; // weak
|
|
|
|
|
const std::map<std::string, std::string>* process_annotations_; // weak
|
2020-06-24 09:03:47 +02:00
|
|
|
|
const std::vector<base::FilePath>* attachments_; // weak
|
2020-01-28 12:02:55 -08:00
|
|
|
|
bool write_minidump_to_database_;
|
|
|
|
|
bool write_minidump_to_log_;
|
2018-02-16 09:13:35 -08:00
|
|
|
|
const UserStreamDataSources* user_stream_data_sources_; // weak
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
|
|
#endif // CRASHPAD_HANDLER_LINUX_CRASH_REPORT_EXCEPTION_HANDLER_H_
|