예제 #1
0
파일: net.c 프로젝트: yunchih/strace
static int
decode_sockname(struct tcb *tcp)
{
	int ulen, rlen;

	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		if (fetch_socklen(tcp, &ulen, tcp->u_arg[1], tcp->u_arg[2])) {
			set_tcb_priv_ulong(tcp, ulen);
			return 0;
		} else {
			printaddr(tcp->u_arg[1]);
			tprints(", ");
			printaddr(tcp->u_arg[2]);
			return RVAL_DECODED;
		}
	}

	ulen = get_tcb_priv_ulong(tcp);

	if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &rlen) < 0) {
		printaddr(tcp->u_arg[1]);
		tprintf(", [%d]", ulen);
	} else {
		decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen);
		if (ulen != rlen)
			tprintf(", [%d->%d]", ulen, rlen);
		else
			tprintf(", [%d]", rlen);
	}

	return RVAL_DECODED;
}
예제 #2
0
파일: io.c 프로젝트: GeoffGats/strace
int
sys_sendfile(struct tcb *tcp)
{
	if (entering(tcp)) {
		off_t offset;

		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		printfd(tcp, tcp->u_arg[1]);
		tprints(", ");
		if (!tcp->u_arg[2])
			tprints("NULL");
//FIXME: obviously bogus.
//Probably should use explicit long.
//Arches with long long offset param should use
//sys_sendfile64, not this fn.
		else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
			tprintf("%#lx", tcp->u_arg[2]);
		else
#ifdef HAVE_LONG_LONG_OFF_T
			tprintf("[%llu]", offset);
#else
			tprintf("[%lu]", offset);
#endif
		tprintf(", %lu", tcp->u_arg[3]);
	}
	return 0;
}
예제 #3
0
파일: ipc.c 프로젝트: Ale1ster/kerneldir
int sys_shmat(struct tcb *tcp)
{
	if (exiting(tcp)) {
		tprintf("%lu", tcp->u_arg[0]);
		if (indirect_ipccall(tcp)) {
			tprintf(", %#lx", tcp->u_arg[3]);
			tprints(", ");
			printflags(shm_flags, tcp->u_arg[1], "SHM_???");
		} else {
			tprintf(", %#lx", tcp->u_arg[1]);
			tprints(", ");
			printflags(shm_flags, tcp->u_arg[2], "SHM_???");
		}
		if (syserror(tcp))
			return 0;
		if (indirect_ipccall(tcp)) {
			unsigned long raddr;
			if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
				return RVAL_NONE;
			tcp->u_rval = raddr;
		}
		return RVAL_HEX;
	}
	return 0;
}
예제 #4
0
static void
print_mreq6(struct tcb *tcp, long addr, unsigned int len)
{
	struct ipv6_mreq mreq;

	if (len < sizeof(mreq))
		goto fail;

	if (umove(tcp, addr, &mreq) < 0) {
		tprintf("%#lx", addr);
		return;
	}

#ifdef HAVE_INET_NTOP
	const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr;
	char address[INET6_ADDRSTRLEN];

	if (!inet_ntop(AF_INET6, in6, address, sizeof(address)))
		goto fail;

	tprints("{ipv6mr_multiaddr=inet_pton(");
	print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED);
	tprints("), ipv6mr_interface=");
	print_ifindex(mreq.ipv6mr_interface);
	tprints("}");
	return;
#endif /* HAVE_INET_NTOP */

