From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Im5GDEDifWfJrQYAWB0awg (envelope-from ) for ; Tue, 07 Jan 2025 21:26:08 -0500 Received: by simark.ca (Postfix, from userid 112) id 2653A1E0C0; Tue, 7 Jan 2025 21:26:08 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 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 904BF1E091 for ; Tue, 7 Jan 2025 21:26:04 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08E8F3858CDA for ; Wed, 8 Jan 2025 02:26:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08E8F3858CDA Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by sourceware.org (Postfix) with ESMTP id 0EA123858D29 for ; Wed, 8 Jan 2025 02:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EA123858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0EA123858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4190:8020::34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736303130; cv=none; b=HOFrQw8z55KbqlcCEf5OcTCQez3VLgaWNVRkhmDfPN887EsCc5xu0TGimOUmsuceSE8dpFirGLPMmbnbUrVnO5jQgfE2DqwiY0l4N+J/U0XhCgcvM7vrmlNiJR6jv6KPT4l24TFCB/0z4v+Xy9QNY+ZAQugEnRDyeff46Apvs2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736303130; c=relaxed/simple; bh=BqheUaFVmSV0NWqKLOI+wWK7BD+ZNzC0pcRUA62y/Yc=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=teixghIFhR6flt4YLnWiGt4C7kw6rJC3VzgZJZGrSo96NM+1LZ42lJm4bIBTFnt4dTxSGvZPD5HhLe/Exs1KUG8zNtzaJmPLkPFD6i6B0llM460OsV6LOe8QNDGUqZx6w/MfV7YvF+Dyp/4PPDoQfIG1nMGqoAFqvVJj6LrbUtg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EA123858D29 Received: by angie.orcam.me.uk (Postfix, from userid 500) id 9135092009C; Wed, 8 Jan 2025 03:25:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 8A74D92009B; Wed, 8 Jan 2025 02:25:28 +0000 (GMT) Date: Wed, 8 Jan 2025 02:25:28 +0000 (GMT) From: "Maciej W. Rozycki" To: Kevin Buettner cc: Milica Matic , gdb-patches@sourceware.org Subject: Re: [PATCH^8] gdb: mips: Add MIPSR6 support In-Reply-To: <20250107134921.4ee64acf@f41-zbm-amd> Message-ID: References: <20250107134921.4ee64acf@f41-zbm-amd> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 Tue, 7 Jan 2025, Kevin Buettner wrote: > > +/* Calculate address of next instruction after BLEZ. */ > > + > > +static CORE_ADDR > > +mips32_blez_pc (struct gdbarch *gdbarch, struct regcache *regcache, > > + ULONGEST inst, CORE_ADDR pc, int invert) > > +{ > > + int rs = itype_rs (inst); > > + int rt = itype_rt (inst); > > + LONGEST val_rs = regcache_raw_get_signed (regcache, rs); > > + LONGEST val_rt = regcache_raw_get_signed (regcache, rt); > > + ULONGEST uval_rs = regcache_raw_get_unsigned (regcache, rs); > > + ULONGEST uval_rt = regcache_raw_get_unsigned (regcache, rt); > > + int taken = 0; > > + int delay_slot_size = 4; > > + > > + /* BLEZ, BLEZL, BGTZ, BGTZL */ > > + if (rt == 0) > > + taken = (val_rs <= 0); > > + else if (is_mipsr6_isa (gdbarch)) > > + { > > + /* BLEZALC, BGTZALC */ > > + if (rs == 0 && rt != 0) > > + taken = (val_rt <= 0); > > + /* BGEZALC, BLTZALC */ > > + else if (rs == rt && rt != 0) > > + taken = (val_rt >= 0); > > + /* BGEUC, BLTUC */ > > + else if (rs != rt && rs != 0 && rt != 0) > > + taken = (uval_rs >= uval_rt); > > + > > + /* Step through the forbidden slot to avoid repeated exceptions we do > > + not currently have access to the BD bit when hitting a breakpoint > > + and therefore cannot tell if the breakpoint hit on the branch or the > > + forbidden slot. */ > > + /* delay_slot_size = 0; */ > > Should "delay_slot_size = 0;" be commented out? If so, I suggest > removing the entire line. And, if it's removed, the comment preceding > it probably doesn't make sense either. I think the comment refers to the current situation rather than where `delay_slot_size' would be set to 0. The comment also seems at best misleading to me. With hosted targets the BD bit is accessible via $cause register, which I do believe all the MIPS OSes supply unmodified. With EJTAG targets or bare metal simulators the target description should supply $debug register providing the analogous DBD bit. The backend could use that information to determine whether a breakpoint has hit in a delay slot; this has been considered before. However we have chosen to refrain from placing breakpoints in delay slots regardless, as that would complicate handling. So it seems to me that the note should instead be rephrased accordingly and moved to the function's introductory comment... > > + } > > + > > + if (invert) > > + taken = !taken; > > + > > + /* Calculate branch target. */ ... and then "or skip over the forbidden" slot added here... > > + if (taken) > > + pc += mips32_relative_offset (inst); > > + else > > + pc += delay_slot_size; ... and then the otherwise unused variable removed (i.e. "pc += 4" here). Similarly in the other place, taking into account the slightly different context (so I think the comments ought to refer to delay slots in general rather than just the forbidden slots, which are a particular subset). Maciej