[Lldb-commits] [lldb] 01d8270 - [LLDB] Make instruction emulation context type private
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 20 02:10:22 PDT 2022
Author: David Spickett
Date: 2022-09-20T09:10:14Z
New Revision: 01d8270a1560f2b9282cb50dab99f087e860a162
URL: https://github.com/llvm/llvm-project/commit/01d8270a1560f2b9282cb50dab99f087e860a162
DIFF: https://github.com/llvm/llvm-project/commit/01d8270a1560f2b9282cb50dab99f087e860a162.diff
LOG: [LLDB] Make instruction emulation context type private
This is the first step to being able to handle non
trivial types in the union.
info_type effects the lifetime of the objects in the union,
so making it private means we know you have to call one of the
Set<...> functions to change it.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D134039
Added:
Modified:
lldb/include/lldb/Core/EmulateInstruction.h
lldb/source/Core/EmulateInstruction.cpp
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h
index e5421e5e91d1..a710c866d980 100644
--- a/lldb/include/lldb/Core/EmulateInstruction.h
+++ b/lldb/include/lldb/Core/EmulateInstruction.h
@@ -183,7 +183,12 @@ class EmulateInstruction : public PluginInterface {
struct Context {
ContextType type = eContextInvalid;
+
+ private:
enum InfoType info_type = eInfoTypeNoArgs;
+
+ public:
+ enum InfoType GetInfoType() const { return info_type; }
union {
struct RegisterPlusOffset {
RegisterInfo reg; // base register
diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp
index c352b0129382..1320e8925553 100644
--- a/lldb/source/Core/EmulateInstruction.cpp
+++ b/lldb/source/Core/EmulateInstruction.cpp
@@ -440,7 +440,7 @@ void EmulateInstruction::Context::Dump(Stream &strm,
break;
}
- switch (info_type) {
+ switch (GetInfoType()) {
case eInfoTypeRegisterPlusOffset:
strm.Printf(" (reg_plus_offset = %s%+" PRId64 ")",
info.RegisterPlusOffset.reg.name,
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 03515a32ff86..acd10bd70c09 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -455,7 +455,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
case EmulateInstruction::eContextPushRegisterOnStack: {
uint32_t reg_num = LLDB_INVALID_REGNUM;
uint32_t generic_regnum = LLDB_INVALID_REGNUM;
- assert(context.info_type ==
+ assert(context.GetInfoType() ==
EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset &&
"unhandled case, add code to handle this!");
const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind();
@@ -574,7 +574,8 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
// with the same amount.
lldb::RegisterKind kind = m_unwind_plan_ptr->GetRegisterKind();
if (m_fp_is_cfa && reg_info->kinds[kind] == m_cfa_reg_info.kinds[kind] &&
- context.info_type == EmulateInstruction::eInfoTypeRegisterPlusOffset &&
+ context.GetInfoType() ==
+ EmulateInstruction::eInfoTypeRegisterPlusOffset &&
context.info.RegisterPlusOffset.reg.kinds[kind] ==
m_cfa_reg_info.kinds[kind]) {
const int64_t offset = context.info.RegisterPlusOffset.signed_offset;
@@ -585,18 +586,19 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
case EmulateInstruction::eContextAbsoluteBranchRegister:
case EmulateInstruction::eContextRelativeBranchImmediate: {
- if (context.info_type == EmulateInstruction::eInfoTypeISAAndImmediate &&
+ if (context.GetInfoType() == EmulateInstruction::eInfoTypeISAAndImmediate &&
context.info.ISAAndImmediate.unsigned_data32 > 0) {
m_forward_branch_offset =
context.info.ISAAndImmediateSigned.signed_data32;
- } else if (context.info_type ==
+ } else if (context.GetInfoType() ==
EmulateInstruction::eInfoTypeISAAndImmediateSigned &&
context.info.ISAAndImmediateSigned.signed_data32 > 0) {
m_forward_branch_offset = context.info.ISAAndImmediate.unsigned_data32;
- } else if (context.info_type == EmulateInstruction::eInfoTypeImmediate &&
+ } else if (context.GetInfoType() ==
+ EmulateInstruction::eInfoTypeImmediate &&
context.info.unsigned_immediate > 0) {
m_forward_branch_offset = context.info.unsigned_immediate;
- } else if (context.info_type ==
+ } else if (context.GetInfoType() ==
EmulateInstruction::eInfoTypeImmediateSigned &&
context.info.signed_immediate > 0) {
m_forward_branch_offset = context.info.signed_immediate;
@@ -609,7 +611,7 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
const uint32_t generic_regnum = reg_info->kinds[eRegisterKindGeneric];
if (reg_num != LLDB_INVALID_REGNUM &&
generic_regnum != LLDB_REGNUM_GENERIC_SP) {
- switch (context.info_type) {
+ switch (context.GetInfoType()) {
case EmulateInstruction::eInfoTypeAddress:
if (m_pushed_regs.find(reg_num) != m_pushed_regs.end() &&
context.info.address == m_pushed_regs[reg_num]) {
More information about the lldb-commits
mailing list