Skip to content

Add an <address-expression> fallback that handles register expressions #8470

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

Conversation

jimingham
Copy link

The Swift expression parser doesn't have a representation for native register values. They aren't so much a thing in swift, so that's not a huge deal, but they are super handy in address expressions. So this patch adds a fallback in the address expression evaluator that will translate register expressions ($pc, etc.) into their values if the expression fails.

…ssions (llvm#85492)

The idea behind the address-expression is that it handles all the common
expressions that produce addresses. It handles actual valid expressions
that return a scalar, and it handles useful cases that the various
source languages don't support. At present, the fallback handles:

<symbol_name>{+-}<offset>

which isn't valid C but is very handy.

This patch adds handling of:

$<reg_name>

and

$<reg_name>{+-}<offset>

That's kind of pointless in C because the C expression parser handles
that expression already. But some languages don't have a straightforward
way to represent register values like this (swift) so having this
fallback is quite a quality of life improvement.

I added a test which tests that I didn't mess up either of these
fallbacks, though it doesn't test the actually handling of registers
that I added, since the expression parser for C succeeds in that case
and returns before this code gets run.

I will add a test on the swift fork for that checks that this works the
same way for a swift frame after this check.

(cherry picked from commit 2c76e88)
@jimingham
Copy link
Author

@swift-ci please test

@jimingham
Copy link
Author

The Windows failure was a failure to clone the repo to start the build.

@jimingham
Copy link
Author

@swift-ci please test Windows

Copy link

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Minor nit inline



class TestImageLookupPCInC(TestBase):
def test_sample_rename_this(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably forgot to rename this test name and the comment below?

@adrian-prantl adrian-prantl merged commit f86065d into swiftlang:swift/release/6.0 Mar 26, 2024
@jimingham jimingham deleted the addr-expression-swift branch March 26, 2024 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants