2015-02-04 18:32:42 -05: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_MAC_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
|
#define CRASHPAD_HANDLER_MAC_CRASH_REPORT_EXCEPTION_HANDLER_H_
|
|
|
|
|
|
|
|
|
|
#include <mach/mach.h>
|
|
|
|
|
|
2015-03-05 15:40:47 -05:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2015-02-04 18:32:42 -05:00
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
#include "client/crash_report_database.h"
|
2015-08-18 15:34:10 -07:00
|
|
|
|
#include "handler/crash_report_upload_thread.h"
|
2015-02-04 18:32:42 -05:00
|
|
|
|
#include "util/mach/exc_server_variants.h"
|
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
|
|
|
|
|
//! \brief An exception handler that writes crash reports for exception messages
|
|
|
|
|
//! to a CrashReportDatabase.
|
|
|
|
|
class CrashReportExceptionHandler : public UniversalMachExcServer::Interface {
|
|
|
|
|
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.
|
2015-02-12 15:03:59 -05:00
|
|
|
|
//! \param[in] upload_thread The upload thread to notify when a new crash
|
|
|
|
|
//! report is written into \a database.
|
2015-03-05 15:40:47 -05: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.
|
|
|
|
|
CrashReportExceptionHandler(
|
|
|
|
|
CrashReportDatabase* database,
|
|
|
|
|
CrashReportUploadThread* upload_thread,
|
|
|
|
|
const std::map<std::string, std::string>* process_annotations);
|
2015-02-04 18:32:42 -05:00
|
|
|
|
|
|
|
|
|
~CrashReportExceptionHandler();
|
|
|
|
|
|
|
|
|
|
// UniversalMachExcServer::Interface:
|
|
|
|
|
|
|
|
|
|
//! \brief Processes an exception message by writing a crash report to this
|
|
|
|
|
//! object’s CrashReportDatabase.
|
|
|
|
|
kern_return_t CatchMachException(
|
|
|
|
|
exception_behavior_t behavior,
|
|
|
|
|
exception_handler_t exception_port,
|
|
|
|
|
thread_t thread,
|
|
|
|
|
task_t task,
|
|
|
|
|
exception_type_t exception,
|
|
|
|
|
const mach_exception_data_type_t* code,
|
|
|
|
|
mach_msg_type_number_t code_count,
|
|
|
|
|
thread_state_flavor_t* flavor,
|
2015-04-02 15:28:28 -04:00
|
|
|
|
ConstThreadState old_state,
|
2015-02-04 18:32:42 -05:00
|
|
|
|
mach_msg_type_number_t old_state_count,
|
|
|
|
|
thread_state_t new_state,
|
|
|
|
|
mach_msg_type_number_t* new_state_count,
|
|
|
|
|
const mach_msg_trailer_t* trailer,
|
|
|
|
|
bool* destroy_complex_request) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CrashReportDatabase* database_; // weak
|
2015-02-12 15:03:59 -05:00
|
|
|
|
CrashReportUploadThread* upload_thread_; // weak
|
2015-03-05 15:40:47 -05:00
|
|
|
|
const std::map<std::string, std::string>* process_annotations_; // weak
|
2015-02-04 18:32:42 -05:00
|
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CrashReportExceptionHandler);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
|
|
#endif // CRASHPAD_HANDLER_MAC_CRASH_REPORT_EXCEPTION_HANDLER_H_
|