[Lldb-commits] [lldb] r186534 - elf-core: Support FreeBSD at compile-time

Ed Maste emaste at freebsd.org
Wed Jul 17 13:13:39 PDT 2013


Author: emaste
Date: Wed Jul 17 15:13:39 2013
New Revision: 186534

URL: http://llvm.org/viewvc/llvm-project?rev=186534&view=rev
Log:
elf-core: Support FreeBSD at compile-time

Compile-time #ifdef-ery isn't right, but this makes core debugging work on
FreeBSD and highlights the parts that will need to be changed for runtime
arch support.

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

Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=186534&r1=186533&r2=186534&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Wed Jul 17 15:13:39 2013
@@ -212,7 +212,11 @@ ProcessElfCore::DoLoadCore ()
             arch.SetTriple ("i386", m_target.GetPlatform().get());
             break;
         case ArchSpec::eCore_x86_64_x86_64:
+#ifdef __FreeBSD__
+            arch.SetTriple ("x86_64-freebsd-unknown", m_target.GetPlatform().get());
+#else
             arch.SetTriple ("x86_64-linux-gnu", m_target.GetPlatform().get());
+#endif
             break;
         default:
             assert(false && "Unhandled core type");

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=186534&r1=186533&r2=186534&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Wed Jul 17 15:13:39 2013
@@ -16,6 +16,7 @@
 
 #include "ThreadElfCore.h"
 #include "ProcessElfCore.h"
+#include "RegisterContextCoreFreeBSD_x86_64.h"
 #include "RegisterContextCoreLinux_x86_64.h"
 
 using namespace lldb;
@@ -94,7 +95,11 @@ 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
                 break;
             default:
                 if (log)

Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h?rev=186534&r1=186533&r2=186534&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Wed Jul 17 15:13:39 2013
@@ -26,11 +26,25 @@ struct compat_timeval
 // simply reading data from the buffer.
 // The following macros are used to specify the size.
 // Calculating size using sizeof() wont work because of padding.
+#ifdef __FreeBSD__
+#define ELFPRSTATUS64_SIZE (48)
+#define ELFPRPSINFO64_SIZE (120)
+#else
 #define ELFPRSTATUS64_SIZE (112)
 #define ELFPRPSINFO64_SIZE (132)
+#endif
 
 struct ELFPrStatus
 {
+#ifdef __FreeBSD__
+    int32_t         pr_version;
+    uint64_t        pr_statussz;
+    uint64_t        pr_gregsetsz;
+    uint64_t        pr_fpregsetsz;
+    int32_t         pr_osreldate;
+    int32_t         pr_cursig;
+    uint32_t        pr_pid;
+#else
     int32_t         si_signo;
     int32_t         si_code;
     int32_t         si_errno;
@@ -49,6 +63,7 @@ struct ELFPrStatus
     compat_timeval  pr_stime;
     compat_timeval  pr_cutime;
     compat_timeval  pr_cstime;
+#endif
 
     ELFPrStatus();
 
@@ -70,6 +85,12 @@ struct ELFPrStatus
 
 struct ELFPrPsInfo
 {
+#ifdef __FreeBSD__
+    int32_t     pr_version;
+    uint64_t    pr_psinfosz;
+    char        pr_fname[17];
+    char        pr_psargs[81];
+#else
     char        pr_state;
     char        pr_sname;
     char        pr_zomb;
@@ -83,6 +104,7 @@ struct ELFPrPsInfo
     int32_t     pr_sid;
     char        pr_fname[16];
     char        pr_psargs[80];
+#endif
 
     ELFPrPsInfo();
 





More information about the lldb-commits mailing list