Fix riscv-linux native gdb build failure.
Commit Message
The linux kernel uses NT_PRFPREG. Glibc before BZ 14890 defines NT_FPREGSET.
After it defines both. Avoid glibc version dependency by using the gdb header
file instead of the glibc header file, and the macro name that gdb defines
which is NT_FPREGSET.
Tested with riscv-linux make and make check with no regressions. OK to
commit?
Jim
gdb/
* riscv-linux-nat.c: Include elf/common.h instead of elf.h.
(riscv_linux_nat_target::fetch_registers): Use NT_FPREGSET instead
of NT_PRFPREG.
(riscv_linux_nat_target::store_registers): Likewise.
---
gdb/riscv-linux-nat.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
* Jim Wilson <jimw@sifive.com> [2018-08-28 16:04:40 -0700]:
> The linux kernel uses NT_PRFPREG. Glibc before BZ 14890 defines NT_FPREGSET.
> After it defines both. Avoid glibc version dependency by using the gdb header
> file instead of the glibc header file, and the macro name that gdb defines
> which is NT_FPREGSET.
>
> Tested with riscv-linux make and make check with no regressions. OK to
> commit?
>
> Jim
>
> gdb/
> * riscv-linux-nat.c: Include elf/common.h instead of elf.h.
> (riscv_linux_nat_target::fetch_registers): Use NT_FPREGSET instead
> of NT_PRFPREG.
> (riscv_linux_nat_target::store_registers): Likewise.
Looks good to me.
Thanks,
Andrew
> ---
> gdb/riscv-linux-nat.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/riscv-linux-nat.c b/gdb/riscv-linux-nat.c
> index 3faa9f9c1f..7dbfe651f2 100644
> --- a/gdb/riscv-linux-nat.c
> +++ b/gdb/riscv-linux-nat.c
> @@ -20,9 +20,10 @@
> #include "regcache.h"
> #include "gregset.h"
> #include "linux-nat.h"
> -#include "elf.h"
> #include "riscv-tdep.h"
>
> +#include "elf/common.h"
> +
> #include <sys/ptrace.h>
>
> /* RISC-V Linux native additions to the default linux support. */
> @@ -191,7 +192,7 @@ riscv_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
> iov.iov_base = ®s;
> iov.iov_len = sizeof (regs);
>
> - if (ptrace (PTRACE_GETREGSET, tid, NT_PRFPREG,
> + if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET,
> (PTRACE_TYPE_ARG3) &iov) == -1)
> perror_with_name (_("Couldn't get registers"));
> else
> @@ -252,14 +253,14 @@ riscv_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
> iov.iov_base = ®s;
> iov.iov_len = sizeof (regs);
>
> - if (ptrace (PTRACE_GETREGSET, tid, NT_PRFPREG,
> + if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET,
> (PTRACE_TYPE_ARG3) &iov) == -1)
> perror_with_name (_("Couldn't get registers"));
> else
> {
> fill_fpregset (regcache, ®s, regnum);
>
> - if (ptrace (PTRACE_SETREGSET, tid, NT_PRFPREG,
> + if (ptrace (PTRACE_SETREGSET, tid, NT_FPREGSET,
> (PTRACE_TYPE_ARG3) &iov) == -1)
> perror_with_name (_("Couldn't set registers"));
> }
> --
> 2.17.1
>
On Wed, Aug 29, 2018 at 3:44 AM, Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
> * Jim Wilson <jimw@sifive.com> [2018-08-28 16:04:40 -0700]:
>> gdb/
>> * riscv-linux-nat.c: Include elf/common.h instead of elf.h.
>> (riscv_linux_nat_target::fetch_registers): Use NT_FPREGSET instead
>> of NT_PRFPREG.
>> (riscv_linux_nat_target::store_registers): Likewise.
>
> Looks good to me.
Thanks. Committed.
Jim
@@ -20,9 +20,10 @@
#include "regcache.h"
#include "gregset.h"
#include "linux-nat.h"
-#include "elf.h"
#include "riscv-tdep.h"
+#include "elf/common.h"
+
#include <sys/ptrace.h>
/* RISC-V Linux native additions to the default linux support. */
@@ -191,7 +192,7 @@ riscv_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
iov.iov_base = ®s;
iov.iov_len = sizeof (regs);
- if (ptrace (PTRACE_GETREGSET, tid, NT_PRFPREG,
+ if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET,
(PTRACE_TYPE_ARG3) &iov) == -1)
perror_with_name (_("Couldn't get registers"));
else
@@ -252,14 +253,14 @@ riscv_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
iov.iov_base = ®s;
iov.iov_len = sizeof (regs);
- if (ptrace (PTRACE_GETREGSET, tid, NT_PRFPREG,
+ if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET,
(PTRACE_TYPE_ARG3) &iov) == -1)
perror_with_name (_("Couldn't get registers"));
else
{
fill_fpregset (regcache, ®s, regnum);
- if (ptrace (PTRACE_SETREGSET, tid, NT_PRFPREG,
+ if (ptrace (PTRACE_SETREGSET, tid, NT_FPREGSET,
(PTRACE_TYPE_ARG3) &iov) == -1)
perror_with_name (_("Couldn't set registers"));
}