Coverage Report

Created: 2026-11-12 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/perfetto/buildtools/android-unwinding/libunwindstack/DwarfCfa.cpp
Line
Count
Source
1
/*
2
 * Copyright (C) 2016 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
#include <inttypes.h>
18
#include <stdint.h>
19
20
#include <string>
21
#include <type_traits>
22
#include <vector>
23
24
#include <android-base/macros.h>
25
#include <android-base/stringprintf.h>
26
27
#include <unwindstack/DwarfError.h>
28
#include <unwindstack/DwarfLocation.h>
29
#include <unwindstack/Elf.h>
30
#include <unwindstack/Log.h>
31
#include <unwindstack/MachineArm64.h>
32
33
#include "DwarfCfa.h"
34
#include "DwarfEncoding.h"
35
#include "DwarfOp.h"
36
37
namespace unwindstack {
38
39
template <typename AddressType>
40
constexpr typename DwarfCfa<AddressType>::process_func DwarfCfa<AddressType>::kCallbackTable[64];
41
42
template <typename AddressType>
43
bool DwarfCfa<AddressType>::GetLocationInfo(uint64_t pc, uint64_t start_offset, uint64_t end_offset,
44
872
                                            DwarfLocations* loc_regs) {
45
872
  if (cie_loc_regs_ != nullptr) {
46
410
    for (const auto& entry : *cie_loc_regs_) {
47
321
      (*loc_regs)[entry.first] = entry.second;
48
321
    }
49
410
  }
50
872
  last_error_.code = DWARF_ERROR_NONE;
51
872
  last_error_.address = 0;
52
53
872
  memory_->set_cur_offset(start_offset);
54
872
  uint64_t cfa_offset;
55
872
  cur_pc_ = fde_->pc_start;
56
872
  loc_regs->pc_start = cur_pc_;
57
28.6k
  while (true) {
58
28.6k
    if (cur_pc_ > pc) {
59
233
      loc_regs->pc_end = cur_pc_;
60
233
      return true;
61
233
    }
62
28.3k
    if ((cfa_offset = memory_->cur_offset()) >= end_offset) {
63
420
      loc_regs->pc_end = fde_->pc_end;
64
420
      return true;
65
420
    }
66
27.9k
    loc_regs->pc_start = cur_pc_;
67
27.9k
    operands_.clear();
68
    // Read the cfa information.
69
27.9k
    uint8_t cfa_value;
70
27.9k
    if (!memory_->ReadBytes(&cfa_value, 1)) {
71
16
      last_error_.code = DWARF_ERROR_MEMORY_INVALID;
72
16
      last_error_.address = memory_->cur_offset();
73
16
      return false;
74
16
    }
75
27.9k
    uint8_t cfa_low = cfa_value & 0x3f;
76
    // Check the 2 high bits.
77
27.9k
    switch (cfa_value >> 6) {
78
3.17k
      case 1:
79
3.17k
        cur_pc_ += cfa_low * fde_->cie->code_alignment_factor;
80
3.17k
        break;
81
1.30k
      case 2: {
82
1.30k
        uint64_t offset;
83
1.30k
        if (!memory_->ReadULEB128(&offset)) {
84
5
          last_error_.code = DWARF_ERROR_MEMORY_INVALID;
85
5
          last_error_.address = memory_->cur_offset();
86
5
          return false;
87
5
        }
88
1.29k
        SignedType signed_offset =
89
1.29k
            static_cast<SignedType>(offset) * fde_->cie->data_alignment_factor;
90
1.29k
        (*loc_regs)[cfa_low] = {.type = DWARF_LOCATION_OFFSET,
91
1.29k
                                .values = {static_cast<uint64_t>(signed_offset)}};
92
1.29k
        break;
93
1.30k
      }
94
5.71k
      case 3: {
95
5.71k
        if (cie_loc_regs_ == nullptr) {
96
79
          Log::Error("Invalid: restore while processing cie.");
97
79
          last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
98
79
          return false;
99
79
        }
100
101
5.63k
        auto reg_entry = cie_loc_regs_->find(cfa_low);
102
5.63k
        if (reg_entry == cie_loc_regs_->end()) {
103
5.37k
          loc_regs->erase(cfa_low);
104
5.37k
        } else {
105
265
          (*loc_regs)[cfa_low] = reg_entry->second;
106
265
        }
107
5.63k
        break;
108
5.71k
      }
109
17.7k
      case 0: {
110
17.7k
        const auto handle_func = DwarfCfa<AddressType>::kCallbackTable[cfa_low];
111
17.7k
        if (handle_func == nullptr) {
112
82
          last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
113
82
          return false;
114
82
        }
115
116
17.6k
        const auto cfa = &DwarfCfaInfo::kTable[cfa_low];
117
24.6k
        for (size_t i = 0; i < cfa->num_operands; i++) {
118
6.96k
          if (cfa->operands[i] == DW_EH_PE_block) {
119
453
            uint64_t block_length;
120
453
            if (!memory_->ReadULEB128(&block_length)) {
121
2
              last_error_.code = DWARF_ERROR_MEMORY_INVALID;
122
2
              last_error_.address = memory_->cur_offset();
123
2
              return false;
124
2
            }
125
451
            operands_.push_back(block_length);
126
451
            memory_->set_cur_offset(memory_->cur_offset() + block_length);
127
451
            continue;
128
453
          }
129
6.50k
          uint64_t value;
130
6.50k
          if (!memory_->ReadEncodedValue<AddressType>(cfa->operands[i], &value)) {
131
13
            last_error_.code = DWARF_ERROR_MEMORY_INVALID;
132
13
            last_error_.address = memory_->cur_offset();
133
13
            return false;
134
13
          }
135
6.49k
          operands_.push_back(value);
136
6.49k
        }
137
138
17.6k
        if (!(this->*handle_func)(loc_regs)) {
139
22
          return false;
140
22
        }
141
17.6k
        break;
142
17.6k
      }
143
27.9k
    }
144
27.9k
  }
145
872
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::GetLocationInfo(unsigned long, unsigned long, unsigned long, unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::GetLocationInfo(unsigned long, unsigned long, unsigned long, unwindstack::DwarfLocations*)
Line
Count
Source
44
872
                                            DwarfLocations* loc_regs) {
45
872
  if (cie_loc_regs_ != nullptr) {
46
410
    for (const auto& entry : *cie_loc_regs_) {
47
321
      (*loc_regs)[entry.first] = entry.second;
48
321
    }
49
410
  }
50
872
  last_error_.code = DWARF_ERROR_NONE;
51
872
  last_error_.address = 0;
52
53
872
  memory_->set_cur_offset(start_offset);
54
872
  uint64_t cfa_offset;
55
872
  cur_pc_ = fde_->pc_start;
56
872
  loc_regs->pc_start = cur_pc_;
57
28.6k
  while (true) {
58
28.6k
    if (cur_pc_ > pc) {
59
233
      loc_regs->pc_end = cur_pc_;
60
233
      return true;
61
233
    }
62
28.3k
    if ((cfa_offset = memory_->cur_offset()) >= end_offset) {
63
420
      loc_regs->pc_end = fde_->pc_end;
64
420
      return true;
65
420
    }
66
27.9k
    loc_regs->pc_start = cur_pc_;
67
27.9k
    operands_.clear();
68
    // Read the cfa information.
69
27.9k
    uint8_t cfa_value;
70
27.9k
    if (!memory_->ReadBytes(&cfa_value, 1)) {
71
16
      last_error_.code = DWARF_ERROR_MEMORY_INVALID;
72
16
      last_error_.address = memory_->cur_offset();
73
16
      return false;
74
16
    }
75
27.9k
    uint8_t cfa_low = cfa_value & 0x3f;
76
    // Check the 2 high bits.
77
27.9k
    switch (cfa_value >> 6) {
78
3.17k
      case 1:
79
3.17k
        cur_pc_ += cfa_low * fde_->cie->code_alignment_factor;
80
3.17k
        break;
81
1.30k
      case 2: {
82
1.30k
        uint64_t offset;
83
1.30k
        if (!memory_->ReadULEB128(&offset)) {
84
5
          last_error_.code = DWARF_ERROR_MEMORY_INVALID;
85
5
          last_error_.address = memory_->cur_offset();
86
5
          return false;
87
5
        }
88
1.29k
        SignedType signed_offset =
89
1.29k
            static_cast<SignedType>(offset) * fde_->cie->data_alignment_factor;
90
1.29k
        (*loc_regs)[cfa_low] = {.type = DWARF_LOCATION_OFFSET,
91
1.29k
                                .values = {static_cast<uint64_t>(signed_offset)}};
92
1.29k
        break;
93
1.30k
      }
94
5.71k
      case 3: {
95
5.71k
        if (cie_loc_regs_ == nullptr) {
96
79
          Log::Error("Invalid: restore while processing cie.");
97
79
          last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
98
79
          return false;
99
79
        }
100
101
5.63k
        auto reg_entry = cie_loc_regs_->find(cfa_low);
102
5.63k
        if (reg_entry == cie_loc_regs_->end()) {
103
5.37k
          loc_regs->erase(cfa_low);
104
5.37k
        } else {
105
265
          (*loc_regs)[cfa_low] = reg_entry->second;
106
265
        }
107
5.63k
        break;
108
5.71k
      }
109
17.7k
      case 0: {
110
17.7k
        const auto handle_func = DwarfCfa<AddressType>::kCallbackTable[cfa_low];
111
17.7k
        if (handle_func == nullptr) {
112
82
          last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
113
82
          return false;
114
82
        }
115
116
17.6k
        const auto cfa = &DwarfCfaInfo::kTable[cfa_low];
117
24.6k
        for (size_t i = 0; i < cfa->num_operands; i++) {
118
6.96k
          if (cfa->operands[i] == DW_EH_PE_block) {
119
453
            uint64_t block_length;
120
453
            if (!memory_->ReadULEB128(&block_length)) {
121
2
              last_error_.code = DWARF_ERROR_MEMORY_INVALID;
122
2
              last_error_.address = memory_->cur_offset();
123
2
              return false;
124
2
            }
125
451
            operands_.push_back(block_length);
126
451
            memory_->set_cur_offset(memory_->cur_offset() + block_length);
127
451
            continue;
128
453
          }
129
6.50k
          uint64_t value;
130
6.50k
          if (!memory_->ReadEncodedValue<AddressType>(cfa->operands[i], &value)) {
131
13
            last_error_.code = DWARF_ERROR_MEMORY_INVALID;
132
13
            last_error_.address = memory_->cur_offset();
133
13
            return false;
134
13
          }
135
6.49k
          operands_.push_back(value);
136
6.49k
        }
137
138
17.6k
        if (!(this->*handle_func)(loc_regs)) {
139
22
          return false;
140
22
        }
141
17.6k
        break;
142
17.6k
      }
143
27.9k
    }
144
27.9k
  }
145
872
}
146
147
template <typename AddressType>
148
std::string DwarfCfa<AddressType>::GetOperandString(uint8_t operand, uint64_t value,
149
0
                                                    uint64_t* cur_pc) {
150
0
  std::string string;
151
0
  switch (operand) {
152
0
    case DwarfCfaInfo::DWARF_DISPLAY_REGISTER:
153
0
      string = " register(" + std::to_string(value) + ")";
154
0
      break;
155
0
    case DwarfCfaInfo::DWARF_DISPLAY_SIGNED_NUMBER:
156
0
      string += " " + std::to_string(static_cast<SignedType>(value));
157
0
      break;
158
0
    case DwarfCfaInfo::DWARF_DISPLAY_ADVANCE_LOC:
159
0
      *cur_pc += value;
160
0
      FALLTHROUGH_INTENDED;
161
      // Fall through to log the value.
162
0
    case DwarfCfaInfo::DWARF_DISPLAY_NUMBER:
163
0
      string += " " + std::to_string(value);
164
0
      break;
165
0
    case DwarfCfaInfo::DWARF_DISPLAY_SET_LOC:
166
0
      *cur_pc = value;
167
0
      FALLTHROUGH_INTENDED;
168
      // Fall through to log the value.
169
0
    case DwarfCfaInfo::DWARF_DISPLAY_ADDRESS:
170
0
      if (std::is_same<AddressType, uint32_t>::value) {
171
0
        string += android::base::StringPrintf(" 0x%" PRIx32, static_cast<uint32_t>(value));
172
0
      } else {
173
0
        string += android::base::StringPrintf(" 0x%" PRIx64, static_cast<uint64_t>(value));
174
0
      }
175
0
      break;
176
0
    default:
177
0
      string = " unknown";
178
0
  }
179
0
  return string;
180
0
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::GetOperandString(unsigned char, unsigned long, unsigned long*)
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned long>::GetOperandString(unsigned char, unsigned long, unsigned long*)
181
182
template <typename AddressType>
183
bool DwarfCfa<AddressType>::LogOffsetRegisterString(uint32_t indent, uint64_t cfa_offset,
184
0
                                                    uint8_t reg) {
185
0
  uint64_t offset;
186
0
  if (!memory_->ReadULEB128(&offset)) {
187
0
    return false;
188
0
  }
189
0
  uint64_t end_offset = memory_->cur_offset();
190
0
  memory_->set_cur_offset(cfa_offset);
191
192
0
  std::string raw_data = "Raw Data:";
193
0
  for (uint64_t i = cfa_offset; i < end_offset; i++) {
194
0
    uint8_t value;
195
0
    if (!memory_->ReadBytes(&value, 1)) {
196
0
      return false;
197
0
    }
198
0
    raw_data += android::base::StringPrintf(" 0x%02x", value);
199
0
  }
200
0
  Log::Info(indent, "DW_CFA_offset register(%d) %" PRId64, reg, offset);
201
0
  Log::Info(indent, "%s", raw_data.c_str());
202
0
  return true;
203
0
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::LogOffsetRegisterString(unsigned int, unsigned long, unsigned char)
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned long>::LogOffsetRegisterString(unsigned int, unsigned long, unsigned char)
204
205
template <typename AddressType>
206
bool DwarfCfa<AddressType>::LogInstruction(uint32_t indent, uint64_t cfa_offset, uint8_t op,
207
0
                                           uint64_t* cur_pc) {
208
0
  const auto* cfa = &DwarfCfaInfo::kTable[op];
209
0
  if (cfa->name[0] == '\0' || (arch_ != ARCH_ARM64 && op == 0x2d)) {
210
0
    if (op == 0x2d) {
211
0
      Log::Info(indent, "Illegal (Only valid on aarch64)");
212
0
    } else {
213
0
      Log::Info(indent, "Illegal");
214
0
    }
215
0
    Log::Info(indent, "Raw Data: 0x%02x", op);
216
0
    return true;
217
0
  }
218
219
0
  std::string log_string(cfa->name);
220
0
  std::vector<std::string> expression_lines;
221
0
  for (size_t i = 0; i < cfa->num_operands; i++) {
222
0
    if (cfa->operands[i] == DW_EH_PE_block) {
223
      // This is a Dwarf Expression.
224
0
      uint64_t end_offset;
225
0
      if (!memory_->ReadULEB128(&end_offset)) {
226
0
        return false;
227
0
      }
228
0
      log_string += " " + std::to_string(end_offset);
229
0
      end_offset += memory_->cur_offset();
230
231
0
      DwarfOp<AddressType> op(memory_, nullptr);
232
0
      op.GetLogInfo(memory_->cur_offset(), end_offset, &expression_lines);
233
0
      memory_->set_cur_offset(end_offset);
234
0
    } else {
235
0
      uint64_t value;
236
0
      if (!memory_->ReadEncodedValue<AddressType>(cfa->operands[i], &value)) {
237
0
        return false;
238
0
      }
239
0
      log_string += GetOperandString(cfa->display_operands[i], value, cur_pc);
240
0
    }
241
0
  }
242
0
  Log::Info(indent, "%s", log_string.c_str());
243
244
  // Get the raw bytes of the data.
245
0
  uint64_t end_offset = memory_->cur_offset();
246
0
  memory_->set_cur_offset(cfa_offset);
247
0
  std::string raw_data("Raw Data:");
248
0
  for (uint64_t i = 0; i < end_offset - cfa_offset; i++) {
249
0
    uint8_t value;
250
0
    if (!memory_->ReadBytes(&value, 1)) {
251
0
      return false;
252
0
    }
253
254
    // Only show 10 raw bytes per line.
255
0
    if ((i % 10) == 0 && i != 0) {
256
0
      Log::Info(indent, "%s", raw_data.c_str());
257
0
      raw_data.clear();
258
0
    }
259
0
    if (raw_data.empty()) {
260
0
      raw_data = "Raw Data:";
261
0
    }
262
0
    raw_data += android::base::StringPrintf(" 0x%02x", value);
263
0
  }
264
0
  if (!raw_data.empty()) {
265
0
    Log::Info(indent, "%s", raw_data.c_str());
266
0
  }
267
268
  // Log any of the expression data.
269
0
  for (const auto& line : expression_lines) {
270
0
    Log::Info(indent + 1, "%s", line.c_str());
271
0
  }
272
0
  return true;
273
0
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::LogInstruction(unsigned int, unsigned long, unsigned char, unsigned long*)
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned long>::LogInstruction(unsigned int, unsigned long, unsigned char, unsigned long*)
274
275
template <typename AddressType>
276
bool DwarfCfa<AddressType>::Log(uint32_t indent, uint64_t pc, uint64_t start_offset,
277
0
                                uint64_t end_offset) {
278
0
  memory_->set_cur_offset(start_offset);
279
0
  uint64_t cfa_offset;
280
0
  uint64_t cur_pc = fde_->pc_start;
281
0
  uint64_t old_pc = cur_pc;
282
0
  while ((cfa_offset = memory_->cur_offset()) < end_offset && cur_pc <= pc) {
283
    // Read the cfa information.
284
0
    uint8_t cfa_value;
285
0
    if (!memory_->ReadBytes(&cfa_value, 1)) {
286
0
      return false;
287
0
    }
288
289
    // Check the 2 high bits.
290
0
    uint8_t cfa_low = cfa_value & 0x3f;
291
0
    switch (cfa_value >> 6) {
292
0
      case 0:
293
0
        if (!LogInstruction(indent, cfa_offset, cfa_low, &cur_pc)) {
294
0
          return false;
295
0
        }
296
0
        break;
297
0
      case 1:
298
0
        Log::Info(indent, "DW_CFA_advance_loc %d", cfa_low);
299
0
        Log::Info(indent, "Raw Data: 0x%02x", cfa_value);
300
0
        cur_pc += cfa_low * fde_->cie->code_alignment_factor;
301
0
        break;
302
0
      case 2:
303
0
        if (!LogOffsetRegisterString(indent, cfa_offset, cfa_low)) {
304
0
          return false;
305
0
        }
306
0
        break;
307
0
      case 3:
308
0
        Log::Info(indent, "DW_CFA_restore register(%d)", cfa_low);
309
0
        Log::Info(indent, "Raw Data: 0x%02x", cfa_value);
310
0
        break;
311
0
    }
312
0
    if (cur_pc != old_pc) {
313
      // This forces a newline or empty log line.
314
0
      Log::Info("");
315
0
      Log::Info(indent, "PC 0x%" PRIx64, cur_pc);
316
0
    }
317
0
    old_pc = cur_pc;
318
0
  }
319
0
  return true;
320
0
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::Log(unsigned int, unsigned long, unsigned long, unsigned long)
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned long>::Log(unsigned int, unsigned long, unsigned long, unsigned long)
321
322
// Static data.
323
template <typename AddressType>
324
7.37k
bool DwarfCfa<AddressType>::cfa_nop(DwarfLocations*) {
325
7.37k
  return true;
326
7.37k
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_nop(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_nop(unwindstack::DwarfLocations*)
Line
Count
Source
324
7.37k
bool DwarfCfa<AddressType>::cfa_nop(DwarfLocations*) {
325
7.37k
  return true;
326
7.37k
}
327
328
template <>
329
0
bool DwarfCfa<uint32_t>::cfa_set_loc(DwarfLocations*) {
330
0
  uint32_t cur_pc = cur_pc_;
331
0
  uint32_t new_pc = operands_[0];
332
0
  if (new_pc < cur_pc) {
333
0
    Log::Info("Warning: PC is moving backwards: old 0x%" PRIx32 " new 0x%" PRIx32, cur_pc, new_pc);
334
0
  }
335
0
  cur_pc_ = new_pc;
336
0
  return true;
337
0
}
338
339
template <>
340
967
bool DwarfCfa<uint64_t>::cfa_set_loc(DwarfLocations*) {
341
967
  uint64_t cur_pc = cur_pc_;
342
967
  uint64_t new_pc = operands_[0];
343
967
  if (new_pc < cur_pc) {
344
418
    Log::Info("Warning: PC is moving backwards: old 0x%" PRIx64 " new 0x%" PRIx64, cur_pc, new_pc);
345
418
  }
346
967
  cur_pc_ = new_pc;
347
967
  return true;
348
967
}
349
350
template <typename AddressType>
351
622
bool DwarfCfa<AddressType>::cfa_advance_loc(DwarfLocations*) {
352
622
  cur_pc_ += operands_[0] * fde_->cie->code_alignment_factor;
353
622
  return true;
354
622
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_advance_loc(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_advance_loc(unwindstack::DwarfLocations*)
Line
Count
Source
351
622
bool DwarfCfa<AddressType>::cfa_advance_loc(DwarfLocations*) {
352
622
  cur_pc_ += operands_[0] * fde_->cie->code_alignment_factor;
353
622
  return true;
354
622
}
355
356
template <typename AddressType>
357
114
bool DwarfCfa<AddressType>::cfa_offset(DwarfLocations* loc_regs) {
358
114
  AddressType reg = operands_[0];
359
114
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {operands_[1]}};
360
114
  return true;
361
114
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_offset(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_offset(unwindstack::DwarfLocations*)
Line
Count
Source
357
114
bool DwarfCfa<AddressType>::cfa_offset(DwarfLocations* loc_regs) {
358
114
  AddressType reg = operands_[0];
359
114
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {operands_[1]}};
360
114
  return true;
361
114
}
362
363
template <typename AddressType>
364
790
bool DwarfCfa<AddressType>::cfa_restore(DwarfLocations* loc_regs) {
365
790
  AddressType reg = operands_[0];
366
790
  if (cie_loc_regs_ == nullptr) {
367
1
    Log::Error("Invalid: restore while processing cie.");
368
1
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
369
1
    return false;
370
1
  }
371
789
  auto reg_entry = cie_loc_regs_->find(reg);
372
789
  if (reg_entry == cie_loc_regs_->end()) {
373
743
    loc_regs->erase(reg);
374
743
  } else {
375
46
    (*loc_regs)[reg] = reg_entry->second;
376
46
  }
377
789
  return true;
378
790
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_restore(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_restore(unwindstack::DwarfLocations*)
Line
Count
Source
364
790
bool DwarfCfa<AddressType>::cfa_restore(DwarfLocations* loc_regs) {
365
790
  AddressType reg = operands_[0];
366
790
  if (cie_loc_regs_ == nullptr) {
367
1
    Log::Error("Invalid: restore while processing cie.");
368
1
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
369
1
    return false;
370
1
  }
371
789
  auto reg_entry = cie_loc_regs_->find(reg);
372
789
  if (reg_entry == cie_loc_regs_->end()) {
373
743
    loc_regs->erase(reg);
374
743
  } else {
375
46
    (*loc_regs)[reg] = reg_entry->second;
376
46
  }
377
789
  return true;
378
790
}
379
380
template <typename AddressType>
381
521
bool DwarfCfa<AddressType>::cfa_undefined(DwarfLocations* loc_regs) {
382
521
  AddressType reg = operands_[0];
383
521
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_UNDEFINED};
384
521
  return true;
385
521
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_undefined(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_undefined(unwindstack::DwarfLocations*)
Line
Count
Source
381
521
bool DwarfCfa<AddressType>::cfa_undefined(DwarfLocations* loc_regs) {
382
521
  AddressType reg = operands_[0];
383
521
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_UNDEFINED};
384
521
  return true;
385
521
}
386
387
template <typename AddressType>
388
298
bool DwarfCfa<AddressType>::cfa_same_value(DwarfLocations* loc_regs) {
389
298
  AddressType reg = operands_[0];
390
298
  loc_regs->erase(reg);
391
298
  return true;
392
298
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_same_value(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_same_value(unwindstack::DwarfLocations*)
Line
Count
Source
388
298
bool DwarfCfa<AddressType>::cfa_same_value(DwarfLocations* loc_regs) {
389
298
  AddressType reg = operands_[0];
390
298
  loc_regs->erase(reg);
391
298
  return true;
392
298
}
393
394
template <typename AddressType>
395
98
bool DwarfCfa<AddressType>::cfa_register(DwarfLocations* loc_regs) {
396
98
  AddressType reg = operands_[0];
397
98
  AddressType reg_dst = operands_[1];
398
98
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_REGISTER, .values = {reg_dst}};
399
98
  return true;
400
98
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_register(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_register(unwindstack::DwarfLocations*)
Line
Count
Source
395
98
bool DwarfCfa<AddressType>::cfa_register(DwarfLocations* loc_regs) {
396
98
  AddressType reg = operands_[0];
397
98
  AddressType reg_dst = operands_[1];
398
98
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_REGISTER, .values = {reg_dst}};
399
98
  return true;
400
98
}
401
402
template <typename AddressType>
403
1.70k
bool DwarfCfa<AddressType>::cfa_remember_state(DwarfLocations* loc_regs) {
404
1.70k
  loc_reg_state_.push(*loc_regs);
405
1.70k
  return true;
406
1.70k
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_remember_state(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_remember_state(unwindstack::DwarfLocations*)
Line
Count
Source
403
1.70k
bool DwarfCfa<AddressType>::cfa_remember_state(DwarfLocations* loc_regs) {
404
1.70k
  loc_reg_state_.push(*loc_regs);
405
1.70k
  return true;
406
1.70k
}
407
408
template <typename AddressType>
409
264
bool DwarfCfa<AddressType>::cfa_restore_state(DwarfLocations* loc_regs) {
410
264
  if (loc_reg_state_.size() == 0) {
411
201
    Log::Info("Warning: Attempt to restore without remember.");
412
201
    return true;
413
201
  }
414
63
  *loc_regs = loc_reg_state_.top();
415
63
  loc_reg_state_.pop();
416
63
  return true;
417
264
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_restore_state(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_restore_state(unwindstack::DwarfLocations*)
Line
Count
Source
409
264
bool DwarfCfa<AddressType>::cfa_restore_state(DwarfLocations* loc_regs) {
410
264
  if (loc_reg_state_.size() == 0) {
411
201
    Log::Info("Warning: Attempt to restore without remember.");
412
201
    return true;
413
201
  }
414
63
  *loc_regs = loc_reg_state_.top();
415
63
  loc_reg_state_.pop();
416
63
  return true;
417
264
}
418
419
template <typename AddressType>
420
425
bool DwarfCfa<AddressType>::cfa_def_cfa(DwarfLocations* loc_regs) {
421
425
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER, .values = {operands_[0], operands_[1]}};
422
425
  return true;
423
425
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa(unwindstack::DwarfLocations*)
Line
Count
Source
420
425
bool DwarfCfa<AddressType>::cfa_def_cfa(DwarfLocations* loc_regs) {
421
425
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER, .values = {operands_[0], operands_[1]}};
422
425
  return true;
423
425
}
424
425
template <typename AddressType>
426
81
bool DwarfCfa<AddressType>::cfa_def_cfa_register(DwarfLocations* loc_regs) {
427
81
  auto cfa_location = loc_regs->find(CFA_REG);
428
81
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
429
10
    Log::Error("Attempt to set new register, but cfa is not already set to a register.");
430
10
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
431
10
    return false;
432
10
  }
433
434
71
  cfa_location->second.values[0] = operands_[0];
435
71
  return true;
436
81
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa_register(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa_register(unwindstack::DwarfLocations*)
Line
Count
Source
426
81
bool DwarfCfa<AddressType>::cfa_def_cfa_register(DwarfLocations* loc_regs) {
427
81
  auto cfa_location = loc_regs->find(CFA_REG);
428
81
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
429
10
    Log::Error("Attempt to set new register, but cfa is not already set to a register.");
430
10
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
431
10
    return false;
432
10
  }
433
434
71
  cfa_location->second.values[0] = operands_[0];
435
71
  return true;
436
81
}
437
438
template <typename AddressType>
439
241
bool DwarfCfa<AddressType>::cfa_def_cfa_offset(DwarfLocations* loc_regs) {
440
  // Changing the offset if this is not a register is illegal.
441
241
  auto cfa_location = loc_regs->find(CFA_REG);
442
241
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
443
6
    Log::Error("Attempt to set offset, but cfa is not set to a register.");
444
6
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
445
6
    return false;
446
6
  }
447
235
  cfa_location->second.values[1] = operands_[0];
448
235
  return true;
449
241
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa_offset(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa_offset(unwindstack::DwarfLocations*)
Line
Count
Source
439
241
bool DwarfCfa<AddressType>::cfa_def_cfa_offset(DwarfLocations* loc_regs) {
440
  // Changing the offset if this is not a register is illegal.
441
241
  auto cfa_location = loc_regs->find(CFA_REG);
442
241
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
443
6
    Log::Error("Attempt to set offset, but cfa is not set to a register.");
444
6
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
445
6
    return false;
446
6
  }
447
235
  cfa_location->second.values[1] = operands_[0];
448
235
  return true;
449
241
}
450
451
template <typename AddressType>
452
174
bool DwarfCfa<AddressType>::cfa_def_cfa_expression(DwarfLocations* loc_regs) {
453
  // There is only one type of expression for CFA evaluation and the DWARF
454
  // specification is unclear whether it returns the address or the
455
  // dereferenced value. GDB expects the value, so will we.
456
174
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_VAL_EXPRESSION,
457
174
                          .values = {operands_[0], memory_->cur_offset()}};
458
174
  return true;
459
174
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa_expression(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa_expression(unwindstack::DwarfLocations*)
Line
Count
Source
452
174
bool DwarfCfa<AddressType>::cfa_def_cfa_expression(DwarfLocations* loc_regs) {
453
  // There is only one type of expression for CFA evaluation and the DWARF
454
  // specification is unclear whether it returns the address or the
455
  // dereferenced value. GDB expects the value, so will we.
456
174
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_VAL_EXPRESSION,
457
174
                          .values = {operands_[0], memory_->cur_offset()}};
458
174
  return true;
459
174
}
460
461
template <typename AddressType>
462
187
bool DwarfCfa<AddressType>::cfa_expression(DwarfLocations* loc_regs) {
463
187
  AddressType reg = operands_[0];
464
187
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_EXPRESSION,
465
187
                      .values = {operands_[1], memory_->cur_offset()}};
466
187
  return true;
467
187
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_expression(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_expression(unwindstack::DwarfLocations*)
Line
Count
Source
462
187
bool DwarfCfa<AddressType>::cfa_expression(DwarfLocations* loc_regs) {
463
187
  AddressType reg = operands_[0];
464
187
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_EXPRESSION,
465
187
                      .values = {operands_[1], memory_->cur_offset()}};
466
187
  return true;
467
187
}
468
469
template <typename AddressType>
470
19
bool DwarfCfa<AddressType>::cfa_offset_extended_sf(DwarfLocations* loc_regs) {
471
19
  AddressType reg = operands_[0];
472
19
  SignedType value = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
473
19
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(value)}};
474
19
  return true;
475
19
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_offset_extended_sf(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_offset_extended_sf(unwindstack::DwarfLocations*)
Line
Count
Source
470
19
bool DwarfCfa<AddressType>::cfa_offset_extended_sf(DwarfLocations* loc_regs) {
471
19
  AddressType reg = operands_[0];
472
19
  SignedType value = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
473
19
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(value)}};
474
19
  return true;
475
19
}
476
477
template <typename AddressType>
478
115
bool DwarfCfa<AddressType>::cfa_def_cfa_sf(DwarfLocations* loc_regs) {
479
115
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
480
115
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER,
481
115
                          .values = {operands_[0], static_cast<uint64_t>(offset)}};
482
115
  return true;
483
115
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa_sf(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa_sf(unwindstack::DwarfLocations*)
Line
Count
Source
478
115
bool DwarfCfa<AddressType>::cfa_def_cfa_sf(DwarfLocations* loc_regs) {
479
115
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
480
115
  (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER,
481
115
                          .values = {operands_[0], static_cast<uint64_t>(offset)}};
482
115
  return true;
483
115
}
484
485
template <typename AddressType>
486
215
bool DwarfCfa<AddressType>::cfa_def_cfa_offset_sf(DwarfLocations* loc_regs) {
487
  // Changing the offset if this is not a register is illegal.
488
215
  auto cfa_location = loc_regs->find(CFA_REG);
489
215
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
490
5
    Log::Error("Attempt to set offset, but cfa is not set to a register.");
491
5
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
492
5
    return false;
493
5
  }
494
210
  SignedType offset = static_cast<SignedType>(operands_[0]) * fde_->cie->data_alignment_factor;
495
210
  cfa_location->second.values[1] = static_cast<uint64_t>(offset);
496
210
  return true;
497
215
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_def_cfa_offset_sf(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_def_cfa_offset_sf(unwindstack::DwarfLocations*)
Line
Count
Source
486
215
bool DwarfCfa<AddressType>::cfa_def_cfa_offset_sf(DwarfLocations* loc_regs) {
487
  // Changing the offset if this is not a register is illegal.
488
215
  auto cfa_location = loc_regs->find(CFA_REG);
489
215
  if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) {
490
5
    Log::Error("Attempt to set offset, but cfa is not set to a register.");
491
5
    last_error_.code = DWARF_ERROR_ILLEGAL_STATE;
492
5
    return false;
493
5
  }
494
210
  SignedType offset = static_cast<SignedType>(operands_[0]) * fde_->cie->data_alignment_factor;
495
210
  cfa_location->second.values[1] = static_cast<uint64_t>(offset);
496
210
  return true;
497
215
}
498
499
template <typename AddressType>
500
63
bool DwarfCfa<AddressType>::cfa_val_offset(DwarfLocations* loc_regs) {
501
63
  AddressType reg = operands_[0];
502
63
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
503
63
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}};
504
63
  return true;
505
63
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_val_offset(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_val_offset(unwindstack::DwarfLocations*)
Line
Count
Source
500
63
bool DwarfCfa<AddressType>::cfa_val_offset(DwarfLocations* loc_regs) {
501
63
  AddressType reg = operands_[0];
502
63
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
503
63
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}};
504
63
  return true;
505
63
}
506
507
template <typename AddressType>
508
92
bool DwarfCfa<AddressType>::cfa_val_offset_sf(DwarfLocations* loc_regs) {
509
92
  AddressType reg = operands_[0];
510
92
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
511
92
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}};
512
92
  return true;
513
92
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_val_offset_sf(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_val_offset_sf(unwindstack::DwarfLocations*)
Line
Count
Source
508
92
bool DwarfCfa<AddressType>::cfa_val_offset_sf(DwarfLocations* loc_regs) {
509
92
  AddressType reg = operands_[0];
510
92
  SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor;
511
92
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}};
512
92
  return true;
513
92
}
514
515
template <typename AddressType>
516
90
bool DwarfCfa<AddressType>::cfa_val_expression(DwarfLocations* loc_regs) {
517
90
  AddressType reg = operands_[0];
518
90
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_EXPRESSION,
519
90
                      .values = {operands_[1], memory_->cur_offset()}};
520
90
  return true;
521
90
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_val_expression(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_val_expression(unwindstack::DwarfLocations*)
Line
Count
Source
516
90
bool DwarfCfa<AddressType>::cfa_val_expression(DwarfLocations* loc_regs) {
517
90
  AddressType reg = operands_[0];
518
90
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_EXPRESSION,
519
90
                      .values = {operands_[1], memory_->cur_offset()}};
520
90
  return true;
521
90
}
522
523
template <typename AddressType>
524
259
bool DwarfCfa<AddressType>::cfa_gnu_negative_offset_extended(DwarfLocations* loc_regs) {
525
259
  AddressType reg = operands_[0];
526
259
  SignedType offset = -static_cast<SignedType>(operands_[1]);
527
259
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(offset)}};
528
259
  return true;
529
259
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_gnu_negative_offset_extended(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_gnu_negative_offset_extended(unwindstack::DwarfLocations*)
Line
Count
Source
524
259
bool DwarfCfa<AddressType>::cfa_gnu_negative_offset_extended(DwarfLocations* loc_regs) {
525
259
  AddressType reg = operands_[0];
526
259
  SignedType offset = -static_cast<SignedType>(operands_[1]);
527
259
  (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(offset)}};
528
259
  return true;
529
259
}
530
531
template <typename AddressType>
532
2.93k
bool DwarfCfa<AddressType>::cfa_aarch64_negate_ra_state(DwarfLocations* loc_regs) {
533
  // Only supported on aarch64.
534
2.93k
  if (arch_ != ARCH_ARM64) {
535
0
    last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
536
0
    return false;
537
0
  }
538
539
2.93k
  auto cfa_location = loc_regs->find(Arm64Reg::ARM64_PREG_RA_SIGN_STATE);
540
2.93k
  if (cfa_location == loc_regs->end()) {
541
136
    (*loc_regs)[Arm64Reg::ARM64_PREG_RA_SIGN_STATE] = {.type = DWARF_LOCATION_PSEUDO_REGISTER,
542
136
                                                       .values = {1}};
543
2.79k
  } else {
544
2.79k
    cfa_location->second.values[0] ^= 1;
545
2.79k
  }
546
2.93k
  return true;
547
2.93k
}
Unexecuted instantiation: unwindstack::DwarfCfa<unsigned int>::cfa_aarch64_negate_ra_state(unwindstack::DwarfLocations*)
unwindstack::DwarfCfa<unsigned long>::cfa_aarch64_negate_ra_state(unwindstack::DwarfLocations*)
Line
Count
Source
532
2.93k
bool DwarfCfa<AddressType>::cfa_aarch64_negate_ra_state(DwarfLocations* loc_regs) {
533
  // Only supported on aarch64.
534
2.93k
  if (arch_ != ARCH_ARM64) {
535
0
    last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
536
0
    return false;
537
0
  }
538
539
2.93k
  auto cfa_location = loc_regs->find(Arm64Reg::ARM64_PREG_RA_SIGN_STATE);
540
2.93k
  if (cfa_location == loc_regs->end()) {
541
136
    (*loc_regs)[Arm64Reg::ARM64_PREG_RA_SIGN_STATE] = {.type = DWARF_LOCATION_PSEUDO_REGISTER,
542
136
                                                       .values = {1}};
543
2.79k
  } else {
544
2.79k
    cfa_location->second.values[0] ^= 1;
545
2.79k
  }
546
2.93k
  return true;
547
2.93k
}
548
549
const DwarfCfaInfo::Info DwarfCfaInfo::kTable[64] = {
550
    {
551
        // 0x00 DW_CFA_nop
552
        "DW_CFA_nop",
553
        2,
554
        0,
555
        {},
556
        {},
557
    },
558
    {
559
        "DW_CFA_set_loc",  // 0x01 DW_CFA_set_loc
560
        2,
561
        1,
562
        {DW_EH_PE_absptr},
563
        {DWARF_DISPLAY_SET_LOC},
564
    },
565
    {
566
        "DW_CFA_advance_loc1",  // 0x02 DW_CFA_advance_loc1
567
        2,
568
        1,
569
        {DW_EH_PE_udata1},
570
        {DWARF_DISPLAY_ADVANCE_LOC},
571
    },
572
    {
573
        "DW_CFA_advance_loc2",  // 0x03 DW_CFA_advance_loc2
574
        2,
575
        1,
576
        {DW_EH_PE_udata2},
577
        {DWARF_DISPLAY_ADVANCE_LOC},
578
    },
579
    {
580
        "DW_CFA_advance_loc4",  // 0x04 DW_CFA_advance_loc4
581
        2,
582
        1,
583
        {DW_EH_PE_udata4},
584
        {DWARF_DISPLAY_ADVANCE_LOC},
585
    },
586
    {
587
        "DW_CFA_offset_extended",  // 0x05 DW_CFA_offset_extended
588
        2,
589
        2,
590
        {DW_EH_PE_uleb128, DW_EH_PE_uleb128},
591
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_NUMBER},
592
    },
593
    {
594
        "DW_CFA_restore_extended",  // 0x06 DW_CFA_restore_extended
595
        2,
596
        1,
597
        {DW_EH_PE_uleb128},
598
        {DWARF_DISPLAY_REGISTER},
599
    },
600
    {
601
        "DW_CFA_undefined",  // 0x07 DW_CFA_undefined
602
        2,
603
        1,
604
        {DW_EH_PE_uleb128},
605
        {DWARF_DISPLAY_REGISTER},
606
    },
607
    {
608
        "DW_CFA_same_value",  // 0x08 DW_CFA_same_value
609
        2,
610
        1,
611
        {DW_EH_PE_uleb128},
612
        {DWARF_DISPLAY_REGISTER},
613
    },
614
    {
615
        "DW_CFA_register",  // 0x09 DW_CFA_register
616
        2,
617
        2,
618
        {DW_EH_PE_uleb128, DW_EH_PE_uleb128},
619
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_REGISTER},
620
    },
621
    {
622
        "DW_CFA_remember_state",  // 0x0a DW_CFA_remember_state
623
        2,
624
        0,
625
        {},
626
        {},
627
    },
628
    {
629
        "DW_CFA_restore_state",  // 0x0b DW_CFA_restore_state
630
        2,
631
        0,
632
        {},
633
        {},
634
    },
635
    {
636
        "DW_CFA_def_cfa",  // 0x0c DW_CFA_def_cfa
637
        2,
638
        2,
639
        {DW_EH_PE_uleb128, DW_EH_PE_uleb128},
640
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_NUMBER},
641
    },
642
    {
643
        "DW_CFA_def_cfa_register",  // 0x0d DW_CFA_def_cfa_register
644
        2,
645
        1,
646
        {DW_EH_PE_uleb128},
647
        {DWARF_DISPLAY_REGISTER},
648
    },
649
    {
650
        "DW_CFA_def_cfa_offset",  // 0x0e DW_CFA_def_cfa_offset
651
        2,
652
        1,
653
        {DW_EH_PE_uleb128},
654
        {DWARF_DISPLAY_NUMBER},
655
    },
656
    {
657
        "DW_CFA_def_cfa_expression",  // 0x0f DW_CFA_def_cfa_expression
658
        2,
659
        1,
660
        {DW_EH_PE_block},
661
        {DWARF_DISPLAY_EVAL_BLOCK},
662
    },
663
    {
664
        "DW_CFA_expression",  // 0x10 DW_CFA_expression
665
        2,
666
        2,
667
        {DW_EH_PE_uleb128, DW_EH_PE_block},
668
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_EVAL_BLOCK},
669
    },
670
    {
671
        "DW_CFA_offset_extended_sf",  // 0x11 DW_CFA_offset_extend_sf
672
        2,
673
        2,
674
        {DW_EH_PE_uleb128, DW_EH_PE_sleb128},
675
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_SIGNED_NUMBER},
676
    },
677
    {
678
        "DW_CFA_def_cfa_sf",  // 0x12 DW_CFA_def_cfa_sf
679
        2,
680
        2,
681
        {DW_EH_PE_uleb128, DW_EH_PE_sleb128},
682
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_SIGNED_NUMBER},
683
    },
684
    {
685
        "DW_CFA_def_cfa_offset_sf",  // 0x13 DW_CFA_def_cfa_offset_sf
686
        2,
687
        1,
688
        {DW_EH_PE_sleb128},
689
        {DWARF_DISPLAY_SIGNED_NUMBER},
690
    },
691
    {
692
        "DW_CFA_val_offset",  // 0x14 DW_CFA_val_offset
693
        2,
694
        2,
695
        {DW_EH_PE_uleb128, DW_EH_PE_uleb128},
696
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_NUMBER},
697
    },
698
    {
699
        "DW_CFA_val_offset_sf",  // 0x15 DW_CFA_val_offset_sf
700
        2,
701
        2,
702
        {DW_EH_PE_uleb128, DW_EH_PE_sleb128},
703
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_SIGNED_NUMBER},
704
    },
705
    {
706
        "DW_CFA_val_expression",  // 0x16 DW_CFA_val_expression
707
        2,
708
        2,
709
        {DW_EH_PE_uleb128, DW_EH_PE_block},
710
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_EVAL_BLOCK},
711
    },
712
    {"", 0, 0, {}, {}},  // 0x17 illegal cfa
713
    {"", 0, 0, {}, {}},  // 0x18 illegal cfa
714
    {"", 0, 0, {}, {}},  // 0x19 illegal cfa
715
    {"", 0, 0, {}, {}},  // 0x1a illegal cfa
716
    {"", 0, 0, {}, {}},  // 0x1b illegal cfa
717
    {"", 0, 0, {}, {}},  // 0x1c DW_CFA_lo_user (Treat as illegal)
718
    {"", 0, 0, {}, {}},  // 0x1d illegal cfa
719
    {"", 0, 0, {}, {}},  // 0x1e illegal cfa
720
    {"", 0, 0, {}, {}},  // 0x1f illegal cfa
721
    {"", 0, 0, {}, {}},  // 0x20 illegal cfa
722
    {"", 0, 0, {}, {}},  // 0x21 illegal cfa
723
    {"", 0, 0, {}, {}},  // 0x22 illegal cfa
724
    {"", 0, 0, {}, {}},  // 0x23 illegal cfa
725
    {"", 0, 0, {}, {}},  // 0x24 illegal cfa
726
    {"", 0, 0, {}, {}},  // 0x25 illegal cfa
727
    {"", 0, 0, {}, {}},  // 0x26 illegal cfa
728
    {"", 0, 0, {}, {}},  // 0x27 illegal cfa
729
    {"", 0, 0, {}, {}},  // 0x28 illegal cfa
730
    {"", 0, 0, {}, {}},  // 0x29 illegal cfa
731
    {"", 0, 0, {}, {}},  // 0x2a illegal cfa
732
    {"", 0, 0, {}, {}},  // 0x2b illegal cfa
733
    {"", 0, 0, {}, {}},  // 0x2c illegal cfa
734
    {
735
        "DW_CFA_AARCH64_negate_ra_state",  // 0x2d DW_CFA_AARCH64_negate_ra_state
736
        3,
737
        0,
738
        {},
739
        {},
740
    },
741
    {
742
        "DW_CFA_GNU_args_size",  // 0x2e DW_CFA_GNU_args_size
743
        2,
744
        1,
745
        {DW_EH_PE_uleb128},
746
        {DWARF_DISPLAY_NUMBER},
747
    },
748
    {
749
        "DW_CFA_GNU_negative_offset_extended",  // 0x2f DW_CFA_GNU_negative_offset_extended
750
        2,
751
        2,
752
        {DW_EH_PE_uleb128, DW_EH_PE_uleb128},
753
        {DWARF_DISPLAY_REGISTER, DWARF_DISPLAY_NUMBER},
754
    },
755
    {"", 0, 0, {}, {}},  // 0x31 illegal cfa
756
    {"", 0, 0, {}, {}},  // 0x32 illegal cfa
757
    {"", 0, 0, {}, {}},  // 0x33 illegal cfa
758
    {"", 0, 0, {}, {}},  // 0x34 illegal cfa
759
    {"", 0, 0, {}, {}},  // 0x35 illegal cfa
760
    {"", 0, 0, {}, {}},  // 0x36 illegal cfa
761
    {"", 0, 0, {}, {}},  // 0x37 illegal cfa
762
    {"", 0, 0, {}, {}},  // 0x38 illegal cfa
763
    {"", 0, 0, {}, {}},  // 0x39 illegal cfa
764
    {"", 0, 0, {}, {}},  // 0x3a illegal cfa
765
    {"", 0, 0, {}, {}},  // 0x3b illegal cfa
766
    {"", 0, 0, {}, {}},  // 0x3c illegal cfa
767
    {"", 0, 0, {}, {}},  // 0x3d illegal cfa
768
    {"", 0, 0, {}, {}},  // 0x3e illegal cfa
769
    {"", 0, 0, {}, {}},  // 0x3f DW_CFA_hi_user (Treat as illegal)
770
};
771
772
// Explicitly instantiate DwarfCfa.
773
template class DwarfCfa<uint32_t>;
774
template class DwarfCfa<uint64_t>;
775
776
}  // namespace unwindstack