diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/loongarch-linux-nat.c | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | binutils-users/simark/clang-format.zip binutils-users/simark/clang-format.tar.gz binutils-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/loongarch-linux-nat.c')
-rw-r--r-- | gdb/loongarch-linux-nat.c | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c index 5eb32b0..2fa335a 100644 --- a/gdb/loongarch-linux-nat.c +++ b/gdb/loongarch-linux-nat.c @@ -34,11 +34,13 @@ class loongarch_linux_nat_target final : public linux_nat_trad_target { public: + /* Add our register access methods. */ void fetch_registers (struct regcache *, int) override; void store_registers (struct regcache *, int) override; protected: + /* Override linux_nat_trad_target methods. */ CORE_ADDR register_u_offset (struct gdbarch *gdbarch, int regnum, int store_p) override; @@ -53,21 +55,20 @@ fetch_gregs_from_thread (struct regcache *regcache, int regnum, pid_t tid) elf_gregset_t regset; if (regnum == -1 || (regnum >= 0 && regnum < 32) - || regnum == LOONGARCH_ORIG_A0_REGNUM - || regnum == LOONGARCH_PC_REGNUM + || regnum == LOONGARCH_ORIG_A0_REGNUM || regnum == LOONGARCH_PC_REGNUM || regnum == LOONGARCH_BADV_REGNUM) - { - struct iovec iov; - - iov.iov_base = ®set; - iov.iov_len = sizeof (regset); - - if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) - perror_with_name (_("Couldn't get NT_PRSTATUS registers")); - else - loongarch_gregset.supply_regset (nullptr, regcache, regnum, - ®set, sizeof (regset)); - } + { + struct iovec iov; + + iov.iov_base = ®set; + iov.iov_len = sizeof (regset); + + if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) + perror_with_name (_ ("Couldn't get NT_PRSTATUS registers")); + else + loongarch_gregset.supply_regset (nullptr, regcache, regnum, ®set, + sizeof (regset)); + } } /* Store to the current thread the valid general-purpose, orig_a0, pc and badv @@ -79,25 +80,24 @@ store_gregs_to_thread (struct regcache *regcache, int regnum, pid_t tid) elf_gregset_t regset; if (regnum == -1 || (regnum >= 0 && regnum < 32) - || regnum == LOONGARCH_ORIG_A0_REGNUM - || regnum == LOONGARCH_PC_REGNUM + || regnum == LOONGARCH_ORIG_A0_REGNUM || regnum == LOONGARCH_PC_REGNUM || regnum == LOONGARCH_BADV_REGNUM) - { - struct iovec iov; - - iov.iov_base = ®set; - iov.iov_len = sizeof (regset); - - if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) - perror_with_name (_("Couldn't get NT_PRSTATUS registers")); - else - { - loongarch_gregset.collect_regset (nullptr, regcache, regnum, - ®set, sizeof (regset)); - if (ptrace (PTRACE_SETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) - perror_with_name (_("Couldn't set NT_PRSTATUS registers")); - } - } + { + struct iovec iov; + + iov.iov_base = ®set; + iov.iov_len = sizeof (regset); + + if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) + perror_with_name (_ ("Couldn't get NT_PRSTATUS registers")); + else + { + loongarch_gregset.collect_regset (nullptr, regcache, regnum, ®set, + sizeof (regset)); + if (ptrace (PTRACE_SETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0) + perror_with_name (_ ("Couldn't set NT_PRSTATUS registers")); + } + } } /* Fill GDB's register array with the fp, fcc and fcsr @@ -109,15 +109,16 @@ fetch_fpregs_from_thread (struct regcache *regcache, int regnum, pid_t tid) elf_fpregset_t regset; if ((regnum == -1) - || (regnum >= LOONGARCH_FIRST_FP_REGNUM && regnum <= LOONGARCH_FCSR_REGNUM)) + || (regnum >= LOONGARCH_FIRST_FP_REGNUM + && regnum <= LOONGARCH_FCSR_REGNUM)) { struct iovec iovec = { .iov_base = ®set, .iov_len = sizeof (regset) }; if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, (long) &iovec) < 0) - perror_with_name (_("Couldn't get NT_FPREGSET registers")); + perror_with_name (_ ("Couldn't get NT_FPREGSET registers")); else - loongarch_fpregset.supply_regset (nullptr, regcache, regnum, - ®set, sizeof (regset)); + loongarch_fpregset.supply_regset (nullptr, regcache, regnum, ®set, + sizeof (regset)); } } @@ -130,18 +131,19 @@ store_fpregs_to_thread (struct regcache *regcache, int regnum, pid_t tid) elf_fpregset_t regset; if ((regnum == -1) - || (regnum >= LOONGARCH_FIRST_FP_REGNUM && regnum <= LOONGARCH_FCSR_REGNUM)) + || (regnum >= LOONGARCH_FIRST_FP_REGNUM + && regnum <= LOONGARCH_FCSR_REGNUM)) { struct iovec iovec = { .iov_base = ®set, .iov_len = sizeof (regset) }; if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, (long) &iovec) < 0) - perror_with_name (_("Couldn't get NT_FPREGSET registers")); + perror_with_name (_ ("Couldn't get NT_FPREGSET registers")); else { loongarch_fpregset.collect_regset (nullptr, regcache, regnum, ®set, sizeof (regset)); if (ptrace (PTRACE_SETREGSET, tid, NT_FPREGSET, (long) &iovec) < 0) - perror_with_name (_("Couldn't set NT_FPREGSET registers")); + perror_with_name (_ ("Couldn't set NT_FPREGSET registers")); } } } @@ -154,8 +156,8 @@ loongarch_linux_nat_target::fetch_registers (struct regcache *regcache, { pid_t tid = get_ptrace_pid (regcache->ptid ()); - fetch_gregs_from_thread(regcache, regnum, tid); - fetch_fpregs_from_thread(regcache, regnum, tid); + fetch_gregs_from_thread (regcache, regnum, tid); + fetch_fpregs_from_thread (regcache, regnum, tid); } /* Implement the "store_registers" target_ops method. */ @@ -167,7 +169,7 @@ loongarch_linux_nat_target::store_registers (struct regcache *regcache, pid_t tid = get_ptrace_pid (regcache->ptid ()); store_gregs_to_thread (regcache, regnum, tid); - store_fpregs_to_thread(regcache, regnum, tid); + store_fpregs_to_thread (regcache, regnum, tid); } /* Return the address in the core dump or inferior of register REGNO. */ @@ -221,6 +223,7 @@ fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregset, /* Initialize LoongArch Linux native support. */ void _initialize_loongarch_linux_nat (); + void _initialize_loongarch_linux_nat () { |