blob: 6118a0976f7d38ca4b93c83bbf65bcdf2b93220e [file] [log] [blame]
Stephen Wilsonf6f40332010-07-24 02:19:04 +00001//===-- ProcessLinux.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
Stephen Wilsond1fbbb42011-03-23 02:14:42 +000011#include <errno.h>
12
Stephen Wilsonf6f40332010-07-24 02:19:04 +000013// C++ Includes
14// Other libraries and framework includes
15#include "lldb/Core/PluginManager.h"
Peter Collingbournead115462011-06-03 20:40:44 +000016#include "lldb/Core/State.h"
Stephen Wilsonf6f40332010-07-24 02:19:04 +000017#include "lldb/Host/Host.h"
18#include "lldb/Symbol/ObjectFile.h"
Stephen Wilson92241ef2011-01-16 19:45:39 +000019#include "lldb/Target/DynamicLoader.h"
Stephen Wilsonf6f40332010-07-24 02:19:04 +000020#include "lldb/Target/Target.h"
21
22#include "ProcessLinux.h"
Johnny Chen7e996472012-01-05 19:17:38 +000023#include "ProcessPOSIXLog.h"
Peter Collingbournead115462011-06-03 20:40:44 +000024#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
Stephen Wilsonf6f40332010-07-24 02:19:04 +000025#include "ProcessMonitor.h"
Johnny Chen7e996472012-01-05 19:17:38 +000026#include "POSIXThread.h"
Stephen Wilsonf6f40332010-07-24 02:19:04 +000027
28using namespace lldb;
29using namespace lldb_private;
30
31//------------------------------------------------------------------------------
32// Static functions.
33
Greg Claytone5eaa302012-02-21 18:40:07 +000034ProcessSP
35ProcessLinux::CreateInstance(Target &target, Listener &listener, const FileSpec *)
Stephen Wilsonf6f40332010-07-24 02:19:04 +000036{
Greg Claytone5eaa302012-02-21 18:40:07 +000037 return ProcessSP(new ProcessLinux(target, listener));
Stephen Wilsonf6f40332010-07-24 02:19:04 +000038}
39
40void
41ProcessLinux::Initialize()
42{
43 static bool g_initialized = false;
44
45 if (!g_initialized)
46 {
Johnny Chenac51e9f2011-10-11 21:21:57 +000047 g_initialized = true;
Stephen Wilsonf6f40332010-07-24 02:19:04 +000048 PluginManager::RegisterPlugin(GetPluginNameStatic(),
49 GetPluginDescriptionStatic(),
50 CreateInstance);
Johnny Chenac51e9f2011-10-11 21:21:57 +000051
52 Log::Callbacks log_callbacks = {
Johnny Chen7e996472012-01-05 19:17:38 +000053 ProcessPOSIXLog::DisableLog,
54 ProcessPOSIXLog::EnableLog,
55 ProcessPOSIXLog::ListLogCategories
Johnny Chenac51e9f2011-10-11 21:21:57 +000056 };
57
58 Log::RegisterLogChannel (ProcessLinux::GetPluginNameStatic(), log_callbacks);
Johnny Chen7e996472012-01-05 19:17:38 +000059 ProcessPOSIXLog::RegisterPluginName(GetPluginNameStatic());
Stephen Wilsonf6f40332010-07-24 02:19:04 +000060 }
61}
62
Stephen Wilsonf6f40332010-07-24 02:19:04 +000063//------------------------------------------------------------------------------
64// Constructors and destructors.
65
66ProcessLinux::ProcessLinux(Target& target, Listener &listener)
Johnny Chen7e996472012-01-05 19:17:38 +000067 : ProcessPOSIX(target, listener)
Stephen Wilsonf6f40332010-07-24 02:19:04 +000068{
Greg Claytonce65d2f2011-11-05 01:09:16 +000069#if 0
Stephen Wilsonf6f40332010-07-24 02:19:04 +000070 // FIXME: Putting this code in the ctor and saving the byte order in a
71 // member variable is a hack to avoid const qual issues in GetByteOrder.
72 ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
73 m_byte_order = obj_file->GetByteOrder();
Greg Claytonce65d2f2011-11-05 01:09:16 +000074#else
75 // XXX: Will work only for local processes.
76 m_byte_order = lldb::endian::InlHostByteOrder();
77#endif
Stephen Wilsonf6f40332010-07-24 02:19:04 +000078}
79
Stephen Wilson92241ef2011-01-16 19:45:39 +000080void
Johnny Chen7e996472012-01-05 19:17:38 +000081ProcessLinux::Terminate()
Stephen Wilson92241ef2011-01-16 19:45:39 +000082{
Stephen Wilson92241ef2011-01-16 19:45:39 +000083}
Johnny Chen7e996472012-01-05 19:17:38 +000084const char *
85ProcessLinux::GetPluginNameStatic()
Stephen Wilsonf6f40332010-07-24 02:19:04 +000086{
Johnny Chen7e996472012-01-05 19:17:38 +000087 return "linux";
Stephen Wilsonf6f40332010-07-24 02:19:04 +000088}
89
Johnny Chen7e996472012-01-05 19:17:38 +000090const char *
91ProcessLinux::GetPluginDescriptionStatic()
Stephen Wilson01316422011-01-15 00:10:37 +000092{
Johnny Chen7e996472012-01-05 19:17:38 +000093 return "Process plugin for Linux";
Stephen Wilson01316422011-01-15 00:10:37 +000094}
95
Stephen Wilsonf6f40332010-07-24 02:19:04 +000096
Greg Claytonc8dd5702012-04-12 19:04:34 +000097bool
Johnny Chenb8f74aa2011-10-10 23:11:50 +000098ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
99{
Matt Kopecf1fda372013-01-08 16:30:18 +0000100 new_thread_list = old_thread_list;
Greg Claytonc8dd5702012-04-12 19:04:34 +0000101 return new_thread_list.GetSize(false) > 0;
Johnny Chenb8f74aa2011-10-10 23:11:50 +0000102}
103
Stephen Wilsond1fbbb42011-03-23 02:14:42 +0000104
Stephen Wilsonf6f40332010-07-24 02:19:04 +0000105//------------------------------------------------------------------------------
106// ProcessInterface protocol.
107
108const char *
109ProcessLinux::GetPluginName()
110{
111 return "process.linux";
112}
113
114const char *
115ProcessLinux::GetShortPluginName()
116{
117 return "process.linux";
118}
119
120uint32_t
121ProcessLinux::GetPluginVersion()
122{
123 return 1;
124}
125
126void
127ProcessLinux::GetPluginCommandHelp(const char *command, Stream *strm)
128{
129}
130
131Error
132ProcessLinux::ExecutePluginCommand(Args &command, Stream *strm)
133{
134 return Error(1, eErrorTypeGeneric);
135}
136
137Log *
138ProcessLinux::EnablePluginLogging(Stream *strm, Args &command)
139{
140 return NULL;
141}