[lldb-dev] Duplicate use of "sp" register name on x86 targets

Pavel Labath via lldb-dev lldb-dev at lists.llvm.org
Mon Sep 6 04:23:47 PDT 2021

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.

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 


More information about the lldb-dev mailing list