]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ProcessInfo.h
Merge from upstream at 4189ef5d from https://github.com/onetrueawk/awk.git
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / ProcessInfo.h
1 //===-- ProcessInfo.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_ProcessInfo_h_
11 #define liblldb_ProcessInfo_h_
12
13 // LLDB headers
14 #include "lldb/Utility/ArchSpec.h"
15 #include "lldb/Utility/Args.h"
16 #include "lldb/Utility/Environment.h"
17 #include "lldb/Utility/FileSpec.h"
18
19 namespace lldb_private {
20 //----------------------------------------------------------------------
21 // ProcessInfo
22 //
23 // A base class for information for a process. This can be used to fill
24 // out information for a process prior to launching it, or it can be used for
25 // an instance of a process and can be filled in with the existing values for
26 // that process.
27 //----------------------------------------------------------------------
28 class ProcessInfo {
29 public:
30   ProcessInfo();
31
32   ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid);
33
34   void Clear();
35
36   const char *GetName() const;
37
38   size_t GetNameLength() const;
39
40   FileSpec &GetExecutableFile() { return m_executable; }
41
42   void SetExecutableFile(const FileSpec &exe_file,
43                          bool add_exe_file_as_first_arg);
44
45   const FileSpec &GetExecutableFile() const { return m_executable; }
46
47   uint32_t GetUserID() const { return m_uid; }
48
49   uint32_t GetGroupID() const { return m_gid; }
50
51   bool UserIDIsValid() const { return m_uid != UINT32_MAX; }
52
53   bool GroupIDIsValid() const { return m_gid != UINT32_MAX; }
54
55   void SetUserID(uint32_t uid) { m_uid = uid; }
56
57   void SetGroupID(uint32_t gid) { m_gid = gid; }
58
59   ArchSpec &GetArchitecture() { return m_arch; }
60
61   const ArchSpec &GetArchitecture() const { return m_arch; }
62
63   void SetArchitecture(const ArchSpec &arch) { m_arch = arch; }
64
65   lldb::pid_t GetProcessID() const { return m_pid; }
66
67   void SetProcessID(lldb::pid_t pid) { m_pid = pid; }
68
69   bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; }
70
71   void Dump(Stream &s, Platform *platform) const;
72
73   Args &GetArguments() { return m_arguments; }
74
75   const Args &GetArguments() const { return m_arguments; }
76
77   llvm::StringRef GetArg0() const;
78
79   void SetArg0(llvm::StringRef arg);
80
81   void SetArguments(const Args &args, bool first_arg_is_executable);
82
83   void SetArguments(char const **argv, bool first_arg_is_executable);
84
85   Environment &GetEnvironment() { return m_environment; }
86   const Environment &GetEnvironment() const { return m_environment; }
87
88 protected:
89   FileSpec m_executable;
90   std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
91   // Not all process plug-ins support specifying an argv[0] that differs from
92   // the resolved platform executable (which is in m_executable)
93   Args m_arguments; // All program arguments except argv[0]
94   Environment m_environment;
95   uint32_t m_uid;
96   uint32_t m_gid;
97   ArchSpec m_arch;
98   lldb::pid_t m_pid;
99 };
100 }
101
102 #endif // #ifndef liblldb_ProcessInfo_h_