Page MenuHomePhabricator

[lldb] [test] Extend aarch64-gp-read test to cover all registers
Needs RevisionPublic

Authored by mgorny on Apr 29 2021, 12:54 PM.



Extend the general-purpose/vector register test for AArch64 to test
all regular registers rather than just the first eight. While this
might seem redundant, we've historically had a bug in reading a single
registers due to a typo.

While at it, use a single array of values for the test. I have
permitted myself to use a different values that were relatively easy
to generate via the following script:

for x in range(32):
    print('    { ', end='')
    for y in range(2):
        print('0x', end='')
        for z in range(8):
            print('%02X' % (x+(1-y)*8+z), end='')
        if y == 0:
            print(', ', end='')
    print(' },')

x8 is used as the special register to hold the data pointer, as this
is what clang is forcing on my system (and it should use it anyway since
it's the only register not in the clobber list), so it is overwritten
last. x29 (fp) is backed up on the stack. The stack pointer (x31)
is tested via pushing the respective value to the stack and then reading
it rather than modifying it directly.

Diff Detail

Event Timeline

mgorny created this revision.Apr 29 2021, 12:54 PM
mgorny requested review of this revision.Apr 29 2021, 12:54 PM
mstorsjo added inline comments.May 3 2021, 3:46 AM

I'm not quite sure what this bit actually tests, with regards to inspecting registers - as it loads a value to a simple register and writes it somewhere else. I guess the thing it tests is expressions involving $sp though?

I guess that's fine but it'd be nice to have it spelled out a bit clearer about the aspect that it actually tests.


You're not allowed to clobber x18 on windows (and on darwin, but it's less fatal there).

Building this for windows gives this warning:

<inline asm>:1:1: warning: inline asm clobber list contains reserved registers: X18
        ld1      {v0.2d,  v1.2d,  v2.2d,  v3.2d},  [x8], #64
<inline asm>:1:1: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
        ld1      {v0.2d,  v1.2d,  v2.2d,  v3.2d},  [x8], #64

And after overwriting x18, things fail when we try to stop for the breakpoint.

mgorny added inline comments.May 3 2021, 4:10 AM

It backs up x29 and stores another test value on the stack to test $sp below.


Would backing it up on the stack and restoring after the trap work or is it entirely forbidden?

mstorsjo added inline comments.May 3 2021, 4:17 AM

Sure. Just clarify that this corresponds with the read of an expression relative to $sp in the test script.


It's pretty much forbidden - the problem here seems to be that having x18 set to an incorrect value breaks things when hitting the trap. In a straight-line code segment with no external interaction you can have x18 set to something else intermittently, but it must be correct whenever you interact with something else, and traps seem to be a case where it's read by something, somewhere, too.


This could just as well be a ldr x29, [sp, #-16] right?

krytarowski accepted this revision.Sep 8 2021, 12:08 AM
This revision is now accepted and ready to land.Sep 8 2021, 12:08 AM
krytarowski requested changes to this revision.Sep 8 2021, 1:12 AM

There is an unhandled comment.

This revision now requires changes to proceed.Sep 8 2021, 1:12 AM