<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/135707>135707</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LLDB] s390x, incorrect byte order issues with `Cast` and `p/x $pc`
</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>
Version: `lldb 20.1.1`
Reproduction:
```console
qemu-s390x -g 1234 ./hello
```
Other terminal:
```console
(lldb) file ./hello
(lldb) gdb-remote 0:1234
(lldb) b main
Breakpoint 1: where = hello`main, address = 0x0000000001002228
(lldb) c
Process 3281862 resuming
Process 3281862 stopped
* thread #1, stop reason = breakpoint 1.1
frame #0: 0x0000000001002228 hello`main
hello`main:
0x1002228 <+0>: ear %r1, %a0
0x100222c <+4>: sllg %r4, %r1, 32
0x1002232 <+10>: stmg %r6, %r15, 48(%r15)
0x1002238 <+16>: ear %r4, %a1
(lldb) register read pc
pswa = 0x0000000001002228 hello`main
(lldb) p/x $pc
(unsigned long) 0x2822000100000000
(lldb)
```
The bug occurs for all registers, not just the `$pc`
We found out this bug, during implementing s390x support for pwndbg.
```console
In [20]: value = pwndbg.regs.by_name('r14')
In [21]: hex(int(value))
Out[21]: '0x7fb84143554a'
In [22]: hex(int(value.cast(pwndbg.aglib.typeinfo.unsigned)))
Out[22]: '0x4a554341b87f0000'
In [23]: pwndbg.aglib.typeinfo.unsigned.inner
Out[23]: unsigned long long
```
Basically internal lldb `Cast` function mess-up byte-ordering somehow.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8ld-O6yYQxp-G3IxiAf6bi1xkdxup0pFOVVXtZYXNxOYcDC7gTfL2FdjZTVa7x4qUEOb7fTPAGOG96g3inpRPpHzZiDkM1u0nEdz1Z9GwctNaed3_jc4ra0h-AFJRrWULnGYsY6SihB4IPfyJk7Ny7s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