truss: centralize pointer-constructing casts.

In nearly all cases, the caller has a uintptr_t compatible argument so
this eliminates a large number of casts.

Add a print_pointer function to centralize printing pointers.

Reviewed by:	jhb
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D22212
This commit is contained in:
Brooks Davis 2019-10-31 22:29:13 +00:00
parent 9dd7582c12
commit cc86d14a47

View File

@ -1051,12 +1051,12 @@ get_syscall(struct threadinfo *t, u_int number, u_int nargs)
* Copy a fixed amount of bytes from the process.
*/
static int
get_struct(pid_t pid, void *offset, void *buf, int len)
get_struct(pid_t pid, uintptr_t offset, void *buf, int len)
{
struct ptrace_io_desc iorequest;
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = offset;
iorequest.piod_offs = (void *)offset;
iorequest.piod_addr = buf;
iorequest.piod_len = len;
if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0)
@ -1072,7 +1072,7 @@ get_struct(pid_t pid, void *offset, void *buf, int len)
* only get that much.
*/
static char *
get_string(pid_t pid, void *addr, int max)
get_string(pid_t pid, uintptr_t addr, int max)
{
struct ptrace_io_desc iorequest;
char *buf, *nbuf;
@ -1093,7 +1093,7 @@ get_string(pid_t pid, void *addr, int max)
return (NULL);
for (;;) {
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = (char *)addr + offset;
iorequest.piod_offs = (void *)(addr + offset);
iorequest.piod_addr = buf + offset;
iorequest.piod_len = size;
if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0) {
@ -1183,7 +1183,15 @@ print_utrace(FILE *fp, void *utrace_addr, size_t len)
}
static void
print_sockaddr(FILE *fp, struct trussinfo *trussinfo, void *arg, socklen_t len)
print_pointer(FILE *fp, uintptr_t arg)
{
fprintf(fp, "%p", (void *)arg);
}
static void
print_sockaddr(FILE *fp, struct trussinfo *trussinfo, uintptr_t arg,
socklen_t len)
{
char addr[64];
struct sockaddr_in *lsin;
@ -1193,20 +1201,20 @@ print_sockaddr(FILE *fp, struct trussinfo *trussinfo, void *arg, socklen_t len)
u_char *q;
pid_t pid = trussinfo->curthread->proc->pid;
if (arg == NULL) {
if (arg == 0) {
fputs("NULL", fp);
return;
}
/* If the length is too small, just bail. */
if (len < sizeof(*sa)) {
fprintf(fp, "%p", arg);
print_pointer(fp, arg);
return;
}
sa = calloc(1, len);
if (get_struct(pid, arg, sa, len) == -1) {
free(sa);
fprintf(fp, "%p", arg);
print_pointer(fp, arg);
return;
}
@ -1252,7 +1260,7 @@ print_sockaddr(FILE *fp, struct trussinfo *trussinfo, void *arg, socklen_t len)
#define IOV_LIMIT 16
static void
print_iovec(FILE *fp, struct trussinfo *trussinfo, void *arg, int iovcnt)
print_iovec(FILE *fp, struct trussinfo *trussinfo, uintptr_t arg, int iovcnt)
{
struct iovec iov[IOV_LIMIT];
size_t max_string = trussinfo->strsize;
@ -1263,7 +1271,7 @@ print_iovec(FILE *fp, struct trussinfo *trussinfo, void *arg, int iovcnt)
bool buf_truncated, iov_truncated;
if (iovcnt <= 0) {
fprintf(fp, "%p", arg);
print_pointer(fp, arg);
return;
}
if (iovcnt > IOV_LIMIT) {
@ -1273,7 +1281,7 @@ print_iovec(FILE *fp, struct trussinfo *trussinfo, void *arg, int iovcnt)
iov_truncated = false;
}
if (get_struct(pid, arg, &iov, iovcnt * sizeof(struct iovec)) == -1) {
fprintf(fp, "%p", arg);
print_pointer(fp, arg);
return;
}
@ -1287,7 +1295,7 @@ print_iovec(FILE *fp, struct trussinfo *trussinfo, void *arg, int iovcnt)
buf_truncated = false;
}
fprintf(fp, "%s{", (i > 0) ? "," : "");
if (len && get_struct(pid, iov[i].iov_base, &tmp2, len) != -1) {
if (len && get_struct(pid, (uintptr_t)iov[i].iov_base, &tmp2, len) != -1) {
tmp3 = malloc(len * 4 + 1);
while (len) {
if (strvisx(tmp3, tmp2, len,
@ -1301,7 +1309,7 @@ print_iovec(FILE *fp, struct trussinfo *trussinfo, void *arg, int iovcnt)
buf_truncated ? "..." : "");
free(tmp3);
} else {
fprintf(fp, "%p", iov[i].iov_base);
print_pointer(fp, (uintptr_t)iov[i].iov_base);
}
fprintf(fp, ",%zu}", iov[i].iov_len);
}
@ -1521,8 +1529,8 @@ print_cmsgs(FILE *fp, pid_t pid, bool receive, struct msghdr *msghdr)
return;
}
cmsgbuf = calloc(1, len);
if (get_struct(pid, msghdr->msg_control, cmsgbuf, len) == -1) {
fprintf(fp, "%p", msghdr->msg_control);
if (get_struct(pid, (uintptr_t)msghdr->msg_control, cmsgbuf, len) == -1) {
print_pointer(fp, (uintptr_t)msghdr->msg_control);
free(cmsgbuf);
return;
}
@ -1602,11 +1610,11 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case PUInt: {
unsigned int val;
if (get_struct(pid, (void *)args[sc->offset], &val,
if (get_struct(pid, args[sc->offset], &val,
sizeof(val)) == 0)
fprintf(fp, "{ %u }", val);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case LongHex:
@ -1629,7 +1637,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
/* NULL-terminated string. */
char *tmp2;
tmp2 = get_string(pid, (void*)args[sc->offset], 0);
tmp2 = get_string(pid, args[sc->offset], 0);
fprintf(fp, "\"%s\"", tmp2);
free(tmp2);
break;
@ -1659,7 +1667,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
len = max_string;
truncated = 1;
}
if (len && get_struct(pid, (void*)args[sc->offset], &tmp2, len)
if (len && get_struct(pid, args[sc->offset], &tmp2, len)
!= -1) {
tmp3 = malloc(len * 4 + 1);
while (len) {
@ -1673,7 +1681,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
"..." : "");
free(tmp3);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
break;
}
@ -1697,7 +1705,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
(trussinfo->flags & EXECVEARGS) == 0) ||
((sc->type & ARG_MASK) == ExecEnv &&
(trussinfo->flags & EXECVEENVS) == 0)) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
@ -1708,13 +1716,13 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
*/
addr = args[sc->offset];
if (addr % sizeof(char *) != 0) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
len = PAGE_SIZE - (addr & PAGE_MASK);
if (get_struct(pid, (void *)addr, u.buf, len) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
if (get_struct(pid, addr, u.buf, len) == -1) {
print_pointer(fp, args[sc->offset]);
break;
}
@ -1722,7 +1730,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
first = 1;
i = 0;
while (u.strarray[i] != NULL) {
string = get_string(pid, u.strarray[i], 0);
string = get_string(pid, (uintptr_t)u.strarray[i], 0);
fprintf(fp, "%s \"%s\"", first ? "" : ",", string);
free(string);
first = 0;
@ -1731,7 +1739,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
if (i == len / sizeof(char *)) {
addr += len;
len = PAGE_SIZE;
if (get_struct(pid, (void *)addr, u.buf, len) ==
if (get_struct(pid, addr, u.buf, len) ==
-1) {
fprintf(fp, ", <inval>");
break;
@ -1771,22 +1779,22 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case PQuadHex: {
uint64_t val;
if (get_struct(pid, (void *)args[sc->offset], &val,
if (get_struct(pid, args[sc->offset], &val,
sizeof(val)) == 0)
fprintf(fp, "{ 0x%jx }", (uintmax_t)val);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Ptr:
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
case Readlinkres: {
char *tmp2;
if (retval[0] == -1)
break;
tmp2 = get_string(pid, (void*)args[sc->offset], retval[0]);
tmp2 = get_string(pid, args[sc->offset], retval[0]);
fprintf(fp, "\"%s\"", tmp2);
free(tmp2);
break;
@ -1811,12 +1819,11 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case Timespec: {
struct timespec ts;
if (get_struct(pid, (void *)args[sc->offset], &ts,
sizeof(ts)) != -1)
if (get_struct(pid, args[sc->offset], &ts, sizeof(ts)) != -1)
fprintf(fp, "{ %jd.%09ld }", (intmax_t)ts.tv_sec,
ts.tv_nsec);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Timespec2: {
@ -1824,8 +1831,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
const char *sep;
unsigned int i;
if (get_struct(pid, (void *)args[sc->offset], &ts, sizeof(ts))
!= -1) {
if (get_struct(pid, args[sc->offset], &ts, sizeof(ts)) != -1) {
fputs("{ ", fp);
sep = "";
for (i = 0; i < nitems(ts); i++) {
@ -1847,57 +1853,54 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
}
fputs(" }", fp);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Timeval: {
struct timeval tv;
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
!= -1)
if (get_struct(pid, args[sc->offset], &tv, sizeof(tv)) != -1)
fprintf(fp, "{ %jd.%06ld }", (intmax_t)tv.tv_sec,
tv.tv_usec);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Timeval2: {
struct timeval tv[2];
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
!= -1)
if (get_struct(pid, args[sc->offset], &tv, sizeof(tv)) != -1)
fprintf(fp, "{ %jd.%06ld, %jd.%06ld }",
(intmax_t)tv[0].tv_sec, tv[0].tv_usec,
(intmax_t)tv[1].tv_sec, tv[1].tv_usec);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Itimerval: {
struct itimerval itv;
if (get_struct(pid, (void *)args[sc->offset], &itv,
sizeof(itv)) != -1)
if (get_struct(pid, args[sc->offset], &itv, sizeof(itv)) != -1)
fprintf(fp, "{ %jd.%06ld, %jd.%06ld }",
(intmax_t)itv.it_interval.tv_sec,
itv.it_interval.tv_usec,
(intmax_t)itv.it_value.tv_sec,
itv.it_value.tv_usec);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case LinuxSockArgs:
{
struct linux_socketcall_args largs;
if (get_struct(pid, (void *)args[sc->offset], (void *)&largs,
if (get_struct(pid, args[sc->offset], (void *)&largs,
sizeof(largs)) != -1)
fprintf(fp, "{ %s, 0x%lx }",
lookup(linux_socketcall_ops, largs.what, 10),
(long unsigned int)largs.args);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Pollfd: {
@ -1914,8 +1917,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
if ((pfd = malloc(bytes)) == NULL)
err(1, "Cannot malloc %zu bytes for pollfd array",
bytes);
if (get_struct(pid, (void *)args[sc->offset], pfd, bytes)
!= -1) {
if (get_struct(pid, args[sc->offset], pfd, bytes) != -1) {
fputs("{", fp);
for (i = 0; i < numfds; i++) {
fprintf(fp, " %d/%s", pfd[i].fd,
@ -1923,7 +1925,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
}
fputs(" }", fp);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
free(pfd);
break;
@ -1942,8 +1944,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
if ((fds = malloc(bytes)) == NULL)
err(1, "Cannot malloc %zu bytes for fd_set array",
bytes);
if (get_struct(pid, (void *)args[sc->offset], fds, bytes)
!= -1) {
if (get_struct(pid, args[sc->offset], fds, bytes) != -1) {
fputs("{", fp);
for (i = 0; i < numfds; i++) {
if (FD_ISSET(i, fds))
@ -1951,7 +1952,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
}
fputs(" }", fp);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
free(fds);
break;
}
@ -1964,9 +1965,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
int i, first;
sig = args[sc->offset];
if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
if (get_struct(pid, args[sc->offset], (void *)&ss,
sizeof(ss)) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
fputs("{ ", fp);
@ -2044,22 +2045,21 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
* the next argument contains a socklen_t by value.
*/
if (sc->type & OUT) {
if (get_struct(pid, (void *)args[sc->offset + 1],
&len, sizeof(len)) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
if (get_struct(pid, args[sc->offset + 1], &len,
sizeof(len)) == -1) {
print_pointer(fp, args[sc->offset]);
break;
}
} else
len = args[sc->offset + 1];
print_sockaddr(fp, trussinfo, (void *)args[sc->offset], len);
print_sockaddr(fp, trussinfo, args[sc->offset], len);
break;
}
case Sigaction: {
struct sigaction sa;
if (get_struct(pid, (void *)args[sc->offset], &sa, sizeof(sa))
!= -1) {
if (get_struct(pid, args[sc->offset], &sa, sizeof(sa)) != -1) {
fputs("{ ", fp);
if (sa.sa_handler == SIG_DFL)
fputs("SIG_DFL", fp);
@ -2070,7 +2070,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
fprintf(fp, " %s ss_t }",
xlookup_bits(sigaction_flags, sa.sa_flags));
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Kevent: {
@ -2099,7 +2099,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
bytes);
} else
ke = NULL;
if (numevents >= 0 && get_struct(pid, (void *)args[sc->offset],
if (numevents >= 0 && get_struct(pid, args[sc->offset],
ke, bytes) != -1) {
fputc('{', fp);
for (i = 0; i < numevents; i++) {
@ -2108,7 +2108,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
}
fputs(" }", fp);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
free(ke);
break;
@ -2134,7 +2134,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
} else
ke11 = NULL;
memset(&ke, 0, sizeof(ke));
if (numevents >= 0 && get_struct(pid, (void *)args[sc->offset],
if (numevents >= 0 && get_struct(pid, args[sc->offset],
ke11, bytes) != -1) {
fputc('{', fp);
for (i = 0; i < numevents; i++) {
@ -2149,7 +2149,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
}
fputs(" }", fp);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
free(ke11);
break;
@ -2157,7 +2157,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case Stat: {
struct stat st;
if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st))
if (get_struct(pid, args[sc->offset], &st, sizeof(st))
!= -1) {
char mode[12];
@ -2167,14 +2167,14 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
(uintmax_t)st.st_ino, (intmax_t)st.st_size,
(long)st.st_blksize);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
break;
}
case Stat11: {
struct freebsd11_stat st;
if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st))
if (get_struct(pid, args[sc->offset], &st, sizeof(st))
!= -1) {
char mode[12];
@ -2184,7 +2184,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
(uintmax_t)st.st_ino, (intmax_t)st.st_size,
(long)st.st_blksize);
} else {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
}
break;
}
@ -2192,7 +2192,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
unsigned int i;
struct statfs buf;
if (get_struct(pid, (void *)args[sc->offset], &buf,
if (get_struct(pid, args[sc->offset], &buf,
sizeof(buf)) != -1) {
char fsid[17];
@ -2208,14 +2208,14 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
"fsid=%s }", buf.f_fstypename, buf.f_mntonname,
buf.f_mntfromname, fsid);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Rusage: {
struct rusage ru;
if (get_struct(pid, (void *)args[sc->offset], &ru, sizeof(ru))
if (get_struct(pid, args[sc->offset], &ru, sizeof(ru))
!= -1) {
fprintf(fp,
"{ u=%jd.%06ld,s=%jd.%06ld,in=%ld,out=%ld }",
@ -2223,24 +2223,24 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
(intmax_t)ru.ru_stime.tv_sec, ru.ru_stime.tv_usec,
ru.ru_inblock, ru.ru_oublock);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Rlimit: {
struct rlimit rl;
if (get_struct(pid, (void *)args[sc->offset], &rl, sizeof(rl))
if (get_struct(pid, args[sc->offset], &rl, sizeof(rl))
!= -1) {
fprintf(fp, "{ cur=%ju,max=%ju }",
rl.rlim_cur, rl.rlim_max);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case ExitStatus: {
int status;
if (get_struct(pid, (void *)args[sc->offset], &status,
if (get_struct(pid, args[sc->offset], &status,
sizeof(status)) != -1) {
fputs("{ ", fp);
if (WIFCONTINUED(status))
@ -2257,7 +2257,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
strsig2(WTERMSIG(status)));
fputs(" }", fp);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Waitoptions:
@ -2293,7 +2293,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
memset(name, 0, sizeof(name));
len = args[sc->offset + 1];
if (get_struct(pid, (void *)args[sc->offset], oid,
if (get_struct(pid, args[sc->offset], oid,
len * sizeof(oid[0])) != -1) {
fprintf(fp, "\"");
if (oid[0] == CTL_SYSCTL) {
@ -2362,11 +2362,11 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
len = args[sc->offset + 1];
utrace_addr = calloc(1, len);
if (get_struct(pid, (void *)args[sc->offset],
if (get_struct(pid, args[sc->offset],
(void *)utrace_addr, len) != -1)
print_utrace(fp, utrace_addr, len);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
free(utrace_addr);
break;
}
@ -2381,7 +2381,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
ndescriptors = nitems(descriptors);
truncated = true;
}
if (get_struct(pid, (void *)args[sc->offset],
if (get_struct(pid, args[sc->offset],
descriptors, ndescriptors * sizeof(descriptors[0])) != -1) {
fprintf(fp, "{");
for (i = 0; i < ndescriptors; i++)
@ -2389,7 +2389,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
descriptors[i]);
fprintf(fp, truncated ? ", ... }" : " }");
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Pipe2:
@ -2399,9 +2399,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
uint32_t rights;
if (sc->type & OUT) {
if (get_struct(pid, (void *)args[sc->offset], &rights,
if (get_struct(pid, args[sc->offset], &rights,
sizeof(rights)) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
} else
@ -2483,13 +2483,13 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case CapRights: {
cap_rights_t rights;
if (get_struct(pid, (void *)args[sc->offset], &rights,
if (get_struct(pid, args[sc->offset], &rights,
sizeof(rights)) != -1) {
fputs("{ ", fp);
sysdecode_cap_rights(fp, &rights);
fputs(" }", fp);
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Acltype:
@ -2537,33 +2537,30 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case Schedparam: {
struct sched_param sp;
if (get_struct(pid, (void *)args[sc->offset], &sp,
sizeof(sp)) != -1)
if (get_struct(pid, args[sc->offset], &sp, sizeof(sp)) != -1)
fprintf(fp, "{ %d }", sp.sched_priority);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case PSig: {
int sig;
if (get_struct(pid, (void *)args[sc->offset], &sig,
sizeof(sig)) == 0)
if (get_struct(pid, args[sc->offset], &sig, sizeof(sig)) == 0)
fprintf(fp, "{ %s }", strsig2(sig));
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Siginfo: {
siginfo_t si;
if (get_struct(pid, (void *)args[sc->offset], &si,
sizeof(si)) != -1) {
if (get_struct(pid, args[sc->offset], &si, sizeof(si)) != -1) {
fprintf(fp, "{ signo=%s", strsig2(si.si_signo));
decode_siginfo(fp, &si);
fprintf(fp, " }");
} else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case Iovec:
@ -2572,15 +2569,15 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
* syscall argument is the number of elements of the array.
*/
print_iovec(fp, trussinfo, (void *)args[sc->offset],
print_iovec(fp, trussinfo, args[sc->offset],
(int)args[sc->offset + 1]);
break;
case Sctpsndrcvinfo: {
struct sctp_sndrcvinfo info;
if (get_struct(pid, (void *)args[sc->offset],
if (get_struct(pid, args[sc->offset],
&info, sizeof(struct sctp_sndrcvinfo)) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
print_sctp_sndrcvinfo(fp, sc->type & OUT, &info);
@ -2589,15 +2586,15 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
case Msghdr: {
struct msghdr msghdr;
if (get_struct(pid, (void *)args[sc->offset],
if (get_struct(pid, args[sc->offset],
&msghdr, sizeof(struct msghdr)) == -1) {
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
fputs("{", fp);
print_sockaddr(fp, trussinfo, msghdr.msg_name, msghdr.msg_namelen);
print_sockaddr(fp, trussinfo, (uintptr_t)msghdr.msg_name, msghdr.msg_namelen);
fprintf(fp, ",%d,", msghdr.msg_namelen);
print_iovec(fp, trussinfo, msghdr.msg_iov, msghdr.msg_iovlen);
print_iovec(fp, trussinfo, (uintptr_t)msghdr.msg_iov, msghdr.msg_iovlen);
fprintf(fp, ",%d,", msghdr.msg_iovlen);
print_cmsgs(fp, pid, sc->type & OUT, &msghdr);
fprintf(fp, ",%u,", msghdr.msg_controllen);
@ -2617,25 +2614,25 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
break;
case CloudABIFDStat: {
cloudabi_fdstat_t fds;
if (get_struct(pid, (void *)args[sc->offset], &fds, sizeof(fds))
if (get_struct(pid, 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]);
print_pointer(fp, args[sc->offset]);
break;
}
case CloudABIFileStat: {
cloudabi_filestat_t fsb;
if (get_struct(pid, (void *)args[sc->offset], &fsb, sizeof(fsb))
if (get_struct(pid, args[sc->offset], &fsb, sizeof(fsb))
!= -1)
fprintf(fp, "{ %s, %ju }",
xlookup(cloudabi_filetype, fsb.st_filetype),
(uintmax_t)fsb.st_size);
else
fprintf(fp, "0x%lx", args[sc->offset]);
print_pointer(fp, args[sc->offset]);
break;
}
case CloudABIFileType: