7 #include "llvm/Support/Win64EH.h"
16 return static_cast<const T *
>(data_extractor.
GetData(&offset, size));
23 SET_FRAME_POINTER_REGISTER,
53 const UnwindInfo *m_unwind_info =
nullptr;
57 const UnwindCode *m_unwind_code =
nullptr;
59 bool m_chained =
false;
64 : m_object_file(object_file),
65 m_unwind_info_rva(unwind_info_rva), m_unwind_code_offset{} {}
68 static constexpr
int UNWIND_INFO_SIZE = 4;
105 runtime_function_rva,
sizeof(RuntimeFunction));
108 const auto *runtime_function =
109 TypedRead<RuntimeFunction>(runtime_function_data, offset);
110 if (!runtime_function) {
148 : m_iterator(object_file, unwind_info_rva) {}
164 static uint32_t machine_to_lldb_register[] = {
170 if (machine_reg >= llvm::array_lengthof(machine_to_lldb_register))
173 return machine_to_lldb_register[machine_reg];
177 static uint32_t xmm_to_lldb_register[] = {
185 if (xmm_reg >= llvm::array_lengthof(xmm_to_lldb_register))
188 return xmm_to_lldb_register[xmm_reg];
193 uint8_t unwind_operation = code.getUnwindOp();
194 uint8_t operation_info = code.getOpInfo();
196 switch (unwind_operation) {
197 case UOP_PushNonVol: {
207 case UOP_AllocLarge: {
217 case UOP_AllocSmall: {
220 static_cast<uint32_t>(operation_info) * 8 + 8});
241 case UOP_SaveNonVolBig: {
259 case UOP_SpareCode: {
264 case UOP_SaveXMM128Big: {
279 case UOP_PushMachFrame: {
352 EHProgram::const_iterator end);
364 EHProgram::const_iterator end)
365 : m_begin(begin), m_end(end) {}
368 std::unique_ptr<UnwindPlan::Row> row = std::make_unique<UnwindPlan::Row>();
371 row->SetOffset(
m_begin->offset);
375 bool frame_pointer_found =
false;
376 for (EHProgram::const_iterator it =
m_begin; it !=
m_end; ++it) {
379 row->GetCFAValue().SetIsRegisterPlusOffset(it->reg, cfa_frame_offset -
381 frame_pointer_found =
true;
386 if (frame_pointer_found)
389 if (!frame_pointer_found)
393 int32_t rsp_frame_offset = 0;
394 for (EHProgram::const_iterator it =
m_begin; it !=
m_end; ++it) {
397 row->SetRegisterLocationToAtCFAPlusOffset(
398 it->reg, rsp_frame_offset - cfa_frame_offset,
false);
399 rsp_frame_offset += it->frame_offset;
402 rsp_frame_offset += it->frame_offset;
405 row->SetRegisterLocationToAtCFAPlusOffset(
406 it->reg, it->frame_offset - cfa_frame_offset,
false);
421 for (EHProgram::const_iterator it =
m_begin; it !=
m_end; ++it) {
425 result += it->frame_offset;
438 : m_object_file(object_file),
439 m_exception_dir(object_file.ReadImageDataByRVA(exception_dir_rva,
440 exception_dir_size)) {}
445 const RuntimeFunction *runtime_function =
447 if (!runtime_function)
453 runtime_function->StartAddress);
471 const RuntimeFunction *runtime_function =
473 if (!runtime_function)
477 if (!builder.
Build())
480 std::vector<UnwindPlan::RowSP> rows;
485 if (it->offset == last_offset)
492 last_offset = it->offset;
495 for (
auto it = rows.rbegin(); it != rows.rend(); ++it)
500 runtime_function->EndAddress - runtime_function->StartAddress));
513 while (begin < end) {
516 offset_t offset = curr *
sizeof(RuntimeFunction);
517 const auto *runtime_function =
519 if (!runtime_function)
522 if (runtime_function->StartAddress < rva + size &&
523 runtime_function->EndAddress > rva)
524 return runtime_function;
526 if (runtime_function->StartAddress >= rva + size)
529 if (runtime_function->EndAddress <= rva)