Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame^] | 1 | //===-- ProcessFreeBSD.cpp ----------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // C Includes |
| 11 | #include <errno.h> |
| 12 | |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | #include "lldb/Core/PluginManager.h" |
| 16 | #include "lldb/Core/State.h" |
| 17 | #include "lldb/Host/Host.h" |
| 18 | #include "lldb/Symbol/ObjectFile.h" |
| 19 | #include "lldb/Target/DynamicLoader.h" |
| 20 | #include "lldb/Target/Target.h" |
| 21 | |
| 22 | #include "ProcessFreeBSD.h" |
| 23 | #include "ProcessPOSIXLog.h" |
| 24 | #include "Plugins/Process/Utility/InferiorCallPOSIX.h" |
| 25 | #include "ProcessMonitor.h" |
| 26 | #include "POSIXThread.h" |
| 27 | |
| 28 | using namespace lldb; |
| 29 | using namespace lldb_private; |
| 30 | |
| 31 | //------------------------------------------------------------------------------ |
| 32 | // Static functions. |
| 33 | |
| 34 | Process* |
| 35 | ProcessFreeBSD::CreateInstance(Target& target, Listener &listener) |
| 36 | { |
| 37 | return new ProcessFreeBSD(target, listener); |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | ProcessFreeBSD::Initialize() |
| 42 | { |
| 43 | static bool g_initialized = false; |
| 44 | |
| 45 | if (!g_initialized) |
| 46 | { |
| 47 | PluginManager::RegisterPlugin(GetPluginNameStatic(), |
| 48 | GetPluginDescriptionStatic(), |
| 49 | CreateInstance); |
| 50 | Log::Callbacks log_callbacks = { |
| 51 | ProcessPOSIXLog::DisableLog, |
| 52 | ProcessPOSIXLog::EnableLog, |
| 53 | ProcessPOSIXLog::ListLogCategories |
| 54 | }; |
| 55 | |
| 56 | Log::RegisterLogChannel (ProcessFreeBSD::GetPluginNameStatic(), log_callbacks); |
| 57 | ProcessPOSIXLog::RegisterPluginName(GetPluginNameStatic()); |
| 58 | g_initialized = true; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | const char * |
| 63 | ProcessFreeBSD::GetPluginNameStatic() |
| 64 | { |
| 65 | return "freebsd"; |
| 66 | } |
| 67 | |
| 68 | const char * |
| 69 | ProcessFreeBSD::GetPluginDescriptionStatic() |
| 70 | { |
| 71 | return "Process plugin for FreeBSD"; |
| 72 | } |
| 73 | |
| 74 | //------------------------------------------------------------------------------ |
| 75 | // ProcessInterface protocol. |
| 76 | |
| 77 | const char * |
| 78 | ProcessFreeBSD::GetPluginName() |
| 79 | { |
| 80 | return "process.freebsd"; |
| 81 | } |
| 82 | |
| 83 | const char * |
| 84 | ProcessFreeBSD::GetShortPluginName() |
| 85 | { |
| 86 | return "process.freebsd"; |
| 87 | } |
| 88 | |
| 89 | uint32_t |
| 90 | ProcessFreeBSD::GetPluginVersion() |
| 91 | { |
| 92 | return 1; |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | ProcessFreeBSD::GetPluginCommandHelp(const char *command, Stream *strm) |
| 97 | { |
| 98 | } |
| 99 | |
| 100 | Error |
| 101 | ProcessFreeBSD::ExecutePluginCommand(Args &command, Stream *strm) |
| 102 | { |
| 103 | return Error(1, eErrorTypeGeneric); |
| 104 | } |
| 105 | |
| 106 | Log * |
| 107 | ProcessFreeBSD::EnablePluginLogging(Stream *strm, Args &command) |
| 108 | { |
| 109 | return NULL; |
| 110 | } |
| 111 | |
| 112 | //------------------------------------------------------------------------------ |
| 113 | // Constructors and destructors. |
| 114 | |
| 115 | ProcessFreeBSD::ProcessFreeBSD(Target& target, Listener &listener) |
| 116 | : ProcessPOSIX(target, listener) |
| 117 | { |
| 118 | // FIXME: Putting this code in the ctor and saving the byte order in a |
| 119 | // member variable is a hack to avoid const qual issues in GetByteOrder. |
| 120 | ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile(); |
| 121 | m_byte_order = obj_file->GetByteOrder(); |
| 122 | } |
| 123 | |
| 124 | void |
| 125 | ProcessFreeBSD::Terminate() |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | uint32_t |
| 130 | ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) |
| 131 | { |
| 132 | // XXX haxx |
| 133 | new_thread_list = old_thread_list; |
| 134 | |
| 135 | return 0; |
| 136 | } |