[BACK]Return to mksubr CVS log [TXT][DIR] Up to [local] / src / usr.bin / kdump

Annotation of src/usr.bin/kdump/mksubr, Revision 1.32

1.1       otto        1: #!/bin/sh
1.32    ! mpi         2: # $OpenBSD: mksubr,v 1.31 2016/06/07 06:12:37 deraadt Exp $
1.1       otto        3: #
                      4: # Copyright (c) 2006 David Kirchner <dpk@dpk.net>
                      5: #
                      6: # Permission to use, copy, modify, and distribute this software for any
                      7: # purpose with or without fee is hereby granted, provided that the above
                      8: # copyright notice and this permission notice appear in all copies.
                      9: #
                     10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17: #
                     18: # $FreeBSD: src/usr.bin/kdump/mksubr,v 1.17 2011/06/06 19:00:38 dchagin Exp $
                     19: #
                     20: # Generates kdump_subr.c
                     21: # mkioctls is a special-purpose script, and works fine as it is
                     22: # now, so it remains independent. The idea behind how it generates
                     23: # its list was heavily borrowed here.
                     24: #
                     25: # Some functions here are automatically generated. This can mean
                     26: # the user will see unusual kdump output or errors while building
                     27: # if the underlying .h files are changed significantly.
                     28: #
                     29: # Key:
                     30: # AUTO: Completely auto-generated with either the "or" or the "switch"
                     31: # method.
                     32: # AUTO - Special: Generated automatically, but with some extra commands
                     33: # that the auto_*_type() functions are inappropriate for.
                     34: # MANUAL: Manually entered and must therefore be manually updated.
                     35:
                     36: set -e
                     37:
                     38: LC_ALL=C; export LC_ALL
                     39:
                     40: if [ -z "$1" ]
                     41: then
                     42:        echo "usage: sh $0 include-dir"
                     43:        exit 1
                     44: fi
                     45: include_dir=$1
                     46:
                     47: #
                     48: # Automatically generates a C function that will print out the
                     49: # numeric input as a pipe-delimited string of the appropriate
                     50: # #define keys. ex:
