2015-09-03 13:31:19 -07:00
|
|
|
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#ifndef CRASHPAD_HANDLER_WIN_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
#define CRASHPAD_HANDLER_WIN_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-11 14:48:10 -04:00
|
|
|
#include "handler/user_stream_data_source.h"
|
2015-09-03 13:31:19 -07:00
|
|
|
#include "util/win/exception_handler_server.h"
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
|
|
|
class CrashReportDatabase;
|
|
|
|
class CrashReportUploadThread;
|
|
|
|
|
|
|
|
//! \brief An exception handler that writes crash reports for exception messages
|
|
|
|
//! to a CrashReportDatabase.
|
2019-08-30 11:51:47 -07:00
|
|
|
class CrashReportExceptionHandler final
|
|
|
|
: public ExceptionHandlerServer::Delegate {
|
2015-09-03 13:31:19 -07:00
|
|
|
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
|
2018-02-20 10:55:17 -08:00
|
|
|
//! report is written into \a database. Report upload is skipped if this
|
|
|
|
//! value is `nullptr`.
|
2015-09-03 13:31:19 -07:00
|
|
|
//! \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.
|
2017-04-13 12:56:52 -04: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.
|
2015-09-03 13:31:19 -07:00
|
|
|
CrashReportExceptionHandler(
|
|
|
|
CrashReportDatabase* database,
|
|
|
|
CrashReportUploadThread* upload_thread,
|
2017-04-11 14:48:10 -04:00
|
|
|
const std::map<std::string, std::string>* process_annotations,
|
2020-06-24 09:03:47 +02:00
|
|
|
const std::vector<base::FilePath>* attachments,
|
2017-04-11 14:48:10 -04:00
|
|
|
const UserStreamDataSources* user_stream_data_sources);
|
2015-09-03 13:31:19 -07:00
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete;
|
|
|
|
CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) =
|
|
|
|
delete;
|
|
|
|
|
2017-12-19 12:03:54 -08:00
|
|
|
~CrashReportExceptionHandler();
|
2015-09-03 13:31:19 -07:00
|
|
|
|
|
|
|
// ExceptionHandlerServer::Delegate:
|
|
|
|
|
|
|
|
//! \brief Processes an exception message by writing a crash report to this
|
|
|
|
//! object's CrashReportDatabase.
|
|
|
|
void ExceptionHandlerServerStarted() override;
|
|
|
|
unsigned int ExceptionHandlerServerException(
|
|
|
|
HANDLE process,
|
2015-10-15 13:18:08 -07:00
|
|
|
WinVMAddress exception_information_address,
|
|
|
|
WinVMAddress debug_critical_section_address) override;
|
2015-09-03 13:31:19 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
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
|
2017-04-11 14:48:10 -04:00
|
|
|
const UserStreamDataSources* user_stream_data_sources_; // weak
|
2015-09-03 13:31:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
#endif // CRASHPAD_HANDLER_WIN_CRASH_REPORT_EXCEPTION_HANDLER_H_
|