From 832af457155320174f759c290d6784a10e7d4299 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Wed, 3 May 2017 12:18:09 +0000 Subject: [PATCH] Add support for [gs]etsockopt(). --- usr.bin/truss/syscall.h | 3 ++- usr.bin/truss/syscalls.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index e4c3beeb292e..48bf2dc5c893 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -46,7 +46,8 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl, LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2, CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd, - Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, + Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel, + Sockoptname, CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags, CloudABIFDStat, CloudABIFileStat, CloudABIFileType, diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 61554115824f..a93574586e7a 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -174,6 +174,9 @@ static struct syscall decoded_syscalls[] = { .args = { { Int, 0 } } }, { .name = "getsockname", .ret_type = 1, .nargs = 3, .args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } }, + { .name = "getsockopt", .ret_type = 1, .nargs = 5, + .args = { { Int, 0 }, { Sockoptlevel, 1 }, { Sockoptname, 2 }, + { Ptr | OUT, 3 }, { Ptr | OUT, 4 } } }, { .name = "gettimeofday", .ret_type = 1, .nargs = 2, .args = { { Timeval | OUT, 0 }, { Ptr, 1 } } }, { .name = "ioctl", .ret_type = 1, .nargs = 3, @@ -295,6 +298,9 @@ static struct syscall decoded_syscalls[] = { .args = { { Int, 0 }, { Itimerval, 1 }, { Itimerval | OUT, 2 } } }, { .name = "setrlimit", .ret_type = 1, .nargs = 2, .args = { { Resource, 0 }, { Rlimit | IN, 1 } } }, + { .name = "setsockopt", .ret_type = 1, .nargs = 5, + .args = { { Int, 0 }, { Sockoptlevel, 1 }, { Sockoptname, 2 }, + { Ptr | IN, 3 }, { Socklent, 4 } } }, { .name = "shutdown", .ret_type = 1, .nargs = 2, .args = { { Int, 0 }, { Shutdown, 1 } } }, { .name = "sigaction", .ret_type = 1, .nargs = 3, @@ -1928,6 +1934,24 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval, } break; } + case Sockoptlevel: + print_integer_arg(sysdecode_sockopt_level, fp, + args[sc->offset]); + break; + case Sockoptname: { + const char *temp; + int level, name; + + level = args[sc->offset - 1]; + name = args[sc->offset]; + temp = sysdecode_sockopt_name(level, name); + if (temp) { + fputs(temp, fp); + } else { + fprintf(fp, "%d", name); + } + break; + } case CloudABIAdvice: fputs(xlookup(cloudabi_advice, args[sc->offset]), fp);