<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/135839>135839</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LLDB] MIPS has missing aliases for register
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          patryk4815
      </td>
    </tr>
</table>

<pre>
    Same bug as in:
- https://github.com/llvm/llvm-project/issues/123903
- https://github.com/llvm/llvm-project/issues/124023

When debugging with gdbserver, some registers lack their "standard" aliases.

(btw qemu-mips don't work - I don't know why, probably qemu issue)

Steps to reproduction:
My small openwrt TP-LINK Switch with ~18MB disk space:
```
root@OpenWrt:/tmp# ./gdbserver 0:1234 /bin/sh
Process /bin/sh created; pid = 4445
Listening on port 1234
```
(not possible to build lldb-server, to fit there)

My host:
```
(lldb) file ./sh
Current executable set to '/tmp/dd/sh' (mipsr2).
(lldb) log enable gdb-remote all
(lldb) gdb-remote 192.168.1.1:1234
Process 4445 stopped
* thread #1, stop reason = signal SIGTRAP
    frame #0: 0x77f3abc0
->  0x77f3abc0: bal 0x77f3abd4
    0x77f3abc4: move   $fp, $zero
(lldb)
(lldb) register read k0
error: Invalid register name 'k0'.
(lldb) register read a0
error: Invalid register name 'a0'.
(lldb) register read v0
error: Invalid register name 'v0'.
```

Gdb protocol:
```
.lldb-wrapped    <  42> send packet: $qXfer:features:read:target.xml:0,2001e#73
.lldb-wrapped    < 618> read packet: $l<?xml version="1.0"?>
<!-- Copyright (C) 2007-2024 Free Software Foundation, Inc.

 *!Copying and distribution of this file, with or without modification,
 *!are permitted in any medium without royalty provided the copyright
 *!notice and this notice are preserved.  -->

<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
  <architecture>mips</architecture>
 <osabi>GNU/Linux</osabi>
  <xi:include href="mips-cpu.xml"/>
 <xi:include href="mips-cp0.xml"/>
  <xi:include href="mips-fpu.xml"/>

  <feature name="org.gnu.gdb.mips.linux">
 * <reg name="restart" bitsize="32" group="system"/>
 </feature>
</target>
#de
.lldb-wrapped    <  44> send packet: $qXfer:features:read:mips-cpu.xml:0,2001e#1a
.lldb-wrapped    <1559> read packet: $l<?xml version="1.0"?>
<!-- Copyright (C) 2007-2024 Free Software Foundation, Inc.

 *!Copying and distribution of this file, with or without modification,
 *!are permitted in any medium without royalty provided the copyright
 *!notice and this notice are preserved.  -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.cpu">
  <reg name="r0" bitsize="32" regnum="0"/>
  <reg name="r1" bitsize="32"/>
  <reg name="r2" bitsize="32"/>
  <reg name="r3" bitsize="32"/>
  <reg name="r4" bitsize="32"/>
  <reg name="r5" bitsize="32"/>
  <reg name="r6" bitsize="32"/>
  <reg name="r7" bitsize="32"/>
  <reg name="r8" bitsize="32"/>
  <reg name="r9" bitsize="32"/>
  <reg name="r10" bitsize="32"/>
  <reg name="r11" bitsize="32"/>
  <reg name="r12" bitsize="32"/>
  <reg name="r13" bitsize="32"/>
  <reg name="r14" bitsize="32"/>
  <reg name="r15" bitsize="32"/>
  <reg name="r16" bitsize="32"/>
  <reg name="r17" bitsize="32"/>
  <reg name="r18" bitsize="32"/>
  <reg name="r19" bitsize="32"/>
  <reg name="r20" bitsize="32"/>
  <reg name="r21" bitsize="32"/>
  <reg name="r22" bitsize="32"/>
  <reg name="r23" bitsize="32"/>
  <reg name="r24" bitsize="32"/>
  <reg name="r25" bitsize="32"/>
  <reg name="r26" bitsize="32"/>
  <reg name="r27" bitsize="32"/>
  <reg name="r28" bitsize="32"/>
  <reg name="r29" bitsize="32"/>
  <reg name="r30" bitsize="32"/>
  <reg name="r31" bitsize="32"/>

  <reg name="lo" bitsize="32" regnum="33"/>
  <reg name="hi" bitsize="32" regnum="34"/>
  <reg name="pc" bitsize="32" regnum="37"/>
</feature>
#9d
.lldb-wrapped    <  44> send packet: $qXfer:features:read:mips-cp0.xml:0,2001e#d5
.lldb-wrapped    < 514> read packet: $l<?xml version="1.0"?>
<!-- Copyright (C) 2007-2024 Free Software Foundation, Inc.

 *!Copying and distribution of this file, with or without modification,
 *!are permitted in any medium without royalty provided the copyright
 *!notice and this notice are preserved.  -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.cp0">
  <reg name="status" bitsize="32" regnum="32"/>
  <reg name="badvaddr" bitsize="32" regnum="35"/>
  <reg name="cause" bitsize="32" regnum="36"/>
</feature>
#f0
.lldb-wrapped    <  44> send packet: $qXfer:features:read:mips-fpu.xml:0,2001e#1d
.lldb-wrapped    <2131> read packet: $l<?xml version="1.0"?>
<!-- Copyright (C) 2007-2024 Free Software Foundation, Inc.

 *!Copying and distribution of this file, with or without modification,
 *!are permitted in any medium without royalty provided the copyright
 *!notice and this notice are preserved.  -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.fpu">
  <reg name="f0" bitsize="32" type="ieee_single" regnum="38"/>
  <reg name="f1" bitsize="32" type="ieee_single"/>
  <reg name="f2" bitsize="32" type="ieee_single"/>
  <reg name="f3" bitsize="32" type="ieee_single"/>
  <reg name="f4" bitsize="32" type="ieee_single"/>
  <reg name="f5" bitsize="32" type="ieee_single"/>
  <reg name="f6" bitsize="32" type="ieee_single"/>
  <reg name="f7" bitsize="32" type="ieee_single"/>
  <reg name="f8" bitsize="32" type="ieee_single"/>
  <reg name="f9" bitsize="32" type="ieee_single"/>
  <reg name="f10" bitsize="32" type="ieee_single"/>
  <reg name="f11" bitsize="32" type="ieee_single"/>
  <reg name="f12" bitsize="32" type="ieee_single"/>
  <reg name="f13" bitsize="32" type="ieee_single"/>
  <reg name="f14" bitsize="32" type="ieee_single"/>
  <reg name="f15" bitsize="32" type="ieee_single"/>
  <reg name="f16" bitsize="32" type="ieee_single"/>
  <reg name="f17" bitsize="32" type="ieee_single"/>
  <reg name="f18" bitsize="32" type="ieee_single"/>
  <reg name="f19" bitsize="32" type="ieee_single"/>
  <reg name="f20" bitsize="32" type="ieee_single"/>
  <reg name="f21" bitsize="32" type="ieee_single"/>
  <reg name="f22" bitsize="32" type="ieee_single"/>
  <reg name="f23" bitsize="32" type="ieee_single"/>
  <reg name="f24" bitsize="32" type="ieee_single"/>
  <reg name="f25" bitsize="32" type="ieee_single"/>
  <reg name="f26" bitsize="32" type="ieee_single"/>
  <reg name="f27" bitsize="32" type="ieee_single"/>
  <reg name="f28" bitsize="32" type="ieee_single"/>
  <reg name="f29" bitsize="32" type="ieee_single"/>
  <reg name="f30" bitsize="32" type="ieee_single"/>
  <reg name="f31" bitsize="32" type="ieee_single"/>

  <reg name="fcsr" bitsize="32" group="float"/>
  <reg name="fir" bitsize="32" group="float"/>
</feature>
#dc
```

