Files
binutils-gdb/gdb/unittests
Tom de Vries e7dd0a0cf4 [gdb/tdep] Fix selftest scoped_mmap on freebsd
On x86_64-freebsd, I run into:
...
$ gdb -q -batch -ex "maint selftest scoped_mmap"
Running selftest scoped_mmap.
Self test failed: self-test failed at scoped_mmap-selftests.c:50

Failures:
  scoped_mmap

Ran 1 unit tests, 1 failed
...

The problem is that this call:
...
    ::scoped_mmap smmap (nullptr, sysconf (_SC_PAGESIZE), PROT_WRITE,
			 MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
...
returns MAP_FAILED and sets errno to EINVAL because the argument fd == 0.

If MAP_ANONYMOUS is used, fd == -1 should be used on freebsd.  On linux, fd is
ignored but -1 is recommended for portability.

Fix this by using fd == -1 instead.

Tested x86_64-freebsd and x86_64-linux.
2025-07-05 13:29:53 +02:00
..