-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb][AIX] Host.cpp for AIX #130582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[lldb][AIX] Host.cpp for AIX #130582
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-lldb Author: Dhruv Srivastava (DhruvSrivastavaX) ChangesThis PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github:
Added base file - aix/Host.cpp for Process info Full diff: https://github.com/llvm/llvm-project/pull/130582.diff 2 Files Affected:
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 9be0c06a516ba..52ef67feeb6ab 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -135,6 +135,7 @@ else()
elseif (CMAKE_SYSTEM_NAME MATCHES "AIX")
add_host_subdirectory(aix
+ aix/Host.cpp
aix/HostInfoAIX.cpp
)
endif()
diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
new file mode 100644
index 0000000000000..38c77b4959ead
--- /dev/null
+++ b/lldb/source/Host/aix/Host.cpp
@@ -0,0 +1,109 @@
+//===-- source/Host/aix/Host.cpp ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Host.h"
+#include "lldb/Utility/ProcessInfo.h"
+#include "lldb/Utility/Status.h"
+#include <dirent.h>
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+enum class ProcessState {
+ Unknown,
+ Dead,
+ DiskSleep,
+ Idle,
+ Paging,
+ Parked,
+ Running,
+ Sleeping,
+ TracedOrStopped,
+ Zombie,
+};
+}
+
+namespace lldb_private {
+class ProcessLaunchInfo;
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+ ProcessState &State, ::pid_t &TracerPid,
+ ::pid_t &Tgid) {
+ return false;
+}
+
+static void GetProcessArgs(::pid_t pid, ProcessInstanceInfo &process_info) {}
+
+static bool GetProcessAndStatInfo(::pid_t pid,
+ ProcessInstanceInfo &process_info,
+ ProcessState &State, ::pid_t &tracerpid) {
+ return false;
+}
+
+uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ 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) {
+
+ lldb::pid_t pid = atoi(direntry->d_name);
+
+ // Skip this process.
+ if (pid == our_pid)
+ continue;
+
+ ::pid_t tracerpid;
+ ProcessState State;
+ ProcessInstanceInfo process_info;
+
+ if (!GetProcessAndStatInfo(pid, process_info, State, tracerpid))
+ continue;
+
+ // Skip if process is being debugged.
+ if (tracerpid != 0)
+ continue;
+
+ if (State == ProcessState::Zombie)
+ 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);
+ }
+
+ closedir(dirproc);
+ }
+
+ return process_infos.size();
+}
+
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+ ::pid_t tracerpid;
+ ProcessState State;
+ return GetProcessAndStatInfo(pid, process_info, State, tracerpid);
+}
+
+Environment Host::GetEnvironment() { return Environment(environ); }
+
+Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+ return Status("unimplemented");
+}
|
labath
reviewed
Mar 10, 2025
labath
reviewed
Mar 10, 2025
labath
reviewed
Mar 10, 2025
labath
approved these changes
Mar 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is in reference to porting LLDB on AIX.
Link to discussions on llvm discourse and github:
The complete changes for porting are present in this draft PR:
Extending LLDB to work on AIX #102601
Added base file - aix/Host.cpp for Process info