Not sure if it is good source: https://mathcs.holycross.edu/~csci226/MIPS/summaryHO.pdf
But I follows this register aliases.
<img width="877" alt="Image" src="https://github.com/user-attachments/assets/22763d91-de79-4e22-81ae-e7c9351f3be6" />
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWktv4zgS_jXMpWBBLMqvQw5uJ-4Ntl_Y9GJ2TgtKpCRuJFFDUnY8h_ntC0p2Hp0oznKMBQZooIG0aNZHVtX3UVU2ubWqaKS8JNMPZHp1wTtXanPZcmf2d8mCTi9SLfaXt7yWkHYFcAuqIWxF4tUESuda6x9wQ3BTKFd2aZTpmuCmqrbHP5PW6P_IzBHcKGs7aQluKLJlzP40SBKjByHx6pdSNiBk2hWFagrYKVdCIVIrzVYagmuwupZgZKGsk8ZCxbM7cKVUBgiidbwR3AiCCLxS3EobDbgEF6nbwW-y7ia1ai0I3RCcO9hpcwcTuHkYuGv0Dnbl3i_WGp3ytNr3dtBvmOByQLx1srXgNBjZGi26zCl9iOjnPdiaVxXoVjY74-D7t8mnmy9_h9udclk5ePUHXXz-AELZO7Atz-RgSmbx4V-8Mlo7ksRfW9n8YtwQWle3BBlEPs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