本文整理汇总了C++中ProcessInstanceInfo类的典型用法代码示例。如果您正苦于以下问题:C++ ProcessInstanceInfo类的具体用法?C++ ProcessInstanceInfo怎么用?C++ ProcessInstanceInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProcessInstanceInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapshot
uint32_t
Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
{
process_infos.Clear();
AutoHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0));
if (!snapshot.IsValid())
return 0;
PROCESSENTRY32 pe = {0};
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(snapshot.get(), &pe))
{
do
{
AutoHandle handle(::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pe.th32ProcessID), nullptr);
ProcessInstanceInfo process;
process.SetExecutableFile(FileSpec(pe.szExeFile, false), true);
process.SetProcessID(pe.th32ProcessID);
process.SetParentProcessID(pe.th32ParentProcessID);
GetProcessExecutableAndTriple(handle, process);
if (match_info.MatchAllProcesses() || match_info.Matches(process))
process_infos.Append(process);
} while (Process32Next(snapshot.get(), &pe));
}
return process_infos.GetSize();
}
示例2: GetNetBSDProcessCPUType
static bool
GetNetBSDProcessCPUType (ProcessInstanceInfo &process_info)
{
if (process_info.ProcessIDIsValid())
{
process_info.GetArchitecture() = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
return true;
}
process_info.GetArchitecture().Clear();
return false;
}
示例3: GetFreeBSDProcessCPUType
static bool
GetFreeBSDProcessCPUType (ProcessInstanceInfo &process_info)
{
if (process_info.ProcessIDIsValid())
{
process_info.GetArchitecture() = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
return true;
}
process_info.GetArchitecture().Clear();
return false;
}
示例4: GetNetBSDProcessArgs
static bool
GetNetBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
ProcessInstanceInfo &process_info)
{
if (!process_info.ProcessIDIsValid())
return false;
int pid = process_info.GetProcessID();
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
char arg_data[8192];
size_t arg_data_size = sizeof(arg_data);
if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) != 0)
return false;
DataExtractor data (arg_data, arg_data_size, lldb::endian::InlHostByteOrder(), sizeof(void *));
lldb::offset_t offset = 0;
const char *cstr;
cstr = data.GetCStr (&offset);
if (!cstr)
return false;
process_info.GetExecutableFile().SetFile(cstr, false);
if (!(match_info_ptr == NULL ||
NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
match_info_ptr->GetNameMatchType(),
match_info_ptr->GetProcessInfo().GetName())))
return false;
Args &proc_args = process_info.GetArguments();
while (1)
{
const uint8_t *p = data.PeekData(offset, 1);
while ((p != NULL) && (*p == '\0') && offset < arg_data_size)
{
++offset;
p = data.PeekData(offset, 1);
}
if (p == NULL || offset >= arg_data_size)
break;
cstr = data.GetCStr(&offset);
if (!cstr)
break;
proc_args.AppendArgument(cstr);
}
return true;
}
示例5: GetTarget
bool
ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info)
{
info.Clear();
info.SetProcessID(GetID());
info.SetArchitecture(GetArchitecture());
lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
if (module_sp)
{
const bool add_exe_file_as_first_arg = false;
info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(), add_exe_file_as_first_arg);
}
return true;
}
示例6:
bool
PlatformRemoteiOS::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
{
// TODO: if connected, send a packet to get the remote process info
process_info.Clear();
return false;
}
示例7: handle
bool
Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
{
process_info.Clear();
AutoHandle handle(::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid),
nullptr);
if (!handle.IsValid())
return false;
process_info.SetProcessID(pid);
GetProcessExecutableAndTriple(handle, process_info);
// Need to read the PEB to get parent process and command line arguments.
return true;
}
示例8: GetLinuxProcessUserAndGroup
static void
GetLinuxProcessUserAndGroup (lldb::pid_t pid, ProcessInstanceInfo &process_info, lldb::pid_t &tracerpid)
{
tracerpid = 0;
uint32_t rUid = UINT32_MAX; // Real User ID
uint32_t eUid = UINT32_MAX; // Effective User ID
uint32_t rGid = UINT32_MAX; // Real Group ID
uint32_t eGid = UINT32_MAX; // Effective Group ID
// Read the /proc/$PID/status file and parse the Uid:, Gid:, and TracerPid: fields.
lldb::DataBufferSP buf_sp = ReadProcPseudoFile (pid, "status");
static const char uid_token[] = "Uid:";
char *buf_uid = strstr ((char *)buf_sp->GetBytes(), uid_token);
if (buf_uid)
{
// Real, effective, saved set, and file system UIDs. Read the first two.
buf_uid += sizeof(uid_token);
rUid = strtol (buf_uid, &buf_uid, 10);
eUid = strtol (buf_uid, &buf_uid, 10);
}
static const char gid_token[] = "Gid:";
char *buf_gid = strstr ((char *)buf_sp->GetBytes(), gid_token);
if (buf_gid)
{
// Real, effective, saved set, and file system GIDs. Read the first two.
buf_gid += sizeof(gid_token);
rGid = strtol (buf_gid, &buf_gid, 10);
eGid = strtol (buf_gid, &buf_gid, 10);
}
static const char tracerpid_token[] = "TracerPid:";
char *buf_tracerpid = strstr((char *)buf_sp->GetBytes(), tracerpid_token);
if (buf_tracerpid)
{
// Tracer PID. 0 if we're not being debugged.
buf_tracerpid += sizeof(tracerpid_token);
tracerpid = strtol (buf_tracerpid, &buf_tracerpid, 10);
}
process_info.SetUserID (rUid);
process_info.SetEffectiveUserID (eUid);
process_info.SetGroupID (rGid);
process_info.SetEffectiveGroupID (eGid);
}
示例9: GetELFProcessCPUType
static bool
GetELFProcessCPUType (const char *exe_path, ProcessInstanceInfo &process_info)
{
// Clear the architecture.
process_info.GetArchitecture().Clear();
ModuleSpecList specs;
FileSpec filespec (exe_path, false);
const size_t num_specs = ObjectFile::GetModuleSpecifications (filespec, 0, 0, specs);
// GetModuleSpecifications() could fail if the executable has been deleted or is locked.
// But it shouldn't return more than 1 architecture.
assert(num_specs <= 1 && "Linux plugin supports only a single architecture");
if (num_specs == 1)
{
ModuleSpec module_spec;
if (specs.GetModuleSpecAtIndex (0, module_spec) && module_spec.GetArchitecture().IsValid())
{
process_info.GetArchitecture () = module_spec.GetArchitecture();
return true;
}
}
return false;
}
示例10: CreateProcessInfoResponse
void GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse(
const ProcessInstanceInfo &proc_info, StreamString &response) {
response.Printf(
"pid:%" PRIu64 ";ppid:%" PRIu64 ";uid:%i;gid:%i;euid:%i;egid:%i;",
proc_info.GetProcessID(), proc_info.GetParentProcessID(),
proc_info.GetUserID(), proc_info.GetGroupID(),
proc_info.GetEffectiveUserID(), proc_info.GetEffectiveGroupID());
response.PutCString("name:");
response.PutCStringAsRawHex8(proc_info.GetExecutableFile().GetCString());
response.PutChar(';');
const ArchSpec &proc_arch = proc_info.GetArchitecture();
if (proc_arch.IsValid()) {
const llvm::Triple &proc_triple = proc_arch.GetTriple();
response.PutCString("triple:");
response.PutCStringAsRawHex8(proc_triple.getTriple().c_str());
response.PutChar(';');
}
}
示例11: CreateProcessInfoResponse
static void
CreateProcessInfoResponse (const ProcessInstanceInfo &proc_info, StreamString &response)
{
response.Printf ("pid:%llu;ppid:%llu;uid:%i;gid:%i;euid:%i;egid:%i;",
proc_info.GetProcessID(),
proc_info.GetParentProcessID(),
proc_info.GetUserID(),
proc_info.GetGroupID(),
proc_info.GetEffectiveUserID(),
proc_info.GetEffectiveGroupID());
response.PutCString ("name:");
response.PutCStringAsRawHex8(proc_info.GetName());
response.PutChar(';');
const ArchSpec &proc_arch = proc_info.GetArchitecture();
if (proc_arch.IsValid())
{
const llvm::Triple &proc_triple = proc_arch.GetTriple();
response.PutCString("triple:");
response.PutCStringAsRawHex8(proc_triple.getTriple().c_str());
response.PutChar(';');
}
}
示例12: GetProcessAndStatInfo
static bool GetProcessAndStatInfo(::pid_t pid,
ProcessInstanceInfo &process_info,
ProcessState &State, ::pid_t &tracerpid) {
tracerpid = 0;
process_info.Clear();
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
// We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
llvm::SmallString<64> ProcExe;
(llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe);
std::string ExePath(PATH_MAX, '\0');
ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
if (len <= 0) {
LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
Status(errno, eErrorTypePOSIX));
return false;
}
ExePath.resize(len);
// If the binary has been deleted, the link name has " (deleted)" appended.
// Remove if there.
llvm::StringRef PathRef = ExePath;
PathRef.consume_back(" (deleted)");
GetELFProcessCPUType(PathRef, process_info);
// Get the process environment.
auto BufferOrError = getProcFile(pid, "environ");
if (!BufferOrError)
return false;
std::unique_ptr<llvm::MemoryBuffer> Environ = std::move(*BufferOrError);
// Get the command line used to start the process.
BufferOrError = getProcFile(pid, "cmdline");
if (!BufferOrError)
return false;
std::unique_ptr<llvm::MemoryBuffer> Cmdline = std::move(*BufferOrError);
// Get User and Group IDs and get tracer pid.
if (!GetStatusInfo(pid, process_info, State, tracerpid))
return false;
process_info.SetProcessID(pid);
process_info.GetExecutableFile().SetFile(PathRef, false);
process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());
llvm::StringRef Rest = Environ->getBuffer();
while (!Rest.empty()) {
llvm::StringRef Var;
std::tie(Var, Rest) = Rest.split('\0');
process_info.GetEnvironmentEntries().AppendArgument(Var);
}
llvm::StringRef Arg0;
std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
process_info.SetArg0(Arg0);
while (!Rest.empty()) {
llvm::StringRef Arg;
std::tie(Arg, Rest) = Rest.split('\0');
process_info.GetArguments().AppendArgument(Arg);
}
return true;
}
示例13: GetNetBSDProcessUserAndGroup
static bool
GetNetBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
{
::kvm_t *kdp;
char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
struct ::kinfo_proc2 *proc_kinfo;
const int pid = process_info.GetProcessID();
int nproc;
if (!process_info.ProcessIDIsValid())
goto error;
if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
goto error;
if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_PID, pid,
sizeof(struct ::kinfo_proc2),
&nproc)) == NULL) {
::kvm_close(kdp);
goto error;
}
if (nproc < 1) {
::kvm_close(kdp); /* XXX: we don't check for error here */
goto error;
}
process_info.SetParentProcessID (proc_kinfo->p_ppid);
process_info.SetUserID (proc_kinfo->p_ruid);
process_info.SetGroupID (proc_kinfo->p_rgid);
process_info.SetEffectiveUserID (proc_kinfo->p_uid);
process_info.SetEffectiveGroupID (proc_kinfo->p_gid);
::kvm_close(kdp); /* XXX: we don't check for error here */
return true;
error:
process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
process_info.SetUserID (UINT32_MAX);
process_info.SetGroupID (UINT32_MAX);
process_info.SetEffectiveUserID (UINT32_MAX);
process_info.SetEffectiveGroupID (UINT32_MAX);
return false;
}
示例14:
bool
Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
{
process_info.Clear();
return false;
}
示例15: GetFreeBSDProcessUserAndGroup
static bool
GetFreeBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
{
struct kinfo_proc proc_kinfo;
size_t proc_kinfo_size;
if (process_info.ProcessIDIsValid())
{
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
(int)process_info.GetProcessID() };
proc_kinfo_size = sizeof(struct kinfo_proc);
if (::sysctl (mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0)
{
if (proc_kinfo_size > 0)
{
process_info.SetParentProcessID (proc_kinfo.ki_ppid);
process_info.SetUserID (proc_kinfo.ki_ruid);
process_info.SetGroupID (proc_kinfo.ki_rgid);
process_info.SetEffectiveUserID (proc_kinfo.ki_uid);
if (proc_kinfo.ki_ngroups > 0)
process_info.SetEffectiveGroupID (proc_kinfo.ki_groups[0]);
else
process_info.SetEffectiveGroupID (UINT32_MAX);
return true;
}
}
}
process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
process_info.SetUserID (UINT32_MAX);
process_info.SetGroupID (UINT32_MAX);
process_info.SetEffectiveUserID (UINT32_MAX);
process_info.SetEffectiveGroupID (UINT32_MAX);
return false;
}