fail:
	printstr(tcp, addr, len);
}
예제 #5
0
파일: ipc.c 프로젝트: Ale1ster/kerneldir
int sys_msgrcv(struct tcb *tcp)
{
	if (entering(tcp)) {
		tprintf("%d, ", (int) tcp->u_arg[0]);
	} else {
		if (indirect_ipccall(tcp)) {
			struct ipc_wrapper {
				struct msgbuf *msgp;
				long msgtyp;
			} tmp;

			if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
				tprintf("%#lx, %lu, ",
					tcp->u_arg[3], tcp->u_arg[1]);
			} else {
				tprint_msgrcv(tcp, (long) tmp.msgp,
					tcp->u_arg[1], tmp.msgtyp);
			}
			printflags(msg_flags, tcp->u_arg[2], "MSG_???");
		} else {
			tprint_msgrcv(tcp, tcp->u_arg[1],
				tcp->u_arg[2], tcp->u_arg[3]);
			printflags(msg_flags, tcp->u_arg[4], "MSG_???");
		}
	}
	return 0;
}
예제 #6
0
int
sys_epoll_ctl(struct tcb *tcp)
{
	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???");
		tprints(", ");
		printfd(tcp, tcp->u_arg[2]);
		tprints(", ");
		if (tcp->u_arg[3] == 0)
			tprints("NULL");
		else {
#ifdef HAVE_SYS_EPOLL_H
			struct epoll_event ev;
			if (
#ifdef EPOLL_CTL_DEL
			    (tcp->u_arg[1] != EPOLL_CTL_DEL) &&
#endif
			    umove(tcp, tcp->u_arg[3], &ev) == 0)
				print_epoll_event(&ev);
			else
#endif
				tprintf("%lx", tcp->u_arg[3]);
		}
	}
	return 0;
}
예제 #7
0
int
sys_sysinfo(struct tcb *tcp)
{
	struct sysinfo si;

	if (exiting(tcp)) {
		if (syserror(tcp) || !verbose(tcp))
			tprintf("%#lx", tcp->u_arg[0]);
		else if (umove(tcp, tcp->u_arg[0], &si) < 0)
			tprints("{...}");
		else {
			tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
				(long) si.uptime, (long) si.loads[0],
				(long) si.loads[1], (long) si.loads[2]);
			tprintf("totalram=%lu, freeram=%lu, ",
				(long) si.totalram, (long) si.freeram);
			tprintf("sharedram=%lu, bufferram=%lu} ",
				(long) si.sharedram, (long) si.bufferram);
			tprintf("totalswap=%lu, freeswap=%lu, procs=%u}",
				(long) si.totalswap, (long) si.freeswap,
				(unsigned)si.procs);
		}
	}
	return 0;
}
예제 #8
0
static int
do_sockname(struct tcb *tcp, int flags_arg)
{
	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		return 0;
	}

	int len;
	if (!tcp->u_arg[2] || !verbose(tcp) || syserror(tcp) ||
	    umove(tcp, tcp->u_arg[2], &len) < 0) {
		printaddr(tcp->u_arg[1]);
		tprints(", ");
		printaddr(tcp->u_arg[2]);
	} else {
		printsock(tcp, tcp->u_arg[1], len);
		tprintf(", [%d]", len);
	}

	if (flags_arg >= 0) {
		tprints(", ");
		printflags(sock_type_flags, tcp->u_arg[flags_arg],
			   "SOCK_???");
	}
	return 0;
}
예제 #9
0
파일: net.c 프로젝트: bigzz/strace_android
static int
do_pipe(struct tcb *tcp, int flags_arg)
{
    if (exiting(tcp)) {
        if (syserror(tcp)) {
            tprintf("%#lx", tcp->u_arg[0]);
        } else {
#ifdef HAVE_GETRVAL2
            if (flags_arg < 0) {
                tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
            } else
#endif
            {
                int fds[2];

                if (umove(tcp, tcp->u_arg[0], &fds) < 0)
                    tprintf("%#lx", tcp->u_arg[0]);
                else
                    tprintf("[%u, %u]", fds[0], fds[1]);
            }
        }
        if (flags_arg >= 0) {
            tprints(", ");
            printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
        }
    }
    return 0;
}
예제 #10
0
파일: ipc.c 프로젝트: max630/strace
int sys_shmat(struct tcb *tcp)
{
#ifdef LINUX
	unsigned long raddr;
#endif /* LINUX */

	if (exiting(tcp)) {
		tprintf("%lu", tcp->u_arg[0]);
		if (indirect_ipccall(tcp)) {
			tprintf(", %#lx", tcp->u_arg[3]);
			tprintf(", ");
			printflags(shm_flags, tcp->u_arg[1], "SHM_???");
		} else {
			tprintf(", %#lx", tcp->u_arg[1]);
			tprintf(", ");
			printflags(shm_flags, tcp->u_arg[2], "SHM_???");
		}
		if (syserror(tcp))
			return 0;
/* HPPA does not use an IPC multiplexer on Linux.  */
#if defined(LINUX) && !defined(HPPA)
		if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
			return RVAL_NONE;
		tcp->u_rval = raddr;
#endif /* LINUX */
		return RVAL_HEX;
	}
	return 0;
}
예제 #11
0
파일: ipc.c 프로젝트: Ale1ster/kerneldir
int
sys_mq_open(struct tcb *tcp)
{
	if (entering(tcp)) {
		printpath(tcp, tcp->u_arg[0]);
		tprints(", ");
		/* flags */
		tprint_open_modes(tcp->u_arg[1]);
		if (tcp->u_arg[1] & O_CREAT) {
# ifndef HAVE_MQUEUE_H
			tprintf(", %lx", tcp->u_arg[2]);
# else
			struct mq_attr attr;
			/* mode */
			tprintf(", %#lo, ", tcp->u_arg[2]);
			if (umove(tcp, tcp->u_arg[3], &attr) < 0)
				tprints("{ ??? }");
			else
				tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
					(long) attr.mq_maxmsg,
					(long) attr.mq_msgsize);
# endif
		}
	}
	return 0;
}
예제 #12
0
static int
do_accept(struct tcb *tcp, int flags_arg)
{
	if (entering(tcp)) {
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		return 0;
	}
	if (!tcp->u_arg[2])
		tprintf("%#lx, NULL", tcp->u_arg[1]);
	else {
		int len;
		if (tcp->u_arg[1] == 0 || syserror(tcp)
		    || umove(tcp, tcp->u_arg[2], &len) < 0) {
			tprintf("%#lx", tcp->u_arg[1]);
		} else {
			printsock(tcp, tcp->u_arg[1], len);
		}
		tprints(", ");
		printnum_int(tcp, tcp->u_arg[2], "%u");
	}
	if (flags_arg >= 0) {
		tprints(", ");
		printflags(sock_type_flags, tcp->u_arg[flags_arg],
			   "SOCK_???");
	}
	return 0;
}
예제 #13
0
파일: resource.c 프로젝트: geofft/strace
void
printrusage(struct tcb *tcp, long addr)
{
	struct rusage ru;

	if (!addr)
		tprints("NULL");
	else if (syserror(tcp) || !verbose(tcp))
		tprintf("%#lx", addr);
	else if (umove(tcp, addr, &ru) < 0)
		tprints("{...}");
	else if (!abbrev(tcp)) {
		tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
			(long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
			(long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
		tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
			ru.ru_maxrss, ru.ru_ixrss);
		tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
			ru.ru_idrss, ru.ru_isrss);
		tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
			ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
		tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
			ru.ru_inblock, ru.ru_oublock);
		tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
			ru.ru_msgsnd, ru.ru_msgrcv);
		tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
			ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
	}
	else {
		tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
			(long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
			(long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
	}
}
예제 #14
0
static void
print_sg_io_v4_res(struct tcb *tcp, const long arg)
{
	struct sg_io_v4 sg_io;
	uint32_t din_len;

	if (umove(tcp, arg, &sg_io) < 0) {
		tprints(", ???");
		return;
	}

	tprintf(", response[%u]=", sg_io.response_len);
	print_sg_io_buffer(tcp, sg_io.response, sg_io.response_len);
	din_len = sg_io.din_xfer_len;
	if (sg_io.din_resid > 0)
		din_len -= sg_io.din_resid;
	tprintf(", din[%u]=", din_len);
	if (sg_io.din_iovec_count)
		tprint_iov_upto(tcp, sg_io.din_iovec_count, sg_io.din_xferp,
				1, din_len);
	else
		print_sg_io_buffer(tcp, sg_io.din_xferp, din_len);
	tprintf(", driver_status=%u", sg_io.driver_status);
	tprintf(", transport_status=%u", sg_io.transport_status);
	tprintf(", device_status=%u", sg_io.device_status);
	tprintf(", retry_delay=%u", sg_io.retry_delay);
	tprintf(", info=%u", sg_io.info);
	tprintf(", duration=%u", sg_io.duration);
	tprintf(", response_len=%u", sg_io.response_len);
	tprintf(", din_resid=%u", sg_io.din_resid);
	tprintf(", dout_resid=%u", sg_io.dout_resid);
	tprintf(", generated_tag=%llu", (unsigned long long) sg_io.generated_tag);
	tprintf(", spare_out=%u", sg_io.spare_out);
}
예제 #15
0
파일: statfs.c 프로젝트: MoroJr/strace
static void
printstatfs64(struct tcb *tcp, long addr)
{
	struct statfs64 statbuf;

	if (syserror(tcp) || !verbose(tcp)) {
		tprintf("%#lx", addr);
		return;
	}
	if (umove(tcp, addr, &statbuf) < 0) {
		tprints("{...}");
		return;
	}
	tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
		sprintfstype(statbuf.f_type),
		(unsigned long long)statbuf.f_bsize,
		(unsigned long long)statbuf.f_blocks,
		(unsigned long long)statbuf.f_bfree);
	tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
		(unsigned long long)statbuf.f_bavail,
		(unsigned long long)statbuf.f_files,
		(unsigned long long)statbuf.f_ffree,
		statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
	tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
#ifdef _STATFS_F_FRSIZE
	tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
#endif
#ifdef _STATFS_F_FLAGS
	tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
#endif
	tprints("}");
}
예제 #16
0
static int
print_sg_io_v3_req(struct tcb *tcp, const long arg)
{
	struct sg_io_hdr sg_io;

	if (umove(tcp, arg, &sg_io) < 0) {
		tprints("???}");
		return RVAL_DECODED | 1;
	}

	printxval(sg_io_dxfer_direction, sg_io.dxfer_direction,
		  "SG_DXFER_???");
	tprintf(", cmd[%u]=", sg_io.cmd_len);
	print_sg_io_buffer(tcp, (unsigned long) sg_io.cmdp, sg_io.cmd_len);
	tprintf(", mx_sb_len=%d", sg_io.mx_sb_len);
	tprintf(", iovec_count=%d", sg_io.iovec_count);
	tprintf(", dxfer_len=%u", sg_io.dxfer_len);
	tprintf(", timeout=%u", sg_io.timeout);
	tprintf(", flags=%#x", sg_io.flags);

	if (sg_io.dxfer_direction == SG_DXFER_TO_DEV ||
	    sg_io.dxfer_direction == SG_DXFER_TO_FROM_DEV) {
		tprintf(", data[%u]=", sg_io.dxfer_len);
		if (sg_io.iovec_count)
			tprint_iov_upto(tcp, sg_io.iovec_count,
					(unsigned long) sg_io.dxferp, 1,
					sg_io.dxfer_len);
		else
			print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp,
					   sg_io.dxfer_len);
	}
	return 1;
}
예제 #17
0
static bool
extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg)
{
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
	if (current_wordsize == 4) {
		struct msghdr32 msg32;

		if (umove(tcp, addr, &msg32) < 0)
			return false;
		copy_from_msghdr32(msg, &msg32);
	} else
#endif
	if (umove(tcp, addr, msg) < 0)
		return false;
	return true;
}
예제 #18
0
static void
print_sg_io_v3_res(struct tcb *tcp, const long arg)
{
	struct sg_io_hdr sg_io;

	if (umove(tcp, arg, &sg_io) < 0) {
		tprints(", ???");
		return;
	}

	if (sg_io.dxfer_direction == SG_DXFER_FROM_DEV ||
	    sg_io.dxfer_direction == SG_DXFER_TO_FROM_DEV) {
		uint32_t din_len = sg_io.dxfer_len;

		if (sg_io.resid > 0)
			din_len -= sg_io.resid;
		tprintf(", data[%u]=", din_len);
		if (sg_io.iovec_count)
			tprint_iov_upto(tcp, sg_io.iovec_count,
					(unsigned long) sg_io.dxferp, 1,
					din_len);
		else
			print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp,
					   din_len);
	}
	tprintf(", status=%02x", sg_io.status);
	tprintf(", masked_status=%02x", sg_io.masked_status);
	tprintf(", sb[%u]=", sg_io.sb_len_wr);
	print_sg_io_buffer(tcp, (unsigned long) sg_io.sbp, sg_io.sb_len_wr);
	tprintf(", host_status=%#x", sg_io.host_status);
	tprintf(", driver_status=%#x", sg_io.driver_status);
	tprintf(", resid=%d", sg_io.resid);
	tprintf(", duration=%d", sg_io.duration);
	tprintf(", info=%#x", sg_io.info);
}
예제 #19
0
static void
decode_fprog(struct tcb *tcp, unsigned short len, unsigned long addr)
{
	if (!len || abbrev(tcp)) {
		tprintf("{len = %u, filter = ", len);
		printaddr(addr);
		tprints("}");
	} else {
		unsigned int i = 0;

		tprints("[");
		while (i < len && i < BPF_MAXINSNS) {
			struct bpf_filter filter;

			if (umove(tcp, addr, &filter) < 0)
				break;
			if (i)
				tprints(", ");
			decode_filter(&filter);

			addr += sizeof(filter);
			++i;
		}
		if (i < len)
			tprints("...");
		tprints("]");
	}
}
예제 #20
0
파일: ldt.c 프로젝트: geofft/strace
void
print_user_desc(struct tcb *tcp, long addr)
{
	struct user_desc desc;

	if (umove(tcp, addr, &desc) < 0) {
		tprintf("%lx", addr);
		return;
	}

	if (!verbose(tcp)) {
		tprintf("{entry_number:%d, ...}", desc.entry_number);
		return;
	}

	tprintf("{entry_number:%d, "
		"base_addr:%#08x, "
		"limit:%d, "
		"seg_32bit:%d, "
		"contents:%d, "
		"read_exec_only:%d, "
		"limit_in_pages:%d, "
		"seg_not_present:%d, "
		"useable:%d}",
		desc.entry_number,
		desc.base_addr,
		desc.limit,
		desc.seg_32bit,
		desc.contents,
		desc.read_exec_only,
		desc.limit_in_pages,
		desc.seg_not_present,
		desc.useable);
}
예제 #21
0
파일: net.c 프로젝트: yunchih/strace
static bool
fetch_socklen(struct tcb *tcp, int *plen,
	      const unsigned long sockaddr, const unsigned long socklen)
{
	return verbose(tcp) && sockaddr && socklen
	       && umove(tcp, socklen, plen) == 0;
}
예제 #22
0
파일: time.c 프로젝트: michaelhood/strace
static void
printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
{
	if (addr == 0)
		tprints("NULL");
	else if (!verbose(tcp))
		tprintf("%#lx", addr);
	else {
		int rc;

		if (bitness == BITNESS_32
#if SUPPORTED_PERSONALITIES > 1
		    || current_wordsize == 4
#endif
			)
		{
			struct {
				struct timeval32 it_interval, it_value;
			} itv;

			rc = umove(tcp, addr, &itv);
			if (rc >= 0) {
				tprints("{it_interval=");
				tprint_timeval32(tcp, &itv.it_interval);
				tprints(", it_value=");
				tprint_timeval32(tcp, &itv.it_value);
				tprints("}");
			}
		} else {
			struct itimerval itv;

			rc = umove(tcp, addr, &itv);
			if (rc >= 0) {
				tprints("{it_interval=");
				tprint_timeval(tcp, &itv.it_interval);
				tprints(", it_value=");
				tprint_timeval(tcp, &itv.it_value);
				tprints("}");
			}
		}
		if (rc < 0)
			tprints("{...}");
	}
}
예제 #23
0
파일: uid.c 프로젝트: MoroJr/strace
static void
get_print_uid(struct tcb *tcp, const char *prefix, const long addr)
{
	uid_t uid;

	if (umove(tcp, addr, &uid) < 0)
		tprintf("%s%#lx", prefix, addr);
	else
		tprintf("%s[%u]", prefix, uid);
}
예제 #24
0
파일: resource.c 프로젝트: geofft/strace
void
printrusage32(struct tcb *tcp, long addr)
{
	struct timeval32 {
		unsigned tv_sec;
		unsigned tv_usec;
	};
	struct rusage32 {
		struct timeval32 ru_utime;	/* user time used */
		struct timeval32 ru_stime;	/* system time used */
		long	ru_maxrss;		/* maximum resident set size */
		long	ru_ixrss;		/* integral shared memory size */
		long	ru_idrss;		/* integral unshared data size */
		long	ru_isrss;		/* integral unshared stack size */
		long	ru_minflt;		/* page reclaims */
		long	ru_majflt;		/* page faults */
		long	ru_nswap;		/* swaps */
		long	ru_inblock;		/* block input operations */
		long	ru_oublock;		/* block output operations */
		long	ru_msgsnd;		/* messages sent */
		long	ru_msgrcv;		/* messages received */
		long	ru_nsignals;		/* signals received */
		long	ru_nvcsw;		/* voluntary context switches */
		long	ru_nivcsw;		/* involuntary " */
	} ru;

	if (!addr)
		tprints("NULL");
	else if (syserror(tcp) || !verbose(tcp))
		tprintf("%#lx", addr);
	else if (umove(tcp, addr, &ru) < 0)
		tprints("{...}");
	else if (!abbrev(tcp)) {
		tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
			(long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
			(long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
		tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
			ru.ru_maxrss, ru.ru_ixrss);
		tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
			ru.ru_idrss, ru.ru_isrss);
		tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
			ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
		tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
			ru.ru_inblock, ru.ru_oublock);
		tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
			ru.ru_msgsnd, ru.ru_msgrcv);
		tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
			ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
	}
	else {
		tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
			(long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
			(long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
	}
}
예제 #25
0
파일: execve.c 프로젝트: geofft/strace
static void
printargc(const char *fmt, struct tcb *tcp, long addr)
{
	int count;
	char *cp;

	for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
		addr += sizeof(char *);
	}
	tprintf(fmt, count, count == 1 ? "" : "s");
}
예제 #26
0
int
sys_io_submit(struct tcb *tcp)
{
	long nr;
	if (entering(tcp)) {
		tprintf("%lu, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
		nr = tcp->u_arg[1];
		/* and if nr is negative? */
		if (nr == 0)
			tprintf("{}");
		else {
#ifdef HAVE_LIBAIO_H
			long i;
			struct iocb *iocbp, **iocbs = (void *)tcp->u_arg[2];

			for (i = 0; i < nr; i++, iocbs++) {
				struct iocb iocb;
				if (i == 0)
					tprintf("{");
				else
					tprintf(", ");

				if (umove(tcp, (unsigned long)iocbs, &iocbp) ||
				    umove(tcp, (unsigned long)iocbp, &iocb)) {
					tprintf("{...}");
					continue;
				}
				tprintf("{%p, %u, %hu, %hu, %d}",
					iocb.data, iocb.key,
					iocb.aio_lio_opcode,
					iocb.aio_reqprio, iocb.aio_fildes);
			}
			if (i)
				tprintf("}");
#else
			tprintf("{...}");
#endif
		}
	}
	return 0;
}
예제 #27
0
파일: io.c 프로젝트: effaremment/alice
void
print_loff_t(struct tcb *tcp, long addr)
{
	loff_t offset;

	if (!addr)
		tprints("NULL");
	else if (umove(tcp, addr, &offset) < 0)
		tprintf("%#lx", addr);
	else
		tprintf("[%llu]", (unsigned long long int) offset);
}
예제 #28
0
파일: signal.c 프로젝트: GeoffGats/strace
int
sys_sigaction(struct tcb *tcp)
{
	long addr;
	sigset_t sigset;
	struct old_sigaction sa;

	if (entering(tcp)) {
		printsignal(tcp->u_arg[0]);
		tprints(", ");
		addr = tcp->u_arg[1];
	} else
		addr = tcp->u_arg[2];
	if (addr == 0)
		tprints("NULL");
	else if (!verbose(tcp))
		tprintf("%#lx", addr);
	else if (umove(tcp, addr, &sa) < 0)
		tprints("{...}");
	else {
		/* Architectures using function pointers, like
		 * hppa, may need to manipulate the function pointer
		 * to compute the result of a comparison. However,
		 * the __sa_handler function pointer exists only in
		 * the address space of the traced process, and can't
		 * be manipulated by strace. In order to prevent the
		 * compiler from generating code to manipulate
		 * __sa_handler we cast the function pointers to long. */
		if ((long)sa.__sa_handler == (long)SIG_ERR)
			tprints("{SIG_ERR, ");
		else if ((long)sa.__sa_handler == (long)SIG_DFL)
			tprints("{SIG_DFL, ");
		else if ((long)sa.__sa_handler == (long)SIG_IGN)
			tprints("{SIG_IGN, ");
		else
			tprintf("{%#lx, ", (long) sa.__sa_handler);
		long_to_sigset(sa.sa_mask, &sigset);
		printsigmask(&sigset, 0);
		tprints(", ");
		printflags(sigact_flags, sa.sa_flags, "SA_???");
#ifdef SA_RESTORER
		if (sa.sa_flags & SA_RESTORER)
			tprintf(", %p", sa.sa_restorer);
#endif
		tprints("}");
	}
	if (entering(tcp))
		tprints(", ");
	else
		tprintf(", %#lx", (unsigned long) sa.sa_restorer);
	return 0;
}
예제 #29
0
static bool
extractmmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg)
{
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
	if (current_wordsize == 4) {
		struct mmsghdr32 mmsg32;

		addr += sizeof(struct mmsghdr32) * idx;
		if (umove(tcp, addr, &mmsg32) < 0)
			return false;

		copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr);
		mmsg->msg_len = mmsg32.msg_len;
	} else
#endif
	{
		addr += sizeof(*mmsg) * idx;
		if (umove(tcp, addr, mmsg) < 0)
			return false;
	}
	return true;
}
예제 #30
0
static cap_user_header_t
get_cap_header(struct tcb *tcp, unsigned long addr)
{
	static struct user_cap_header_struct header;

	if (!addr || !verbose(tcp))
		return NULL;

	if (umove(tcp, addr, &header) < 0)
		return NULL;

	return &header;
}