Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Marek Pikula <m.pikula@partner.samsung.com>
To: gdb-patches@sourceware.org
Cc: s.rutka@samsung.com, palmer@dabbelt.com, andrew@sifive.com,
	jim.wilson.gcc@gmail.com, nelson@rivosinc.com,
	f.wasil@samsung.com
Subject: Re: [PATCH v2] RISC-V: Fix ISA string detection for disassembly
Date: Wed, 28 May 2025 15:14:40 +0200	[thread overview]
Message-ID: <fcd410e0-5c70-49c1-bc09-0161472a96c9@partner.samsung.com> (raw)
In-Reply-To: <20250528115447.2750177-1-m.pikula@partner.samsung.com>

This patch addresses previous feedback from Andrew Burgess.

On 28.05.2025 13:54, Marek Pikuła wrote:
> Commit 3f61a38 introduced a regression where the ISA string was no
> longer detected based on the ELF header. The mechanism was changed from
> directly referencing `abfd` to using `disassembler_info->section`, which
> was not properly initialized for RISC-V.
>
> The previous implementation ignored the object in scope, leading to
> issues such as failing to decode RVV instructions when a library was
> compiled as `rv64gcv` and the main application as `rv64gc`.
>
> This patch resolves both problems by initializing
> `disassembler_info->section` with the object currently in scope,
> ensuring correct ISA string detection during disassembly.
>
> Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
> ---
>   gdb/riscv-tdep.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> index 8998a297315..01e5dd00153 100644
> --- a/gdb/riscv-tdep.c
> +++ b/gdb/riscv-tdep.c
> @@ -4163,6 +4163,19 @@ riscv_gnu_triplet_regexp (struct gdbarch *gdbarch)
>     return "riscv(32|64)?";
>   }
>
> +/* Implement the "print_insn" gdbarch method.  */
> +static int
> +riscv_print_insn (bfd_vma addr, struct disassemble_info *info)
> +{
> +  /* Initialize the BFD section to enable ISA string detection depending on the
> +     object in scope.  */
> +  struct obj_section *s = find_pc_section (addr);
> +  if (s != nullptr)
> +    info->section = s->the_bfd_section;
> +
> +  return default_print_insn (addr, info);
> +}
> +
>   /* Implementation of `gdbarch_stap_is_single_operand', as defined in
>      gdbarch.h.  */
>
> @@ -4429,6 +4442,9 @@ riscv_gdbarch_init (struct gdbarch_info info,
>   					  disassembler_options_riscv ());
>     set_gdbarch_disassembler_options (gdbarch, &riscv_disassembler_options);
>
> +  /* Disassembler print_insn.  */
> +  set_gdbarch_print_insn (gdbarch, riscv_print_insn);
> +
>     /* SystemTap Support.  */
>     set_gdbarch_stap_is_single_operand (gdbarch, riscv_stap_is_single_operand);
>     set_gdbarch_stap_register_indirection_prefixes
> --
> 2.49.0
>

  reply	other threads:[~2025-05-28 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250528115450eucas1p1e57249bb51f4b7f41741772f60186468@eucas1p1.samsung.com>
2025-05-28 11:54 ` Marek Pikuła
2025-05-28 13:14   ` Marek Pikula [this message]
2025-07-09 15:53     ` Marek Pikula
2025-07-17 17:07       ` Andrew Burgess
2025-07-17 17:14         ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fcd410e0-5c70-49c1-bc09-0161472a96c9@partner.samsung.com \
    --to=m.pikula@partner.samsung.com \
    --cc=andrew@sifive.com \
    --cc=f.wasil@samsung.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=nelson@rivosinc.com \
    --cc=palmer@dabbelt.com \
    --cc=s.rutka@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox