[Lldb-commits] [lldb] r187422 - Run-time reg context selection for POSIX targets
Ed Maste
emaste at freebsd.org
Tue Jul 30 07:40:59 PDT 2013
Author: emaste
Date: Tue Jul 30 09:40:59 2013
New Revision: 187422
URL: http://llvm.org/viewvc/llvm-project?rev=187422&view=rev
Log:
Run-time reg context selection for POSIX targets
Instantiate RegisterContext... based on getOS() instead of with
compile-time #ifdef-ery.
The assert() here is unfortunate, but better than crashing with no
explanation.
This change is equivalent to r186865 for elf-core.
Modified:
lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp?rev=187422&r1=187421&r2=187422&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp Tue Jul 30 09:40:59 2013
@@ -145,14 +145,18 @@ POSIXThread::GetRegisterContext()
break;
case ArchSpec::eCore_x86_64_x86_64:
-// TODO: Use target OS/architecture detection rather than ifdefs so that
-// lldb built on FreeBSD can debug on Linux and vice-versa.
-#ifdef __linux__
- m_reg_context_sp.reset(new RegisterContextLinux_x86_64(*this, 0));
-#endif
-#ifdef __FreeBSD__
- m_reg_context_sp.reset(new RegisterContextFreeBSD_x86_64(*this, 0));
-#endif
+ switch (arch.GetTriple().getOS())
+ {
+ case llvm::Triple::FreeBSD:
+ m_reg_context_sp.reset(new RegisterContextFreeBSD_x86_64(*this, 0));
+ break;
+ case llvm::Triple::Linux:
+ m_reg_context_sp.reset(new RegisterContextLinux_x86_64(*this, 0));
+ break;
+ default:
+ assert(false && "OS not supported");
+ break;
+ }
break;
}
}
More information about the lldb-commits
mailing list