[lldb-dev] Duplicate use of "sp" register name on x86 targets
Michał Górny via lldb-dev
lldb-dev at lists.llvm.org
Mon Sep 6 04:35:37 PDT 2021
On Mon, 2021-09-06 at 13:23 +0200, Pavel Labath wrote:
> On 25/08/2021 21:13, Michał Górny via lldb-dev wrote:
> > Hi,
> > While working on improving gdbserver compatibility, I've noticed that
> > "sp" is used twice:
> > 1. as an alt_name for esp/rsp register (giving full 32/64-bit stack
> > pointer),
> > 2. and as the name of sp pseudo-register (giving ESP/RSP truncated to 16
> > bits).
> > FWICS the current lookup logic (at least for LLGS targets) means that 1.
> > takes precedence, i.e. 'register read sp' and 'p $sp' will both resolve
> > to RSP. The 16-bit SP is only visible via 'register read --all'.
> > However, I'm wondering whether this is actually desirable.
> > In particular, should 'sp' generic name take precedence over an actual
> > 'sp' (pseudo-)register?
> Given that accessing the lower 16 bits of the stack pointer is pretty
> useless, and I can think of several use cases for accessing the (full)
> stack pointer in an architecture-agnostic way, I think that the current
> precedence is right.
Thanks, this makes sense to me.
> Which is not to say that the situation is ideal, but I'm not sure what
> can we (short of travelling back in time) do about it. Maybe we can
> provide some alias (sp_16, sp_86, ???), so that the register remains
I was originally thinking of "_sp" but I suppose more specific names
make more sense ;-). That said, I guess it can probably wait until
someone actually sees a need for it.
More information about the lldb-dev