1.12      guenther   51: # 0x1a4<S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH>
1.1       otto       52: # The XOR is necessary to prevent including the "0"-value in every
                     53: # line.
                     54: #
                     55: auto_or_type () {
                     56:        local name grep file
                     57:        name=$1
                     58:        grep=$2
                     59:        file=$3
1.21      guenther   60:        format=${4-%#x}
1.1       otto       61:
                     62:        cat <<_EOF_
                     63: /* AUTO */
                     64: void
                     65: $name (int arg)
                     66: {
                     67:        int     or = 0;
1.21      guenther   68:        printf("$format<", arg);
1.1       otto       69: _EOF_
                     70:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                     71:                $include_dir/$file | \
                     72:        awk '{ for (i = 1; i <= NF; i++) \
                     73:                if ($i ~ /define/) \
                     74:                        break; \
                     75:                ++i; \
                     76:                printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
                     77: cat <<_EOF_
                     78:        printf(">");
                     79:        if (or == 0)
1.24      guenther   80:                (void)printf("<invalid>%d", arg);
1.1       otto       81: }
                     82:
                     83: _EOF_
                     84: }
                     85:
                     86: #
1.8       guenther   87: # Like auto_or_type(), but a zero value is valid and prints as "0<>"
                     88: #
                     89: auto_orz_type () {
                     90:        local name grep file
                     91:        name=$1
                     92:        grep=$2
                     93:        file=$3
1.21      guenther   94:        format=${4-%#x}
1.8       guenther   95:
                     96:        cat <<_EOF_
                     97: /* AUTO */
                     98: void
                     99: $name (int arg)
                    100: {
                    101:        int     or = 0;
                    102:        if (arg == 0) {
                    103:                printf("0<>");
                    104:                return;
                    105:        }
1.21      guenther  106:        printf("$format<", arg);
1.8       guenther  107: _EOF_
                    108:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    109:                $include_dir/$file | \
                    110:        awk '{ for (i = 1; i <= NF; i++) \
                    111:                if ($i ~ /define/) \
                    112:                        break; \
                    113:                ++i; \
                    114:                printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
                    115: cat <<_EOF_
                    116:        printf(">");
                    117:        if (or == 0)
1.24      guenther  118:                (void)printf("<invalid>%d", arg);
1.8       guenther  119: }
                    120:
                    121: _EOF_
                    122: }
                    123:
                    124: #
1.12      guenther  125: # Automatically generates a C function that will print out a
                    126: # file flags input as a pipe-delimited string of the appropriate
                    127: # #define keys. ex:
                    128: # 0x30000<O_RDONLY|O_CLOEXEC|O_DIRECTORY>
                    129: # This is different than the others to handle O_RDONLY correctly when
                    130: # other flags are present and to diagnose an invalid O_ACCMODE value
                    131: #
                    132: auto_fflags_type () {
                    133:        local name grep file
                    134:        name=$1
                    135:        grep=$2
                    136:        file=$3
                    137:
                    138:        cat <<_EOF_
                    139: /* AUTO */
                    140: void
1.22      guenther  141: $name (int arg, int show_accmode)
1.12      guenther  142: {
1.22      guenther  143:        int     or = 0;
                    144:
1.12      guenther  145:        printf("%#x<", arg);
1.22      guenther  146:        if (show_accmode || (arg & O_ACCMODE)) {
                    147:                or = 1;
                    148:                switch (arg & O_ACCMODE) {
                    149:                case O_RDONLY:
                    150:                        printf("O_RDONLY");
                    151:                        break;
                    152:                case O_WRONLY:
                    153:                        printf("O_WRONLY");
                    154:                        break;
                    155:                case O_RDWR:
                    156:                        printf("O_RDWR");
                    157:                        break;
                    158:                default:
                    159:                        printf("<invalid>O_ACCMODE");
                    160:                        break;
                    161:                }
1.12      guenther  162:        }
                    163: _EOF_
                    164:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    165:                $include_dir/$file | \
                    166:        egrep -v 'O_(RD(ONLY|WR)|WRONLY|ACCMODE)' | \
                    167:        awk '{ for (i = 1; i <= NF; i++) \
                    168:                if ($i ~ /define/) \
                    169:                        break; \
                    170:                ++i; \
1.22      guenther  171:                printf "\tif_print_or(arg, %s, or);\n", $i }'
1.12      guenther  172: cat <<_EOF_
                    173:        printf(">");
                    174: }
                    175:
1.22      guenther  176: /*
1.24      guenther  177:  * Wrappers of the above to use with pn()
1.22      guenther  178:  */
                    179: void
                    180: flagsname(int flags)
                    181: {
                    182:        doflagsname(flags, 0);
                    183: }
                    184:
1.24      guenther  185: void
                    186: openflagsname(int flags)
                    187: {
                    188:        doflagsname(flags, 1);
                    189: }
                    190:
1.22      guenther  191:
1.12      guenther  192: _EOF_
                    193: }
                    194:
                    195:
                    196: #
1.1       otto      197: # Automatically generates a C function used when the argument
                    198: # maps to a single, specific #definition
                    199: #
                    200: auto_switch_type () {
                    201:        local name grep file
                    202:        name=$1
                    203:        grep=$2
                    204:        file=$3
                    205:
                    206:        cat <<_EOF_
                    207: /* AUTO */
                    208: void
                    209: $name (int arg)
                    210: {
                    211:        switch (arg) {
                    212: _EOF_
                    213:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    214:                $include_dir/$file | \
                    215:        awk '{ for (i = 1; i <= NF; i++) \
                    216:                if ($i ~ /define/) \
                    217:                        break; \
                    218:                ++i; \
                    219:                printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }'
                    220: cat <<_EOF_
                    221:        default: /* Should not reach */
1.24      guenther  222:                (void)printf("<invalid=%d>", arg);
1.1       otto      223:        }
                    224: }
                    225:
                    226: _EOF_
                    227: }
                    228:
                    229: #
                    230: # Automatically generates a C function used when the argument
                    231: # maps to a #definition
                    232: #
                    233: auto_if_type () {
                    234:        local name grep file
                    235:        name=$1
                    236:        grep=$2
                    237:        file=$3
                    238:
                    239:        cat <<_EOF_
                    240: /* AUTO */
                    241: void
                    242: $name (int arg)
                    243: {
                    244: _EOF_
                    245:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    246:                $include_dir/$file | \
                    247:        awk '{ printf "\t"; \
                    248:                if (NR > 1) \
                    249:                        printf "else " ; \
                    250:                printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
                    251: cat <<_EOF_
                    252:        else /* Should not reach */
1.24      guenther  253:                (void)printf("<invalid=%d>", arg);
1.1       otto      254: }
                    255:
                    256: _EOF_
                    257: }
                    258:
                    259: # C start
                    260:
                    261: cat <<_EOF_
                    262: #include <stdio.h>
1.2       otto      263: #include <sys/param.h>
1.29      guenther  264: #include <sys/event.h>
1.1       otto      265: #include <sys/fcntl.h>
                    266: #include <sys/stat.h>
                    267: #include <sys/unistd.h>
1.19      matthew   268: #define _KERNEL
1.1       otto      269: #include <sys/mman.h>
1.19      matthew   270: #undef _KERNEL
1.1       otto      271: #include <sys/wait.h>
1.2       otto      272: #include <sys/proc.h>
1.1       otto      273: #include <sys/socket.h>
                    274: #include <netinet/in.h>
                    275: #include <sys/param.h>
                    276: #include <sys/mount.h>
1.14      guenther  277: #include <sys/poll.h>
1.1       otto      278: #include <sys/ptrace.h>
                    279: #include <sys/resource.h>
                    280: #include <sys/reboot.h>
1.18      guenther  281: #include <sys/uio.h>
                    282: #include <sys/ktrace.h>
1.1       otto      283: #include <sched.h>
1.2       otto      284: #if 0
1.1       otto      285: #include <sys/linker.h>
                    286: #define _KERNEL
                    287: #include <sys/thr.h>
                    288: #undef _KERNEL
                    289: #include <sys/extattr.h>
                    290: #include <sys/acl.h>
                    291: #include <aio.h>
1.2       otto      292: #endif
1.1       otto      293: #include <sys/sem.h>
                    294: #include <sys/ipc.h>
1.2       otto      295: #if 0
1.1       otto      296: #include <sys/rtprio.h>
1.2       otto      297: #endif
1.1       otto      298: #include <sys/shm.h>
1.2       otto      299: #if 0
1.1       otto      300: #include <nfsserver/nfs.h>
1.2       otto      301: #endif
1.1       otto      302: #include <ufs/ufs/quota.h>
1.30      guenther  303: #include <sys/syslog.h>
1.32    ! mpi       304: #include <sys/futex.h>
1.1       otto      305:
                    306: #include "kdump_subr.h"
                    307:
                    308: _EOF_
                    309:
1.21      guenther  310: auto_orz_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" "%#o"
1.22      guenther  311: auto_fflags_type "doflagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
1.8       guenther  312: auto_orz_type "atflagsname" "AT_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
1.3       otto      313: auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h"
1.1       otto      314: auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
1.13      matthew   315: auto_or_type "mmapflagsname" "(__)?MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
1.8       guenther  316: auto_orz_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h"
                    317: #auto_or_type "timerflagsname" "TIMER_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/time.h"
1.2       otto      318: #auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h"
1.24      guenther  319: auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h"
                    320: auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
1.3       otto      321: auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
1.2       otto      322: #auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
1.3       otto      323: auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
1.8       guenther  324: auto_orz_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h"
1.2       otto      325: #auto_or_type "nfssvcname" "NFSSVC_[A-Z]+[[:space:]]+0x[0-9]+" "nfsserver/nfs.h"
                    326: #
1.3       otto      327: auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
1.14      guenther  328: auto_switch_type "pathconfname" "_PC_[_A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
1.3       otto      329: auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
1.14      guenther  330: auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
1.24      guenther  331: auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
1.3       otto      332: auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
                    333: auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
1.15      guenther  334: auto_switch_type "clocktypename" "CLOCK_[_A-Z]+[[:space:]]+[0-9]+" "sys/_time.h"
1.2       otto      335: #auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
                    336: #auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
                    337: #auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h"
                    338: #auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
                    339: #auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
                    340: #auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h"
1.16      guenther  341: auto_switch_type "rusagewho" "RUSAGE_[A-Z]+[[:space:]]+[-0-9()]+" "sys/resource.h"
1.9       guenther  342: auto_orz_type "sigactionflagname" "SA_[A-Z]+[[:space:]]+0x[0-9]+" "sys/signal.h"
1.1       otto      343: auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
1.7       deraadt   344: auto_switch_type "sigill_name" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    345: auto_switch_type "sigtrap_name" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    346: auto_switch_type "sigemt_name" "EMT_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    347: auto_switch_type "sigfpe_name" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    348: auto_switch_type "sigbus_name" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    349: auto_switch_type "sigsegv_name" "SEGV_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    350: auto_switch_type "sigchld_name" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
1.2       otto      351: #auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
1.20      otto      352: auto_switch_type "minheritname" "MAP_INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
1.23      guenther  353: auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
1.27      guenther  354: #auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
1.5       otto      355: auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
1.3       otto      356: auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
                    357: auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
1.2       otto      358: #auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
1.29      guenther  359: # exclude KTRFAC_MASK
1.18      guenther  360: auto_orz_type "ktracefacname" "KTRFAC_[^M][[:alnum:]_]+" "sys/ktrace.h"
                    361: auto_switch_type "itimername" "ITIMER_[[:alnum:]_]+" "sys/time.h"
1.29      guenther  362: auto_switch_type "evfiltername" "EVFILT_[[:alnum:]_]+[[:space:]]+[(]" "sys/event.h"
1.31      deraadt   363: auto_orz_type "pollfdeventname" "POLL[^_][[:alnum:]_]+[[:space:]]+0x" "sys/poll.h"
1.29      guenther  364: # exclude EV_{SYSFLAGS,FLAG1}
                    365: auto_orz_type "evflagsname" "EV_[^S][A-Z]+[[:space:]]+0x" "sys/event.h"
1.30      guenther  366: auto_orz_type "syslogflagname" "LOG_[A-Z]+[[:space:]]+0x0*[1248]0*[[:space:]]" "sys/syslog.h"
1.32    ! mpi       367: auto_orz_type "futexflagname" "FUTEX_[A-Z_]+[[:space:]]+[0-9]+" "sys/futex.h"
1.1       otto      368:
                    369: cat <<_EOF_
                    370: /*
                    371:  * AUTO - Special
                    372:  * F_ is used to specify fcntl commands as well as arguments. Both sets are
                    373:  * grouped in fcntl.h, and this awk script grabs the first group.
                    374:  */
                    375: void
1.24      guenther  376: fcntlcmdname (int arg)
1.1       otto      377: {
1.24      guenther  378:        switch (arg1) {
1.1       otto      379: _EOF_
1.6       matthew   380: egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z_]+[[:space:]]+[0-9]+[[:space:]]*" \
1.1       otto      381:        $include_dir/sys/fcntl.h | \
                    382:        awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \
                    383:                if ($i ~ /define/) \
                    384:                        break; \
                    385:                ++i; \
                    386:                if (o <= $(i+1)) \
                    387:                        printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i; \
                    388:                else \
                    389:                        exit; \
                    390:                o = $(i+1) }'
                    391: cat <<_EOF_
                    392:        default: /* Should not reach */
1.24      guenther  393:                (void)printf("<invalid=%d>", arg1);
1.1       otto      394:        }
1.24      guenther  395:        if (arg1 == F_SETFD) {
1.14      guenther  396:                (void)putchar(',');
1.1       otto      397:                if (arg == FD_CLOEXEC)
                    398:                        (void)printf("FD_CLOEXEC");
                    399:                else if (arg == 0)
                    400:                        (void)printf("0");
1.24      guenther  401:                else
                    402:                        (void)printf("<invalid>%#x", arg);
1.14      guenther  403:
1.24      guenther  404:        } else if (arg1 == F_SETFL) {
1.14      guenther  405:                (void)putchar(',');
1.24      guenther  406:                doflagsname(arg, 0);
1.28      deraadt   407:        } else if (!fancy || (arg1 != F_GETFD && arg1 != F_GETFL && arg1 != F_ISATTY))
1.24      guenther  408:                (void)printf(",%#x", arg);
1.1       otto      409: }
                    410:
                    411: /*
                    412:  * AUTO - Special
                    413:  *
                    414:  * The send and recv functions have a flags argument which can be
                    415:  * set to 0. There is no corresponding #define. The auto_ functions
                    416:  * detect this as "invalid", which is incorrect here.
                    417:  */
                    418: void
                    419: sendrecvflagsname (int flags)
                    420: {
                    421:        int     or = 0;
                    422:
                    423:        if (flags == 0) {
                    424:                (void)printf("0");
                    425:                return;
                    426:        }
                    427:
                    428:        printf("%#x<", flags);
                    429: _EOF_
1.22      guenther  430: egrep "^#[[:space:]]*define[[:space:]]+MSG_[_A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \
1.1       otto      431:        awk '{ for (i = 1; i <= NF; i++) \
                    432:                if ($i ~ /define/) \
                    433:                        break; \
                    434:                ++i; \
                    435:                printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
                    436: cat <<_EOF_
                    437:        printf(">");
1.22      guenther  438: }
                    439:
                    440: /*
                    441:  * AUTO - Special
                    442:  *
                    443:  * SOCK_NONBLOCK and SOCK_CLOEXEC are or'ed into the type
                    444:  */
                    445: static void
                    446: dosocktypename (int arg, int show_type)
                    447: {
                    448:        int     type = arg & 0xff;              /* XXX */
                    449:        int     or = 0;
                    450:
                    451:        printf("%#x<", arg);
                    452:        if (show_type || type) {
                    453:                or = 1;
                    454:                switch (type) {
                    455: _EOF_
                    456:        egrep "^#[[:space:]]*define[[:space:]]+SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*[[:space:]]*" \
                    457:                $include_dir/sys/socket.h | \
                    458:        awk '{ for (i = 1; i <= NF; i++) \
                    459:                if ($i ~ /define/) \
                    460:                        break; \
                    461:                ++i; \
1.25      guenther  462:                printf "\t\tcase %s:\n\t\t\t(void)printf(\"%s\");\n\t\t\tbreak;\n", $i, $i }'
1.22      guenther  463: cat <<_EOF_
                    464:                default: /* Should not reach */
                    465:                        (void)printf("<invalid=%d>", arg);
                    466:                }
                    467:        }
                    468:
                    469: _EOF_
                    470:        egrep "^#[[:space:]]*define[[:space:]]+SOCK_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" \
                    471:                $include_dir/sys/socket.h | \
                    472:        awk '{ for (i = 1; i <= NF; i++) \
                    473:                if ($i ~ /define/) \
                    474:                        break; \
                    475:                ++i; \
                    476:                printf "\tif_print_or(arg, %s, or);\n", $i }'
                    477: cat <<_EOF_
                    478:        printf(">");
                    479: }
                    480:
                    481: void
                    482: socktypename (int arg)
                    483: {
                    484:        dosocktypename(arg, 1);
                    485: }
                    486:
                    487: void
                    488: sockflagsname (int arg)
                    489: {
                    490:        dosocktypename(arg, 0);
1.23      guenther  491: }
                    492:
                    493: void
                    494: quotactlcmdname(int cmd)
                    495: {
1.25      guenther  496:        printf("%#x<QCMD(", cmd);
1.23      guenther  497:        quotactlname(cmd >> SUBCMDSHIFT);
                    498:        switch (cmd & SUBCMDMASK) {
                    499:        case USRQUOTA:
1.25      guenther  500:                printf(",%s)>", "USRQUOTA");
1.23      guenther  501:                break;
                    502:        case GRPQUOTA:
1.25      guenther  503:                printf(",%s)>", "GRPQUOTA");
1.23      guenther  504:                break;
                    505:        default:
1.25      guenther  506:                printf(",<invalid>%#x)>", cmd & SUBCMDMASK);
1.23      guenther  507:                break;
                    508:        }
1.29      guenther  509: }
                    510:
                    511: /*
                    512:  * AUTO - Special
                    513:  *
                    514:  * kevent() NOTE_* interpretation depends on the filter type
                    515:  */
                    516: void
                    517: evfflagsname (int filter, int fflags)
                    518: {
                    519:        int     or = 0;
                    520:
                    521:        if (fflags == 0) {
                    522:                printf("0<>");
                    523:                return;
                    524:        }
                    525:        printf("%#x<", fflags);
                    526:        switch (filter) {
                    527:        case EVFILT_READ:
                    528:        case EVFILT_WRITE:
                    529:                if_print_or(fflags, NOTE_LOWAT, or);
                    530:                if_print_or(fflags, NOTE_EOF, or);
                    531:                break;
                    532:        case EVFILT_VNODE:
                    533: _EOF_
                    534:        egrep "^#[[:space:]]*define[[:space:]]+NOTE_.[^O][A-Z]+[[:space:]]+0x[01248]{4}[^[:alnum:]]" \
                    535:                $include_dir/sys/event.h | \
                    536:        awk '{ for (i = 1; i <= NF; i++) \
                    537:                if ($i ~ /define/) \
                    538:                        break; \
                    539:                ++i; \
                    540:                printf "\t\tif_print_or(fflags, %s, or);\n", $i }'
                    541: cat <<_EOF_
                    542:                break;
                    543:        case EVFILT_PROC:
                    544: _EOF_
                    545:        egrep "^#[[:space:]]*define[[:space:]]+NOTE_[^S][A-Z]+[[:space:]]+0x[01248]{8}" \
                    546:                $include_dir/sys/event.h | \
                    547:        awk '{ for (i = 1; i <= NF; i++) \
                    548:                if ($i ~ /define/) \
                    549:                        break; \
                    550:                ++i; \
                    551:                printf "\t\tif_print_or(fflags, %s, or);\n", $i }'
                    552: cat <<_EOF_
                    553:                break;
                    554:        }
                    555:        printf(">");
1.1       otto      556: }
                    557:
                    558: _EOF_