This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/5] RISC-V: Add native linux support.
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Jim Wilson <jimw at sifive dot com>, gdb-patches at sourceware dot org
- Date: Thu, 25 Oct 2018 12:09:47 +0100
- Subject: Re: [PATCH 4/5] RISC-V: Add native linux support.
- References: <CAFyWVaZoF3a=-QjADoUdzq_hz5skHVaxmXtB1X5ZT-a_sns5PA@mail.gmail.com> <20180808233908.8149-1-jimw@sifive.com> <mvm8t2mpahm.fsf@suse.de>
* Andreas Schwab <schwab@suse.de> [2018-10-25 12:49:09 +0200]:
> On Aug 08 2018, Jim Wilson <jimw@sifive.com> wrote:
>
> > + if ((regnum == RISCV_CSR_MISA_REGNUM)
> > + || (regnum == -1))
> > + {
> > + /* TODO: Need to add a ptrace call for this. */
> > + regcache->raw_supply_zeroed (regnum);
>
> ../../gdb/gdb/regcache.c:337: internal-error: void reg_buffer::assert_regnum(int) const: Assertion `regnum >= 0' failed.
Thanks for the report.
I pushed the patch below to fix this issue.
Thanks,
Andrew
---
[PATCH] gdb/riscv: Use correct regnum in riscv_linux_nat_target::fetch_registers
In riscv_linux_nat_target::fetch_registers, if we are asked to supply
all registers (regnum parameter is -1), then we currently end up
calling regcache::raw_supply_zeroed with the regnum -1, which is
invalid. Instead we should be passing the regnum of the specific
register we wish to supply zeroed, in this case RISCV_CSR_MISA_REGNUM.
I removed the extra { ... } block in line with the coding standard
while editing this area.
gdb/ChangeLog:
* riscv-linux-nat.c (riscv_linux_nat_target::fetch_registers):
Pass correct regnum to raw_supply_zeroed.
---
gdb/ChangeLog | 5 +++++
gdb/riscv-linux-nat.c | 6 ++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gdb/riscv-linux-nat.c b/gdb/riscv-linux-nat.c
index 7dbfe651f2c..c09121d052b 100644
--- a/gdb/riscv-linux-nat.c
+++ b/gdb/riscv-linux-nat.c
@@ -201,10 +201,8 @@ riscv_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
if ((regnum == RISCV_CSR_MISA_REGNUM)
|| (regnum == -1))
- {
- /* TODO: Need to add a ptrace call for this. */
- regcache->raw_supply_zeroed (regnum);
- }
+ /* TODO: Need to add a ptrace call for this. */
+ regcache->raw_supply_zeroed (RISCV_CSR_MISA_REGNUM);
/* Access to other CSRs has potential security issues, don't support them for
now. */
--
2.14.5