summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss
diff options
context:
space:
mode:
authortuexen <tuexen@FreeBSD.org>2017-06-01 12:33:33 +0000
committertuexen <tuexen@FreeBSD.org>2017-06-01 12:33:33 +0000
commitac471f3f8b4303115a2813182e87e27d00aff4d5 (patch)
treeedebb4d9e8e5802e5926227ddb916b05193e2769 /usr.bin/truss
parentaae59ee4e4b5e9565344c36b9a8d18c6d9982ae7 (diff)
downloadFreeBSD-src-ac471f3f8b4303115a2813182e87e27d00aff4d5.zip
FreeBSD-src-ac471f3f8b4303115a2813182e87e27d00aff4d5.tar.gz
MFC r317730:
Add support for listen() call. MFC r317731: Add Socklent for handling args of type socklen_t. MFC r317732: Decode the third argument of socket(). MFC r317736: Add support for [gs]etsockopt(). MFC r317737: Decode the fourth argument of sendto and recvfrom call. MFC r317739: Add support for sendmsg() and recvmsg(). MFC r317747: Add support for socket option names related to the IPPROTO_SCTP level. MFC r317748: Add support for socket option names related to the IPPROTO_IPV6 level. MFC r317750: Add support for sctp_generic_sendmsg() and sctp_generic_recvmsg(). MFC r317789: Add support for socket option names related to the level IPPROTO_UDPLITE. MFC r318879: Improve the decoding of the third argument of the socket() call. Decoding of the third argument depends on the first one. For doing this, add a corresponding function to libsysdecode. Thanks to jhb@ for suggesting this.
Diffstat (limited to 'usr.bin/truss')
-rw-r--r--usr.bin/truss/syscall.h3
-rw-r--r--usr.bin/truss/syscalls.c80
2 files changed, 74 insertions, 9 deletions
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index 0ed08bd..46bef46 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,
+ Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
+ Sockoptname, Msgflags,
CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
CloudABIFDStat, CloudABIFileStat, CloudABIFileType,
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index bd8b932..1bf1e88 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -86,7 +86,7 @@ static struct syscall decoded_syscalls[] = {
{ .name = "access", .ret_type = 1, .nargs = 2,
.args = { { Name | IN, 0 }, { Accessmode, 1 } } },
{ .name = "bind", .ret_type = 1, .nargs = 3,
- .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
+ .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Socklent, 2 } } },
{ .name = "bindat", .ret_type = 1, .nargs = 4,
.args = { { Atfd, 0 }, { Int, 1 }, { Sockaddr | IN, 2 },
{ Int, 3 } } },
@@ -114,7 +114,7 @@ static struct syscall decoded_syscalls[] = {
{ .name = "close", .ret_type = 1, .nargs = 1,
.args = { { Int, 0 } } },
{ .name = "connect", .ret_type = 1, .nargs = 3,
- .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
+ .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Socklent, 2 } } },
{ .name = "connectat", .ret_type = 1, .nargs = 4,
.args = { { Atfd, 0 }, { Int, 1 }, { Sockaddr | IN, 2 },
{ Int, 3 } } },
@@ -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,
@@ -212,7 +215,9 @@ static struct syscall decoded_syscalls[] = {
{ .name = "linkat", .ret_type = 1, .nargs = 5,
.args = { { Atfd, 0 }, { Name, 1 }, { Atfd, 2 }, { Name, 3 },
{ Atflags, 4 } } },
- { .name = "lseek", .ret_type = 2, .nargs = 3,
+ { .name = "listen", .ret_type = 1, .nargs = 2,
+ .args = { { Int, 0 }, { Int, 1 } } },
+ { .name = "lseek", .ret_type = 2, .nargs = 3,
.args = { { Int, 0 }, { QuadHex, 1 }, { Whence, 2 } } },
{ .name = "lstat", .ret_type = 1, .nargs = 2,
.args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
@@ -273,8 +278,11 @@ static struct syscall decoded_syscalls[] = {
.args = { { Atfd, 0 }, { Name, 1 }, { Readlinkres | OUT, 2 },
{ Sizet, 3 } } },
{ .name = "recvfrom", .ret_type = 1, .nargs = 6,
- .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 }, { Hex, 3 },
- { Sockaddr | OUT, 4 }, { Ptr | OUT, 5 } } },
+ .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 },
+ { Msgflags, 3 }, { Sockaddr | OUT, 4 },
+ { Ptr | OUT, 5 } } },
+ { .name = "recvmsg", .ret_type = 1, .nargs = 3,
+ .args = { { Int, 0 }, { Ptr, 1 }, { Msgflags, 2 } } },
{ .name = "rename", .ret_type = 1, .nargs = 2,
.args = { { Name, 0 }, { Name, 1 } } },
{ .name = "renameat", .ret_type = 1, .nargs = 4,
@@ -283,16 +291,30 @@ static struct syscall decoded_syscalls[] = {
.args = { { Rforkflags, 0 } } },
{ .name = "rmdir", .ret_type = 1, .nargs = 1,
.args = { { Name, 0 } } },
+ { .name = "sctp_generic_recvmsg", .ret_type = 1, .nargs = 7,
+ .args = { { Int, 0 }, { Ptr | IN, 1 }, { Int, 2 },
+ { Sockaddr | OUT, 3 }, { Ptr | OUT, 4 }, { Ptr | OUT, 5 },
+ { Ptr | OUT, 6 } } },
+ { .name = "sctp_generic_sendmsg", .ret_type = 1, .nargs = 7,
+ .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 },
+ { Sockaddr | IN, 3 }, { Socklent, 4 }, { Ptr | IN, 5 },
+ { Msgflags, 6 } } },
{ .name = "select", .ret_type = 1, .nargs = 5,
.args = { { Int, 0 }, { Fd_set, 1 }, { Fd_set, 2 }, { Fd_set, 3 },
{ Timeval, 4 } } },
+ { .name = "sendmsg", .ret_type = 1, .nargs = 3,
+ .args = { { Int, 0 }, { Ptr, 1 }, { Msgflags, 2 } } },
{ .name = "sendto", .ret_type = 1, .nargs = 6,
- .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 }, { Hex, 3 },
- { Sockaddr | IN, 4 }, { Int | IN, 5 } } },
+ .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 },
+ { Msgflags, 3 }, { Sockaddr | IN, 4 },
+ { Socklent | IN, 5 } } },
{ .name = "setitimer", .ret_type = 1, .nargs = 3,
.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,
@@ -315,7 +337,7 @@ static struct syscall decoded_syscalls[] = {
{ .name = "sigwaitinfo", .ret_type = 1, .nargs = 2,
.args = { { Sigset | IN, 0 }, { Ptr, 1 } } },
{ .name = "socket", .ret_type = 1, .nargs = 3,
- .args = { { Sockdomain, 0 }, { Socktype, 1 }, { Int, 2 } } },
+ .args = { { Sockdomain, 0 }, { Socktype, 1 }, { Sockprotocol, 2 } } },
{ .name = "stat", .ret_type = 1, .nargs = 2,
.args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
{ .name = "statfs", .ret_type = 1, .nargs = 2,
@@ -1912,6 +1934,48 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
case Madvice:
print_integer_arg(sysdecode_madvice, fp, args[sc->offset]);
break;
+ case Socklent:
+ fprintf(fp, "%u", (socklen_t)args[sc->offset]);
+ break;
+ case Sockprotocol: {
+ const char *temp;
+ int domain, protocol;
+
+ domain = args[sc->offset - 2];
+ protocol = args[sc->offset];
+ if (protocol == 0) {
+ fputs("0", fp);
+ } else {
+ temp = sysdecode_socket_protocol(domain, protocol);
+ if (temp) {
+ fputs(temp, fp);
+ } else {
+ fprintf(fp, "%d", protocol);
+ }
+ }
+ 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 Msgflags:
+ print_mask_arg(sysdecode_msg_flags, fp, args[sc->offset]);
+ break;
case CloudABIAdvice:
fputs(xlookup(cloudabi_advice, args[sc->offset]), fp);
OpenPOWER on IntegriCloud