-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[lldb][AIX] Added Ptrace extensions for AIX #108000
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//===-- Ptrace.h ------------------------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// This file defines ptrace functions & structures | ||
|
||
#ifndef LIBLLDB_HOST_AIX_PTRACE_H_ | ||
#define LIBLLDB_HOST_AIX_PTRACE_H_ | ||
|
||
#include <sys/ptrace.h> | ||
|
||
// Support ptrace extensions even when compiled without required kernel support | ||
#ifndef PTRACE_GETREGS | ||
#define PTRACE_GETREGS (PT_COMMAND_MAX + 1) | ||
#endif | ||
#ifndef PTRACE_SETREGS | ||
#define PTRACE_SETREGS (PT_COMMAND_MAX + 2) | ||
#endif | ||
#ifndef PTRACE_GETFPREGS | ||
#define PTRACE_GETFPREGS (PT_COMMAND_MAX + 3) | ||
#endif | ||
#ifndef PTRACE_SETFPREGS | ||
#define PTRACE_SETFPREGS (PT_COMMAND_MAX + 4) | ||
#endif | ||
#ifndef PTRACE_GETREGSET | ||
#define PTRACE_GETREGSET 0x4204 | ||
#endif | ||
#ifndef PTRACE_SETREGSET | ||
#define PTRACE_SETREGSET 0x4205 | ||
#endif | ||
#ifndef PTRACE_GETVRREGS | ||
#define PTRACE_GETVRREGS (PT_COMMAND_MAX + 5) | ||
#endif | ||
#ifndef PTRACE_GETVSRREGS | ||
#define PTRACE_GETVSRREGS (PT_COMMAND_MAX + 6) | ||
#endif | ||
|
||
#endif // LIBLLDB_HOST_AIX_PTRACE_H_ |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PT_COMMAND_MAX is provided by some AIX include file, correct?
If that's correct then using it like this is fine because PTrace.h is only included in code built natively.
Do you have public documentation for these ptrace numbers? Perhaps there is a man page like https://man7.org/linux/man-pages/man2/ptrace.2.html? It would be good to include a link to that in the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just add that all of these defines are only required if your system headers don't always provide these definitions. This was necessary on linux (in the past, maybe not in present), because people built lldb on all kinds of kernel versions. If you're only going to support building lldb on AIX version >=X (where
X
may even be the most recent version of the OS) then you only need to provide the symbols that aren't available on every supported version. If all the supported versions of AIX define these symbols, then you don't need to define anything here (and maybe you don't even need this file).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to avoid confusion, this comment was actually question: Is it the case that the AIX system headers (on all supported versions) do not already define these constants?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is defined in AIX's system header
sys/ptrace.h
, its not been mentioned in AIX public documentation.For other details, here is the link though:
https://www.ibm.com/docs/en/aix/7.3?topic=p-ptrace-ptracex-ptrace64-subroutine
We are actually using these defines do some emulation in the NativeProcess files, hence the need for them. Please take a look here:
https://github.com/llvm/llvm-project/pull/102601/files#diff-932a7c13bbba2ce92d14f75c525489f726af9e95f955df24b3f840727e9f757a
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pasting a small snippet from that here:
line: 1755
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so if I understand what you're saying, these definitions don't correspond to any actual values defined or supported by the system.
In that case, I think these values do not belong here, as this is basically an OS compatibility header. In fact, I think there's no reason for these constants should exist. You don't have to follow the patterns in NativeProcessLinux, if they don't make sense for you. There's nothing forcing you do implement ReadGPR like this
If your host ptrace call does not support reading GPRs in bulk. If you need to read registers one by one, the most obvious implementation is to just do that directly inside the ReadGPR function -- basically inline the relevant part of PtraceWrapper into this function (and then get rid of the constant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, sure. I will try that implementation as well.