[Lldb-commits] [lldb] r221677 - Add an operator== to the RegisterNumber class; it simplifies
Jason Molenda
jmolenda at apple.com
Tue Nov 11 00:26:44 PST 2014
Author: jmolenda
Date: Tue Nov 11 02:26:44 2014
New Revision: 221677
URL: http://llvm.org/viewvc/llvm-project?rev=221677&view=rev
Log:
Add an operator== to the RegisterNumber class; it simplifies
RegisterContextLLDB a bit more in a few places.
Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=221677&r1=221676&r2=221677&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Nov 11 02:26:44 2014
@@ -1196,8 +1196,8 @@ RegisterContextLLDB::SavedLocationForReg
// 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::SavedLocationForReg
{
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::SavedLocationForReg
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
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=221677&r1=221676&r2=221677&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Tue Nov 11 02:26:44 2014
@@ -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;
}
More information about the lldb-commits
mailing list