Patch by David Forsythe to build lldb on FreeBSD!
I did not take the patch for ClangExpressionParser.cpp since there was a
recent change by Peter for the same line. Feel free to disagree. :-)
Reference:
----------------------------------------------------------------------
r136580 | pcc | 2011-07-30 15:42:24 -0700 (Sat, 30 Jul 2011) | 3 lines
Add reloc arg to standard JIT createJIT()
Fixes non-__APPLE__ build. Patch by Matt Johnson!
----------------------------------------------------------------------
Also, I ignore the part of the patch to remove the RegisterContextDarwin*.h/.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136720 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/Makefile b/source/Host/Makefile
index b26528c..44597f6 100644
--- a/source/Host/Makefile
+++ b/source/Host/Makefile
@@ -21,4 +21,8 @@
DIRS += linux
endif
+ifeq ($(HOST_OS),FreeBSD)
+DIRS += freebsd
+endif
+
include $(LLDB_LEVEL)/Makefile
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 6908eb1..f56c4b7 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -43,6 +43,12 @@
#include <sys/wait.h>
+#elif defined (__FreeBSD__)
+
+#include <sys/wait.h>
+#include <sys/sysctl.h>
+#include <pthread_np.h>
+
#endif
using namespace lldb;
@@ -357,6 +363,8 @@
g_vendor.SetCString("apple");
#elif defined (__linux__)
g_vendor.SetCString("gnu");
+#elif defined (__FreeBSD__)
+ g_vendor.SetCString("freebsd");
#endif
}
return g_vendor;
@@ -372,6 +380,8 @@
g_os_string.SetCString("darwin");
#elif defined (__linux__)
g_os_string.SetCString("linux");
+#elif defined (__FreeBSD__)
+ g_os_string.SetCString("freebsd");
#endif
}
return g_os_string;
@@ -410,6 +420,8 @@
{
#if defined (__APPLE__)
return ::mach_thread_self();
+#elif defined(__FreeBSD__)
+ return lldb::tid_t(pthread_getthreadid_np());
#else
return lldb::tid_t(pthread_self());
#endif
@@ -470,19 +482,17 @@
{
}
-#if !defined (__APPLE__) // see macosx/Host.mm
+#if !defined (__APPLE__) && !defined (__FreeBSD__) // see macosx/Host.mm
void
Host::ThreadCreated (const char *thread_name)
{
}
-void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{
// TODO: Is there a way to backtrace the current process on linux? Other systems?
}
-
size_t
Host::GetEnvironment (StringList &env)
{
@@ -1120,9 +1130,7 @@
return NULL;
}
-
-#if !defined (__APPLE__) // see macosx/Host.mm
-
+#if !defined (__APPLE__) && !defined (__FreeBSD__) // see macosx/Host.mm
bool
Host::GetOSBuildString (std::string &s)
{
@@ -1136,21 +1144,27 @@
s.clear();
return false;
}
+#endif
+#if !defined(__APPLE__)
uint32_t
Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
{
process_infos.Clear();
return process_infos.GetSize();
}
+#endif
+#if !defined (__APPLE__) && !defined (__FreeBSD__)
bool
Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
{
process_info.Clear();
return false;
}
+#endif
+#if !defined (__APPLE__)
bool
Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
{
diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp
new file mode 100644
index 0000000..3d6596c
--- /dev/null
+++ b/source/Host/freebsd/Host.cpp
@@ -0,0 +1,277 @@
+//===-- source/Host/freebsd/Host.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#include <execinfo.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/utsname.h>
+#include <sys/sysctl.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Target/Process.h"
+
+#include "llvm/Support/Host.h"
+
+extern "C" {
+ char **environ;
+}
+
+using namespace lldb;
+using namespace lldb_private;
+
+class FreeBSDThread
+{
+public:
+ FreeBSDThread(const char *thread_name)
+ {
+ Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name);
+ }
+ static void PThreadDestructor (void *v)
+ {
+ delete (FreeBSDThread*)v;
+ }
+};
+
+static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
+static pthread_key_t g_thread_create_key = 0;
+
+static void
+InitThreadCreated()
+{
+ ::pthread_key_create (&g_thread_create_key, FreeBSDThread::PThreadDestructor);
+}
+
+void
+Host::ThreadCreated (const char *thread_name)
+{
+ ::pthread_once (&g_thread_create_once, InitThreadCreated);
+ if (g_thread_create_key)
+ {
+ ::pthread_setspecific (g_thread_create_key, new FreeBSDThread(thread_name));
+ }
+}
+
+void
+Host::Backtrace (Stream &strm, uint32_t max_frames)
+{
+ char backtrace_path[] = "/tmp/lldb-backtrace-tmp-XXXXXX";
+ int backtrace_fd = ::mkstemp (backtrace_path);
+ if (backtrace_fd != -1)
+ {
+ std::vector<void *> frame_buffer (max_frames, NULL);
+ int count = ::backtrace (&frame_buffer[0], frame_buffer.size());
+ ::backtrace_symbols_fd (&frame_buffer[0], count, backtrace_fd);
+
+ const off_t buffer_size = ::lseek(backtrace_fd, 0, SEEK_CUR);
+
+ if (::lseek(backtrace_fd, 0, SEEK_SET) == 0)
+ {
+ char *buffer = (char *)::malloc (buffer_size);
+ if (buffer)
+ {
+ ssize_t bytes_read = ::read (backtrace_fd, buffer, buffer_size);
+ if (bytes_read > 0)
+ strm.Write(buffer, bytes_read);
+ ::free (buffer);
+ }
+ }
+ ::close (backtrace_fd);
+ ::unlink (backtrace_path);
+ }
+}
+
+size_t
+Host::GetEnvironment (StringList &env)
+{
+ char *v;
+ char **var = environ;
+ for (var = environ; var != NULL; ++var) {
+ v = strchr(*var, (int)'-');
+ if (v == NULL)
+ continue;
+ env.AppendString(v);
+ }
+ return env.GetSize();
+}
+
+bool
+Host::GetOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update)
+{
+ struct utsname un;
+ int status;
+
+ if (uname(&un) < 0)
+ return false;
+
+ status = sscanf(un.release, "%u.%u-%u", &major, &minor, &update);
+ return status == 3;
+}
+
+Error
+Host::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+ Error error;
+ assert(!"Not implemented yet!!!");
+ return error;
+}
+
+bool
+Host::GetOSBuildString (std::string &s)
+{
+ int mib[2] = { CTL_KERN, KERN_OSREV };
+ char cstr[PATH_MAX];
+ size_t cstr_len = sizeof(cstr);
+ if (::sysctl (mib, 2, cstr, &cstr_len, NULL, 0) == 0)
+ {
+ s.assign (cstr, cstr_len);
+ return true;
+ }
+ s.clear();
+ return false;
+}
+
+bool
+Host::GetOSKernelDescription (std::string &s)
+{
+ int mib[2] = { CTL_KERN, KERN_VERSION };
+ char cstr[PATH_MAX];
+ size_t cstr_len = sizeof(cstr);
+ if (::sysctl (mib, 2, cstr, &cstr_len, NULL, 0) == 0)
+ {
+ s.assign (cstr, cstr_len);
+ return true;
+ }
+ s.clear();
+ return false;
+}
+
+static bool
+GetFreeBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
+ ProcessInstanceInfo &process_info)
+{
+ if (process_info.ProcessIDIsValid()) {
+ int mib[3] = { CTL_KERN, KERN_PROC_ARGS, process_info.GetProcessID() };
+
+ char arg_data[8192];
+ size_t arg_data_size = sizeof(arg_data);
+ if (::sysctl (mib, 3, arg_data, &arg_data_size , NULL, 0) == 0)
+ {
+ DataExtractor data (arg_data, arg_data_size, lldb::endian::InlHostByteOrder(), sizeof(void *));
+ uint32_t offset = 0;
+ uint32_t start_offset;
+ uint32_t argc = data.GetU32 (&offset);
+ const char *cstr;
+
+ cstr = data.GetCStr (&offset);
+ if (cstr)
+ {
+ process_info.GetExecutableFile().SetFile(cstr, false);
+
+ if (match_info_ptr == NULL ||
+ NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
+ match_info_ptr->GetNameMatchType(),
+ match_info_ptr->GetProcessInfo().GetName()))
+ {
+ // Skip NULLs
+ while (1)
+ {
+ const uint8_t *p = data.PeekData(offset, 1);
+ if ((p == NULL) || (*p != '\0'))
+ break;
+ ++offset;
+ }
+ // Now extract all arguments
+ Args &proc_args = process_info.GetArguments();
+ for (int i=0; i<argc; ++i)
+ {
+ start_offset = offset;
+ cstr = data.GetCStr(&offset);
+ if (cstr)
+ proc_args.AppendArgument(cstr);
+ }
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+static bool
+GetFreeBSDProcessCPUType (ProcessInstanceInfo &process_info)
+{
+ if (process_info.ProcessIDIsValid()) {
+ // TODO: This
+ // return true;
+ }
+ process_info.GetArchitecture().Clear();
+ return false;
+}
+
+static bool
+GetFreeBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
+{
+ struct kinfo_proc proc_kinfo;
+ size_t proc_kinfo_size;
+
+ if (process_info.ProcessIDIsValid())
+ {
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ process_info.GetProcessID() };
+ proc_kinfo_size = sizeof(struct kinfo_proc);
+
+ if (::sysctl (mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0)
+ {
+ if (proc_kinfo_size > 0)
+ {
+ process_info.SetParentProcessID (proc_kinfo.ki_ppid);
+ process_info.SetUserID (proc_kinfo.ki_ruid);
+ process_info.SetGroupID (proc_kinfo.ki_rgid);
+ process_info.SetEffectiveUserID (proc_kinfo.ki_uid);
+ if (proc_kinfo.ki_ngroups > 0)
+ process_info.SetEffectiveGroupID (proc_kinfo.ki_groups[0]);
+ else
+ process_info.SetEffectiveGroupID (UINT32_MAX);
+ return true;
+ }
+ }
+ }
+ process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
+ process_info.SetUserID (UINT32_MAX);
+ process_info.SetGroupID (UINT32_MAX);
+ process_info.SetEffectiveUserID (UINT32_MAX);
+ process_info.SetEffectiveGroupID (UINT32_MAX);
+ return false;
+}
+
+bool
+Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ process_info.SetProcessID(pid);
+ if (GetFreeBSDProcessArgs(NULL, process_info)) {
+ // should use libprocstat instead of going right into sysctl?
+ GetFreeBSDProcessCPUType(process_info);
+ GetFreeBSDProcessUserAndGroup(process_info);
+ return true;
+ }
+ process_info.Clear();
+ return false;
+}
diff --git a/source/Host/freebsd/Makefile b/source/Host/freebsd/Makefile
new file mode 100644
index 0000000..4484ee2
--- /dev/null
+++ b/source/Host/freebsd/Makefile
@@ -0,0 +1,16 @@
+##===- source/Host/freebsd/Makefile --------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../..
+LIBRARYNAME := lldbHostFreeBSD
+BUILD_ARCHIVE = 1
+
+CPPFLAGS += -I/usr/local/include
+
+include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Makefile b/source/Plugins/Makefile
index c5b9279..8ab8771 100644
--- a/source/Plugins/Makefile
+++ b/source/Plugins/Makefile
@@ -21,7 +21,7 @@
LanguageRuntime/ObjC/AppleObjCRuntime
ifeq ($(HOST_OS),Darwin)
-DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \
+DIRS += Process/Darwin DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \
ObjectFile/Mach-O SymbolVendor/MacOSX
#DIRS += Process/MacOSX-User
endif
diff --git a/source/Plugins/Platform/FreeBSD/Makefile b/source/Plugins/Platform/FreeBSD/Makefile
new file mode 100644
index 0000000..e396247
--- /dev/null
+++ b/source/Plugins/Platform/FreeBSD/Makefile
@@ -0,0 +1,14 @@
+##===- source/Plugins/Platform/Linux/Makefile --------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../../..
+LIBRARYNAME := lldbPluginPlatformFreeBSD
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
new file mode 100644
index 0000000..ea9cdea
--- /dev/null
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -0,0 +1,262 @@
+//===-- PlatformFreeBSD.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformFreeBSD.h"
+
+// C Includes
+#include <stdio.h>
+#include <sys/utsname.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+Platform *
+PlatformFreeBSD::CreateInstance ()
+{
+ return new PlatformFreeBSD();
+}
+
+const char *
+PlatformFreeBSD::GetPluginNameStatic()
+{
+ return "plugin.platform.FreeBSD";
+}
+
+const char *
+PlatformFreeBSD::GetPluginDescriptionStatic()
+{
+ return "Default platform plugin for FreeBSD";
+}
+
+void
+PlatformFreeBSD::Initialize ()
+{
+ static bool g_initialized = false;
+
+ if (!g_initialized)
+ {
+ PlatformSP default_platform_sp (CreateInstance());
+ Platform::SetDefaultPlatform (default_platform_sp);
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(),
+ CreateInstance);
+ g_initialized = true;
+ }
+}
+
+void
+PlatformFreeBSD::Terminate ()
+{
+ PluginManager::UnregisterPlugin (PlatformFreeBSD::CreateInstance);
+}
+
+
+Error
+PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,
+ const ArchSpec &exe_arch,
+ lldb::ModuleSP &exe_module_sp)
+{
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ FileSpec resolved_exe_file (exe_file);
+
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ if (!resolved_exe_file.Exists())
+ resolved_exe_file.ResolveExecutableLocation ();
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle (resolved_exe_file);
+
+ if (resolved_exe_file.Exists())
+ {
+ if (exe_arch.IsValid())
+ {
+ error = ModuleList::GetSharedModule (resolved_exe_file,
+ exe_arch,
+ NULL,
+ NULL,
+ 0,
+ exe_module_sp,
+ NULL,
+ NULL);
+
+ if (exe_module_sp->GetObjectFile() == NULL)
+ {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""),
+ exe_arch.GetArchitectureName());
+ }
+ }
+ else
+ {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+ {
+ error = ModuleList::GetSharedModule (resolved_exe_file,
+ platform_arch,
+ NULL,
+ NULL,
+ 0,
+ exe_module_sp,
+ NULL,
+ NULL);
+ // Did we find an executable using one of the
+ if (error.Success())
+ {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString (", ");
+ arch_names.PutCString (platform_arch.GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp)
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""),
+ GetShortPluginName(),
+ arch_names.GetString().c_str());
+ }
+ }
+ }
+ else
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' does not exist",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""));
+ }
+
+ return error;
+}
+
+Error
+PlatformFreeBSD::GetFile (const FileSpec &platform_file,
+ const UUID *uuid, FileSpec &local_file)
+{
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
+}
+
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformFreeBSD::PlatformFreeBSD () :
+ Platform(true)
+{
+}
+
+//------------------------------------------------------------------
+/// Destructor.
+///
+/// The destructor is virtual since this class is designed to be
+/// inherited from by the plug-in instance.
+//------------------------------------------------------------------
+PlatformFreeBSD::~PlatformFreeBSD()
+{
+}
+
+bool
+PlatformFreeBSD::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ return Host::GetProcessInfo (pid, process_info);
+}
+
+bool
+PlatformFreeBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+ if (idx == 0)
+ {
+ arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+ return arch.IsValid();
+ }
+ return false;
+}
+
+void
+PlatformFreeBSD::GetStatus (Stream &strm)
+{
+ struct utsname un;
+
+ if (uname(&un)) {
+ strm << "FreeBSD";
+ return;
+ }
+
+ strm << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
+}
+
+size_t
+PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode (Target &target,
+ BreakpointSite *bp_site)
+{
+ static const uint8_t g_i386_opcode[] = { 0xCC };
+
+ ArchSpec arch = target.GetArchitecture();
+ const uint8_t *opcode = NULL;
+ size_t opcode_size = 0;
+
+ switch (arch.GetCore())
+ {
+ default:
+ assert(false && "CPU type not supported!");
+ break;
+
+ case ArchSpec::eCore_x86_32_i386:
+ case ArchSpec::eCore_x86_64_x86_64:
+ opcode = g_i386_opcode;
+ opcode_size = sizeof(g_i386_opcode);
+ break;
+ }
+
+ bp_site->SetTrapOpcode(opcode, opcode_size);
+ return opcode_size;
+}
+
+lldb::ProcessSP
+PlatformFreeBSD::Attach(lldb::pid_t pid,
+ Debugger &debugger,
+ Target *target,
+ Listener &listener,
+ Error &error)
+{
+ ProcessSP processSP;
+ assert(!"Not implemented yet!");
+ return processSP;
+}
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
new file mode 100644
index 0000000..be895d4
--- /dev/null
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -0,0 +1,109 @@
+//===-- PlatformFreeBSD.h -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_PlatformFreeBSD_h_
+#define liblldb_PlatformFreeBSD_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+
+ class PlatformFreeBSD : public Platform
+ {
+ public:
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ PlatformFreeBSD ();
+
+ virtual
+ ~PlatformFreeBSD();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ static Platform *
+ CreateInstance ();
+
+ static const char *
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ virtual const char *
+ GetPluginName()
+ {
+ return GetPluginNameStatic();
+ }
+
+ virtual const char *
+ GetShortPluginName()
+ {
+ return "PlatformFreeBSD";
+ }
+
+ virtual uint32_t
+ GetPluginVersion()
+ {
+ return 1;
+ }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ virtual Error
+ ResolveExecutable (const FileSpec &exe_file,
+ const ArchSpec &arch,
+ lldb::ModuleSP &module_sp);
+
+ virtual const char *
+ GetDescription ()
+ {
+ return GetPluginDescriptionStatic();
+ }
+
+ virtual void
+ GetStatus (Stream &strm);
+
+ virtual Error
+ GetFile (const FileSpec &platform_file,
+ const UUID* uuid, FileSpec &local_file);
+
+ virtual bool
+ GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
+
+ virtual bool
+ GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
+
+ virtual size_t
+ GetSoftwareBreakpointTrapOpcode (Target &target,
+ BreakpointSite *bp_site);
+
+ virtual lldb::ProcessSP
+ Attach(lldb::pid_t pid, Debugger &debugger, Target *target,
+ Listener &listener, Error &error);
+
+ protected:
+
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN (PlatformFreeBSD);
+ };
+} // namespace lldb_private
+
+#endif // liblldb_PlatformFreeBSD_h_
diff --git a/source/Plugins/Platform/Makefile b/source/Plugins/Platform/Makefile
index 38dc2de..cf4f4bf 100644
--- a/source/Plugins/Platform/Makefile
+++ b/source/Plugins/Platform/Makefile
@@ -19,6 +19,10 @@
ifeq ($(HOST_OS),Linux)
DIRS += Linux
-endif
+endif
+
+ifeq ($(HOST_OS),FreeBSD)
+ DIRS += FreeBSD
+endif
include $(LLDB_LEVEL)/Makefile
diff --git a/source/lldb.cpp b/source/lldb.cpp
index ec3495a..b6610b7 100644
--- a/source/lldb.cpp
+++ b/source/lldb.cpp
@@ -56,6 +56,10 @@
#include "Plugins/Process/Linux/ProcessLinux.h"
#endif
+#if defined (__FreeBSD__)
+#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
+#endif
+
#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
@@ -116,6 +120,9 @@
ProcessLinux::Initialize();
DynamicLoaderLinuxDYLD::Initialize();
#endif
+#if defined (__FreeBSD__)
+ PlatformFreeBSD::Initialize();
+#endif
//----------------------------------------------------------------------
// Platform agnostic plugins
//----------------------------------------------------------------------
@@ -181,6 +188,10 @@
ProcessLinux::Terminate();
DynamicLoaderLinuxDYLD::Terminate();
#endif
+
+#if defined (__FreeBSD__)
+ PlatformFreeBSD::Terminate();
+#endif
DynamicLoaderStatic::Terminate();