[Lldb-commits] [PATCH] D88583: [lldb] [test/Register] Add read/write tests for x87 regs

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 1 05:35:51 PDT 2020

labath added inline comments.

Comment at: lldb/test/Shell/Register/x86-fp-read.test:27-28
+# CHECK: fdivs (%{{[er]}}bx)
+print *(uint32_t*)($foseg * 0x100000000 + $fooff)
+# CHECK: (uint32_t) $1 = 0
mgorny wrote:
> labath wrote:
> > zero is pretty common value. It would be better to check that the address actually points to the address of the `zero` variable. I think something like this ought to do it:
> > ```
> > print &zero
> > # CHECK: (uint32_t *) $0 = [[ZERO:0x[0-9a-f]*]]
> > print (uint32_t*)($foseg * 0x100000000 + $fooff)
> > # CHECK: (uint32_t *) $1 = [[ZERO]]
> > ```
> > Something similar can be done with the disassemble command too. That way we'll see the actual register value in case it turns out to be wrong.
> Cool idea, thanks!
> As for FIP, I suppose that would require getting address corresponding to the FDIV instruction somehow. I suppose we can rely on constant-length encoding on `int3` and `fdivs ...`, so I guess `$rip-3` might work.
I was thinking you could disassemble the `main` function and capture the address before the `fdivs` instruction. But yes, a fixed offset from `$rip` should work just fine...



More information about the lldb-commits mailing list