ProcessLinux.h revision 3a80431855f12a4397707176e6947f4b0033cae7
1//===-- ProcessLinux.h ------------------------------------------*- 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#ifndef liblldb_ProcessLinux_H_
11#define liblldb_ProcessLinux_H_
12
13// C Includes
14
15// C++ Includes
16#include <queue>
17
18// Other libraries and framework includes
19#include "lldb/Target/Process.h"
20#include "ProcessMessage.h"
21
22class ProcessMonitor;
23
24class ProcessLinux :
25    public lldb_private::Process
26{
27public:
28    //------------------------------------------------------------------
29    // Static functions.
30    //------------------------------------------------------------------
31    static Process*
32    CreateInstance(lldb_private::Target& target,
33                   lldb_private::Listener &listener);
34
35    static void
36    Initialize();
37
38    static void
39    Terminate();
40
41    static const char *
42    GetPluginNameStatic();
43
44    static const char *
45    GetPluginDescriptionStatic();
46
47    //------------------------------------------------------------------
48    // Constructors and destructors
49    //------------------------------------------------------------------
50    ProcessLinux(lldb_private::Target& target,
51                 lldb_private::Listener &listener);
52
53    virtual
54    ~ProcessLinux();
55
56    //------------------------------------------------------------------
57    // Process protocol.
58    //------------------------------------------------------------------
59    virtual bool
60    CanDebug(lldb_private::Target &target);
61
62    virtual lldb_private::Error
63    DoAttachToProcessWithID(lldb::pid_t pid);
64
65    virtual lldb_private::Error
66    DoLaunch(lldb_private::Module *module,
67             char const *argv[],
68             char const *envp[],
69             uint32_t launch_flags,
70             const char *stdin_path,
71             const char *stdout_path,
72             const char *stderr_path);
73
74    virtual void
75    DidLaunch();
76
77    virtual lldb_private::Error
78    DoResume();
79
80    virtual lldb_private::Error
81    DoHalt(bool &caused_stop);
82
83    virtual lldb_private::Error
84    DoDetach();
85
86    virtual lldb_private::Error
87    DoSignal(int signal);
88
89    virtual lldb_private::Error
90    DoDestroy();
91
92    virtual void
93    RefreshStateAfterStop();
94
95    virtual bool
96    IsAlive();
97
98    virtual size_t
99    DoReadMemory(lldb::addr_t vm_addr,
100                 void *buf,
101                 size_t size,
102                 lldb_private::Error &error);
103
104    virtual size_t
105    DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
106                  lldb_private::Error &error);
107
108    virtual lldb::addr_t
109    DoAllocateMemory(size_t size, uint32_t permissions,
110                     lldb_private::Error &error);
111
112    lldb::addr_t
113    AllocateMemory(size_t size, uint32_t permissions,
114                   lldb_private::Error &error);
115
116    virtual lldb_private::Error
117    DoDeallocateMemory(lldb::addr_t ptr);
118
119    virtual size_t
120    GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
121
122    virtual lldb_private::Error
123    EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
124
125    virtual lldb_private::Error
126    DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
127
128    virtual uint32_t
129    UpdateThreadListIfNeeded();
130
131    virtual lldb::ByteOrder
132    GetByteOrder() const;
133
134    //------------------------------------------------------------------
135    // PluginInterface protocol
136    //------------------------------------------------------------------
137    virtual const char *
138    GetPluginName();
139
140    virtual const char *
141    GetShortPluginName();
142
143    virtual uint32_t
144    GetPluginVersion();
145
146    virtual void
147    GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
148
149    virtual lldb_private::Error
150    ExecutePluginCommand(lldb_private::Args &command,
151                         lldb_private::Stream *strm);
152
153    virtual lldb_private::Log *
154    EnablePluginLogging(lldb_private::Stream *strm,
155                        lldb_private::Args &command);
156
157    //--------------------------------------------------------------------------
158    // ProcessLinux internal API.
159
160    /// Registers the given message with this process.
161    void SendMessage(const ProcessMessage &message);
162
163    ProcessMonitor &GetMonitor() { return *m_monitor; }
164
165private:
166    /// Target byte order.
167    lldb::ByteOrder m_byte_order;
168
169    /// Process monitor;
170    ProcessMonitor *m_monitor;
171
172    /// The module we are executing.
173    lldb_private::Module *m_module;
174
175    /// Message queue notifying this instance of inferior process state changes.
176    lldb_private::Mutex m_message_mutex;
177    std::queue<ProcessMessage> m_message_queue;
178
179    /// Updates the loaded sections provided by the executable.
180    ///
181    /// FIXME:  It would probably be better to delegate this task to the
182    /// DynamicLoader plugin, when we have one.
183    void UpdateLoadedSections();
184
185    /// Returns true if the process has exited.
186    bool HasExited();
187};
188
189#endif  // liblldb_MacOSXProcess_H_
190