Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_UTILS_DWARF_CFI_H_ |
| 18 | #define ART_COMPILER_UTILS_DWARF_CFI_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | /** |
| 25 | * @brief Enter a 'DW_CFA_advance_loc' into an FDE buffer |
| 26 | * @param buf FDE buffer. |
| 27 | * @param increment Amount by which to increase the current location. |
| 28 | */ |
| 29 | void DW_CFA_advance_loc(std::vector<uint8_t>* buf, uint32_t increment); |
| 30 | |
| 31 | /** |
| 32 | * @brief Enter a 'DW_CFA_offset_extended_sf' into an FDE buffer |
| 33 | * @param buf FDE buffer. |
| 34 | * @param reg Register number. |
| 35 | * @param offset Offset of register address from CFA. |
| 36 | */ |
| 37 | void DW_CFA_offset_extended_sf(std::vector<uint8_t>* buf, int reg, int32_t offset); |
| 38 | |
| 39 | /** |
| 40 | * @brief Enter a 'DW_CFA_offset' into an FDE buffer |
| 41 | * @param buf FDE buffer. |
| 42 | * @param reg Register number. |
| 43 | * @param offset Offset of register address from CFA. |
| 44 | */ |
| 45 | void DW_CFA_offset(std::vector<uint8_t>* buf, int reg, uint32_t offset); |
| 46 | |
| 47 | /** |
| 48 | * @brief Enter a 'DW_CFA_def_cfa_offset' into an FDE buffer |
| 49 | * @param buf FDE buffer. |
| 50 | * @param offset New offset of CFA. |
| 51 | */ |
| 52 | void DW_CFA_def_cfa_offset(std::vector<uint8_t>* buf, int32_t offset); |
| 53 | |
| 54 | /** |
| 55 | * @brief Enter a 'DW_CFA_remember_state' into an FDE buffer |
| 56 | * @param buf FDE buffer. |
| 57 | */ |
| 58 | void DW_CFA_remember_state(std::vector<uint8_t>* buf); |
| 59 | |
| 60 | /** |
| 61 | * @brief Enter a 'DW_CFA_restore_state' into an FDE buffer |
| 62 | * @param buf FDE buffer. |
| 63 | */ |
| 64 | void DW_CFA_restore_state(std::vector<uint8_t>* buf); |
| 65 | |
| 66 | /** |
| 67 | * @brief Write FDE header into an FDE buffer |
| 68 | * @param buf FDE buffer. |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 69 | * @param is_64bit If FDE is for 64bit application. |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 70 | */ |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 71 | void WriteFDEHeader(std::vector<uint8_t>* buf, bool is_64bit); |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * @brief Set 'address_range' field of an FDE buffer |
| 75 | * @param buf FDE buffer. |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 76 | * @param data Data value. |
| 77 | * @param is_64bit If FDE is for 64bit application. |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 78 | */ |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 79 | void WriteFDEAddressRange(std::vector<uint8_t>* buf, uint64_t data, bool is_64bit); |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * @brief Set 'length' field of an FDE buffer |
| 83 | * @param buf FDE buffer. |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 84 | * @param is_64bit If FDE is for 64bit application. |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 85 | */ |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 86 | void WriteCFILength(std::vector<uint8_t>* buf, bool is_64bit); |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * @brief Pad an FDE buffer with 0 until its size is a multiple of 4 |
| 90 | * @param buf FDE buffer. |
| 91 | */ |
| 92 | void PadCFI(std::vector<uint8_t>* buf); |
| 93 | } // namespace art |
| 94 | |
| 95 | #endif // ART_COMPILER_UTILS_DWARF_CFI_H_ |