[Lldb-commits] [lldb] r186865 - elf-core: Run-time reg context selection

Ed Maste emaste at freebsd.org
Mon Jul 22 13:20:55 PDT 2013


Author: emaste
Date: Mon Jul 22 15:20:55 2013
New Revision: 186865

URL: http://llvm.org/viewvc/llvm-project?rev=186865&view=rev
Log:
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.


Modified:
    lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=186865&r1=186864&r2=186865&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Mon Jul 22 15:20:55 2013
@@ -95,16 +95,27 @@ ThreadElfCore::CreateRegisterContextForF
         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;
     }





More information about the lldb-commits mailing list