File: traceaio.stp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (48 lines) | stat: -rwxr-xr-x 1,830 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env stap
#
# Copyright (C) 2021 Red Hat, Inc.
# Written by Nir Soffer <nsoffer@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#

@define IOCB_CMD_PREADV   %( 7 %)
@define IOCB_CMD_PWRITEV  %( 8 %)

probe begin {
    println("Tracing started");
}

probe syscall.io_submit
{
    if (pid() == target()) {
        printf("[%s] io_submit(%s)\n", thread_indent(0), argstr);

        for (i = 0; i < nr; i++) {
            iocbp = user_uint64(iocbpp_uaddr + i * 8)
            fd = user_uint32(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_fildes)
            opcode = user_uint16(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_lio_opcode)
            offset = user_int64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_offset)
            nbytes = user_uint64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_nbytes)
            buf = user_uint64(&@cast(iocbp, "iocb", "kernel<linux/aio.h>")->aio_buf)
            printf("    iocb[%4d]=%p, fd=%d, opcode=%d, offset=%d, nbytes=%d, buf=%p\n",
                   i, iocbp, fd, opcode, offset, nbytes, buf)

            if (opcode == @IOCB_CMD_PREADV || opcode == @IOCB_CMD_PWRITEV) {
                for (j = 0; j < nbytes; j++) {
                    iovecp = &@cast(buf, "iovec", "kernel<linux/uio.h>")[j]
                    base = user_uint64(&@cast(iovecp, "iovec", "kernel<linux/uio.h>")->iov_base)
                    len = user_uint32(&@cast(iovecp, "iovec", "kernel<linux/uio.h>")->iov_len)
                    printf("        iovec[%4d]=%p, base=%p, len=%d\n",
                           j, iovecp, base, len)
                }
            }
        }
    }
}

probe end {
    println("Tracing stopped");
}