1254721Semaste//===-- Host.h --------------------------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_Host_h_
11254721Semaste#define liblldb_Host_h_
12254721Semaste#if defined(__cplusplus)
13254721Semaste
14254721Semaste#include <stdarg.h>
15254721Semaste
16254721Semaste#include <map>
17254721Semaste#include <string>
18254721Semaste
19254721Semaste#include "lldb/lldb-private.h"
20254721Semaste#include "lldb/Core/StringList.h"
21263363Semaste#include "lldb/Host/File.h"
22254721Semaste
23254721Semastenamespace lldb_private {
24254721Semaste
25254721Semaste//----------------------------------------------------------------------
26254721Semaste/// @class Host Host.h "lldb/Host/Host.h"
27254721Semaste/// @brief A class that provides host computer information.
28254721Semaste///
29254721Semaste/// Host is a class that answers information about the host operating
30254721Semaste/// system.
31254721Semaste//----------------------------------------------------------------------
32254721Semasteclass Host
33254721Semaste{
34254721Semastepublic:
35254721Semaste    typedef bool (*MonitorChildProcessCallback) (void *callback_baton,
36254721Semaste                                                 lldb::pid_t pid,
37254721Semaste                                                 bool exited,
38254721Semaste                                                 int signal,    // Zero for no signal
39254721Semaste                                                 int status);   // Exit value of process if signal is zero
40254721Semaste
41254721Semaste    //------------------------------------------------------------------
42254721Semaste    /// Start monitoring a child process.
43254721Semaste    ///
44254721Semaste    /// Allows easy monitoring of child processes. \a callback will be
45254721Semaste    /// called when the child process exits or if it gets a signal. The
46254721Semaste    /// callback will only be called with signals if \a monitor_signals
47254721Semaste    /// is \b true. \a callback will usually be called from another
48254721Semaste    /// thread so the callback function must be thread safe.
49254721Semaste    ///
50254721Semaste    /// When the callback gets called, the return value indicates if
51254721Semaste    /// minotoring should stop. If \b true is returned from \a callback
52254721Semaste    /// the information will be removed. If \b false is returned then
53254721Semaste    /// monitoring will continue. If the child process exits, the
54254721Semaste    /// monitoring will automatically stop after the callback returned
55254721Semaste    /// ragardless of the callback return value.
56254721Semaste    ///
57254721Semaste    /// @param[in] callback
58254721Semaste    ///     A function callback to call when a child receives a signal
59254721Semaste    ///     (if \a monitor_signals is true) or a child exits.
60254721Semaste    ///
61254721Semaste    /// @param[in] callback_baton
62254721Semaste    ///     A void * of user data that will be pass back when
63254721Semaste    ///     \a callback is called.
64254721Semaste    ///
65254721Semaste    /// @param[in] pid
66254721Semaste    ///     The process ID of a child process to monitor, -1 for all
67254721Semaste    ///     processes.
68254721Semaste    ///
69254721Semaste    /// @param[in] monitor_signals
70254721Semaste    ///     If \b true the callback will get called when the child
71254721Semaste    ///     process gets a signal. If \b false, the callback will only
72254721Semaste    ///     get called if the child process exits.
73254721Semaste    ///
74254721Semaste    /// @return
75254721Semaste    ///     A thread handle that can be used to cancel the thread that
76254721Semaste    ///     was spawned to monitor \a pid.
77254721Semaste    ///
78254721Semaste    /// @see static void Host::StopMonitoringChildProcess (uint32_t)
79254721Semaste    //------------------------------------------------------------------
80254721Semaste    static lldb::thread_t
81254721Semaste    StartMonitoringChildProcess (MonitorChildProcessCallback callback,
82254721Semaste                                 void *callback_baton,
83254721Semaste                                 lldb::pid_t pid,
84254721Semaste                                 bool monitor_signals);
85254721Semaste
86254721Semaste    //------------------------------------------------------------------
87254721Semaste    /// Get the host page size.
88254721Semaste    ///
89254721Semaste    /// @return
90254721Semaste    ///     The size in bytes of a VM page on the host system.
91254721Semaste    //------------------------------------------------------------------
92254721Semaste    static size_t
93254721Semaste    GetPageSize();
94254721Semaste
95254721Semaste    //------------------------------------------------------------------
96254721Semaste    /// Returns the endianness of the host system.
97254721Semaste    ///
98254721Semaste    /// @return
99254721Semaste    ///     Returns the endianness of the host system as a lldb::ByteOrder
100254721Semaste    ///     enumeration.
101254721Semaste    //------------------------------------------------------------------
102254721Semaste    static lldb::ByteOrder
103254721Semaste    GetByteOrder ();
104254721Semaste
105254721Semaste    //------------------------------------------------------------------
106254721Semaste    /// Returns the number of CPUs on this current host.
107254721Semaste    ///
108254721Semaste    /// @return
109254721Semaste    ///     Number of CPUs on this current host, or zero if the number
110254721Semaste    ///     of CPUs can't be determined on this host.
111254721Semaste    //------------------------------------------------------------------
112254721Semaste    static uint32_t
113254721Semaste    GetNumberCPUS ();
114254721Semaste
115254721Semaste    static bool
116254721Semaste    GetOSVersion (uint32_t &major,
117254721Semaste                  uint32_t &minor,
118254721Semaste                  uint32_t &update);
119254721Semaste
120254721Semaste    static bool
121254721Semaste    GetOSBuildString (std::string &s);
122254721Semaste
123254721Semaste    static bool
124254721Semaste    GetOSKernelDescription (std::string &s);
125254721Semaste
126254721Semaste    static bool
127254721Semaste    GetHostname (std::string &s);
128254721Semaste
129254721Semaste    static const char *
130254721Semaste    GetUserName (uint32_t uid, std::string &user_name);
131254721Semaste
132254721Semaste    static const char *
133254721Semaste    GetGroupName (uint32_t gid, std::string &group_name);
134254721Semaste
135254721Semaste    static uint32_t
136254721Semaste    GetUserID ();
137254721Semaste
138254721Semaste    static uint32_t
139254721Semaste    GetGroupID ();
140254721Semaste
141254721Semaste    static uint32_t
142254721Semaste    GetEffectiveUserID ();
143254721Semaste
144254721Semaste    static uint32_t
145254721Semaste    GetEffectiveGroupID ();
146254721Semaste
147254721Semaste
148254721Semaste    enum SystemLogType
149254721Semaste    {
150254721Semaste        eSystemLogWarning,
151254721Semaste        eSystemLogError
152254721Semaste    };
153254721Semaste
154254721Semaste    static void
155254721Semaste    SystemLog (SystemLogType type, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
156254721Semaste
157254721Semaste    static void
158254721Semaste    SystemLog (SystemLogType type, const char *format, va_list args);
159254721Semaste
160254721Semaste    //------------------------------------------------------------------
161254721Semaste    /// Gets the host architecture.
162254721Semaste    ///
163254721Semaste    /// @return
164254721Semaste    ///     A const architecture object that represents the host
165254721Semaste    ///     architecture.
166254721Semaste    //------------------------------------------------------------------
167254721Semaste    enum SystemDefaultArchitecture
168254721Semaste    {
169254721Semaste        eSystemDefaultArchitecture,     // The overall default architecture that applications will run on this host
170254721Semaste        eSystemDefaultArchitecture32,   // If this host supports 32 bit programs, return the default 32 bit arch
171254721Semaste        eSystemDefaultArchitecture64    // If this host supports 64 bit programs, return the default 64 bit arch
172254721Semaste    };
173254721Semaste
174254721Semaste    static const ArchSpec &
175254721Semaste    GetArchitecture (SystemDefaultArchitecture arch_kind = eSystemDefaultArchitecture);
176254721Semaste
177254721Semaste    //------------------------------------------------------------------
178254721Semaste    /// Gets the host vendor string.
179254721Semaste    ///
180254721Semaste    /// @return
181254721Semaste    ///     A const string object containing the host vendor name.
182254721Semaste    //------------------------------------------------------------------
183254721Semaste    static const ConstString &
184254721Semaste    GetVendorString ();
185254721Semaste
186254721Semaste    //------------------------------------------------------------------
187254721Semaste    /// Gets the host Operating System (OS) string.
188254721Semaste    ///
189254721Semaste    /// @return
190254721Semaste    ///     A const string object containing the host OS name.
191254721Semaste    //------------------------------------------------------------------
192254721Semaste    static const ConstString &
193254721Semaste    GetOSString ();
194254721Semaste
195254721Semaste    //------------------------------------------------------------------
196254721Semaste    /// Gets the host target triple as a const string.
197254721Semaste    ///
198254721Semaste    /// @return
199254721Semaste    ///     A const string object containing the host target triple.
200254721Semaste    //------------------------------------------------------------------
201254721Semaste    static const ConstString &
202254721Semaste    GetTargetTriple ();
203254721Semaste
204254721Semaste    //------------------------------------------------------------------
205269024Semaste    /// Gets the name of the distribution (i.e. distributor id).
206269024Semaste    ///
207269024Semaste    /// On Linux, this will return the equivalent of lsb_release -i.
208269024Semaste    /// Android will return 'android'.  Other systems may return
209269024Semaste    /// nothing.
210269024Semaste    ///
211269024Semaste    /// @return
212269024Semaste    ///     A ConstString reference containing the OS distribution id.
213269024Semaste    ///     The return string will be all lower case, with whitespace
214269024Semaste    ///     replaced with underscores.  The return string will be
215269024Semaste    ///     empty (result.AsCString() will return NULL) if the distribution
216269024Semaste    ///     cannot be obtained.
217269024Semaste    //------------------------------------------------------------------
218269024Semaste    static const ConstString &
219269024Semaste    GetDistributionId ();
220269024Semaste
221269024Semaste    //------------------------------------------------------------------
222254721Semaste    /// Get the process ID for the calling process.
223254721Semaste    ///
224254721Semaste    /// @return
225254721Semaste    ///     The process ID for the current process.
226254721Semaste    //------------------------------------------------------------------
227254721Semaste    static lldb::pid_t
228254721Semaste    GetCurrentProcessID ();
229254721Semaste
230263363Semaste    static void
231263363Semaste    Kill(lldb::pid_t pid, int signo);
232263363Semaste
233254721Semaste    //------------------------------------------------------------------
234254721Semaste    /// Get the thread ID for the calling thread in the current process.
235254721Semaste    ///
236254721Semaste    /// @return
237254721Semaste    ///     The thread ID for the calling thread in the current process.
238254721Semaste    //------------------------------------------------------------------
239254721Semaste    static lldb::tid_t
240254721Semaste    GetCurrentThreadID ();
241254721Semaste
242254721Semaste    //------------------------------------------------------------------
243254721Semaste    /// Get the thread token (the one returned by ThreadCreate when the thread was created) for the
244254721Semaste    /// calling thread in the current process.
245254721Semaste    ///
246254721Semaste    /// @return
247254721Semaste    ///     The thread token for the calling thread in the current process.
248254721Semaste    //------------------------------------------------------------------
249254721Semaste    static lldb::thread_t
250254721Semaste    GetCurrentThread ();
251254721Semaste
252254721Semaste    static const char *
253254721Semaste    GetSignalAsCString (int signo);
254254721Semaste
255254721Semaste    static void
256254721Semaste    WillTerminate ();
257254721Semaste    //------------------------------------------------------------------
258254721Semaste    /// Host specific thread created function call.
259254721Semaste    ///
260254721Semaste    /// This function call lets the current host OS do any thread
261254721Semaste    /// specific initialization that it needs, including naming the
262254721Semaste    /// thread. No cleanup routine is exptected to be called
263254721Semaste    ///
264254721Semaste    /// @param[in] name
265254721Semaste    ///     The current thread's name in the current process.
266254721Semaste    //------------------------------------------------------------------
267254721Semaste    static void
268254721Semaste    ThreadCreated (const char *name);
269254721Semaste
270254721Semaste    static lldb::thread_t
271254721Semaste    ThreadCreate (const char *name,
272254721Semaste                  lldb::thread_func_t function,
273254721Semaste                  lldb::thread_arg_t thread_arg,
274254721Semaste                  Error *err);
275254721Semaste
276254721Semaste    static bool
277254721Semaste    ThreadCancel (lldb::thread_t thread,
278254721Semaste                  Error *error);
279254721Semaste
280254721Semaste    static bool
281254721Semaste    ThreadDetach (lldb::thread_t thread,
282254721Semaste                  Error *error);
283254721Semaste    static bool
284254721Semaste    ThreadJoin (lldb::thread_t thread,
285254721Semaste                lldb::thread_result_t *thread_result_ptr,
286254721Semaste                Error *error);
287254721Semaste
288263363Semaste    typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
289263363Semaste
290263363Semaste    static lldb::thread_key_t
291263363Semaste    ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback);
292263363Semaste
293263363Semaste    static void*
294263363Semaste    ThreadLocalStorageGet(lldb::thread_key_t key);
295263363Semaste
296263363Semaste    static void
297263363Semaste    ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
298263363Semaste
299254721Semaste    //------------------------------------------------------------------
300254721Semaste    /// Gets the name of a thread in a process.
301254721Semaste    ///
302254721Semaste    /// This function will name a thread in a process using it's own
303254721Semaste    /// thread name pool, and also will attempt to set a thread name
304254721Semaste    /// using any supported host OS APIs.
305254721Semaste    ///
306254721Semaste    /// @param[in] pid
307254721Semaste    ///     The process ID in which we are trying to get the name of
308254721Semaste    ///     a thread.
309254721Semaste    ///
310254721Semaste    /// @param[in] tid
311254721Semaste    ///     The thread ID for which we are trying retrieve the name of.
312254721Semaste    ///
313254721Semaste    /// @return
314254721Semaste    ///     A std::string containing the thread name.
315254721Semaste    //------------------------------------------------------------------
316254721Semaste    static std::string
317254721Semaste    GetThreadName (lldb::pid_t pid, lldb::tid_t tid);
318254721Semaste
319254721Semaste    //------------------------------------------------------------------
320254721Semaste    /// Sets the name of a thread in the current process.
321254721Semaste    ///
322254721Semaste    /// @param[in] pid
323254721Semaste    ///     The process ID in which we are trying to name a thread.
324254721Semaste    ///
325254721Semaste    /// @param[in] tid
326254721Semaste    ///     The thread ID which we are trying to name.
327254721Semaste    ///
328254721Semaste    /// @param[in] name
329254721Semaste    ///     The current thread's name in the current process to \a name.
330254721Semaste    ///
331254721Semaste    /// @return
332254721Semaste    ///     \b true if the thread name was able to be set, \b false
333254721Semaste    ///     otherwise.
334254721Semaste    //------------------------------------------------------------------
335254721Semaste    static bool
336254721Semaste    SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name);
337254721Semaste
338254721Semaste    //------------------------------------------------------------------
339254721Semaste    /// Sets a shortened name of a thread in the current process.
340254721Semaste    ///
341254721Semaste    /// @param[in] pid
342254721Semaste    ///     The process ID in which we are trying to name a thread.
343254721Semaste    ///
344254721Semaste    /// @param[in] tid
345254721Semaste    ///     The thread ID which we are trying to name.
346254721Semaste    ///
347254721Semaste    /// @param[in] name
348254721Semaste    ///     The current thread's name in the current process to \a name.
349254721Semaste    ///
350254721Semaste    /// @param[in] len
351254721Semaste    ///     The maximum length for the thread's shortened name.
352254721Semaste    ///
353254721Semaste    /// @return
354254721Semaste    ///     \b true if the thread name was able to be set, \b false
355254721Semaste    ///     otherwise.
356254721Semaste    static bool
357254721Semaste    SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name, size_t len);
358254721Semaste
359254721Semaste    //------------------------------------------------------------------
360254721Semaste    /// Gets the FileSpec of the current process (the process that
361254721Semaste    /// that is running the LLDB code).
362254721Semaste    ///
363254721Semaste    /// @return
364254721Semaste    ///     \b A file spec with the program name.
365254721Semaste    //------------------------------------------------------------------
366254721Semaste    static FileSpec
367254721Semaste    GetProgramFileSpec ();
368254721Semaste
369254721Semaste    //------------------------------------------------------------------
370254721Semaste    /// Given an address in the current process (the process that
371254721Semaste    /// is running the LLDB code), return the name of the module that
372254721Semaste    /// it comes from. This can be useful when you need to know the
373254721Semaste    /// path to the shared library that your code is running in for
374254721Semaste    /// loading resources that are relative to your binary.
375254721Semaste    ///
376254721Semaste    /// @param[in] host_addr
377254721Semaste    ///     The pointer to some code in the current process.
378254721Semaste    ///
379254721Semaste    /// @return
380254721Semaste    ///     \b A file spec with the module that contains \a host_addr,
381254721Semaste    ///     which may be invalid if \a host_addr doesn't fall into
382254721Semaste    ///     any valid module address range.
383254721Semaste    //------------------------------------------------------------------
384254721Semaste    static FileSpec
385254721Semaste    GetModuleFileSpecForHostAddress (const void *host_addr);
386254721Semaste
387254721Semaste
388254721Semaste
389254721Semaste    //------------------------------------------------------------------
390254721Semaste    /// If you have an executable that is in a bundle and want to get
391254721Semaste    /// back to the bundle directory from the path itself, this
392254721Semaste    /// function will change a path to a file within a bundle to the
393254721Semaste    /// bundle directory itself.
394254721Semaste    ///
395254721Semaste    /// @param[in] file
396254721Semaste    ///     A file spec that might point to a file in a bundle.
397254721Semaste    ///
398254721Semaste    /// @param[out] bundle_directory
399254721Semaste    ///     An object will be filled in with the bundle directory for
400254721Semaste    ///     the bundle when \b true is returned. Otherwise \a file is
401254721Semaste    ///     left untouched and \b false is returned.
402254721Semaste    ///
403254721Semaste    /// @return
404254721Semaste    ///     \b true if \a file was resolved in \a bundle_directory,
405254721Semaste    ///     \b false otherwise.
406254721Semaste    //------------------------------------------------------------------
407254721Semaste    static bool
408254721Semaste    GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory);
409254721Semaste
410254721Semaste    //------------------------------------------------------------------
411254721Semaste    /// When executable files may live within a directory, where the
412254721Semaste    /// directory represents an executable bundle (like the MacOSX
413254721Semaste    /// app bundles), the locate the executable within the containing
414254721Semaste    /// bundle.
415254721Semaste    ///
416254721Semaste    /// @param[in,out] file
417254721Semaste    ///     A file spec that currently points to the bundle that will
418254721Semaste    ///     be filled in with the executable path within the bundle
419254721Semaste    ///     if \b true is returned. Otherwise \a file is left untouched.
420254721Semaste    ///
421254721Semaste    /// @return
422254721Semaste    ///     \b true if \a file was resolved, \b false if this function
423254721Semaste    ///     was not able to resolve the path.
424254721Semaste    //------------------------------------------------------------------
425254721Semaste    static bool
426254721Semaste    ResolveExecutableInBundle (FileSpec &file);
427254721Semaste
428254721Semaste    //------------------------------------------------------------------
429254721Semaste    /// Find a resource files that are related to LLDB.
430254721Semaste    ///
431254721Semaste    /// Operating systems have different ways of storing shared
432254721Semaste    /// libraries and related resources. This function abstracts the
433254721Semaste    /// access to these paths.
434254721Semaste    ///
435254721Semaste    /// @param[in] path_type
436254721Semaste    ///     The type of LLDB resource path you are looking for. If the
437254721Semaste    ///     enumeration ends with "Dir", then only the \a file_spec's
438254721Semaste    ///     directory member gets filled in.
439254721Semaste    ///
440254721Semaste    /// @param[in] file_spec
441254721Semaste    ///     A file spec that gets filled in with the appriopriate path.
442254721Semaste    ///
443254721Semaste    /// @return
444254721Semaste    ///     \b true if \a resource_path was resolved, \a false otherwise.
445254721Semaste    //------------------------------------------------------------------
446254721Semaste    static bool
447254721Semaste    GetLLDBPath (PathType path_type,
448254721Semaste                 FileSpec &file_spec);
449254721Semaste
450254721Semaste    //------------------------------------------------------------------
451254721Semaste    /// Set a string that can be displayed if host application crashes.
452254721Semaste    ///
453254721Semaste    /// Some operating systems have the ability to print a description
454254721Semaste    /// for shared libraries when a program crashes. If the host OS
455254721Semaste    /// supports such a mechanism, it should be implemented to help
456254721Semaste    /// with crash triage.
457254721Semaste    ///
458254721Semaste    /// @param[in] format
459254721Semaste    ///     A printf format that will be used to form a new crash
460254721Semaste    ///     description string.
461254721Semaste    //------------------------------------------------------------------
462254721Semaste    static void
463254721Semaste    SetCrashDescriptionWithFormat (const char *format, ...)  __attribute__ ((format (printf, 1, 2)));
464254721Semaste
465254721Semaste    static void
466254721Semaste    SetCrashDescription (const char *description);
467254721Semaste
468254721Semaste    static uint32_t
469254721Semaste    FindProcesses (const ProcessInstanceInfoMatch &match_info,
470254721Semaste                   ProcessInstanceInfoList &proc_infos);
471254721Semaste
472254721Semaste    typedef std::map<lldb::pid_t, bool> TidMap;
473254721Semaste    typedef std::pair<lldb::pid_t, bool> TidPair;
474254721Semaste    static bool
475254721Semaste    FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach);
476254721Semaste
477254721Semaste    static bool
478254721Semaste    GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
479269024Semaste
480269024Semaste#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__)
481269024Semaste    static short
482269024Semaste    GetPosixspawnFlags (ProcessLaunchInfo &launch_info);
483269024Semaste
484269024Semaste    static Error
485269024Semaste    LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_info, ::pid_t &pid);
486269024Semaste#endif
487269024Semaste
488254721Semaste    static lldb::pid_t
489254721Semaste    LaunchApplication (const FileSpec &app_file_spec);
490254721Semaste
491254721Semaste    static Error
492254721Semaste    LaunchProcess (ProcessLaunchInfo &launch_info);
493254721Semaste
494254721Semaste    static Error
495254721Semaste    RunShellCommand (const char *command,           // Shouldn't be NULL
496254721Semaste                     const char *working_dir,       // Pass NULL to use the current working directory
497254721Semaste                     int *status_ptr,               // Pass NULL if you don't want the process exit status
498254721Semaste                     int *signo_ptr,                // Pass NULL if you don't want the signal that caused the process to exit
499254721Semaste                     std::string *command_output,   // Pass NULL if you don't want the command output
500254721Semaste                     uint32_t timeout_sec,
501263363Semaste                     const char *shell = LLDB_DEFAULT_SHELL);
502254721Semaste
503254721Semaste    static lldb::DataBufferSP
504254721Semaste    GetAuxvData (lldb_private::Process *process);
505254721Semaste
506254721Semaste    static lldb::TargetSP
507254721Semaste    GetDummyTarget (Debugger &debugger);
508254721Semaste
509254721Semaste    static bool
510254721Semaste    OpenFileInExternalEditor (const FileSpec &file_spec,
511254721Semaste                              uint32_t line_no);
512254721Semaste
513254721Semaste    static void
514254721Semaste    Backtrace (Stream &strm, uint32_t max_frames);
515254721Semaste
516254721Semaste    static size_t
517254721Semaste    GetEnvironment (StringList &env);
518254721Semaste
519254721Semaste    enum DynamicLibraryOpenOptions
520254721Semaste    {
521254721Semaste        eDynamicLibraryOpenOptionLazy           = (1u << 0),  // Lazily resolve symbols in this dynamic library
522254721Semaste        eDynamicLibraryOpenOptionLocal          = (1u << 1),  // Only open a shared library with local access (hide it from the global symbol namespace)
523254721Semaste        eDynamicLibraryOpenOptionLimitGetSymbol = (1u << 2)   // DynamicLibraryGetSymbol calls on this handle will only return matches from this shared library
524254721Semaste    };
525254721Semaste    static void *
526254721Semaste    DynamicLibraryOpen (const FileSpec &file_spec,
527254721Semaste                        uint32_t options,
528254721Semaste                        Error &error);
529254721Semaste
530254721Semaste    static Error
531254721Semaste    DynamicLibraryClose (void *dynamic_library_handle);
532254721Semaste
533254721Semaste    static void *
534254721Semaste    DynamicLibraryGetSymbol (void *dynamic_library_handle,
535254721Semaste                             const char *symbol_name,
536254721Semaste                             Error &error);
537263363Semaste
538263367Semaste    static Error
539263367Semaste    MakeDirectory (const char* path, uint32_t mode);
540263363Semaste
541263367Semaste    static Error
542263367Semaste    GetFilePermissions (const char* path, uint32_t &file_permissions);
543263367Semaste
544263367Semaste    static Error
545263367Semaste    SetFilePermissions (const char* path, uint32_t file_permissions);
546263367Semaste
547263367Semaste    static Error
548263367Semaste    Symlink (const char *src, const char *dst);
549263367Semaste
550263367Semaste    static Error
551263367Semaste    Readlink (const char *path, char *buf, size_t buf_len);
552263367Semaste
553263367Semaste    static Error
554263367Semaste    Unlink (const char *path);
555263367Semaste
556263363Semaste    static lldb::user_id_t
557263363Semaste    OpenFile (const FileSpec& file_spec,
558263363Semaste              uint32_t flags,
559263367Semaste              uint32_t mode,
560263363Semaste              Error &error);
561263363Semaste
562263363Semaste    static bool
563263363Semaste    CloseFile (lldb::user_id_t fd,
564263363Semaste               Error &error);
565263363Semaste
566263363Semaste    static uint64_t
567263363Semaste    WriteFile (lldb::user_id_t fd,
568263363Semaste               uint64_t offset,
569263363Semaste               const void* src,
570263363Semaste               uint64_t src_len,
571263363Semaste               Error &error);
572263363Semaste
573263363Semaste    static uint64_t
574263363Semaste    ReadFile (lldb::user_id_t fd,
575263363Semaste              uint64_t offset,
576263363Semaste              void* dst,
577263363Semaste              uint64_t dst_len,
578263363Semaste              Error &error);
579263363Semaste
580263363Semaste    static lldb::user_id_t
581263363Semaste    GetFileSize (const FileSpec& file_spec);
582263363Semaste
583263363Semaste    static bool
584263363Semaste    GetFileExists (const FileSpec& file_spec);
585263363Semaste
586263363Semaste    static bool
587263363Semaste    CalculateMD5 (const FileSpec& file_spec,
588263363Semaste                  uint64_t &low,
589263363Semaste                  uint64_t &high);
590263363Semaste
591254721Semaste};
592254721Semaste
593254721Semaste} // namespace lldb_private
594254721Semaste
595254721Semaste#endif  // #if defined(__cplusplus)
596254721Semaste#endif  // liblldb_Host_h_
597