From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WfxgCfCCuGhuUBMAWB0awg (envelope-from ) for ; Wed, 03 Sep 2025 14:03:28 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=eagercon.com header.i=@eagercon.com header.a=rsa-sha256 header.s=dreamhost header.b=XYVSpLkC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 21B171E08D; Wed, 03 Sep 2025 14:03:28 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 518FB1E047 for ; Wed, 03 Sep 2025 14:03:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D80D4385841B for ; Wed, 3 Sep 2025 18:03:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D80D4385841B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=eagercon.com header.i=@eagercon.com header.a=rsa-sha256 header.s=dreamhost header.b=XYVSpLkC Received: from beetle.yew.relay.mailchannels.net (beetle.yew.relay.mailchannels.net [23.83.220.15]) by sourceware.org (Postfix) with ESMTPS id ECD323858D26 for ; Wed, 3 Sep 2025 18:02:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECD323858D26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eagercon.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eagercon.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ECD323858D26 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=23.83.220.15 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1756922546; cv=pass; b=fTy4a7IlOpdcxvfmZ4lppbmHveze5ARYfP9LXh5qmM968kfJuQHr4aKzJKuj4JB6D+C1rpUuXZG8Wj10W5mbu2y0t7IWqiEw4wlhNlpfaDmXWWYkaoRae1SFDiMxv+xIGeuDcGP4AKoAi2DMcg94vqkdhd/eUjNrX4048Lvnl8Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1756922546; c=relaxed/simple; bh=DKypLECSNT40qXJPgxoolntGxaK2pJCCfVJ5oxo7e7I=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Jn8+W1T8DSl+LdL2ATN10IrCAxWectvXSWhuoh1Ri/7b/WUtMsgbUUaEy7kaR8wU9CrhJY8kDSGn87ofEgYOeDLAYsfJG8jRUlhFAtv6neKNN5UCmT6Tr7VR6vjYm/nqz1csTtxQjq7tdtVGjtZwvAZ//fBZ+aYTfFYkTMUhDxw= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECD323858D26 X-Sender-Id: dreamhost|x-authsender|eager@eagerm.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AB4778341F; Wed, 3 Sep 2025 18:02:24 +0000 (UTC) Received: from pdx1-sub0-mail-a230.dreamhost.com (100-102-62-95.trex-nlb.outbound.svc.cluster.local [100.102.62.95]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 2B92B814F2; Wed, 3 Sep 2025 18:02:24 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1756922544; a=rsa-sha256; cv=none; b=5L2RdyWM6E5Uz7RfD/+oZjD89CdasteoVZiY1DDgYtuQP0PAAXD/K2eW49FdKUNRDUugX/ 35vMj+slkRH+M+42kRynNbExkhIB5394TQcMBjqCBizMAuUTQo0yzjLsD/QDrvw6XPT40N pRyitbV0XoMTjXlcPMIsgStJrEBNq9vJ5C19+SvN7Zh/Ia/CLSV9GS1C+5RjFqAbUGGtXh H5ce6DcIYQOY4FIIg+ORlOQ/Ui8OuPDODihUksablPVXEwKtUBKzigK5atJdPzESUZionv HSXRaMrrRfnsL1k5O74B/4r5EOMnxItHPHWDPBtUEoyMMlj/PTPj/ksUHZc+0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1756922544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qqE1KdBTdWfvOcekNYXJOM+Gx9eR2q6Bo0E2GKHe3QI=; b=10JUqeC2GMXOiDogMBEdKgNxn0wtKY5nqtZJTNo1v+0BJsp4EXmf7ka+HrdiNALYJeTGag SR1op9YUBrnaMIbg/fW1KPWif+3Jd2havRUQyt5cKYuNj/qPA2Wyd0jfpc7FjX/Ta4XkZ7 vYo57YAwVhgPtoaqq1y02y38bt7WWGLXjR2f/GVXK21gOGKdkBlrb/hFG0AmGTyBqjS/Nb vUQ6zGxRQMxKyZPMo/w7o5hyuP8eMPlqBkCwjPfq0SoNG0YPq8GYtafZOQQ81O1VSZQA96 3OdfS5OEJyvGyGT0IQqEWSm8ppftWYkunXnNgxkpOasTL0Fs5XhGbZubNr5AJQ== ARC-Authentication-Results: i=1; rspamd-8b9589799-7n25b; auth=pass smtp.auth=dreamhost smtp.mailfrom=eager@eagercon.com X-Sender-Id: dreamhost|x-authsender|eager@eagerm.com X-MC-Relay: Good X-MailChannels-SenderId: dreamhost|x-authsender|eager@eagerm.com X-MailChannels-Auth-Id: dreamhost X-Illustrious-Oafish: 1e649ceb0128df73_1756922544580_2794961429 X-MC-Loop-Signature: 1756922544580:1286038696 X-MC-Ingress-Time: 1756922544580 Received: from pdx1-sub0-mail-a230.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.102.62.95 (trex/7.1.3); Wed, 03 Sep 2025 18:02:24 +0000 Received: from [192.168.20.10] (99-119-193-198.lightspeed.sntcca.sbcglobal.net [99.119.193.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eager@eagerm.com) by pdx1-sub0-mail-a230.dreamhost.com (Postfix) with ESMTPSA id 4cH9Rz6SMyz64; Wed, 3 Sep 2025 11:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eagercon.com; s=dreamhost; t=1756922544; bh=qqE1KdBTdWfvOcekNYXJOM+Gx9eR2q6Bo0E2GKHe3QI=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=XYVSpLkChWSC56Q359zMb+hDAsVpPuXsgUxvoKBBTnCkrw4VV0i77uzxyhCtKMFBs vw8HlAvcx2HJUuzsOl1BYtAwXvRnI4l9UAwk5J8cPRQd5qSZraL9Ax7OrLY1dkXnm+ GIGR69yFFkGCSRH+7IgRCKV+2hp11GKUFicsHpCDZ8blbTp1JgsjZ/BxnKgWA8lYKl xTeLAOuQ2KD6OzzDwBSd9RlFz/1N55pQ95ju1kyVazPd6NMdJGT/Eks7nkwpMRDZgH hZ4guIxpdZHveOQVTrYVhsDxd54WHItMvPltQ6SBUnurtJR6GyVsgnzMl79bnGbzrA W7oMozFhwwJWg== Message-ID: <33ea6f2a-2585-404f-aded-565f33ffa40c@eagercon.com> Date: Wed, 3 Sep 2025 11:02:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 ] MicroBlaze: Add microblaze_get_next_pcs To: Gopi Kumar Bulusu References: <3bdebc70-e678-44e7-98ec-18c6b23dccca@simark.ca> <93642dcc-4922-4a15-84ae-2404e9d54a17@simark.ca> Content-Language: en-US Cc: Simon Marchi , gdb-patches@sourceware.org From: Michael Eager In-Reply-To: <93642dcc-4922-4a15-84ae-2404e9d54a17@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Please submit revised patch. On 9/3/25 10:57 AM, 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 >> 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 >> Signed-off-by: Nathan Rossi >> Signed-off-by: Mahesh Bodapati >> Signed-off-by: Gopi Kumar Bulusu >> --- >> 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 >> +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 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 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. > > Approved-By: Simon Marchi > > Simon > -- Michael Eager