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_UTIL_MACH_SYMBOLIC_CONSTANTS_MACH_H_ |
| 16 #define CRASHPAD_UTIL_MACH_SYMBOLIC_CONSTANTS_MACH_H_ |
| 17 |
| 18 #include <mach/mach.h> |
| 19 |
| 20 #include <string> |
| 21 |
| 22 #include "base/strings/string_piece.h" |
| 23 #include "util/misc/symbolic_constants_common.h" |
| 24 |
| 25 namespace crashpad { |
| 26 |
| 27 //! \brief Converts a Mach exception value to a textual representation. |
| 28 //! |
| 29 //! \param[in] exception The Mach exception value to convert. |
| 30 //! \param[in] options Options affecting the conversion. ::kUseOr is ignored. |
| 31 //! For ::kUnknownIsNumeric, the format is `"%d"`. |
| 32 //! |
| 33 //! \return The converted string. |
| 34 std::string ExceptionToString(exception_type_t exception, |
| 35 SymbolicConstantToStringOptions options); |
| 36 |
| 37 //! \brief Converts a string to its corresponding Mach exception value. |
| 38 //! |
| 39 //! \param[in] string The string to convert. |
| 40 //! \param[in] options Options affecting the conversion. ::kAllowOr is ignored. |
| 41 //! \param[out] exception The converted Mach exception value. |
| 42 //! |
| 43 //! \return `true` on success, `false` if \a string could not be converted as |
| 44 //! requested. |
| 45 bool StringToException(const base::StringPiece& string, |
| 46 StringToSymbolicConstantOptions options, |
| 47 exception_type_t* exception); |
| 48 |
| 49 //! \brief Converts a Mach exception mask value to a textual representation. |
| 50 //! |
| 51 //! \param[in] exception_mask The Mach exception mask value to convert. |
| 52 //! \param[in] options Options affecting the conversion. ::kUseOr is honored. |
| 53 //! For ::kUnknownIsNumeric, the format is `"%#x"`. |
| 54 //! |
| 55 //! \return The converted string. |
| 56 std::string ExceptionMaskToString(exception_mask_t exception_mask, |
| 57 SymbolicConstantToStringOptions options); |
| 58 |
| 59 //! \brief Converts a string to its corresponding Mach exception mask value. |
| 60 //! |
| 61 //! \param[in] string The string to convert. |
| 62 //! \param[in] options Options affecting the conversion. ::kAllowOr is honored. |
| 63 //! \param[out] exception_mask The converted Mach exception mask value. |
| 64 //! |
| 65 //! \return `true` on success, `false` if \a string could not be converted as |
| 66 //! requested. |
| 67 bool StringToExceptionMask(const base::StringPiece& string, |
| 68 StringToSymbolicConstantOptions options, |
| 69 exception_mask_t* exception_mask); |
| 70 |
| 71 //! \brief Converts a Mach exception behavior value to a textual representation. |
| 72 //! |
| 73 //! \param[in] behavior The Mach exception behavior value to convert. |
| 74 //! \param[in] options Options affecting the conversion. ::kUseOr is ignored. |
| 75 //! `MACH_EXCEPTION_CODES` can always be ORed in, but no other values can be |
| 76 //! ORed with each other. For ::kUnknownIsNumeric, the format is `"%#x"`. |
| 77 //! |
| 78 //! \return The converted string. |
| 79 std::string ExceptionBehaviorToString(exception_behavior_t behavior, |
| 80 SymbolicConstantToStringOptions options); |
| 81 |
| 82 //! \brief Converts a string to its corresponding Mach exception behavior value. |
| 83 //! |
| 84 //! \param[in] string The string to convert. |
| 85 //! \param[in] options Options affecting the conversion. ::kAllowOr is ignored. |
| 86 //! `MACH_EXCEPTION_CODES` can always be ORed in, but no other values can be |
| 87 //! ORed with each other. |
| 88 //! \param[out] behavior The converted Mach exception behavior value. |
| 89 //! |
| 90 //! \return `true` on success, `false` if \a string could not be converted as |
| 91 //! requested. |
| 92 bool StringToExceptionBehavior(const base::StringPiece& string, |
| 93 StringToSymbolicConstantOptions options, |
| 94 exception_behavior_t* behavior); |
| 95 |
| 96 //! \brief Converts a thread state flavor value to a textual representation. |
| 97 //! |
| 98 //! \param[in] flavor The thread state flavor value to convert. |
| 99 //! \param[in] options Options affecting the conversion. ::kUseOr is ignored. |
| 100 //! For ::kUnknownIsNumeric, the format is `"%d"`. |
| 101 //! |
| 102 //! \return The converted string. |
| 103 std::string ThreadStateFlavorToString(thread_state_flavor_t flavor, |
| 104 SymbolicConstantToStringOptions options); |
| 105 |
| 106 //! \brief Converts a string to its corresponding thread state flavor value. |
| 107 //! |
| 108 //! \param[in] string The string to convert. |
| 109 //! \param[in] options Options affecting the conversion. ::kAllowOr is ignored. |
| 110 //! \param[out] flavor The converted thread state flavor value. |
| 111 //! |
| 112 //! \return `true` on success, `false` if \a string could not be converted as |
| 113 //! requested. |
| 114 bool StringToThreadStateFlavor(const base::StringPiece& string, |
| 115 StringToSymbolicConstantOptions options, |
| 116 thread_state_flavor_t* flavor); |
| 117 |
| 118 } // namespace crashpad |
| 119 |
| 120 #endif // CRASHPAD_UTIL_MACH_SYMBOLIC_CONSTANTS_MACH_H_ |
OLD | NEW |