This commit introduces a new type iov_decoder which will be used instead of as a decoder parameter.
* defs.h (iov_decoder): New enum. (tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decoder. * aio.c (print_iocb): Change type of "decode_iov" to enum iov_decoder in tprint_iov() call. * keyctl.c (keyctl_instantiate_key_iov): Likewise. * process.c (ptrace): Likewise. * process_vm.c (process_vm_readv, process_vm_writev): Likewise. * io.c (writev, do_pwritev, vmsplice): Likewise. (print_iovec): Replace the condition with a switch. (tprint_iov_upto): Change type of "decode_iov" to enum iov_decoder. (readv, do_preadv): Change type of "decode_iov" to enum iov_decoder in tprint_iov_upto() call. * scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req, print_sg_io_v4_res): Likewise. --- aio.c | 4 +++- defs.h | 10 ++++++++-- io.c | 40 ++++++++++++++++++++++++---------------- keyctl.c | 2 +- net.c | 3 ++- process.c | 6 ++++-- process_vm.c | 10 ++++++---- scsi.c | 10 ++++++---- 8 files changed, 54 insertions(+), 31 deletions(-) diff --git a/aio.c b/aio.c index e02af7d..83a29fc 100644 --- a/aio.c +++ b/aio.c @@ -140,7 +140,9 @@ print_iocb(struct tcb *tcp, const struct iocb *cb) if (iocb_is_valid(cb)) { tprints(", iovec="); tprint_iov(tcp, cb->aio_nbytes, cb->aio_buf, - cb->aio_lio_opcode == 8); + cb->aio_lio_opcode == 8 + ? IOV_DECODER_STR + : IOV_DECODER_ADDR); } else { tprintf(", buf=%#" PRIx64 ", nbytes=%" PRIu64, (uint64_t) cb->aio_buf, diff --git a/defs.h b/defs.h index 311fccd..a86c78c 100644 --- a/defs.h +++ b/defs.h @@ -442,6 +442,11 @@ enum sock_proto { }; extern enum sock_proto get_proto_by_name(const char *); +enum iov_decoder { + IOV_DECODER_ADDR, + IOV_DECODER_STR +}; + typedef enum { CFLAG_NONE = 0, CFLAG_ONLY_STATS, @@ -659,8 +664,9 @@ extern const char *sprintsigmask_n(const char *, const void *, unsigned int); #define tprintsigmask_addr(prefix, mask) \ tprints(sprintsigmask_n((prefix), (mask), sizeof(mask))) extern void printsignal(int); -extern void tprint_iov(struct tcb *, unsigned long, unsigned long, int decode_iov); -extern void tprint_iov_upto(struct tcb *, unsigned long, unsigned long, int decode_iov, unsigned long); +extern void tprint_iov(struct tcb *, unsigned long, unsigned long, enum iov_decoder); +extern void tprint_iov_upto(struct tcb *, unsigned long, unsigned long, + enum iov_decoder, unsigned long); extern void tprint_open_modes(unsigned int); extern const char *sprint_open_modes(unsigned int); extern void print_seccomp_filter(struct tcb *, unsigned long); diff --git a/io.c b/io.c index 87b5f47..ad92d84 100644 --- a/io.c +++ b/io.c @@ -79,14 +79,21 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) tprints("{"); - if (c->decode_iov) { - unsigned long len = iov[1]; - if (len > c->data_size) - len = c->data_size; - c->data_size -= len; - printstr(tcp, iov[0], len); - } else { - printaddr(iov[0]); + switch (c->decode_iov) { + case IOV_DECODER_STR: + { + unsigned long len = iov[1]; + if (len > c->data_size) + len = c->data_size; + c->data_size -= len; + printstr(tcp, iov[0], len); + break; + } + default: + { + printaddr(iov[0]); + break; + } } tprintf(", %lu}", iov[1]); @@ -100,7 +107,7 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) */ void tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, - int decode_iov, unsigned long data_size) + enum iov_decoder decode_iov, unsigned long data_size) { unsigned long iov[2]; struct print_iovec_config config = @@ -111,7 +118,8 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, } void -tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, int decode_iov) +tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, + enum iov_decoder decode_iov) { tprint_iov_upto(tcp, len, addr, decode_iov, (unsigned long) -1L); } @@ -122,8 +130,8 @@ SYS_FUNC(readv) printfd(tcp, tcp->u_arg[0]); tprints(", "); } else { - tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], 1, - tcp->u_rval); + tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], + IOV_DECODER_STR, tcp->u_rval); tprintf(", %lu", tcp->u_arg[2]); } return 0; @@ -133,7 +141,7 @@ SYS_FUNC(writev) { printfd(tcp, tcp->u_arg[0]); tprints(", "); - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); + tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODER_STR); tprintf(", %lu", tcp->u_arg[2]); return RVAL_DECODED; @@ -216,7 +224,7 @@ do_preadv(struct tcb *tcp, const int flags_arg) printfd(tcp, tcp->u_arg[0]); tprints(", "); } else { - tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], 1, + tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODER_STR, tcp->u_rval); tprintf(", %lu, ", tcp->u_arg[2]); print_lld_from_low_high_val(tcp, 3); @@ -243,7 +251,7 @@ do_pwritev(struct tcb *tcp, const int flags_arg) { printfd(tcp, tcp->u_arg[0]); tprints(", "); - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); + tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODER_STR); tprintf(", %lu, ", tcp->u_arg[2]); print_lld_from_low_high_val(tcp, 3); if (flags_arg >= 0) { @@ -310,7 +318,7 @@ SYS_FUNC(vmsplice) printfd(tcp, tcp->u_arg[0]); tprints(", "); /* const struct iovec *iov, unsigned long nr_segs */ - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); + tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODER_STR); tprintf(", %lu, ", tcp->u_arg[2]); /* unsigned int flags */ printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???"); diff --git a/keyctl.c b/keyctl.c index 50d6fb4..a75734c 100644 --- a/keyctl.c +++ b/keyctl.c @@ -156,7 +156,7 @@ keyctl_instantiate_key_iov(struct tcb *tcp, key_serial_t id1, { print_keyring_serial_number(id1); tprints(", "); - tprint_iov(tcp, len, addr, 1); + tprint_iov(tcp, len, addr, IOV_DECODER_STR); tprintf(", %lu, ", len); print_keyring_serial_number(id2); } diff --git a/net.c b/net.c index 124ac8d..e088477 100644 --- a/net.c +++ b/net.c @@ -580,8 +580,9 @@ do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size) printsock(tcp, (long)msg->msg_name, msg->msg_namelen); tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen); + tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen, - (unsigned long)msg->msg_iov, 1, data_size); + (unsigned long)msg->msg_iov, IOV_DECODER_STR, data_size); #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen); diff --git a/process.c b/process.c index 3aecf08..6702518 100644 --- a/process.c +++ b/process.c @@ -201,7 +201,8 @@ SYS_FUNC(ptrace) print_sigset_addr_len(tcp, data, addr); break; case PTRACE_SETREGSET: - tprint_iov(tcp, /*len:*/ 1, data, /*as string:*/ 0); + tprint_iov(tcp, /*len:*/ 1, data, + /*as string:*/ IOV_DECODER_ADDR); break; #ifndef IA64 case PTRACE_PEEKDATA: @@ -238,7 +239,8 @@ SYS_FUNC(ptrace) printnum_ulong(tcp, data); break; case PTRACE_GETREGSET: - tprint_iov(tcp, /*len:*/ 1, data, /*as string:*/ 0); + tprint_iov(tcp, /*len:*/ 1, data, + /*as string:*/ IOV_DECODER_ADDR); break; case PTRACE_GETSIGINFO: printsiginfo_at(tcp, data); diff --git a/process_vm.c b/process_vm.c index 82e1e16..bbbd850 100644 --- a/process_vm.c +++ b/process_vm.c @@ -38,7 +38,8 @@ SYS_FUNC(process_vm_readv) if (syserror(tcp)) { printaddr(tcp->u_arg[1]); } else { - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); + tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], + IOV_DECODER_STR); } /* arg 3: local iovcnt */ tprintf(", %lu, ", tcp->u_arg[2]); @@ -46,7 +47,8 @@ SYS_FUNC(process_vm_readv) if (syserror(tcp)) { printaddr(tcp->u_arg[3]); } else { - tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0); + tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], + IOV_DECODER_ADDR); } /* arg 5: remote iovcnt */ /* arg 6: flags */ @@ -60,11 +62,11 @@ SYS_FUNC(process_vm_writev) /* arg 1: pid */ tprintf("%ld, ", tcp->u_arg[0]); /* arg 2: local iov */ - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); + tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODER_STR); /* arg 3: local iovcnt */ tprintf(", %lu, ", tcp->u_arg[2]); /* arg 4: remote iov */ - tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0); + tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], IOV_DECODER_ADDR); /* arg 5: remote iovcnt */ /* arg 6: flags */ tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]); diff --git a/scsi.c b/scsi.c index 83ff8fe..6c02ca3 100644 --- a/scsi.c +++ b/scsi.c @@ -84,7 +84,8 @@ print_sg_io_v3_req(struct tcb *tcp, const long arg) 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, + (unsigned long) sg_io.dxferp, + IOV_DECODER_STR, sg_io.dxfer_len); else print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp, @@ -112,7 +113,8 @@ print_sg_io_v3_res(struct tcb *tcp, const long arg) tprintf(", data[%u]=", din_len); if (sg_io.iovec_count) tprint_iov_upto(tcp, sg_io.iovec_count, - (unsigned long) sg_io.dxferp, 1, + (unsigned long) sg_io.dxferp, + IOV_DECODER_STR, din_len); else print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp, @@ -163,7 +165,7 @@ print_sg_io_v4_req(struct tcb *tcp, const long arg) tprintf(", dout[%u]=", sg_io.dout_xfer_len); if (sg_io.dout_iovec_count) tprint_iov_upto(tcp, sg_io.dout_iovec_count, sg_io.dout_xferp, - 1, sg_io.dout_xfer_len); + IOV_DECODER_STR, sg_io.dout_xfer_len); else print_sg_io_buffer(tcp, sg_io.dout_xferp, sg_io.dout_xfer_len); return 1; @@ -188,7 +190,7 @@ print_sg_io_v4_res(struct tcb *tcp, const long arg) 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); + IOV_DECODER_STR, din_len); else print_sg_io_buffer(tcp, sg_io.din_xferp, din_len); tprintf(", driver_status=%u", sg_io.driver_status); -- 2.8.3 ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohomanageengine _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel