diff options
author | Ed Maste <emaste@freebsd.org> | 2013-07-22 20:20:55 +0000 |
---|---|---|
committer | Ed Maste <emaste@freebsd.org> | 2013-07-22 20:20:55 +0000 |
commit | 1423616562fe98269b57fd5569192030ad701541 (patch) | |
tree | e9c70ca202dfbc669466f8355d1abd6309d7c632 | |
parent | fae98dbd2501f53fe3ad5b331bf00d5234e274da (diff) | |
download | lldb-1423616562fe98269b57fd5569192030ad701541.tar.gz |
elf-core: Run-time reg context selection
Instantiate RegisterContextCore... based on getOS() instead of with
compile-time #ifdef-ery.
The assert()s here are unfortunate, but better than crashing with no
explanation. (This would previously happen for an unsupported
architecture, anyhow.)
We should add an equivalent OS and architecture test to
ProcessElfCore::DoLoadCore() and cleanly report the error to the user.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@186865 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | source/Plugins/Process/elf-core/ThreadElfCore.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp index 6ac12fef7..7d0397ead 100644 --- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -95,16 +95,27 @@ ThreadElfCore::CreateRegisterContextForFrame (StackFrame *frame) switch (arch.GetMachine()) { case llvm::Triple::x86_64: -#ifdef __FreeBSD__ - m_thread_reg_ctx_sp.reset(new RegisterContextCoreFreeBSD_x86_64 (*this, gpregset_data, m_fpregset_data)); -#else - m_thread_reg_ctx_sp.reset(new RegisterContextCoreLinux_x86_64 (*this, gpregset_data, m_fpregset_data)); -#endif + switch (arch.GetTriple().getOS()) + { + case llvm::Triple::FreeBSD: + m_thread_reg_ctx_sp.reset(new RegisterContextCoreFreeBSD_x86_64 (*this, gpregset_data, m_fpregset_data)); + break; + case llvm::Triple::Linux: + m_thread_reg_ctx_sp.reset(new RegisterContextCoreLinux_x86_64 (*this, gpregset_data, m_fpregset_data)); + break; + default: + if (log) + log->Printf ("elf-core::%s:: OS(%d) not supported", + __FUNCTION__, arch.GetTriple().getOS()); + assert (false && "OS not supported"); + break; + } break; default: if (log) log->Printf ("elf-core::%s:: Architecture(%d) not supported", __FUNCTION__, arch.GetMachine()); + assert (false && "Architecture not supported"); } reg_ctx_sp = m_thread_reg_ctx_sp; } |