1 //===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // Other libraries and framework includes
16 #include "lldb/Target/ProcessInfo.h"
18 #include "lldb/Core/Stream.h"
21 using namespace lldb_private;
23 ProcessInfo::ProcessInfo () :
30 m_pid (LLDB_INVALID_PROCESS_ID)
34 ProcessInfo::ProcessInfo (const char *name, const ArchSpec &arch, lldb::pid_t pid) :
35 m_executable (name, false),
50 m_environment.Clear();
54 m_pid = LLDB_INVALID_PROCESS_ID;
58 ProcessInfo::GetName() const
60 return m_executable.GetFilename().GetCString();
64 ProcessInfo::GetNameLength() const
66 return m_executable.GetFilename().GetLength();
70 ProcessInfo::Dump (Stream &s, Platform *platform) const
72 s << "Executable: " << GetName() << "\n";
80 s << "Environment:\n";
81 m_environment.Dump(s, "env");
85 ProcessInfo::SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg)
89 m_executable = exe_file;
90 if (add_exe_file_as_first_arg)
92 char filename[PATH_MAX];
93 if (exe_file.GetPath(filename, sizeof(filename)))
94 m_arguments.InsertArgumentAtIndex (0, filename);
104 ProcessInfo::GetArg0 () const
106 return (m_arg0.empty() ? nullptr : m_arg0.c_str());
110 ProcessInfo::SetArg0 (const char *arg)
119 ProcessInfo::SetArguments (char const **argv, bool first_arg_is_executable)
121 m_arguments.SetArguments (argv);
123 // Is the first argument the executable?
124 if (first_arg_is_executable)
126 const char *first_arg = m_arguments.GetArgumentAtIndex (0);
129 // Yes the first argument is an executable, set it as the executable
130 // in the launch options. Don't resolve the file path as the path
131 // could be a remote platform path
132 const bool resolve = false;
133 m_executable.SetFile(first_arg, resolve);
139 ProcessInfo::SetArguments (const Args& args, bool first_arg_is_executable)
141 // Copy all arguments
144 // Is the first argument the executable?
145 if (first_arg_is_executable)
147 const char *first_arg = m_arguments.GetArgumentAtIndex (0);
150 // Yes the first argument is an executable, set it as the executable
151 // in the launch options. Don't resolve the file path as the path
152 // could be a remote platform path
153 const bool resolve = false;
154 m_executable.SetFile(first_arg, resolve);