[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed May 7 00:18:16 PDT 2025
================
@@ -133,7 +142,45 @@ static bool GetProcessAndStatInfo(::pid_t pid,
uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
ProcessInstanceInfoList &process_infos) {
- return 0;
+ static const char procdir[] = "/proc/";
+
+ DIR *dirproc = opendir(procdir);
+ if (dirproc) {
+ struct dirent *direntry = nullptr;
+ const uid_t our_uid = getuid();
+ const lldb::pid_t our_pid = getpid();
+ bool all_users = match_info.GetMatchAllUsers();
+
+ while ((direntry = readdir(dirproc)) != nullptr) {
+ if (!IsDirNumeric(direntry->d_name))
+ continue;
+
+ lldb::pid_t pid = atoi(direntry->d_name);
+ // Skip this process.
+ if (pid == our_pid)
+ continue;
+
+ ProcessState State;
+ ProcessInstanceInfo process_info;
+ if (!GetProcessAndStatInfo(pid, process_info, State))
+ continue;
+
+ if (State == ProcessState::Zombie ||
+ State == ProcessState::TracedOrStopped)
+ continue;
+
+ // Check for user match if we're not matching all users and not running
+ // as root.
+ if (!all_users && (our_uid != 0) && (process_info.GetUserID() != our_uid))
+ continue;
+
+ if (match_info.Matches(process_info)) {
+ process_infos.push_back(process_info);
+ }
----------------
labath wrote:
```suggestion
if (match_info.Matches(process_info))
process_infos.push_back(process_info);
```
https://github.com/llvm/llvm-project/pull/138687
More information about the lldb-commits
mailing list