OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_H_ |
| 16 #define CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_H_ |
| 17 |
| 18 #include <stdint.h> |
| 19 |
| 20 #include <vector> |
| 21 |
| 22 namespace crashpad { |
| 23 |
| 24 struct CPUContext; |
| 25 |
| 26 //! \brief An abstract interface to a snapshot representing an exception that a |
| 27 //! snapshot process sustained and triggered the snapshot being taken. |
| 28 class ExceptionSnapshot { |
| 29 public: |
| 30 //! \brief Returns a CPUContext object corresponding to the exception thread’s |
| 31 //! CPU context at the time of the exception. |
| 32 //! |
| 33 //! The caller does not take ownership of this object, it is scoped to the |
| 34 //! lifetime of the ThreadSnapshot object that it was obtained from. |
| 35 virtual const CPUContext* Context() const = 0; |
| 36 |
| 37 //! \brief Returns the thread identifier of the thread that triggered the |
| 38 //! exception. |
| 39 //! |
| 40 //! This value can be compared to ThreadSnapshot::ThreadID() to associate an |
| 41 //! ExceptionSnapshot object with the ThreadSnapshot that contains a snapshot |
| 42 //! of the thread that triggered the exception. |
| 43 virtual uint64_t ThreadID() const = 0; |
| 44 |
| 45 //! \brief Returns the top-level exception code identifying the exception. |
| 46 //! |
| 47 //! This is an operating system-specific value. |
| 48 //! |
| 49 //! For Mac OS X, this will be an \ref EXC_x "EXC_*" exception type, such as |
| 50 //! `EXC_BAD_ACCESS`. `EXC_CRASH` will not appear here for exceptions |
| 51 //! processed as `EXC_CRASH` when generated from another preceding exception: |
| 52 //! the original exception code will appear instead. The exception type as it |
| 53 //! was received will appear at index 0 of Codes(). |
| 54 virtual uint32_t Exception() const = 0; |
| 55 |
| 56 //! \brief Returns the second-level exception code identifying the exception. |
| 57 //! |
| 58 //! This is an operating system-specific value. |
| 59 //! |
| 60 //! For Mac OS X, this will be the value of the exception code at index 0 as |
| 61 //! received by a Mach exception handler. For `EXC_CRASH` exceptions generated |
| 62 //! from another preceding exception, the original exception code will appear |
| 63 //! here, not the code as received by the Mach exception handler. The code as |
| 64 //! it was received will appear at index 1 of Codes(). |
| 65 virtual uint32_t ExceptionInfo() const = 0; |
| 66 |
| 67 //! \brief Returns the address that triggered the exception. |
| 68 //! |
| 69 //! This may be the address that caused a fault on data access, or it may be |
| 70 //! the instruction pointer that contained an offending instruction. For |
| 71 //! exceptions where this value cannot be determined, it will be `0`. |
| 72 //! |
| 73 //! For Mac OS X, this will be the value of the exception code at index 1 as |
| 74 //! received by a Mach exception handler. |
| 75 virtual uint64_t ExceptionAddress() const = 0; |
| 76 |
| 77 //! \brief Returns a series of operating system-specific exception codes. |
| 78 //! |
| 79 //! The precise interpretation of these codes is specific to the snapshot |
| 80 //! operating system. These codes may provide a duplicate of information |
| 81 //! available elsewhere, they may extend information available elsewhere, or |
| 82 //! they may not be present at all. In this case, an empty vector will be |
| 83 //! returned. |
| 84 //! |
| 85 //! For Mac OS X, this will be a vector containing the original exception type |
| 86 //! and the values of `code[0]` and `code[1]` as received by a Mach exception |
| 87 //! handler. |
| 88 virtual const std::vector<uint64_t>& Codes() const = 0; |
| 89 |
| 90 protected: |
| 91 ~ExceptionSnapshot() {} |
| 92 }; |
| 93 |
| 94 } // namespace crashpad |
| 95 |
| 96 #endif // CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_H_ |
OLD | NEW |