From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id D732C385625F for ; Tue, 24 May 2022 09:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D732C385625F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from [10.130.0.135] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxKthpo4xiXA4hAA--.42066S3; Tue, 24 May 2022 17:20:42 +0800 (CST) Subject: Re: [PUSHED OBV] Fix loongarch_iterate_over_regset_sections for non-native targets. To: John Baldwin , gdb-patches@sourceware.org References: <20220523181559.54764-1-jhb@FreeBSD.org> From: Tiezhu Yang Message-ID: <9ff1f06f-f274-36e0-0921-bac72ff4df74@loongson.cn> Date: Tue, 24 May 2022 17:20:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20220523181559.54764-1-jhb@FreeBSD.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9AxKthpo4xiXA4hAA--.42066S3 X-Coremail-Antispam: 1UD129KBjvJXoWxuF4rCFy8ur4UGryxXr45GFg_yoW5GryUpa 1UCw12yr48GrnrCFWDJw1rZ390gFs3KrWa9a43X34YkrsxX340gw48tFy5GF18t348Kryj gw4kAa98uFWkZaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvSb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCYjI0SjxkI62AI1cAE67vIY487 MxkIecxEwVAFwVW8uwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s 026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_ Jrv_JF1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20x vEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43 ZEXa7IUYjXd5UUUUU== X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: 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: , X-List-Received-Date: Tue, 24 May 2022 09:20:46 -0000 On 05/24/2022 02:15 AM, John Baldwin wrote: > Define a constant for the number of registers stored in a register set > and use this with register_size to compute the size of the > general-purpose register set in core dumps. > > This also fixes the build on hosts such as FreeBSD that do not define > an elf_gregset_t type. Hi John, Sorry for the related issues on FreeBSD, the original patch is only tested on LoongArch Linux, thank you very much for your test and fix. > --- > gdb/loongarch-linux-tdep.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c > index f13756dd003..bbb43abe13f 100644 > --- a/gdb/loongarch-linux-tdep.c > +++ b/gdb/loongarch-linux-tdep.c > @@ -29,6 +29,11 @@ > #include "trad-frame.h" > #include "tramp-frame.h" > > +/* The general-purpose regset consists of 32 R registers, plus PC, > + and BADV registers. */ > + > +#define LOONGARCH_LINUX_NUM_GREGSET (34) LOONGARCH_LINUX_NUM_GREGSET should be defined as 45 (32 + 1 + 1 + 11) due to reserved 11 for extension in glibc, otherwise when execute: make check-gdb TESTS="gdb.base/corefile.exp" there exists the following failed testcase: (gdb) core-file /home/loongson/build.git/gdb/testsuite/outputs/gdb.base/corefile/corefile.core [New LWP 7742] warning: Unexpected size of section `.reg/7742' in core file. Core was generated by `/home/loongson/build.git/gdb/testsuite/outputs/gdb.base/corefile/corefile'. Program terminated with signal SIGABRT, Aborted. warning: Unexpected size of section `.reg/7742' in core file. #0 0x000000fff76f4e24 in raise () from /lib/loongarch64-linux-gnu/libc.so.6 (gdb) FAIL: gdb.base/corefile.exp: core-file warning-free I will send a patch to fix the above issue. Thanks, Tiezhu > + > /* Unpack an elf_gregset_t into GDB's register cache. */ > > static void > @@ -172,8 +177,13 @@ loongarch_iterate_over_regset_sections (struct gdbarch *gdbarch, > void *cb_data, > const struct regcache *regcache) > { > - cb (".reg", sizeof (elf_gregset_t), sizeof (elf_gregset_t), > - &loongarch_gregset, NULL, cb_data); > + loongarch_gdbarch_tdep *tdep > + = (loongarch_gdbarch_tdep *) gdbarch_tdep (gdbarch); > + auto regs = tdep->regs; > + int regsize = register_size (gdbarch, regs.r); > + > + cb (".reg", LOONGARCH_LINUX_NUM_GREGSET * regsize, > + LOONGARCH_LINUX_NUM_GREGSET * regsize, &loongarch_gregset, NULL, cb_data); > } > > /* Initialize LoongArch Linux ABI info. */ >