Page MenuHomeFreeBSD

truss: handle shm_open's special SHM_ANON value better.
ClosedPublic

Authored by munro_ip9.org on Oct 7 2018, 9:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 12 2024, 2:16 AM
Unknown Object (File)
Dec 20 2023, 1:25 AM
Unknown Object (File)
Dec 10 2023, 7:39 PM
Unknown Object (File)
Nov 8 2023, 1:45 AM
Unknown Object (File)
Oct 13 2023, 2:09 PM
Unknown Object (File)
Oct 7 2023, 3:41 AM
Unknown Object (File)
Oct 7 2023, 12:38 AM
Unknown Object (File)
Aug 22 2023, 8:20 AM
Subscribers

Details

Summary

The support for decoding shm_open(2) just added in D17457 causes truss to display shmopen("(null"), ...) if you use the special SHM_ANON value as a segment name. Maybe that's OK, but it'd be better to detect that value and show it properly.

Test Plan
$ cat test.c
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>

int main(int argc, char *argv[])
{
    shm_open(SHM_ANON, O_RDWR | O_CREAT | O_EXCL, 0600);
    shm_open("/test-shm-segment", O_RDWR | O_CREAT | O_EXCL, 0600);
    shm_unlink("/test-shm-segment");
    return 0;
}
$ cc test.c
$ truss ./a.out

As of r339224 that shows:

shm_open("(null)",O_RDWR|O_CREAT|O_EXCL,0600)    = 3 (0x3)
shm_open("/test-shm-segment",O_RDWR|O_CREAT|O_EXCL,0600) = 4 (0x4)

With this patch it shows:

shm_open(SHM_ANON,O_RDWR|O_CREAT|O_EXCL,0600)    = 3 (0x3)
shm_open("/test-shm-segment",O_RDWR|O_CREAT|O_EXCL,0600) = 4 (0x4)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jhb added a subscriber: jhb.

Looks good apart from a sorting nit.

usr.bin/truss/syscall.h
43

I think I probably haven't bothered updating the comment block of new types FWIW.

150

These enum lists are sorted first by type and then alphabetically within each type.

This revision is now accepted and ready to land.Oct 8 2018, 4:03 PM
usr.bin/truss/syscalls.c
1599

No space after cast in FreeBSD's style.

1603

Best to use the style-mandated '/* FALLTHROUGH */' as it is also recognized by compilers and static analyzers.

Fixes for style feedback from jhb. Thanks!

This revision now requires review to proceed.Oct 8 2018, 8:35 PM
This revision is now accepted and ready to land.Oct 8 2018, 9:09 PM
This revision was automatically updated to reflect the committed changes.