blob: 0c8b1516ddc035d6f12e4aee6f0a7e1301e94f6c [file] [log] [blame]
Tong Shen547cdfd2014-08-05 01:54:19 -07001/*
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
22namespace 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 */
29void 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 */
37void 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 */
45void 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 */
52void 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 */
58void 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 */
64void 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 Roubane3ea8382014-08-08 16:29:38 +070069 * @param is_64bit If FDE is for 64bit application.
Tong Shen547cdfd2014-08-05 01:54:19 -070070 */
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070071void WriteFDEHeader(std::vector<uint8_t>* buf, bool is_64bit);
Tong Shen547cdfd2014-08-05 01:54:19 -070072
73/**
74 * @brief Set 'address_range' field of an FDE buffer
75 * @param buf FDE buffer.
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070076 * @param data Data value.
77 * @param is_64bit If FDE is for 64bit application.
Tong Shen547cdfd2014-08-05 01:54:19 -070078 */
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070079void WriteFDEAddressRange(std::vector<uint8_t>* buf, uint64_t data, bool is_64bit);
Tong Shen547cdfd2014-08-05 01:54:19 -070080
81/**
82 * @brief Set 'length' field of an FDE buffer
83 * @param buf FDE buffer.
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070084 * @param is_64bit If FDE is for 64bit application.
Tong Shen547cdfd2014-08-05 01:54:19 -070085 */
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070086void WriteCFILength(std::vector<uint8_t>* buf, bool is_64bit);
Tong Shen547cdfd2014-08-05 01:54:19 -070087
88/**
89 * @brief Pad an FDE buffer with 0 until its size is a multiple of 4
90 * @param buf FDE buffer.
91 */
92void PadCFI(std::vector<uint8_t>* buf);
93} // namespace art
94
95#endif // ART_COMPILER_UTILS_DWARF_CFI_H_