| 1 |
#! /usr/bin/env stap |
| 2 |
# |
| 3 |
# Copyright (C) 2021 Red Hat, Inc. |
| 4 |
# Written by Nir Soffer <[email protected]> |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License version 2 as |
| 8 |
# published by the Free Software Foundation. |
| 9 |
# |
| 10 |
|
| 11 |
@define IOCB_CMD_PREADV %( 7 %) |
| 12 |
@define IOCB_CMD_PWRITEV %( 8 %) |
| 13 |
|
| 14 |
probe begin { |
| 15 |
println("Tracing started"); |
| 16 |
} |
| 17 |
|
| 18 |
probe syscall.io_submit |
| 19 |
{ |
| 20 |
if (pid() == target()) { |
| 21 |
printf("[%s] io_submit(%s)\n", thread_indent(0), argstr); |
| 22 |
|
| 23 |
for (i = 0; i < nr; i++) { |
| 24 |
iocbp = user_uint64(iocbpp_uaddr + i * 8) |
| 25 |
fd = user_uint32(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_fildes) |
| 26 |
opcode = user_uint16(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_lio_opcode) |
| 27 |
offset = user_int64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_offset) |
| 28 |
nbytes = user_uint64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_nbytes) |
| 29 |
buf = user_uint64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_buf) |
| 30 |
printf(" iocb[%4d]=%p, fd=%d, opcode=%d, offset=%d, nbytes=%d, buf=%p\n", |
| 31 |
i, iocbp, fd, opcode, offset, nbytes, buf) |
| 32 |
|
| 33 |
if (opcode == @IOCB_CMD_PREADV || opcode == @IOCB_CMD_PWRITEV) { |
| 34 |
for (j = 0; j < nbytes; j++) { |
| 35 |
iovecp = &@cast(buf, "iovec", "kernel<linux/uio.h>")[j] |
| 36 |
base = user_uint64(&@cast(iovecp, "iovec", "kernel<linux/uio.h>")->iov_base) |
| 37 |
len = user_uint32(&@cast(iovecp, "iovec", "kernel<linux/uio.h>")->iov_len) |
| 38 |
printf(" iovec[%4d]=%p, base=%p, len=%d\n", |
| 39 |
j, iovecp, base, len) |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
probe end { |
| 47 |
println("Tracing stopped"); |
| 48 |
} |