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 //===----------------------------------------------------------------------===//
10 #include "lldb/Target/ProcessInfo.h"
16 using namespace lldb_private;
18 ProcessInfo::ProcessInfo () :
25 m_pid (LLDB_INVALID_PROCESS_ID)
29 ProcessInfo::ProcessInfo (const char *name, const ArchSpec &arch, lldb::pid_t pid) :
30 m_executable (name, false),
45 m_environment.Clear();
49 m_pid = LLDB_INVALID_PROCESS_ID;
53 ProcessInfo::GetName() const
55 return m_executable.GetFilename().GetCString();
59 ProcessInfo::GetNameLength() const
61 return m_executable.GetFilename().GetLength();
65 ProcessInfo::SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg)
69 m_executable = exe_file;
70 if (add_exe_file_as_first_arg)
72 char filename[PATH_MAX];
73 if (exe_file.GetPath(filename, sizeof(filename)))
74 m_arguments.InsertArgumentAtIndex (0, filename);
84 ProcessInfo::GetArg0 () const
88 return m_arg0.c_str();
92 ProcessInfo::SetArg0 (const char *arg)
101 ProcessInfo::SetArguments (char const **argv, bool first_arg_is_executable)
103 m_arguments.SetArguments (argv);
105 // Is the first argument the executable?
106 if (first_arg_is_executable)
108 const char *first_arg = m_arguments.GetArgumentAtIndex (0);
111 // Yes the first argument is an executable, set it as the executable
112 // in the launch options. Don't resolve the file path as the path
113 // could be a remote platform path
114 const bool resolve = false;
115 m_executable.SetFile(first_arg, resolve);
120 ProcessInfo::SetArguments (const Args& args, bool first_arg_is_executable)
122 // Copy all arguments
125 // Is the first argument the executable?
126 if (first_arg_is_executable)
128 const char *first_arg = m_arguments.GetArgumentAtIndex (0);
131 // Yes the first argument is an executable, set it as the executable
132 // in the launch options. Don't resolve the file path as the path
133 // could be a remote platform path
134 const bool resolve = false;
135 m_executable.SetFile(first_arg, resolve);