OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 //! \brief A structure that can be used by a Crashpad-enabled program to | 26 //! \brief A structure that can be used by a Crashpad-enabled program to |
27 //! provide information to the Crashpad crash handler. | 27 //! provide information to the Crashpad crash handler. |
28 //! | 28 //! |
29 //! It is possible for one CrashpadInfo structure to appear in each loaded code | 29 //! It is possible for one CrashpadInfo structure to appear in each loaded code |
30 //! module in a process, but from the perspective of the user of the client | 30 //! module in a process, but from the perspective of the user of the client |
31 //! interface, there is only one global CrashpadInfo structure, located in the | 31 //! interface, there is only one global CrashpadInfo structure, located in the |
32 //! module that contains the client interface code. | 32 //! module that contains the client interface code. |
33 struct CrashpadInfo { | 33 struct CrashpadInfo { |
34 public: | 34 public: |
| 35 //! \brief Options to enable and disable features. |
| 36 //! |
| 37 //! \sa CrashpadInfoClientOptions::TriState |
| 38 enum class TriState : uint8_t { |
| 39 //! \brief No special behavior is requested, and the defaults are desired. |
| 40 kDefault = 0, |
| 41 |
| 42 //! \brief The behavior should be enabled. |
| 43 kEnabled, |
| 44 |
| 45 //! \brief The behavior should be disabled. |
| 46 kDisabled, |
| 47 }; |
| 48 |
35 //! \brief Returns the global CrashpadInfo structure. | 49 //! \brief Returns the global CrashpadInfo structure. |
36 static CrashpadInfo* GetCrashpadInfo(); | 50 static CrashpadInfo* GetCrashpadInfo(); |
37 | 51 |
38 CrashpadInfo(); | 52 CrashpadInfo(); |
39 | 53 |
40 void set_simple_annotations(SimpleStringDictionary* simple_annotations) { | 54 void set_simple_annotations(SimpleStringDictionary* simple_annotations) { |
41 simple_annotations_ = simple_annotations; | 55 simple_annotations_ = simple_annotations; |
42 } | 56 } |
43 | 57 |
| 58 //! \brief Enables or disables Crashpad handler processing. |
| 59 //! |
| 60 //! When handling an exception, the Crashpad handler will scan all modules in |
| 61 //! a process. The first one that has a CrashpadInfo structure populated with |
| 62 //! a value other than #kDefault for \a state will dictate whether the handler |
| 63 //! is functional or not. If all modules with a CrashpadInfo structure specify |
| 64 //! #kDefault, the handler will be enabled. If disabled, the Crashpad handler |
| 65 //! will still run and receive exceptions, but will not take any action on an |
| 66 //! exception on its own behalf, except for the action necessary to determine |
| 67 //! that it has been disabled. |
| 68 //! |
| 69 //! The Crashpad handler should not normally be disabled. More commonly, it |
| 70 //! is appropraite to disable crash report upload by calling |
| 71 //! Settings::SetUploadsEnabled(). |
| 72 void set_crashpad_handler_behavior(TriState crashpad_handler_behavior) { |
| 73 crashpad_handler_behavior_ = crashpad_handler_behavior; |
| 74 } |
| 75 |
| 76 //! \brief Enables or disables Crashpad forwarding of exceptions to the |
| 77 //! system’s crash reporter. |
| 78 //! |
| 79 //! When handling an exception, the Crashpad handler will scan all modules in |
| 80 //! a process. The first one that has a CrashpadInfo structure populated with |
| 81 //! a value other than #kDefault for \a state will dictate whether the |
| 82 //! exception is forwarded to the system’s crash reporter. If all modules with |
| 83 //! a CrashpadInfo structure specify #kDefault, forwarding will be enabled. |
| 84 //! Unless disabled, forwarding may still occur if the Crashpad handler is |
| 85 //! disabled by SetCrashpadHandlerState(). Even when forwarding is enabled, |
| 86 //! the Crashpad handler may choose not to forward all exceptions to the |
| 87 //! system’s crash reporter in cases where it has reason to believe that the |
| 88 //! system’s crash reporter would not normally have handled the exception in |
| 89 //! Crashpad’s absence. |
| 90 void set_system_crash_reporter_forwarding( |
| 91 TriState system_crash_reporter_forwarding) { |
| 92 system_crash_reporter_forwarding_ = system_crash_reporter_forwarding; |
| 93 } |
| 94 |
44 static const uint32_t kSignature = 'CPad'; | 95 static const uint32_t kSignature = 'CPad'; |
45 | 96 |
46 private: | 97 private: |
47 // The compiler won’t necessarily see anyone using these fields, but it | 98 // The compiler won’t necessarily see anyone using these fields, but it |
48 // shouldn’t warn about that. These fields aren’t intended for use by the | 99 // shouldn’t warn about that. These fields aren’t intended for use by the |
49 // process they’re found in, they’re supposed to be read by the crash | 100 // process they’re found in, they’re supposed to be read by the crash |
50 // reporting process. | 101 // reporting process. |
51 #if defined(__clang__) | 102 #if defined(__clang__) |
52 #pragma clang diagnostic push | 103 #pragma clang diagnostic push |
53 #pragma clang diagnostic ignored "-Wunused-private-field" | 104 #pragma clang diagnostic ignored "-Wunused-private-field" |
54 #endif | 105 #endif |
55 | 106 |
56 // Fields present in version 1: | 107 // Fields present in version 1: |
57 uint32_t signature_; // kSignature | 108 uint32_t signature_; // kSignature |
58 uint32_t size_; // The size of the entire CrashpadInfo structure. | 109 uint32_t size_; // The size of the entire CrashpadInfo structure. |
59 uint32_t version_; // kVersion | 110 uint32_t version_; // kVersion |
60 uint32_t padding_0_; | 111 TriState crashpad_handler_behavior_; |
| 112 TriState system_crash_reporter_forwarding_; |
| 113 uint16_t padding_0_; |
61 SimpleStringDictionary* simple_annotations_; // weak | 114 SimpleStringDictionary* simple_annotations_; // weak |
62 | 115 |
63 #if defined(__clang__) | 116 #if defined(__clang__) |
64 #pragma clang diagnostic pop | 117 #pragma clang diagnostic pop |
65 #endif | 118 #endif |
66 | 119 |
67 DISALLOW_COPY_AND_ASSIGN(CrashpadInfo); | 120 DISALLOW_COPY_AND_ASSIGN(CrashpadInfo); |
68 }; | 121 }; |
69 | 122 |
70 } // namespace crashpad | 123 } // namespace crashpad |
71 | 124 |
72 #endif // CRASHPAD_CLIENT_CRASHPAD_INFO_H_ | 125 #endif // CRASHPAD_CLIENT_CRASHPAD_INFO_H_ |
OLD | NEW |