diff options
| author | Jason Molenda <jmolenda@apple.com> | 2015-01-10 04:01:03 +0000 |
|---|---|---|
| committer | Jason Molenda <jmolenda@apple.com> | 2015-01-10 04:01:03 +0000 |
| commit | a05677126d06cf1abc019db231f5f918cf08e3f7 (patch) | |
| tree | 1f4bd1d2b40dd7e33af89d25e6309a2d605fe2bc /lldb/source/Plugins/Process/Utility | |
| parent | c552218e286b172a6fc388b8c3237eb0c2825123 (diff) | |
| download | bcm5719-llvm-a05677126d06cf1abc019db231f5f918cf08e3f7.tar.gz bcm5719-llvm-a05677126d06cf1abc019db231f5f918cf08e3f7.zip | |
Hoist the RegisterNumber class out of RegisterContextLLDB and make
it more generally available.
Add checks to UnwindAssembly_x86::AugmentUnwindPlanFromCallSite() so
that it won't try to augment an UnwindPlan that already describes
the function epilogue.
Add a test case for backtracing out of _sigtramp on Darwin systems.
This could probably be adapted to test the same thing on linux/bsd but
the function names of sigtramp and kill are probably platform
specific and I'm not sure what they should be.
llvm-svn: 225578
Diffstat (limited to 'lldb/source/Plugins/Process/Utility')
| -rw-r--r-- | lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h | 160 |
1 files changed, 1 insertions, 159 deletions
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h index 636e9524021..5f94a977448 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h @@ -16,6 +16,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/RegisterNumber.h" #include "UnwindLLDB.h" namespace lldb_private { @@ -86,165 +87,6 @@ public: private: - //-------------------------------------------------------------------- - /// A convenience class for RegisterContextLLDB which can convert between - /// different register kinds. - /// - /// This ends up being a common operation in RegisterContextLLDB as we try - /// to bridge between the different register numbering systems -- having a - /// simple object to enclose all of that conversion, and cache results so - /// we don't re-fetch, simplifies the code significantly. - //-------------------------------------------------------------------- - class RegisterNumber { - public: - RegisterNumber (lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num) : - m_reg_ctx_sp (thread.GetRegisterContext()), - m_regnum (num), - m_kind (kind), - m_kind_regnum_map (), - m_name ("") - { - if (m_reg_ctx_sp.get()) - { - const lldb_private::RegisterInfo *reginfo = m_reg_ctx_sp->GetRegisterInfoAtIndex (GetAsKind (lldb::eRegisterKindLLDB)); - if (reginfo && reginfo->name) - { - m_name = reginfo->name; - } - } - } - - // 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), - m_kind (lldb::kNumRegisterKinds), - m_kind_regnum_map (), - m_name (nullptr) - { - } - - void - init (lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num) - { - m_reg_ctx_sp = thread.GetRegisterContext(); - m_regnum = num; - m_kind = kind; - if (m_reg_ctx_sp.get()) - { - const lldb_private::RegisterInfo *reginfo = m_reg_ctx_sp->GetRegisterInfoAtIndex (GetAsKind (lldb::eRegisterKindLLDB)); - if (reginfo && reginfo->name) - { - m_name = reginfo->name; - } - } - } - - const RegisterNumber & - operator = (const RegisterNumber &rhs) - { - m_reg_ctx_sp = rhs.m_reg_ctx_sp; - m_regnum = rhs.m_regnum; - m_kind = rhs.m_kind; - for (auto it : rhs.m_kind_regnum_map) - m_kind_regnum_map[it.first] = it.second; - m_name = rhs.m_name; - return *this; - } - - bool - 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; - } - - uint32_t - GetAsKind (lldb::RegisterKind kind) - { - if (m_regnum == LLDB_INVALID_REGNUM) - return LLDB_INVALID_REGNUM; - - if (kind == m_kind) - return m_regnum; - - Collection::iterator iter = m_kind_regnum_map.find (kind); - if (iter != m_kind_regnum_map.end()) - { - return iter->second; - } - uint32_t output_regnum = LLDB_INVALID_REGNUM; - if (m_reg_ctx_sp - && m_reg_ctx_sp->ConvertBetweenRegisterKinds (m_kind, m_regnum, kind, output_regnum) - && output_regnum != LLDB_INVALID_REGNUM) - { - m_kind_regnum_map[kind] = output_regnum; - } - return output_regnum; - } - - uint32_t - GetRegisterNumber () const - { - return m_regnum; - } - - lldb::RegisterKind - GetRegisterKind () const - { - return m_kind; - } - - const char * - GetName () - { - return m_name; - } - - private: - typedef std::map<lldb::RegisterKind, uint32_t> Collection; - - lldb::RegisterContextSP m_reg_ctx_sp; - uint32_t m_regnum; - lldb::RegisterKind m_kind; - Collection m_kind_regnum_map; - const char *m_name; - }; - enum FrameType { eNormalFrame, |

