lh03061238 created this revision. lh03061238 added reviewers: SixWeining, wangleiat, xen0n, xry111, MaskRay, seehearfeel, DavidSpickett. Herald added subscribers: jeroen.dobbelaere, StephenFan. Herald added a project: All. lh03061238 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
In LoongArch_DWARF_Registers.h, r22 is defined twice. Having an extra array member causes problems reading and writing registers defined after r22. So, for r22, keep the alias fp, delete the s9 alias. The PC register is incorrectly accessed when the step command is executed. The step command behavior is incorrect. This test reflects this problem: loongson@linux:~$ cat test.c #include <stdio.h> int func(int a) { return a + 1; } int main(int argc, char const *argv[]) { func(10); return 0; } loongson@linux:~$ clang -g test.c -o test Without this patch: loongson@linux:~$ llvm-project/llvm/build/bin/lldb test (lldb) target create "test" Current executable set to '/home/loongson/test' (loongarch64). (lldb) b main Breakpoint 1: where = test`main + 40 at test.c:8:3, address = 0x0000000120000668 (lldb) r Process 278049 launched: '/home/loongson/test' (loongarch64) Process 278049 stopped * thread #1, name = 'test', stop reason = breakpoint 1.1 frame #0: 0x0000000120000668 test`main(argc=1, argv=0x00007fffffff72a8) at test.c:8:3 5 } 6 7 int main(int argc, char const *argv[]) { -> 8 func(10); 9 return 0; 10 } 11 (lldb) s Process 278049 stopped * thread #1, name = 'test', stop reason = step in frame #0: 0x0000000120000670 test`main(argc=1, argv=0x00007fffffff72a8) at test.c:9:3 6 7 int main(int argc, char const *argv[]) { 8 func(10); -> 9 return 0; 10 } With this patch: loongson@linux:~$ llvm-project/llvm/build/bin/lldb test (lldb) target create "test" Current executable set to '/home/loongson/test' (loongarch64). (lldb) b main Breakpoint 1: where = test`main + 40 at test.c:8:3, address = 0x0000000120000668 (lldb) r Process 278632 launched: '/home/loongson/test' (loongarch64) Process 278632 stopped * thread #1, name = 'test', stop reason = breakpoint 1.1 frame #0: 0x0000000120000668 test`main(argc=1, argv=0x00007fffffff72a8) at test.c:8:3 5 } 6 7 int main(int argc, char const *argv[]) { -> 8 func(10); 9 return 0; 10 } 11 (lldb) s Process 278632 stopped * thread #1, name = 'test', stop reason = step in frame #0: 0x0000000120000624 test`func(a=10) at test.c:4:10 1 #include <stdio.h> 2 3 int func(int a) { -> 4 return a + 1; 5 } Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140615 Files: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h lldb/source/Utility/LoongArch_DWARF_Registers.h Index: lldb/source/Utility/LoongArch_DWARF_Registers.h =================================================================== --- lldb/source/Utility/LoongArch_DWARF_Registers.h +++ lldb/source/Utility/LoongArch_DWARF_Registers.h @@ -128,7 +128,6 @@ dwarf_gpr_t7 = dwarf_gpr_r19, dwarf_gpr_t8 = dwarf_gpr_r20, dwarf_gpr_fp = dwarf_gpr_r22, - dwarf_gpr_s9 = dwarf_gpr_r22, dwarf_gpr_s0 = dwarf_gpr_r23, dwarf_gpr_s1 = dwarf_gpr_r24, dwarf_gpr_s2 = dwarf_gpr_r25, Index: lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h =================================================================== --- lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h +++ lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h @@ -85,7 +85,6 @@ gpr_t7_loongarch = gpr_r19_loongarch, gpr_t8_loongarch = gpr_r20_loongarch, gpr_fp_loongarch = gpr_r22_loongarch, - gpr_s9_loongarch = gpr_r22_loongarch, gpr_s0_loongarch = gpr_r23_loongarch, gpr_s1_loongarch = gpr_r24_loongarch, gpr_s2_loongarch = gpr_r25_loongarch, Index: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h +++ lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h @@ -100,7 +100,6 @@ DEFINE_GPR64_ALT(r20, t8, LLDB_INVALID_REGNUM), DEFINE_GPR64(r21, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r22, fp, LLDB_REGNUM_GENERIC_FP), - DEFINE_GPR64_ALT(r22, s9, LLDB_REGNUM_GENERIC_FP), DEFINE_GPR64_ALT(r23, s0, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r24, s1, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r25, s2, LLDB_INVALID_REGNUM),
Index: lldb/source/Utility/LoongArch_DWARF_Registers.h =================================================================== --- lldb/source/Utility/LoongArch_DWARF_Registers.h +++ lldb/source/Utility/LoongArch_DWARF_Registers.h @@ -128,7 +128,6 @@ dwarf_gpr_t7 = dwarf_gpr_r19, dwarf_gpr_t8 = dwarf_gpr_r20, dwarf_gpr_fp = dwarf_gpr_r22, - dwarf_gpr_s9 = dwarf_gpr_r22, dwarf_gpr_s0 = dwarf_gpr_r23, dwarf_gpr_s1 = dwarf_gpr_r24, dwarf_gpr_s2 = dwarf_gpr_r25, Index: lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h =================================================================== --- lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h +++ lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h @@ -85,7 +85,6 @@ gpr_t7_loongarch = gpr_r19_loongarch, gpr_t8_loongarch = gpr_r20_loongarch, gpr_fp_loongarch = gpr_r22_loongarch, - gpr_s9_loongarch = gpr_r22_loongarch, gpr_s0_loongarch = gpr_r23_loongarch, gpr_s1_loongarch = gpr_r24_loongarch, gpr_s2_loongarch = gpr_r25_loongarch, Index: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h +++ lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h @@ -100,7 +100,6 @@ DEFINE_GPR64_ALT(r20, t8, LLDB_INVALID_REGNUM), DEFINE_GPR64(r21, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r22, fp, LLDB_REGNUM_GENERIC_FP), - DEFINE_GPR64_ALT(r22, s9, LLDB_REGNUM_GENERIC_FP), DEFINE_GPR64_ALT(r23, s0, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r24, s1, LLDB_INVALID_REGNUM), DEFINE_GPR64_ALT(r25, s2, LLDB_INVALID_REGNUM),
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits