]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix various procfs.c compilation errors
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 17 Nov 2022 09:55:25 +0000 (10:55 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 17 Nov 2022 09:55:25 +0000 (10:55 +0100)
commitf4ad82b3bcc4ae2cecba00177561ddfad49ccef2
treec596580fe81673018d1a417c08e37c671a24fb09
parent01804a098dea7d08857eee82bcaad04676dd8ea1
Fix various procfs.c compilation errors

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: \91int
procfs_target::auxv_parse(gdb_byte**, gdb_byte*, CORE_ADDR*, CORE_ADDR*)\92
marked \91override\92, 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 \91void
dead_procinfo(procinfo*, const char*, int)\92:
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:563:11: warning: the address
of \91procinfo::pathname\92 will never be NULL [-Waddress]
  563 |   if (pi->pathname)
      |       ~~~~^~~~~~~~
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:238:8: note:
\91procinfo::pathname\92 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 \91virtual void procfs_target::create_inferior(const char*, const std::string&, char**, int)\92:
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2815:19: warning: \91char* std::strncpy(char*, const char*, size_t)\92 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.

* find_memory_regions_callback fails with

/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function \91int find_memory_regions_callback(prmap*, find_memory_region_ftype, void*)\92:
/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 <luis.machado@arm.com>
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.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/procfs.c