From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kdG+B6etumhLExUAWB0awg (envelope-from ) for ; Fri, 05 Sep 2025 05:30:15 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=S3CVjEJ0; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yTYVL5gG; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=S3CVjEJ0; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yTYVL5gG; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 141821E087; Fri, 05 Sep 2025 05:30:15 -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 164651E023 for ; Fri, 05 Sep 2025 05:30:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA7413858416 for ; Fri, 5 Sep 2025 09:30:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA7413858416 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=S3CVjEJ0; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yTYVL5gG; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=S3CVjEJ0; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yTYVL5gG Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 2D6233858D39 for ; Fri, 5 Sep 2025 09:29:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D6233858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D6233858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757064554; cv=none; b=V4esvy+bpdIHnRT94ZxKWUMDnc8OMFQTcGb38q9PPOQvBDwN0b1/bZl7T6GP13/FQgpwguhk5sdvLdWaRUeZt5NBMvwLPlY6hiuJy+vr2sLTWRnJeDBa3lvo5LxHUZkQre0O2LxmJFsKOAiiM2MZqQ0gNyoPz8AK2UBgATDmYek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757064554; c=relaxed/simple; bh=tXvORKJ+Il3SvyKq7jmY1g4FjYmzzqujvb+V9qVYh2c=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=nvJLmIolmGjUo9bLjWZrB8IRLVieoQoRBcRp0VMeDAOQ6IIKY67P03+q/XEXKsJSsP8MrGbJVz1I96T5Mf0M+epLxF3imliZogK/zwNldoZRfjt1r3xlFSFOVPo9WtMT8SJSbNbLkANmqLeROvqBdNB9mOvasEJOsagtlJakxr8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D6233858D39 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B98C4DE4F; Fri, 5 Sep 2025 09:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1757064553; h=from:from:reply-to: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; bh=C66A2fJBr0PWmvk5/FU2+3RAmkWtpGwvci2+rw1CWAc=; b=S3CVjEJ0h6kOY1c8MiCoj06PuGEt+vkpIiJjousGXC9r88YMlfxgX133Kg5+4vzginrSlp P+9M+GrujoO9X8HLfuWU6+Fjh709Pxlm4MGPpiyibqBGcO3Q2Lgov/4kCh5qRttZdg0GLO sz8OWAsGp3nUvd6svFqYaQcBNXoKao8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1757064553; h=from:from:reply-to: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; bh=C66A2fJBr0PWmvk5/FU2+3RAmkWtpGwvci2+rw1CWAc=; b=yTYVL5gGQ5Yor3yaTirnqgGGsXnMJyEFfq2dfq+4KBJbBRPxwwjh/dYdg1NKPUsBkjSbp6 JXyalvnZA1D+IlCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1757064553; h=from:from:reply-to: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; bh=C66A2fJBr0PWmvk5/FU2+3RAmkWtpGwvci2+rw1CWAc=; b=S3CVjEJ0h6kOY1c8MiCoj06PuGEt+vkpIiJjousGXC9r88YMlfxgX133Kg5+4vzginrSlp P+9M+GrujoO9X8HLfuWU6+Fjh709Pxlm4MGPpiyibqBGcO3Q2Lgov/4kCh5qRttZdg0GLO sz8OWAsGp3nUvd6svFqYaQcBNXoKao8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1757064553; h=from:from:reply-to: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; bh=C66A2fJBr0PWmvk5/FU2+3RAmkWtpGwvci2+rw1CWAc=; b=yTYVL5gGQ5Yor3yaTirnqgGGsXnMJyEFfq2dfq+4KBJbBRPxwwjh/dYdg1NKPUsBkjSbp6 JXyalvnZA1D+IlCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E0E51139B9; Fri, 5 Sep 2025 09:29:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UUOCNWitumhpLAAAD6G6ig (envelope-from ); Fri, 05 Sep 2025 09:29:12 +0000 Message-ID: <9e20ab3e-b7d2-42d8-9444-1985e75f60bd@suse.de> Date: Fri, 5 Sep 2025 11:29:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 ] MicroBlaze: Add microblaze_get_next_pcs To: Simon Marchi , Gopi Kumar Bulusu , gdb-patches@sourceware.org Cc: Michael Eager References: <3bdebc70-e678-44e7-98ec-18c6b23dccca@simark.ca> <93642dcc-4922-4a15-84ae-2404e9d54a17@simark.ca> Content-Language: en-US From: Tom de Vries In-Reply-To: <93642dcc-4922-4a15-84ae-2404e9d54a17@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sourceware.org:url,suse.de:mid] 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 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 >> 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. > This caused a buildbreaker on arm-linux with --enable-targets=all and --enable-64-bit-bfd. I've filed a PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=33381 ). Thanks, - Tom > Approved-By: Simon Marchi > > Simon