Date: Tue, 11 Apr 2017 15:14:26 +0200 From: Fabian Keil <freebsd-listen@fabiankeil.de> To: Christopher Bowman <crb@chrisbowman.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Dtrace oddity Message-ID: <20170411151426.3b760182@fabiankeil.de> In-Reply-To: <CD5E9B03-6147-4E4D-BED6-6C45022051E3@chrisbowman.com> References: <CD5E9B03-6147-4E4D-BED6-6C45022051E3@chrisbowman.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Christopher Bowman <crb@chrisbowman.com> wrote:
> The man page lists a bunch of reasons for EINVAL so I want to
> investigate this and I don’t quite know good strategies to debug the
> kernel (yet) so I thought I’d experiment with Dtrace a bit. Here is the
> oddity: when I run Dtrace and then run my test program I get the
> following output from Dtrace:
>
> crb@retread:60> dtrace -n 'syscall:freebsd:mmap:entry /execname == "test"/ {}'
> dtrace: description 'syscall:freebsd:mmap:entry ' matched 1
> probe CPU ID FUNCTION:NAME
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
> 0 63401 mmap:entry
>
> I think Dtrace is indicating that the mmap syscall was called 12 times
> by my test program yet I can see how the program below would have done
> that.
A bunch of mmap syscalls occur before main is even entered.
Try running your program with truss to see what's going on.
> Here is my program:
[...]
> printf("opening device %s\n", argv[1]);
> int device = open (argv[1], O_RDWR);
> if (device == 0) {
You should check for -1 here.
> void *pa = mmap (0, 4095, PROT_READ | PROT_WRITE, 0, device, 0);
No flags? From the mmap man page:
| [EINVAL] None of MAP_ANON, MAP_PRIVATE, MAP_SHARED, or
| MAP_STACK was specified. At least one of these flags
| must be included.
Fabian
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
iF0EARECAB0WIQTKUNd6H/m3+ByGULIFiohV/3dUnQUCWOzWswAKCRAFiohV/3dU
naR9AKC88uaGiPliml1AEINPpCMkoYMAWQCfSPsCr/Gj/fo9J+0zFGmy+EYYvXU=
=JFvI
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170411151426.3b760182>
