diff options
author | Jason Molenda <jmolenda@apple.com> | 2014-11-11 08:26:44 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2014-11-11 08:26:44 +0000 |
commit | d158db0f63cece2520e0d70b8bd712001cd78322 (patch) | |
tree | 1c1c024b72c9a2c0023829a2930f5765255dfba3 | |
parent | cdcbfba3b6cdf06b75a195022165d9bd6c9df812 (diff) | |
download | bcm5719-llvm-d158db0f63cece2520e0d70b8bd712001cd78322.tar.gz bcm5719-llvm-d158db0f63cece2520e0d70b8bd712001cd78322.zip |
Add an operator== to the RegisterNumber class; it simplifies
RegisterContextLLDB a bit more in a few places.
llvm-svn: 221677
-rw-r--r-- | lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h | 38 |
2 files changed, 43 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 9169b2b3108..0bd07f69474 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -1196,8 +1196,8 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat // If we're fetching the saved pc and this UnwindPlan defines a ReturnAddress register (e.g. lr on arm), // look for the return address register number in the UnwindPlan's row. - if (pc_regnum.GetAsKind (eRegisterKindLLDB) != LLDB_INVALID_REGNUM - && pc_regnum.GetAsKind (eRegisterKindLLDB) == regnum.GetAsKind (eRegisterKindLLDB) + if (pc_regnum.IsValid() + && pc_regnum == regnum && m_full_unwind_plan_sp->GetReturnAddressRegister() != LLDB_INVALID_REGNUM) { @@ -1211,12 +1211,13 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat { if (unwindplan_registerkind == eRegisterKindGeneric) { - UnwindLogMsg ("could not convert lldb regnum %s (%d) into eRegisterKindGeneric reg numbering scheme", regnum.GetName(), regnum.GetAsKind (eRegisterKindLLDB)); + UnwindLogMsg ("could not convert lldb regnum %s (%d) into eRegisterKindGeneric reg numbering scheme", + regnum.GetName(), regnum.GetAsKind (eRegisterKindLLDB)); } else { UnwindLogMsg ("could not convert lldb regnum %s (%d) into %d RegisterKind reg numbering scheme", - regnum.GetName(), regnum.GetAsKind (eRegisterKindLLDB), (int) unwindplan_registerkind); + regnum.GetName(), regnum.GetAsKind (eRegisterKindLLDB), (int) unwindplan_registerkind); } return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; } @@ -1268,8 +1269,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat RegisterNumber arch_default_ra_regnum (m_thread, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); if (arch_default_ra_regnum.GetAsKind (unwindplan_registerkind) != LLDB_INVALID_REGNUM - && pc_regnum.GetAsKind (eRegisterKindLLDB) != LLDB_INVALID_REGNUM - && pc_regnum.GetAsKind (eRegisterKindLLDB) == regnum.GetAsKind (eRegisterKindLLDB) + && pc_regnum == regnum && unwindplan_regloc.IsInOtherRegister() && unwindplan_regloc.GetRegisterNumber() == arch_default_ra_regnum.GetAsKind (unwindplan_registerkind) && m_full_unwind_plan_sp->GetSourcedFromCompiler() != eLazyBoolYes diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h index d6e11bf03e0..66d62ac94cc 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h @@ -114,6 +114,10 @@ private: } } + // This constructor plus the init() method below allow for the placeholder + // creation of an invalid object initially, possibly to be filled in. It + // would be more consistent to have three Set* methods to set the three + // data that the object needs. RegisterNumber () : m_reg_ctx_sp(), m_regnum (LLDB_INVALID_REGNUM), @@ -152,7 +156,39 @@ private: } bool - IsValid () + operator == (RegisterNumber &rhs) + { + if (IsValid() != rhs.IsValid()) + return false; + + if (m_kind == rhs.m_kind) + { + if (m_regnum == rhs.m_regnum) + return true; + else + return false; + } + + uint32_t rhs_regnum = rhs.GetAsKind (m_kind); + if (rhs_regnum != LLDB_INVALID_REGNUM) + { + if (m_regnum == rhs_regnum) + return true; + else + return false; + } + uint32_t lhs_regnum = GetAsKind (rhs.m_kind); + { + if (lhs_regnum == rhs.m_regnum) + return true; + else + return false; + } + return false; + } + + bool + IsValid () const { return m_regnum != LLDB_INVALID_REGNUM; } |