[PATCH] RISC-V: Dump CSR according to the elf privileged spec attributes.

Jim Wilson jimw@sifive.com
Thu Dec 10 00:31:40 GMT 2020


On Tue, Dec 8, 2020 at 2:14 AM Nelson Chu <nelson.chu@sifive.com> wrote:

> I see that csky and rl78 define their get_disassembler in the
> opcodes/disassemble.h, but arc and cris define their get_disassembler
> in the include/dis-asm.h.  I'm a little confused about whether the
> get_disassembler change will affect the current riscv-gdb or not...
> It would be great if you can give me some suggestions or comments, to
> make sure that if this change is fine to you :)
>

The comments at the top of opcodes/disassembler.h and include/dis-asm.h
explain their purpose.  disassembler.h is for internal use in opcodes.
dis-asm.h is for communication between opcodes and users like gdb.  The arc
get_disassembler is in dis-asm.h because gdb used to call it directly.  If
I look at gdb-5.2.1 I see that gdb/arc-tdep.c has a arc_print_insn function
that calls arc_get_disassembler.  The gdb arc port was dropped in 2002.
Then a new one was added in 2016.  The new one does not call
arc_get_disassembler.  It looks like the declaration in dis-asm.h is an old
artifact, and it should be moved to disassembler.h as a separate patch, or
maybe file a bug report for the arc maintainer to fix.  The story with cris
in simpler, I can see the cris_get_disassembler call being removed from gdb
in an infrastructure change in 2017.  However, there is a cris gdb sim that
still calls it, so it looks like we still need the declaration in
dis-asm.h.  Unless we rewrite the simulator to avoid the call.

As for gdb, I'd say that there are 3 sources for the priv spec, the priv
spec specified by the target (gdb server/openocd), the priv spec specified
by the elf file, and the priv spec specified by the user.  The one returned
by the target probably should take precedence.  However, currently, I think
there is no way for the user to specify this.  And probably no way for the
target xml file to specify this.  If this xml feature is added later, gdb
should probably use disassembler_options to pass the info to the
disassembler, so your patch should still work.  There is just the
precedence issue, but if you are always warning it should be OK.

Jim


More information about the Binutils mailing list