-
Notifications
You must be signed in to change notification settings - Fork 40
hdbg arm64 implementation proposal. #19
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
Open
devnexen
wants to merge
2
commits into
peadar:master
Choose a base branch
from
devnexen:getframe_arm64
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 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
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.
My version and (lack of) documentation for i386 and x86_64 were not a great example to follow here, but the idea of this function is to return both the instruction pointer (not stack pointer), and the frame pointer.
For aarch64, the frame pointer is indeed x29, and you can use the link register, x30, to get the caller's IP. They should really come from the same "frame", though - that's why I had the naked attribute on the x86 versions.
I'm not an ARM expert by any stretch, but it's possible that for leaf functions, the you can just use x29 directly, assuming it doesn't get manipulated in the prologue for "getframe" here. (i.e. I'm not sure if the lack of a naked attribute affects anything here - ISTR it isn't supported on aarch64.
Also, given you have given the output variables names, you might as well just assign the passed parameters from the output names in C, rather than doing it in asm.
I really need to add a test for this - I can do it tomorrow, but if you haven't worked it out, something like:
Compiling with -fno-omit-frame-pointer and running
you should see the backtrace for the memory leak in the output.
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.
My bad I misread.
I guess, if we are to use inline assembly, we can strip down to just to something like this:
static void __attribute__((naked,noinline)) getframe(void ***bp, void ***ip) { asm( "mov x29, x0;" "mov x30, x1;" "ret;" ); }
otherwise no point using variables as I did indeed.
I won t be able to come back to it until wednesday..