]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/API/SBLaunchInfo.cpp
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / API / SBLaunchInfo.cpp
1 //===-- SBLaunchInfo.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 #include "lldb/API/SBLaunchInfo.h"
11
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/API/SBListener.h"
14 #include "lldb/Target/ProcessLaunchInfo.h"
15
16 using namespace lldb;
17 using namespace lldb_private;
18
19 SBLaunchInfo::SBLaunchInfo(const char **argv)
20     : m_opaque_sp(new ProcessLaunchInfo()) {
21   m_opaque_sp->GetFlags().Reset(eLaunchFlagDebug | eLaunchFlagDisableASLR);
22   if (argv && argv[0])
23     m_opaque_sp->GetArguments().SetArguments(argv);
24 }
25
26 SBLaunchInfo::~SBLaunchInfo() {}
27
28 lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() { return *m_opaque_sp; }
29
30 const lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() const {
31   return *m_opaque_sp;
32 }
33
34 lldb::pid_t SBLaunchInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); }
35
36 uint32_t SBLaunchInfo::GetUserID() { return m_opaque_sp->GetUserID(); }
37
38 uint32_t SBLaunchInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); }
39
40 bool SBLaunchInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); }
41
42 bool SBLaunchInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); }
43
44 void SBLaunchInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); }
45
46 void SBLaunchInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); }
47
48 SBFileSpec SBLaunchInfo::GetExecutableFile() {
49   return SBFileSpec(m_opaque_sp->GetExecutableFile());
50 }
51
52 void SBLaunchInfo::SetExecutableFile(SBFileSpec exe_file,
53                                      bool add_as_first_arg) {
54   m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
55 }
56
57 SBListener SBLaunchInfo::GetListener() {
58   return SBListener(m_opaque_sp->GetListener());
59 }
60
61 void SBLaunchInfo::SetListener(SBListener &listener) {
62   m_opaque_sp->SetListener(listener.GetSP());
63 }
64
65 uint32_t SBLaunchInfo::GetNumArguments() {
66   return m_opaque_sp->GetArguments().GetArgumentCount();
67 }
68
69 const char *SBLaunchInfo::GetArgumentAtIndex(uint32_t idx) {
70   return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx);
71 }
72
73 void SBLaunchInfo::SetArguments(const char **argv, bool append) {
74   if (append) {
75     if (argv)
76       m_opaque_sp->GetArguments().AppendArguments(argv);
77   } else {
78     if (argv)
79       m_opaque_sp->GetArguments().SetArguments(argv);
80     else
81       m_opaque_sp->GetArguments().Clear();
82   }
83 }
84
85 uint32_t SBLaunchInfo::GetNumEnvironmentEntries() {
86   return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount();
87 }
88
89 const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) {
90   return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx);
91 }
92
93 void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) {
94   if (append) {
95     if (envp)
96       m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp);
97   } else {
98     if (envp)
99       m_opaque_sp->GetEnvironmentEntries().SetArguments(envp);
100     else
101       m_opaque_sp->GetEnvironmentEntries().Clear();
102   }
103 }
104
105 void SBLaunchInfo::Clear() { m_opaque_sp->Clear(); }
106
107 const char *SBLaunchInfo::GetWorkingDirectory() const {
108   return m_opaque_sp->GetWorkingDirectory().GetCString();
109 }
110
111 void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) {
112   m_opaque_sp->SetWorkingDirectory(FileSpec{working_dir, false});
113 }
114
115 uint32_t SBLaunchInfo::GetLaunchFlags() {
116   return m_opaque_sp->GetFlags().Get();
117 }
118
119 void SBLaunchInfo::SetLaunchFlags(uint32_t flags) {
120   m_opaque_sp->GetFlags().Reset(flags);
121 }
122
123 const char *SBLaunchInfo::GetProcessPluginName() {
124   return m_opaque_sp->GetProcessPluginName();
125 }
126
127 void SBLaunchInfo::SetProcessPluginName(const char *plugin_name) {
128   return m_opaque_sp->SetProcessPluginName(plugin_name);
129 }
130
131 const char *SBLaunchInfo::GetShell() {
132   // Constify this string so that it is saved in the string pool.  Otherwise
133   // it would be freed when this function goes out of scope.
134   ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
135   return shell.AsCString();
136 }
137
138 void SBLaunchInfo::SetShell(const char *path) {
139   m_opaque_sp->SetShell(FileSpec(path, false));
140 }
141
142 bool SBLaunchInfo::GetShellExpandArguments() {
143   return m_opaque_sp->GetShellExpandArguments();
144 }
145
146 void SBLaunchInfo::SetShellExpandArguments(bool expand) {
147   m_opaque_sp->SetShellExpandArguments(expand);
148 }
149
150 uint32_t SBLaunchInfo::GetResumeCount() {
151   return m_opaque_sp->GetResumeCount();
152 }
153
154 void SBLaunchInfo::SetResumeCount(uint32_t c) {
155   m_opaque_sp->SetResumeCount(c);
156 }
157
158 bool SBLaunchInfo::AddCloseFileAction(int fd) {
159   return m_opaque_sp->AppendCloseFileAction(fd);
160 }
161
162 bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) {
163   return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd);
164 }
165
166 bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read,
167                                      bool write) {
168   return m_opaque_sp->AppendOpenFileAction(fd, FileSpec{path, false}, read,
169                                            write);
170 }
171
172 bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) {
173   return m_opaque_sp->AppendSuppressFileAction(fd, read, write);
174 }
175
176 void SBLaunchInfo::SetLaunchEventData(const char *data) {
177   m_opaque_sp->SetLaunchEventData(data);
178 }
179
180 const char *SBLaunchInfo::GetLaunchEventData() const {
181   return m_opaque_sp->GetLaunchEventData();
182 }
183
184 void SBLaunchInfo::SetDetachOnError(bool enable) {
185   m_opaque_sp->SetDetachOnError(enable);
186 }
187
188 bool SBLaunchInfo::GetDetachOnError() const {
189   return m_opaque_sp->GetDetachOnError();
190 }