LLDB mainline
UnwindAssemblyInstEmulation.h
Go to the documentation of this file.
1//===-- UnwindAssemblyInstEmulation.h ---------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
10#define LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
11
16#include "lldb/lldb-private.h"
17
19public:
20 ~UnwindAssemblyInstEmulation() override = default;
21
24 lldb_private::UnwindPlan &unwind_plan) override;
25
26 bool
28 uint8_t *opcode_data, size_t opcode_size,
29 lldb_private::UnwindPlan &unwind_plan);
30
31 bool
34 lldb_private::UnwindPlan &unwind_plan) override;
35
38 lldb_private::UnwindPlan &unwind_plan) override;
39
40 // thread may be NULL in which case we only use the Target (e.g. if this is
41 // called pre-process-launch).
42 bool
44 const lldb_private::ExecutionContext &exe_ctx,
45 lldb_private::Address &first_non_prologue_insn) override;
46
49
50 // PluginInterface protocol
51 static void Initialize();
52
53 static void Terminate();
54
55 static llvm::StringRef GetPluginNameStatic() { return "inst-emulation"; }
56
57 static llvm::StringRef GetPluginDescriptionStatic();
58
59 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
60
61private:
62 // Call CreateInstance to get an instance of this class
74
75 static size_t
76 ReadMemory(lldb_private::EmulateInstruction *instruction, void *baton,
78 lldb::addr_t addr, void *dst, size_t length);
79
80 static size_t
81 WriteMemory(lldb_private::EmulateInstruction *instruction, void *baton,
83 lldb::addr_t addr, const void *dst, size_t length);
84
85 static bool ReadRegister(lldb_private::EmulateInstruction *instruction,
86 void *baton,
87 const lldb_private::RegisterInfo *reg_info,
89
90 static bool
91 WriteRegister(lldb_private::EmulateInstruction *instruction, void *baton,
93 const lldb_private::RegisterInfo *reg_info,
94 const lldb_private::RegisterValue &reg_value);
95
96 // size_t
97 // ReadMemory (lldb_private::EmulateInstruction *instruction,
98 // const lldb_private::EmulateInstruction::Context &context,
99 // lldb::addr_t addr,
100 // void *dst,
101 // size_t length);
102
105 lldb::addr_t addr, const void *dst, size_t length);
106
108 const lldb_private::RegisterInfo *reg_info,
109 lldb_private::RegisterValue &reg_value);
110
113 const lldb_private::RegisterInfo *reg_info,
114 const lldb_private::RegisterValue &reg_value);
115
116 static uint64_t
118
119 void SetRegisterValue(const lldb_private::RegisterInfo &reg_info,
120 const lldb_private::RegisterValue &reg_value);
121
122 bool GetRegisterValue(const lldb_private::RegisterInfo &reg_info,
123 lldb_private::RegisterValue &reg_value);
124
125 typedef std::map<uint64_t, lldb_private::RegisterValue> RegisterValueMap;
132
133 std::unique_ptr<lldb_private::EmulateInstruction> m_inst_emulator_up;
137 typedef std::map<uint64_t, uint64_t> PushedRegisterToAddrMap;
138 uint64_t m_initial_sp;
140
141 // While processing the instruction stream, we need to communicate some state
142 // change
143 // information up to the higher level loop that makes decisions about how to
144 // push
145 // the unwind instructions for the UnwindPlan we're constructing.
146
147 // The instruction we're processing updated the UnwindPlan::Row contents
149 // The instruction is branching forward with the given offset. 0 value means
150 // no branching.
152};
153
154#endif // LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
bool GetRegisterValue(const lldb_private::RegisterInfo &reg_info, lldb_private::RegisterValue &reg_value)
static llvm::StringRef GetPluginNameStatic()
bool GetFastUnwindPlan(lldb_private::AddressRange &func, lldb_private::Thread &thread, lldb_private::UnwindPlan &unwind_plan) override
std::map< uint64_t, uint64_t > PushedRegisterToAddrMap
std::unique_ptr< lldb_private::EmulateInstruction > m_inst_emulator_up
lldb_private::UnwindPlan * m_unwind_plan_ptr
static size_t WriteMemory(lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t length)
std::map< uint64_t, lldb_private::RegisterValue > RegisterValueMap
~UnwindAssemblyInstEmulation() override=default
static bool WriteRegister(lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &reg_value)
static llvm::StringRef GetPluginDescriptionStatic()
bool AugmentUnwindPlanFromCallSite(lldb_private::AddressRange &func, lldb_private::Thread &thread, lldb_private::UnwindPlan &unwind_plan) override
static size_t ReadMemory(lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, lldb::addr_t addr, void *dst, size_t length)
lldb_private::AddressRange * m_range_ptr
llvm::StringRef GetPluginName() override
static bool ReadRegister(lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &reg_value)
static uint64_t MakeRegisterKindValuePair(const lldb_private::RegisterInfo &reg_info)
static lldb_private::UnwindAssembly * CreateInstance(const lldb_private::ArchSpec &arch)
bool GetNonCallSiteUnwindPlanFromAssembly(lldb_private::AddressRange &func, lldb_private::Thread &thread, lldb_private::UnwindPlan &unwind_plan) override
void SetRegisterValue(const lldb_private::RegisterInfo &reg_info, const lldb_private::RegisterValue &reg_value)
UnwindAssemblyInstEmulation(const lldb_private::ArchSpec &arch, lldb_private::EmulateInstruction *inst_emulator)
bool FirstNonPrologueInsn(lldb_private::AddressRange &func, const lldb_private::ExecutionContext &exe_ctx, lldb_private::Address &first_non_prologue_insn) override
A section + offset based address range class.
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:31
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
UnwindAssembly(const ArchSpec &arch)
uint64_t addr_t
Definition lldb-types.h:80
Every register is described in detail including its name, alternate name (optional),...