From patchwork Tue Oct 4 09:45:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 1677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp42677wrs; Tue, 4 Oct 2022 02:46:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SL8tZkQfmA9VFzZrg9lOYb27Zjf/RyKm7dvA0BE9yskTN864IZ3+5a1UvEonR+lRfT/uC X-Received: by 2002:a17:907:7287:b0:783:ad45:27aa with SMTP id dt7-20020a170907728700b00783ad4527aamr18210860ejc.99.1664876806445; Tue, 04 Oct 2022 02:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664876806; cv=none; d=google.com; s=arc-20160816; b=le9EPYRql9ZIMX6HNTwPEHk0w5NHXoXBRz2J7mO83p51xmFTRNrGJjSbOC12LYEigy 2QAJ2Jo0Ir3EvmvOyYqZNX2mK1ZyWqnkglyKvXxc/p21vL9eP6wY6sE1zuFyNXd1pxi3 1I1rPT1vBUjYZYiBdhGIQglhFQ9b8d3O533Q+VxhOFghvWw14IBDlZBLjQX0Smn4Kv5F m6UCxH3aMbH59waPCMnGD9jWf1djlqOd7F684RDMSloNWQlwT17yagCVOVMj32joYkZH bftgmnHgFJmV7Ji5YFE2zDj6Gf381kAidMNJMZdlUU9BiMFeBpDwy04SK+NffDDohhgv nRog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=ORE6MwU/WXwXXj2EPipdnDlfxgTJztsz5Pf/z3YDIA8=; b=rHPCcyxEYJbpbbhaGuprJpt0GCYvlwsyDKkLPC0DC6aOFAM/W5NXBtxpJDIyTYgBGp 620vThfpfBz+M5XeaWB40eTxk0Uqd3ppt6mybqSYN7n4y9iP0BimE0GObJk2trLNSShj DU5wfss4NQBuxoEGH64bViob49OUcfiYea0oFihuijTKxyBLCixIzyRs8pJzS2j1EHbh K3UMugKxOlEEPPtj1Xh3av3VhBke3ZM9XpIQTUZ2g0rVwVJXSweAUNbhYYtgAUgEMt2V ZF+eATBzBGDA1FPNLjzPdOdbT86tOpXoz9LcYvLrLQSaM1o4Ehvd0BdTwj2gztpef7HG FXPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WxONRb8+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d29-20020a50f69d000000b004589d7e983esi9199050edn.596.2022.10.04.02.46.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 02:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WxONRb8+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D9E1385C41F for ; Tue, 4 Oct 2022 09:46:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D9E1385C41F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664876791; bh=ORE6MwU/WXwXXj2EPipdnDlfxgTJztsz5Pf/z3YDIA8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WxONRb8+8Emkv22tKuyrnA+iZs1u6BajYfwaaKJcKQ8CoxMt41D4B4X+tQHEwZQ0s ZIfq2FPYfBSLDhX94upzsfO9Tz35NcUoMM4mgLd/qxQPq/Ss4bY2pgv0iXxVIBp+Qm du4PWx91z72b52GUzdVj/eAOqdqfkYPakLXPcZEk= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 85F353858297; Tue, 4 Oct 2022 09:46:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 85F353858297 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id C9F41300089; Tue, 4 Oct 2022 09:46:20 +0000 (UTC) To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt , Andrew Burgess , Jan Beulich , Andreas Schwab Subject: [PATCH v2 2/2] gdb/riscv: Partial support for instructions up to 176-bits Date: Tue, 4 Oct 2022 09:45:50 +0000 Message-Id: <4eb6e59ae2e790dbbf2bc92477edd281648d8814.1664876744.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Binutils From: Tsukasa OI Reply-To: Tsukasa OI Cc: binutils@sourceware.org, gdb-patches@sourceware.org Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745749862306627435?= X-GMAIL-MSGID: =?utf-8?q?1745749862306627435?= Because riscv_insn_length started to support instructions up to 176-bit, we need to increase packet buffer size to 176-bit in size. Also, that would break an assumption in riscv_insn::decode so this commit fixes it. --- gdb/riscv-tdep.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 47d8f9e601b..433311e1024 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1770,7 +1770,7 @@ riscv_insn::fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR addr, int *len) { enum bfd_endian byte_order = gdbarch_byte_order_for_code (gdbarch); - gdb_byte buf[8]; + gdb_byte buf[RISCV_MAX_INSN_LEN]; int instlen, status; /* All insns are at least 16 bits. */ @@ -1933,9 +1933,10 @@ riscv_insn::decode (struct gdbarch *gdbarch, CORE_ADDR pc) } else { - /* This must be a 6 or 8 byte instruction, we don't currently decode - any of these, so just ignore it. */ - gdb_assert (m_length == 6 || m_length == 8); + /* 6 - 22 bytes instruction. If the length is larger than 8, we don't + have full instruction bits in ival. At least, such long instructions + are not defined yet, so just ignore it. */ + gdb_assert (m_length > 0 && m_length % 2 == 0); m_opcode = OTHER; } }