Go to the documentation of this file.
16 #include "llvm/ADT/SmallString.h"
24 ProcessInfo::ProcessInfo()
25 : m_executable(), m_arguments(), m_environment(), m_arch() {}
29 : m_executable(name), m_arguments(), m_environment(), m_arch(arch),
51 s <<
"Executable: " <<
GetName() <<
"\n";
63 bool add_exe_file_as_first_arg) {
66 if (add_exe_file_as_first_arg) {
67 llvm::SmallString<128> filename;
69 if (!filename.empty())
82 bool first_arg_is_executable) {
86 if (first_arg_is_executable) {
102 if (first_arg_is_executable) {
128 for (
uint32_t i = 0; i < argc; i++) {
131 s.
Printf(
" arg[%u] = %s\n", i, arg);
133 s.
Printf(
"arg[%u] = %s\n", i, arg);
166 if (show_args || verbose)
172 s.
Printf(
"PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "
176 "====== ====== ========== ========== ========== ========== "
177 "============================== ============================\n");
179 s.
Printf(
"PID PARENT USER TRIPLE %s\n",
181 s.
PutCString(
"====== ====== ========== ============================== "
182 "============================\n");
187 bool show_args,
bool verbose)
const {
199 const char *format =
"{0,-10} ";
200 if (!(this->*isValid)()) {
205 if (
auto name = (resolver.*getName)(
id))
230 if (verbose || show_args) {
233 for (
uint32_t i = 0; i < argc; i++) {
336 void llvm::yaml::MappingTraits<ProcessInstanceInfo>::mapping(
338 io.mapRequired(
"executable", Info.m_executable);
339 io.mapRequired(
"arg0", Info.m_arg0);
340 io.mapRequired(
"args", Info.m_arguments);
341 io.mapRequired(
"arch", Info.m_arch);
342 io.mapRequired(
"uid", Info.m_uid);
343 io.mapRequired(
"gid", Info.m_gid);
344 io.mapRequired(
"pid", Info.m_pid);
345 io.mapRequired(
"effective-uid", Info.m_euid);
346 io.mapRequired(
"effective-gid", Info.m_egid);
347 io.mapRequired(
"parent-pid", Info.m_parent_pid);
351 llvm::Optional<ProcessInstanceInfoList>
353 static std::unique_ptr<repro::MultiLoader<repro::ProcessInfoProvider>>
360 llvm::Optional<std::string> nextfile = loader->GetNextFile();
364 auto error_or_file = llvm::MemoryBuffer::getFile(*nextfile);
365 if (std::error_code err = error_or_file.getError())
369 llvm::yaml::Input yin((*error_or_file)->getBuffer());
372 if (
auto err = yin.error())
void Format(const char *format, Args &&... args)
NameMatch m_name_match_type
bool ProcessIDIsValid() const
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
#define LLDB_INVALID_PROCESS_ID
llvm::Optional< llvm::StringRef > GetGroupName(id_t gid)
bool NameMatches(const char *process_name) const
Return true iff the process name in this object matches process_name.
uint32_t GetGroupID() const
uint32_t GetUserID() const
llvm::Optional< ProcessInstanceInfoList > GetReplayProcessInstanceInfoList()
bool ArchitectureMatches(const ArchSpec &arch_spec) const
Return true iff the architecture in this object matches arch_spec.
static std::unique_ptr< MultiLoader > Create(Loader *loader)
uint32_t GetEffectiveGroupID() const
void Clear()
Clear the arguments.
lldb::pid_t GetProcessID() const
bool EffectiveUserIDIsValid() const
bool UserIDIsValid() const
bool Matches(const ProcessInstanceInfo &proc_info) const
bool IsCompatibleMatch(const ArchSpec &rhs) const
Compare an ArchSpec to another ArchSpec, requiring a compatible cpu type match between them.
static void DumpTableHeader(Stream &s, bool show_args, bool verbose)
void DumpTriple(llvm::raw_ostream &s) const
void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char='\0')
Insert the argument value at index idx to arg_str.
llvm::Optional< llvm::StringRef > GetUserName(id_t uid)
uint32_t GetEffectiveUserID() const
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetArguments(size_t argc, const char **argv)
Sets the argument vector value, optionally copying all arguments into an internal buffer.
bool GroupIDIsValid() const
void SetArg0(llvm::StringRef arg)
const char * GetData() const
bool MatchAllProcesses() const
bool ParentProcessIDIsValid() const
const char * GetName() const
llvm::StringRef GetNameAsStringRef() const
string(SUBSTRING ${p} 10 -1 pStripped) if($
Environment m_environment
bool IsValid() const
Tests if this ArchSpec is valid.
bool EffectiveGroupIDIsValid() const
void Clear()
Clears the object state.
An abstract interface for things that know how to map numeric user/group IDs into names.
lldb::pid_t GetParentProcessID() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
bool UserIDsMatch(const ProcessInstanceInfo &proc_info) const
Return true iff the (both effective and real) user and group IDs in this object match the ones in pro...
ProcessInstanceInfo m_match_info
size_t EOL()
Output and End of Line character to the stream.
void Dump(Stream &s, UserIDResolver &resolver) const
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
const char * GetCString() const
Get the string value as a C string.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
void DumpAsTableRow(Stream &s, UserIDResolver &resolver, bool show_args, bool verbose) const
ArchSpec & GetArchitecture()
A class that represents a running process on the host machine.
llvm::StringRef GetArg0() const
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
void Clear()
Clears the object state.
void Dump(Stream &s, const char *label_name="argv") const
Dump all entries to the stream s using label label_name.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static Reproducer & Instance()
void Dump(Stream &s, Platform *platform) const
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
bool ProcessIDsMatch(const ProcessInstanceInfo &proc_info) const
Return true iff the process ID and parent process IDs in this object match the ones in proc_info.
ConstString & GetFilename()
Filename string get accessor.
void SetArguments(const Args &args, bool first_arg_is_executable)
bool NameMatches(llvm::StringRef name, NameMatch match_type, llvm::StringRef match)