From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id A99BB395B425 for ; Wed, 16 Nov 2022 15:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A99BB395B425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=none smtp.mailfrom=cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id A7FB6644FC; Wed, 16 Nov 2022 16:02:48 +0100 (CET) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id smS5SzS6PW_U; Wed, 16 Nov 2022 16:02:48 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p50855a16.dip0.t-ipconnect.de [80.133.90.22]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id F320664B1E; Wed, 16 Nov 2022 16:02:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1668610968; bh=vUC80Te+mmvyNjGTheZBxHVcAihFbVk6Bhy4GVQa4Lk=; h=From:To:Cc:Subject:Date:From; b=P1VaVpAZmz/uXVZSwTA7odMsrAw3mduj4kcGT6HqRyu1OIghmis/ZIuVcwLGEuMC4 HU3O4qPxFELB2teCor/y/KOtQzPHc/JCOJO3SjJxJjsVVNfZkEdGtE0QfHT+03D8WX CO9smnY6xkP3e11l91mDvnP0u03ouSrbEif4CvNxN0osojg974xlTdf8AlP/KeXw7F cK+Eu5HBrAP9GlhIg+N9buJ0GM7Hs//kkM4blCMYlptSF9S3YP4U4UoD2CyaqW3Kgk uerCxa6woUZ/qhm1d7sRrivKBmbES2I0GS4mrEM2iAV4UCT4tRl1bj327DlnPeYh/u som2J/FMtHm1w== From: Rainer Orth To: gdb-patches@sourceware.org Cc: Luis Machado Subject: [PATCH] Fix various procfs.c compilation errors Date: Wed, 16 Nov 2022 16:02:47 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-3794.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,KAM_ASCII_DIVIDERS,SPF_HELO_NONE,SPF_NONE,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 List-Id: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: =E2=80=98int pro= cfs_target::auxv_parse(gdb_byte**, gdb_byte*, CORE_ADDR*, CORE_ADDR*)=E2=80= =99 marked =E2=80=98override=E2=80=99, but does not override 144 | int auxv_parse (gdb_byte **readptr, | ^~~~~~~~~~ Obviouly, procfs.c was missed in the auxv_parse constification. * dead_procinfo has: /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function =E2=80=98void dea= d_procinfo(procinfo*, const char*, int)=E2=80=99: /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:563:11: warning: the address o= f =E2=80=98procinfo::pathname=E2=80=99 will never be NULL [-Waddress] 563 | if (pi->pathname) | ~~~~^~~~~~~~ /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:238:8: note: =E2=80=98procinfo= ::pathname=E2=80=99 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 =E2=80=98v= irtual void procfs_target::create_inferior(const char*, const std::string&,= char**, int)=E2=80=99: /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2815:19: warning: =E2=80=98cha= r* std::strncpy(char*, const char*, size_t)=E2=80=99 output truncated befor= e terminating nul copying as many bytes from a string as its length [-Wstri= ngop-truncation] 2815 | strncpy (tryname, p, len); | ~~~~~~~~^~~~~~~~~~~~~~~~~ /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2814:26: note: length computed= here 2814 | len =3D 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. * find_memory_regions_callback fails with /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function =E2=80=98int find= _memory_regions_callback(prmap*, find_memory_region_ftype, void*)=E2=80=99: /vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:3167:18: error: too few argume= nts to function 3167 | return (*func) ((CORE_ADDR) map->pr_vaddr, | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 3168 | map->pr_size, | ~~~~~~~~~~~~~ 3169 | (map->pr_mflags & MA_READ) !=3D 0, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3170 | (map->pr_mflags & MA_WRITE) !=3D 0, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | (map->pr_mflags & MA_EXEC) !=3D 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 --=20 ---------------------------------------------------------------------------= -- Rainer Orth, Center for Biotechnology, Bielefeld University --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=sol2-procfs-various.patch diff --git a/gdb/procfs.c b/gdb/procfs.c --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -141,8 +141,8 @@ public: bool info_proc (const char *, enum info_proc_what) override; #if PR_MODEL_NATIVE == PR_MODEL_LP64 - int auxv_parse (gdb_byte **readptr, - gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) + int auxv_parse (const gdb_byte **readptr, + const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) override; #endif @@ -169,11 +169,12 @@ static procfs_target the_procfs_target; is presented in 64-bit format. We need to provide a custom parser to handle that. */ int -procfs_target::auxv_parse (gdb_byte **readptr, - gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) +procfs_target::auxv_parse (const gdb_byte **readptr, + const gdb_byte *endptr, CORE_ADDR *typep, + CORE_ADDR *valp) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); - gdb_byte *ptr = *readptr; + const gdb_byte *ptr = *readptr; if (endptr == ptr) return 0; @@ -559,15 +560,7 @@ enum { NOKILL, KILL }; static void dead_procinfo (procinfo *pi, const char *msg, int kill_p) { - char procfile[80]; - - if (pi->pathname) - print_sys_errmsg (pi->pathname, errno); - else - { - xsnprintf (procfile, sizeof (procfile), "process %d", pi->pid); - print_sys_errmsg (procfile, errno); - } + print_sys_errmsg (pi->pathname, errno); if (kill_p == KILL) kill (pi->pid, SIGKILL); @@ -2813,7 +2806,7 @@ procfs_target::create_inferior (const ch len = p1 - p; else len = strlen (p); - strncpy (tryname, p, len); + memcpy (tryname, p, len); tryname[len] = '\0'; strcat (tryname, "/"); strcat (tryname, shell_file); @@ -3170,6 +3163,7 @@ find_memory_regions_callback (struct prm (map->pr_mflags & MA_WRITE) != 0, (map->pr_mflags & MA_EXEC) != 0, 1, /* MODIFIED is unknown, pass it as true. */ + false, data); } --=-=-=--