From: Gopi Kumar Bulusu <gopi@sankhya.com>
To: Tom de Vries <tdevries@suse.de>
Cc: Simon Marchi <simark@simark.ca>,
gdb-patches@sourceware.org, Michael Eager <eager@eagercon.com>
Subject: Re: [PATCH v2 ] MicroBlaze: Add microblaze_get_next_pcs
Date: Fri, 5 Sep 2025 14:57:36 +0530 [thread overview]
Message-ID: <CAL1P33yVRHB8Bs0AfAegE22HPOfs5Ej62NmR9FRVpUUT2UT+0w@mail.gmail.com> (raw)
In-Reply-To: <9e20ab3e-b7d2-42d8-9444-1985e75f60bd@suse.de>
[-- Attachment #1: Type: text/plain, Size: 6358 bytes --]
On Fri, Sep 5, 2025 at 2:59 PM Tom de Vries <tdevries@suse.de> wrote:
> On 9/3/25 19:57, Simon Marchi wrote:
> > On 9/2/25 8:27 AM, Gopi Kumar Bulusu wrote:
> >> From 7f2bacc6fffa6830991da36c2044431237bacba1 Mon Sep 17 00:00:00 2001
> >> From: Gopi Kumar Bulusu <gopi@sankhya.com>
> >> Date: Tue, 12 Aug 2025 09:42:48 +0530
> >> Subject: [PATCH v2] MicroBlaze: Add microblaze_get_next_pcs
> >>
> >> This patch enables software single stepping for gdbserver target
> >>
> >> * gdb/microblaze-tdep.c: Add microblaze_get_next_pcs
> >>
> >> Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
> >> Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
> >> Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
> >> Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
> >> ---
> >> gdb/microblaze-tdep.c | 91 +++++++++++++++++++++++++++++++++++++++++++
> >> 1 file changed, 91 insertions(+)
> >>
> >> diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
> >> index 7b58220871c..cacec8ba186 100644
> >> --- a/gdb/microblaze-tdep.c
> >> +++ b/gdb/microblaze-tdep.c
> >> @@ -590,6 +590,95 @@ microblaze_stabs_argument_has_addr (struct gdbarch
> *gdbarch, struct type *type)
> >> return (type->length () == 16);
> >> }
> >>
> >> +/* Return next pc values : next in sequence and/or branch/return
> target. */
> >> +
> >> +static std::vector<CORE_ADDR>
> >> +microblaze_get_next_pcs (regcache *regcache)
> >> +{
> >> + CORE_ADDR pc = regcache_read_pc (regcache);
> >> + long insn = microblaze_fetch_instruction (pc);
> >> +
> >> + enum microblaze_instr_type insn_type;
> >> + short delay_slots;
> >> + bool isunsignednum;
> >> +
> >> + /* If the current instruction is an imm, look at the inst after. */
> >> +
> >> + get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
> >> +
> >> + int imm;
> >> + bool immfound = false;
> >> +
> >> + if (insn_type == immediate_inst)
> >> + {
> >> + int rd, ra, rb;
> >> + immfound = true;
> >> + microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
> >> + pc += INST_WORD_SIZE;
> >> + insn = microblaze_fetch_instruction (pc);
> >> + get_insn_microblaze (insn, &isunsignednum, &insn_type,
> &delay_slots);
> >> + }
> >> +
> >> + std::optional<CORE_ADDR> next_pc, branch_or_return_pc;
> >> +
> >> + /* Compute next instruction address - skip delay slots if any. */
> >> +
> >> + if (insn_type != return_inst)
> >> + next_pc = pc + INST_WORD_SIZE + (delay_slots * INST_WORD_SIZE);
> >> +
> >> + microblaze_debug ("single-step insn_type=0x%x pc=0x%lx insn=0x%lx\n",
> >> + insn_type, pc, insn);
> >
> > You shouldn't need the trailing \n. Apply elsewhere too.
> >
> >> +
> >> + /* Compute target instruction address for branch or return
> instruction. */
> >> + if (insn_type == branch_inst || insn_type == return_inst)
> >> + {
> >> + int limm;
> >> + int lrd, lra, lrb;
> >> + long ra, rb;
> >> + bool targetvalid;
> >> + bool unconditionalbranch;
> >
> > Declare when first use, where possible (ra and rb).
> >
> > ra and rb should probably be of the type ULONGEST.
> >
> >> +
> >> + microblaze_decode_insn (insn, &lrd, &lra, &lrb, &limm);
> >> + ra = regcache_raw_get_unsigned (regcache, lra);
> >> + rb = regcache_raw_get_unsigned (regcache, lrb);
> >> +
> >> + branch_or_return_pc = microblaze_get_target_address (insn,
> immfound,
> >> + imm, pc, ra, rb, &targetvalid, &unconditionalbranch);
> >
> > Format like this:
> >
> > branch_or_return_pc
> > = microblaze_get_target_address (insn, immfound,
> > imm, pc, ra, rb, &targetvalid,
> > &unconditionalbranch);
> >
> >> +
> >> + microblaze_debug (
> >> + "single-step uncondbr=%d targetvalid=%d
> target=0x%lx\n",
> >> + unconditionalbranch, targetvalid,
> >> + branch_or_return_pc.value () );
> >
> > Format like this:
> >
> > microblaze_debug ("single-step uncondbr=%d targetvalid=%d
> target=0x%lx",
> > unconditionalbranch, targetvalid,
> > branch_or_return_pc.value ());
> >
> >> +
> >> + /* Can't reach next address. */
> >> + if (unconditionalbranch)
> >> + next_pc.reset ();
> >> +
> >> + /* Can't reach a distinct (not here) target address. */
> >> + if (! targetvalid || branch_or_return_pc == pc ||
> >> + (next_pc && (branch_or_return_pc == next_pc)))
> >> + branch_or_return_pc.reset ();
> >
> > Format like this:
> >
> > /* Can't reach a distinct (not here) target address. */
> > if (!targetvalid
> > || branch_or_return_pc == pc
> > || (next_pc.has_value () && branch_or_return_pc == next_pc))
> > branch_or_return_pc.reset ();
> >
> >
> >> + } /* if (branch or return instruction). */
> >> +
> >> + /* Create next_pcs vector to return. */
> >> +
> >> + std::vector<CORE_ADDR> next_pcs;
> >> +
> >> + if (next_pc)
> >
> > .has_value ()
> >
> >> + {
> >> + next_pcs.push_back (next_pc.value () );
> >
> > We typically use `*next_pc` to access the value (apply elsewhere too).
> >
> > Remove the space before closing parenthesis (apply elsewhere too).
> >
> >> + microblaze_debug ("push_back next_pc(0x%lx)\n", next_pc.value ()
> );
> >> + }
> >> +
> >> + if (branch_or_return_pc)
> >> + {
> >> + next_pcs.push_back ( branch_or_return_pc.value () );
> >> + microblaze_debug ("push_back branch_or_return_pc(0x%lx)\n",
> >> + branch_or_return_pc.value ());
> >
> > Align the last line properly.
> >
> > The patch LGTM with those fixed. Let me know if you need help pushing
> > the patch.
> >
>
> This caused a buildbreaker on arm-linux with --enable-targets=all and
> --enable-64-bit-bfd.
>
>
reverted commit c6df5d79aac5c4a77c06314fd26c837470360f70
dhanyavaadaaha
gopi
I've filed a PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=33381 ).
> Thanks,
> - Tom
>
> > Approved-By: Simon Marchi <simon.marchi@efficios.com>
> >
> > Simon
>
>
[-- Attachment #2: Type: text/html, Size: 9160 bytes --]
next prev parent reply other threads:[~2025-09-05 9:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 5:30 [PATCH] MicroBlaze: Add microblaze_software_single_step Gopi Kumar Bulusu
2025-08-13 20:11 ` Simon Marchi
2025-08-14 10:28 ` Gopi Kumar Bulusu
2025-09-02 12:27 ` [PATCH v2 ] MicroBlaze: Add microblaze_get_next_pcs Gopi Kumar Bulusu
2025-09-03 17:57 ` Simon Marchi
2025-09-03 18:02 ` Michael Eager
2025-09-04 11:43 ` Gopi Kumar Bulusu
2025-09-04 11:40 ` Gopi Kumar Bulusu
2025-09-05 9:29 ` Tom de Vries
2025-09-05 9:27 ` Gopi Kumar Bulusu [this message]
2025-09-05 13:24 ` Tom Tromey
2025-09-05 13:29 ` Gopi Kumar Bulusu
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=CAL1P33yVRHB8Bs0AfAegE22HPOfs5Ej62NmR9FRVpUUT2UT+0w@mail.gmail.com \
--to=gopi@sankhya.com \
--cc=eager@eagercon.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--cc=tdevries@suse.de \
/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