From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id foRuK2KBel+NdgAAWB0awg (envelope-from ) for ; Sun, 04 Oct 2020 22:13:54 -0400 Received: by simark.ca (Postfix, from userid 112) id A4F0C1EE0F; Sun, 4 Oct 2020 22:13:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0089D1E58E for ; Sun, 4 Oct 2020 22:13:54 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9CE2A3857C57; Mon, 5 Oct 2020 02:13:53 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 164A93857C57 for ; Mon, 5 Oct 2020 02:13:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 164A93857C57 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8030D1E58E; Sun, 4 Oct 2020 22:13:50 -0400 (EDT) Subject: Re: [PATCH v2] arc: Add support for Linux coredump files To: Shahab Vahedi , gdb-patches@sourceware.org References: <20200827112728.4275-1-shahab.vahedi@gmail.com> <20200929161547.19168-1-shahab.vahedi@gmail.com> From: Simon Marchi Message-ID: <7e10e689-2de3-c9cc-6552-495510bd37c6@simark.ca> Date: Sun, 4 Oct 2020 22:13:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200929161547.19168-1-shahab.vahedi@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anton Kolesov , Shahab Vahedi , Francois Bedard Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi Shahab, The patch LGTM with the nits below fixed. On 2020-09-29 12:15 p.m., Shahab Vahedi wrote: > +/* arc_linux_core_reg_offsets[i] is the offset in the .reg section of GDB > + regnum i. Array index is an internal GDB register number, as defined in > + arc-tdep.h:arc_regnum. > + > + From include/uapi/asm/ptrace.h in the ARC Linux sources. */ Thanks for this, I _love_ it when people point to references that help make sense of the code. > +void > +arc_linux_supply_gregset (const struct regset *regset, > + struct regcache *regcache, > + int regnum, const void *gregs, size_t size) > +{ > + gdb_static_assert (ARC_LAST_REGNUM > + < ARRAY_SIZE (arc_linux_core_reg_offsets)); > + > + const bfd_byte *buf = (const bfd_byte *) gregs; > + > + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) > + { > + if (arc_linux_core_reg_offsets[reg] != ARC_OFFSET_NO_REGISTER) > + regcache->raw_supply (reg, buf + arc_linux_core_reg_offsets[reg]); > + } I might have mislead you in the past by telling you to use curly braces in this situation before. I recently learned that it's not necessary. You can do: for (...) if (...) something (); It's only needed for nested ifs: if (...) { if (...) something (); } to avoid the problem of the dangling else. > +void > +arc_linux_collect_gregset (const struct regset *regset, > + const struct regcache *regcache, > + int regnum, void *gregs, size_t size) > +{ > + gdb_static_assert (ARC_LAST_REGNUM > + < ARRAY_SIZE (arc_linux_core_reg_offsets)); > + > + gdb_byte *buf = (gdb_byte *) gregs; > + struct gdbarch *gdbarch = regcache->arch (); > + > + /* regnum == -1 means writing all the registers. */ > + if (regnum == -1) > + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) > + collect_register (regcache, gdbarch, reg, buf); > + else if (regnum <= ARC_LAST_REGNUM) > + collect_register (regcache, gdbarch, regnum, buf); > + else > + gdb_assert (!"Invalid regnum in arc_linux_collect_gregset."); You can use gdb_assert_not_reached exactly for this. Simon