Date: Thu, 8 Oct 2015 05:27:45 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289004 - in head: sys/compat/cloudabi usr.bin/truss Message-ID: <201510080527.t985Rj6h016369@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Thu Oct 8 05:27:45 2015 New Revision: 289004 URL: https://svnweb.freebsd.org/changeset/base/289004 Log: Properly format pointer size independent CloudABI system calls. CloudABI has approximately 50 system calls that do not depend on the pointer size of the system. As the ABI is pretty compact, it takes little effort to each truss(8) the formatting rules for these system calls. Start off by formatting pointer size independent system calls. Changes: - Make it possible to include the CloudABI system call definitions in FreeBSD userspace builds. Add ${root}/sys to the truss(8) Makefile so we can pull in <compat/cloudabi/cloudabi_syscalldefs.h>. - Refactoring: patch up amd64-cloudabi64.c to use the CLOUDABI_* constants instead of rolling our own table. - Add table entries for all of the system calls. - Add new generic formatting types (UInt, IntArray) that we'll be using to format unsigned integers and arrays of integers. - Add CloudABI specific formatting types. Approved by: jhb Differential Revision: https://reviews.freebsd.org/D3836 Modified: head/sys/compat/cloudabi/cloudabi_syscalldefs.h head/usr.bin/truss/Makefile head/usr.bin/truss/amd64-cloudabi64.c head/usr.bin/truss/syscall.h head/usr.bin/truss/syscalls.c Modified: head/sys/compat/cloudabi/cloudabi_syscalldefs.h ============================================================================== --- head/sys/compat/cloudabi/cloudabi_syscalldefs.h Thu Oct 8 04:29:39 2015 (r289003) +++ head/sys/compat/cloudabi/cloudabi_syscalldefs.h Thu Oct 8 05:27:45 2015 (r289004) @@ -28,12 +28,19 @@ #ifndef _CLOUDABI_SYSCALLDEFS_H_ #define _CLOUDABI_SYSCALLDEFS_H_ +#ifdef _KERNEL #include <sys/types.h> #include <sys/stdint.h> #define alignas _Alignas #define alignof _Alignof #define static_assert _Static_assert +#else +#include <assert.h> +#include <stdalign.h> +#include <stddef.h> +#include <stdint.h> +#endif /* Import machine-independent CloudABI definitions. */ #include <contrib/cloudabi/syscalldefs_mi.h> Modified: head/usr.bin/truss/Makefile ============================================================================== --- head/usr.bin/truss/Makefile Thu Oct 8 04:29:39 2015 (r289003) +++ head/usr.bin/truss/Makefile Thu Oct 8 05:27:45 2015 (r289004) @@ -13,7 +13,7 @@ SRCS+= ${MACHINE_CPUARCH}-fbsd.c .PATH: ${.CURDIR:H}/kdump SRCS+= utrace.c -CFLAGS+= -I${.CURDIR} -I. +CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys CLEANFILES= syscalls.master syscalls.h ioctl.c .SUFFIXES: .master Modified: head/usr.bin/truss/amd64-cloudabi64.c ============================================================================== --- head/usr.bin/truss/amd64-cloudabi64.c Thu Oct 8 04:29:39 2015 (r289003) +++ head/usr.bin/truss/amd64-cloudabi64.c Thu Oct 8 05:27:45 2015 (r289004) @@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <stdio.h> +#include <compat/cloudabi/cloudabi_syscalldefs.h> + #include "cloudabi64_syscalls.h" #include "truss.h" @@ -67,18 +69,82 @@ amd64_cloudabi64_fetch_args(struct truss } static const int cloudabi_errno_table[] = { - 0, E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, - EAGAIN, EALREADY, EBADF, EBADMSG, EBUSY, ECANCELED, ECHILD, - ECONNABORTED, ECONNREFUSED, ECONNRESET, EDEADLK, EDESTADDRREQ, - EDOM, EDQUOT, EEXIST, EFAULT, EFBIG, EHOSTUNREACH, EIDRM, - EILSEQ, EINPROGRESS, EINTR, EINVAL, EIO, EISCONN, EISDIR, ELOOP, - EMFILE, EMLINK, EMSGSIZE, EMULTIHOP, ENAMETOOLONG, ENETDOWN, - ENETRESET, ENETUNREACH, ENFILE, ENOBUFS, ENODEV, ENOENT, - ENOEXEC, ENOLCK, ENOLINK, ENOMEM, ENOMSG, ENOPROTOOPT, ENOSPC, - ENOSYS, ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTRECOVERABLE, ENOTSOCK, - ENOTSUP, ENOTTY, ENXIO, EOVERFLOW, EOWNERDEAD, EPERM, EPIPE, - EPROTO, EPROTONOSUPPORT, EPROTOTYPE, ERANGE, EROFS, ESPIPE, - ESRCH, ESTALE, ETIMEDOUT, ETXTBSY, EXDEV, ENOTCAPABLE, + [CLOUDABI_E2BIG] = E2BIG, + [CLOUDABI_EACCES] = EACCES, + [CLOUDABI_EADDRINUSE] = EADDRINUSE, + [CLOUDABI_EADDRNOTAVAIL] = EADDRNOTAVAIL, + [CLOUDABI_EAFNOSUPPORT] = EAFNOSUPPORT, + [CLOUDABI_EAGAIN] = EAGAIN, + [CLOUDABI_EALREADY] = EALREADY, + [CLOUDABI_EBADF] = EBADF, + [CLOUDABI_EBADMSG] = EBADMSG, + [CLOUDABI_EBUSY] = EBUSY, + [CLOUDABI_ECANCELED] = ECANCELED, + [CLOUDABI_ECHILD] = ECHILD, + [CLOUDABI_ECONNABORTED] = ECONNABORTED, + [CLOUDABI_ECONNREFUSED] = ECONNREFUSED, + [CLOUDABI_ECONNRESET] = ECONNRESET, + [CLOUDABI_EDEADLK] = EDEADLK, + [CLOUDABI_EDESTADDRREQ] = EDESTADDRREQ, + [CLOUDABI_EDOM] = EDOM, + [CLOUDABI_EDQUOT] = EDQUOT, + [CLOUDABI_EEXIST] = EEXIST, + [CLOUDABI_EFAULT] = EFAULT, + [CLOUDABI_EFBIG] = EFBIG, + [CLOUDABI_EHOSTUNREACH] = EHOSTUNREACH, + [CLOUDABI_EIDRM] = EIDRM, + [CLOUDABI_EILSEQ] = EILSEQ, + [CLOUDABI_EINPROGRESS] = EINPROGRESS, + [CLOUDABI_EINTR] = EINTR, + [CLOUDABI_EINVAL] = EINVAL, + [CLOUDABI_EIO] = EIO, + [CLOUDABI_EISCONN] = EISCONN, + [CLOUDABI_EISDIR] = EISDIR, + [CLOUDABI_ELOOP] = ELOOP, + [CLOUDABI_EMFILE] = EMFILE, + [CLOUDABI_EMLINK] = EMLINK, + [CLOUDABI_EMSGSIZE] = EMSGSIZE, + [CLOUDABI_EMULTIHOP] = EMULTIHOP, + [CLOUDABI_ENAMETOOLONG] = ENAMETOOLONG, + [CLOUDABI_ENETDOWN] = ENETDOWN, + [CLOUDABI_ENETRESET] = ENETRESET, + [CLOUDABI_ENETUNREACH] = ENETUNREACH, + [CLOUDABI_ENFILE] = ENFILE, + [CLOUDABI_ENOBUFS] = ENOBUFS, + [CLOUDABI_ENODEV] = ENODEV, + [CLOUDABI_ENOENT] = ENOENT, + [CLOUDABI_ENOEXEC] = ENOEXEC, + [CLOUDABI_ENOLCK] = ENOLCK, + [CLOUDABI_ENOLINK] = ENOLINK, + [CLOUDABI_ENOMEM] = ENOMEM, + [CLOUDABI_ENOMSG] = ENOMSG, + [CLOUDABI_ENOPROTOOPT] = ENOPROTOOPT, + [CLOUDABI_ENOSPC] = ENOSPC, + [CLOUDABI_ENOSYS] = ENOSYS, + [CLOUDABI_ENOTCONN] = ENOTCONN, + [CLOUDABI_ENOTDIR] = ENOTDIR, + [CLOUDABI_ENOTEMPTY] = ENOTEMPTY, + [CLOUDABI_ENOTRECOVERABLE] = ENOTRECOVERABLE, + [CLOUDABI_ENOTSOCK] = ENOTSOCK, + [CLOUDABI_ENOTSUP] = ENOTSUP, + [CLOUDABI_ENOTTY] = ENOTTY, + [CLOUDABI_ENXIO] = ENXIO, + [CLOUDABI_EOVERFLOW] = EOVERFLOW, + [CLOUDABI_EOWNERDEAD] = EOWNERDEAD, + [CLOUDABI_EPERM] = EPERM, + [CLOUDABI_EPIPE] = EPIPE, + [CLOUDABI_EPROTO] = EPROTO, + [CLOUDABI_EPROTONOSUPPORT] = EPROTONOSUPPORT, + [CLOUDABI_EPROTOTYPE] = EPROTOTYPE, + [CLOUDABI_ERANGE] = ERANGE, + [CLOUDABI_EROFS] = EROFS, + [CLOUDABI_ESPIPE] = ESPIPE, + [CLOUDABI_ESRCH] = ESRCH, + [CLOUDABI_ESTALE] = ESTALE, + [CLOUDABI_ETIMEDOUT] = ETIMEDOUT, + [CLOUDABI_ETXTBSY] = ETXTBSY, + [CLOUDABI_EXDEV] = EXDEV, + [CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, }; static int @@ -97,7 +163,8 @@ amd64_cloudabi64_fetch_retval(struct tru retval[0] = regs.r_rax; retval[1] = regs.r_rdx; *errorp = (regs.r_rflags & PSL_C) != 0; - if (*errorp && *retval >= 0 && *retval < nitems(cloudabi_errno_table)) + if (*errorp && *retval >= 0 && *retval < nitems(cloudabi_errno_table) && + cloudabi_errno_table[*retval] != 0) *retval = cloudabi_errno_table[*retval]; return (0); } Modified: head/usr.bin/truss/syscall.h ============================================================================== --- head/usr.bin/truss/syscall.h Thu Oct 8 04:29:39 2015 (r289003) +++ head/usr.bin/truss/syscall.h Thu Oct 8 05:27:45 2015 (r289004) @@ -37,14 +37,21 @@ * $FreeBSD$ */ -enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, - Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, - Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, +enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl, + Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, + Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open, Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, - Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace }; + Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, + + CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags, + CloudABIFDStat, CloudABIFileStat, CloudABIFileType, + CloudABIFSFlags, CloudABILookup, CloudABIMFlags, CloudABIMProt, + CloudABIMSFlags, CloudABIOFlags, CloudABISDFlags, + CloudABISignal, CloudABISockStat, CloudABISSFlags, + CloudABITimestamp, CloudABIULFlags, CloudABIWhence }; #define ARG_MASK 0xff #define OUT 0x100 Modified: head/usr.bin/truss/syscalls.c ============================================================================== --- head/usr.bin/truss/syscalls.c Thu Oct 8 04:29:39 2015 (r289003) +++ head/usr.bin/truss/syscalls.c Thu Oct 8 05:27:45 2015 (r289004) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <fcntl.h> #include <poll.h> #include <signal.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -68,6 +69,8 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <vis.h> +#include <compat/cloudabi/cloudabi_syscalldefs.h> + #include "truss.h" #include "extern.h" #include "syscall.h" @@ -382,6 +385,120 @@ static struct syscall decoded_syscalls[] { .name = "linux_stat64", .ret_type = 1, .nargs = 3, .args = { { Name | IN, 0 }, { Ptr | OUT, 1 }, { Ptr | IN, 1 } } }, + /* CloudABI system calls. */ + { .name = "cloudabi_sys_clock_res_get", .ret_type = 1, .nargs = 1, + .args = { { CloudABIClockID, 0 } } }, + { .name = "cloudabi_sys_clock_time_get", .ret_type = 1, .nargs = 2, + .args = { { CloudABIClockID, 0 }, { CloudABITimestamp, 1 } } }, + { .name = "cloudabi_sys_condvar_signal", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 }, { UInt, 2 } } }, + { .name = "cloudabi_sys_fd_close", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_create1", .ret_type = 1, .nargs = 1, + .args = { { CloudABIFileType, 0 } } }, + { .name = "cloudabi_sys_fd_create2", .ret_type = 1, .nargs = 2, + .args = { { CloudABIFileType, 0 }, { PipeFds | OUT, 0 } } }, + { .name = "cloudabi_sys_fd_datasync", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_dup", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_replace", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_fd_seek", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { CloudABIWhence, 2 } } }, + { .name = "cloudabi_sys_fd_stat_get", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABIFDStat | OUT, 1 } } }, + { .name = "cloudabi_sys_fd_stat_put", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABIFDStat | IN, 1 }, + { ClouduABIFDSFlags, 2 } } }, + { .name = "cloudabi_sys_fd_sync", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_file_advise", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { Int, 1 }, { Int, 2 }, + { CloudABIAdvice, 3 } } }, + { .name = "cloudabi_sys_file_allocate", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { Int, 2 } } }, + { .name = "cloudabi_sys_file_create", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIFileType, 3 } } }, + { .name = "cloudabi_sys_file_link", .ret_type = 1, .nargs = 4, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { Int, 3 }, { BinString | IN, 4 } } }, + { .name = "cloudabi_sys_file_open", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIOFlags, 3 }, { CloudABIFDStat | IN, 4 } } }, + { .name = "cloudabi_sys_file_readdir", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, + { Int, 3 } } }, + { .name = "cloudabi_sys_file_readlink", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { BinString | OUT, 3 }, { Int, 4 } } }, + { .name = "cloudabi_sys_file_rename", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { Int, 3 }, { BinString | IN, 4 } } }, + { .name = "cloudabi_sys_file_stat_fget", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABIFileStat | OUT, 1 } } }, + { .name = "cloudabi_sys_file_stat_fput", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABIFileStat | IN, 1 }, + { CloudABIFSFlags, 2 } } }, + { .name = "cloudabi_sys_file_stat_get", .ret_type = 1, .nargs = 3, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { CloudABIFileStat | OUT, 3 } } }, + { .name = "cloudabi_sys_file_stat_put", .ret_type = 1, .nargs = 4, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { CloudABIFileStat | IN, 3 }, { CloudABIFSFlags, 4 } } }, + { .name = "cloudabi_sys_file_symlink", .ret_type = 1, .nargs = 3, + .args = { { BinString | IN, 0 }, + { Int, 2 }, { BinString | IN, 3 } } }, + { .name = "cloudabi_sys_file_unlink", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIULFlags, 3 } } }, + { .name = "cloudabi_sys_lock_unlock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, + { .name = "cloudabi_sys_mem_advise", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIAdvice, 2 } } }, + { .name = "cloudabi_sys_mem_lock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_mem_map", .ret_type = 1, .nargs = 6, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 }, + { CloudABIMFlags, 3 }, { Int, 4 }, { Int, 5 } } }, + { .name = "cloudabi_sys_mem_protect", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 } } }, + { .name = "cloudabi_sys_mem_sync", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMSFlags, 2 } } }, + { .name = "cloudabi_sys_mem_unlock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_mem_unmap", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_proc_exec", .ret_type = 1, .nargs = 5, + .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, + { IntArray, 3 }, { Int, 4 } } }, + { .name = "cloudabi_sys_proc_exit", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_proc_fork", .ret_type = 1, .nargs = 0 }, + { .name = "cloudabi_sys_proc_raise", .ret_type = 1, .nargs = 1, + .args = { { CloudABISignal, 0 } } }, + { .name = "cloudabi_sys_random_get", .ret_type = 1, .nargs = 2, + .args = { { BinString | OUT, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_sock_accept", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABISockStat | OUT, 1 } } }, + { .name = "cloudabi_sys_sock_bind", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { BinString | IN, 2 } } }, + { .name = "cloudabi_sys_sock_connect", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { BinString | IN, 2 } } }, + { .name = "cloudabi_sys_sock_listen", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_sock_shutdown", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABISDFlags, 1 } } }, + { .name = "cloudabi_sys_sock_stat_get", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABISockStat | OUT, 1 }, + { CloudABISSFlags, 2 } } }, + { .name = "cloudabi_sys_thread_exit", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, + { .name = "cloudabi_sys_thread_tcb_set", .ret_type = 1, .nargs = 1, + .args = { { Ptr, 0 } } }, + { .name = "cloudabi_sys_thread_yield", .ret_type = 1, .nargs = 0 }, + { .name = 0 }, }; static STAILQ_HEAD(, syscall) syscalls; @@ -598,6 +715,126 @@ static struct xlat sigprocmask_ops[] = { }; #undef X +#define X(a) { CLOUDABI_##a, #a }, + +static struct xlat cloudabi_advice[] = { + X(ADVICE_DONTNEED) X(ADVICE_NOREUSE) X(ADVICE_NORMAL) + X(ADVICE_RANDOM) X(ADVICE_SEQUENTIAL) X(ADVICE_WILLNEED) + XEND +}; + +static struct xlat cloudabi_clockid[] = { + X(CLOCK_MONOTONIC) X(CLOCK_PROCESS_CPUTIME_ID) + X(CLOCK_REALTIME) X(CLOCK_THREAD_CPUTIME_ID) + XEND +}; + +static struct xlat cloudabi_errno[] = { + X(E2BIG) X(EACCES) X(EADDRINUSE) X(EADDRNOTAVAIL) + X(EAFNOSUPPORT) X(EAGAIN) X(EALREADY) X(EBADF) X(EBADMSG) + X(EBUSY) X(ECANCELED) X(ECHILD) X(ECONNABORTED) X(ECONNREFUSED) + X(ECONNRESET) X(EDEADLK) X(EDESTADDRREQ) X(EDOM) X(EDQUOT) + X(EEXIST) X(EFAULT) X(EFBIG) X(EHOSTUNREACH) X(EIDRM) X(EILSEQ) + X(EINPROGRESS) X(EINTR) X(EINVAL) X(EIO) X(EISCONN) X(EISDIR) + X(ELOOP) X(EMFILE) X(EMLINK) X(EMSGSIZE) X(EMULTIHOP) + X(ENAMETOOLONG) X(ENETDOWN) X(ENETRESET) X(ENETUNREACH) + X(ENFILE) X(ENOBUFS) X(ENODEV) X(ENOENT) X(ENOEXEC) X(ENOLCK) + X(ENOLINK) X(ENOMEM) X(ENOMSG) X(ENOPROTOOPT) X(ENOSPC) + X(ENOSYS) X(ENOTCONN) X(ENOTDIR) X(ENOTEMPTY) X(ENOTRECOVERABLE) + X(ENOTSOCK) X(ENOTSUP) X(ENOTTY) X(ENXIO) X(EOVERFLOW) + X(EOWNERDEAD) X(EPERM) X(EPIPE) X(EPROTO) X(EPROTONOSUPPORT) + X(EPROTOTYPE) X(ERANGE) X(EROFS) X(ESPIPE) X(ESRCH) X(ESTALE) + X(ETIMEDOUT) X(ETXTBSY) X(EXDEV) X(ENOTCAPABLE) + XEND +}; + +static struct xlat cloudabi_fdflags[] = { + X(FDFLAG_APPEND) X(FDFLAG_DSYNC) X(FDFLAG_NONBLOCK) + X(FDFLAG_RSYNC) X(FDFLAG_SYNC) + XEND +}; + +static struct xlat cloudabi_fdsflags[] = { + X(FDSTAT_FLAGS) X(FDSTAT_RIGHTS) + XEND +}; + +static struct xlat cloudabi_filetype[] = { + X(FILETYPE_UNKNOWN) X(FILETYPE_BLOCK_DEVICE) + X(FILETYPE_CHARACTER_DEVICE) X(FILETYPE_DIRECTORY) + X(FILETYPE_FIFO) X(FILETYPE_POLL) X(FILETYPE_PROCESS) + X(FILETYPE_REGULAR_FILE) X(FILETYPE_SHARED_MEMORY) + X(FILETYPE_SOCKET_DGRAM) X(FILETYPE_SOCKET_SEQPACKET) + X(FILETYPE_SOCKET_STREAM) X(FILETYPE_SYMBOLIC_LINK) + XEND +}; + +static struct xlat cloudabi_fsflags[] = { + X(FILESTAT_ATIM) X(FILESTAT_ATIM_NOW) X(FILESTAT_MTIM) + X(FILESTAT_MTIM_NOW) X(FILESTAT_SIZE) + XEND +}; + +static struct xlat cloudabi_mflags[] = { + X(MAP_ANON) X(MAP_FIXED) X(MAP_PRIVATE) X(MAP_SHARED) + XEND +}; + +static struct xlat cloudabi_mprot[] = { + X(PROT_EXEC) X(PROT_WRITE) X(PROT_READ) + XEND +}; + +static struct xlat cloudabi_msflags[] = { + X(MS_ASYNC) X(MS_INVALIDATE) X(MS_SYNC) + XEND +}; + +static struct xlat cloudabi_oflags[] = { + X(O_CREAT) X(O_DIRECTORY) X(O_EXCL) X(O_TRUNC) + XEND +}; + +static struct xlat cloudabi_sa_family[] = { + X(AF_UNSPEC) X(AF_INET) X(AF_INET6) X(AF_UNIX) + XEND +}; + +static struct xlat cloudabi_sdflags[] = { + X(SHUT_RD) X(SHUT_WR) + XEND +}; + +static struct xlat cloudabi_signal[] = { + X(SIGABRT) X(SIGALRM) X(SIGBUS) X(SIGCHLD) X(SIGCONT) X(SIGFPE) + X(SIGHUP) X(SIGILL) X(SIGINT) X(SIGKILL) X(SIGPIPE) X(SIGQUIT) + X(SIGSEGV) X(SIGSTOP) X(SIGSYS) X(SIGTERM) X(SIGTRAP) X(SIGTSTP) + X(SIGTTIN) X(SIGTTOU) X(SIGURG) X(SIGUSR1) X(SIGUSR2) + X(SIGVTALRM) X(SIGXCPU) X(SIGXFSZ) + XEND +}; + +static struct xlat cloudabi_ssflags[] = { + X(SOCKSTAT_CLEAR_ERROR) + XEND +}; + +static struct xlat cloudabi_ssstate[] = { + X(SOCKSTAT_ACCEPTCONN) + XEND +}; + +static struct xlat cloudabi_ulflags[] = { + X(UNLINK_REMOVEDIR) + XEND +}; + +static struct xlat cloudabi_whence[] = { + X(WHENCE_CUR) X(WHENCE_END) X(WHENCE_SET) + XEND +}; + +#undef X #undef XEND /* @@ -910,6 +1147,9 @@ print_arg(struct syscall_args *sc, unsig case Int: fprintf(fp, "%d", (int)args[sc->offset]); break; + case UInt: + fprintf(fp, "%u", (unsigned int)args[sc->offset]); + break; case LongHex: fprintf(fp, "0x%lx", args[sc->offset]); break; @@ -1638,6 +1878,122 @@ print_arg(struct syscall_args *sc, unsig free(utrace_addr); break; } + case IntArray: { + int descriptors[16]; + unsigned long i, ndescriptors; + bool truncated; + + ndescriptors = args[sc->offset + 1]; + truncated = false; + if (ndescriptors > nitems(descriptors)) { + ndescriptors = nitems(descriptors); + truncated = true; + } + if (get_struct(pid, (void *)args[sc->offset], + descriptors, ndescriptors * sizeof(descriptors[0])) != -1) { + fprintf(fp, "{"); + for (i = 0; i < ndescriptors; i++) + fprintf(fp, i == 0 ? " %d" : ", %d", + descriptors[i]); + fprintf(fp, truncated ? ", ... }" : " }"); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + + case CloudABIAdvice: + fputs(xlookup(cloudabi_advice, args[sc->offset]), fp); + break; + case CloudABIClockID: + fputs(xlookup(cloudabi_clockid, args[sc->offset]), fp); + break; + case ClouduABIFDSFlags: + fputs(xlookup_bits(cloudabi_fdsflags, args[sc->offset]), fp); + break; + case CloudABIFDStat: { + cloudabi_fdstat_t fds; + if (get_struct(pid, (void *)args[sc->offset], &fds, sizeof(fds)) + != -1) { + fprintf(fp, "{ %s, ", + xlookup(cloudabi_filetype, fds.fs_filetype)); + fprintf(fp, "%s, ... }", + xlookup_bits(cloudabi_fdflags, fds.fs_flags)); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABIFileStat: { + cloudabi_filestat_t fsb; + if (get_struct(pid, (void *)args[sc->offset], &fsb, sizeof(fsb)) + != -1) + fprintf(fp, "{ %s, %lu }", + xlookup(cloudabi_filetype, fsb.st_filetype), + fsb.st_size); + else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABIFileType: + fputs(xlookup(cloudabi_filetype, args[sc->offset]), fp); + break; + case CloudABIFSFlags: + fputs(xlookup_bits(cloudabi_fsflags, args[sc->offset]), fp); + break; + case CloudABILookup: + if ((args[sc->offset] & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) != 0) + fprintf(fp, "%d|LOOKUP_SYMLINK_FOLLOW", + (int)args[sc->offset]); + else + fprintf(fp, "%d", (int)args[sc->offset]); + break; + case CloudABIMFlags: + fputs(xlookup_bits(cloudabi_mflags, args[sc->offset]), fp); + break; + case CloudABIMProt: + fputs(xlookup_bits(cloudabi_mprot, args[sc->offset]), fp); + break; + case CloudABIMSFlags: + fputs(xlookup_bits(cloudabi_msflags, args[sc->offset]), fp); + break; + case CloudABIOFlags: + fputs(xlookup_bits(cloudabi_oflags, args[sc->offset]), fp); + break; + case CloudABISDFlags: + fputs(xlookup_bits(cloudabi_sdflags, args[sc->offset]), fp); + break; + case CloudABISignal: + fputs(xlookup(cloudabi_signal, args[sc->offset]), fp); + break; + case CloudABISockStat: { + cloudabi_sockstat_t ss; + if (get_struct(pid, (void *)args[sc->offset], &ss, sizeof(ss)) + != -1) { + fprintf(fp, "{ %s, ", xlookup( + cloudabi_sa_family, ss.ss_sockname.sa_family)); + fprintf(fp, "%s, ", xlookup( + cloudabi_sa_family, ss.ss_peername.sa_family)); + fprintf(fp, "%s, ", xlookup( + cloudabi_errno, ss.ss_error)); + fprintf(fp, "%s }", xlookup_bits( + cloudabi_ssstate, ss.ss_state)); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABISSFlags: + fputs(xlookup_bits(cloudabi_ssflags, args[sc->offset]), fp); + break; + case CloudABITimestamp: + fprintf(fp, "%lu.%09lus", args[sc->offset] / 1000000000, + args[sc->offset] % 1000000000); + break; + case CloudABIULFlags: + fputs(xlookup_bits(cloudabi_ulflags, args[sc->offset]), fp); + break; + case CloudABIWhence: + fputs(xlookup(cloudabi_whence, args[sc->offset]), fp); + break; + default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510080527.t985Rj6h016369>