From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 04AB8395B424 for ; Wed, 16 Nov 2022 15:53:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 04AB8395B424 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 57C681E11E; Wed, 16 Nov 2022 10:53:49 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1668614030; bh=0lxDUvRqHVWhbyMyzIK9NkMNiP9XyujdFjWOpyaNXdQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=rD0u4GsCAAvPnEk90zkzB5U4rlEMV34279PsiFzJkCOeH4+hX4vl/6i2OGCF/XYXp 0Ju4zEmLEDg5d1penjyO6pMlzWEuIyd6lCVhRee727yaKIoLCJ+rLx+PG4Mz31HYFA 8R71cE2DGPAk7BAq3lvcF+x9PJbc5FZztDoVZZdY= Message-ID: Date: Wed, 16 Nov 2022 10:53:49 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] Fix various procfs.c compilation errors Content-Language: fr To: Rainer Orth , gdb-patches@sourceware.org Cc: Luis Machado References: From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_ASCII_DIVIDERS,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/16/22 10:02, Rainer Orth wrote: > procfs.c has accumulated several compilation errors lately (some of them > new with GCC 12), which are fixed by this patch: > > * auxv_parse gets: > > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:144:7: error: ‘int procfs_target::auxv_parse(gdb_byte**, gdb_byte*, CORE_ADDR*, CORE_ADDR*)’ marked ‘override’, but does not override > 144 | int auxv_parse (gdb_byte **readptr, > | ^~~~~~~~~~ > > Obviouly, procfs.c was missed in the auxv_parse constification. Sorry, my bad for this one. > > * dead_procinfo has: > > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function ‘void dead_procinfo(procinfo*, const char*, int)’: > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:563:11: warning: the address of ‘procinfo::pathname’ will never be NULL [-Waddress] > 563 | if (pi->pathname) > | ~~~~^~~~~~~~ > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:238:8: note: ‘procinfo::pathname’ declared here > 238 | char pathname[MAX_PROC_NAME_SIZE]; /* Pathname to /proc entry */ > | ^~~~~~~~ > > The warning is correct, so the code can lose support for the NULL > pathname case. > > * create_inferior has this ugly warning: > > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In member function ‘virtual void procfs_target::create_inferior(const char*, const std::string&, char**, int)’: > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2815:19: warning: ‘char* std::strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] > 2815 | strncpy (tryname, p, len); > | ~~~~~~~~^~~~~~~~~~~~~~~~~ > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2814:26: note: length computed here > 2814 | len = strlen (p); > | ~~~~~~~^~~ > > It seems that this is another case of GCC PR middle-end/88059, which > Martin Sebor refuses to fix. So I'm using the hack suggested in the > PR to use memcpy instead of strncpy. You could also make the code use std::string to build tryname, it would be simpler and less error-prone. But I'm fine with what you have too. > > * find_memory_regions_callback fails with > > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function ‘int find_memory_regions_callback(prmap*, find_memory_region_ftype, void*)’: > /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:3167:18: error: too few arguments to function > 3167 | return (*func) ((CORE_ADDR) map->pr_vaddr, > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ > 3168 | map->pr_size, > | ~~~~~~~~~~~~~ > 3169 | (map->pr_mflags & MA_READ) != 0, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 3170 | (map->pr_mflags & MA_WRITE) != 0, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 3171 | (map->pr_mflags & MA_EXEC) != 0, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 3172 | 1, /* MODIFIED is unknown, pass it as true. */ > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 3173 | data); > | ~~~~~ > > Again, procfs.c was overlooked when adding the new memory_tagged arg. > Unfortunately, it wasn't even documented in gdb/defs.h when it was > added in > > commit 68cffbbd4406b4efe1aa6e18460b1d7ca02549f1 > Author: Luis Machado > Date: Thu Mar 31 11:42:35 2022 +0100 > > [AArch64] MTE corefile support > > With those changes, procfs.c compiles again. Together with the hack > from the Solaris gdbsupport breakage reported in PR build/29791, I was > able to build and test gdb on both amd64-pc-solaris2.11 and > sparcv9-sun-solaris2.11. > > Will commit the patch soon. > > Rainer Thanks, you can add my: Approved-By: Simon Marchi Simon