[Lldb-commits] [PATCH] D101563: [lldb] [test] Extend aarch64-gp-read test to cover all registers

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 3 04:17:04 PDT 2021


mstorsjo added inline comments.


================
Comment at: lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp:57
+    "ldr      x0,       [%0, #248]\n\t"
+    "stp      x29, x0,  [sp, #-16]\n\t"
+    "\n\t"
----------------
mgorny wrote:
> mstorsjo wrote:
> > 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.
> It backs up `x29` and stores another test value on the stack to test `$sp` below.
Sure. Just clarify that this corresponds with the read of an expression relative to `$sp` in the test script.


================
Comment at: lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp:67
+    "ldp      x16, x17, [%0, #128]\n\t"
+    "ldp      x18, x19, [%0, #144]\n\t"
+    "ldp      x20, x21, [%0, #160]\n\t"
----------------
mgorny wrote:
> mstorsjo wrote:
> > 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.
> Would backing it up on the stack and restoring after the trap work or is it entirely forbidden?
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.


================
Comment at: lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp:79
+    // restore x29, discard the other value
+    "ldp      x29, xzr, [sp, #-16]\n\t"
     :
----------------
This could just as well be a `ldr x29, [sp, #-16]` right?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101563/new/

https://reviews.llvm.org/D101563



More information about the lldb-commits mailing list