Commit b708926
Automerge: [lldb][LoongArch] Fix the incorrect floating-point register dwarf number
According to the documentation described at
https://github.com/loongson/la-abi-specs/blob/release/ladwarf.adoc, the
dwarf numbers for floating-point registers range from 32 to 63.
An incorrect dwarf number will prevent the register values from being
properly restored during unwinding.
This test reflects this problem:
```
loongson@linux:~$ cat test.c
void foo() {
asm volatile ("movgr2fr.d $fs2, $ra":::"$fs2");
}
int main() {
asm volatile ("movgr2fr.d $fs2, $sp":::"$fs2");
foo();
return 0;
}
loongson@linux:~$ clang -g test.c -o test
```
Without this patch:
```
loongson@linux:~$ ./_build/bin/lldb ./t
(lldb) target create "./t"
Current executable set to
'/home/loongson/llvm-project/_build_lldb/t' (loongarch64).
(lldb) b foo
Breakpoint 1: where = t`foo + 20 at test.c:4:1, address =
0x0000000000000714
(lldb) r
Process 2455626 launched: '/home/loongson/llvm-project/_build_lldb/t' (loongarch64)
Process 2455626 stopped
* thread #1, name = 't', stop reason = breakpoint 1.1
frame #0: 0x0000555555554714 t`foo at test.c:4:1
1 #include <stdio.h>
2
3 void foo() {
-> 4 asm volatile ("movgr2fr.d $fs2, $ra":::"$fs2");
5 }
6 int main() {
7 asm volatile ("movgr2fr.d $fs2, $sp":::"$fs2");
(lldb) si
Process 2455626 stopped
* thread #1, name = 't', stop reason = instruction step into
frame #0: 0x0000555555554718 t`foo at test.c:4:1
1 #include <stdio.h>
2
3 void foo() {
-> 4 asm volatile ("movgr2fr.d $fs2, $ra":::"$fs2");
5 }
6 int main() {
7 asm volatile ("movgr2fr.d $fs2, $sp":::"$fs2");
(lldb) f 1
frame #1: 0x0000555555554768 t`main at test.c:8:1
5 }
6 int main() {
7 asm volatile ("movgr2fr.d $fs2, $sp":::"$fs2");
-> 8 foo();
9 return 0;
10 }
(lldb) register read -a
General Purpose Registers:
r1 = 0x0000555555554768 t`main + 40 at test.c:8:1
r3 = 0x00007ffffffef780
r22 = 0x00007ffffffef7b0
r23 = 0x00007ffffffef918
r24 = 0x0000000000000001
r25 = 0x0000000000000000
r26 = 0x000055555555be08 t`__do_global_dtors_aux_fini_array_entry
r27 = 0x0000555555554740 t`main at test.c:6
r28 = 0x00007ffffffef928
r29 = 0x00007ffff7febc88 ld-linux-loongarch-lp64d.so.1`_rtld_global_ro
r30 = 0x000055555555be08 t`__do_global_dtors_aux_fini_array_entry
pc = 0x0000555555554768 t`main + 40 at test.c:8:1
33 registers were unavailable.
Floating Point Registers:
f13 = 0x00007ffffffef780 !!!!! wrong register
f24 = 0xffffffffffffffff
f25 = 0xffffffffffffffff
f26 = 0x0000555555554768 t`main + 40 at test.c:8:1
f27 = 0xffffffffffffffff
f28 = 0xffffffffffffffff
f29 = 0xffffffffffffffff
f30 = 0xffffffffffffffff
f31 = 0xffffffffffffffff
32 registers were unavailable.
```
With this patch:
```
The previous operations are the same.
(lldb) register read -a
General Purpose Registers:
r1 = 0x0000555555554768 t`main + 40 at test.c:8:1
r3 = 0x00007ffffffef780
r22 = 0x00007ffffffef7b0
r23 = 0x00007ffffffef918
r24 = 0x0000000000000001
r25 = 0x0000000000000000
r26 = 0x000055555555be08 t`__do_global_dtors_aux_fini_array_entry
r27 = 0x0000555555554740 t`main at test.c:6
r28 = 0x00007ffffffef928
r29 = 0x00007ffff7febc88 ld-linux-loongarch-lp64d.so.1`_rtld_global_ro
r30 = 0x000055555555be08 t`__do_global_dtors_aux_fini_array_entry
pc = 0x0000555555554768 t`main + 40 at test.c:8:1
33 registers were unavailable.
Floating Point Registers:
f24 = 0xffffffffffffffff
f25 = 0xffffffffffffffff
f26 = 0x00007ffffffef780
f27 = 0xffffffffffffffff
f28 = 0xffffffffffffffff
f29 = 0xffffffffffffffff
f30 = 0xffffffffffffffff
f31 = 0xffffffffffffffff
33 registers were unavailable.
```
Reviewed By: SixWeining
Pull Request: llvm/llvm-project#1203911 file changed
+19
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 50 | + | |
66 | 51 | | |
67 | 52 | | |
68 | 53 | | |
| |||
93 | 78 | | |
94 | 79 | | |
95 | 80 | | |
96 | | - | |
| 81 | + | |
97 | 82 | | |
98 | 83 | | |
99 | 84 | | |
| |||
170 | 155 | | |
171 | 156 | | |
172 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
0 commit comments