When displaying fcntl() arguments, kdump knows that fcntl commands 
F_GETFD, F_GETFL, and F_ISATTY don't take an additional argument.  That's 
also true of F_GETOWN, so add it to that list.

This diff would be three lines, but I think it's cleaner to figure out 
whether an argument should be displayed in the main 'switch' in 
fcntlcmdname() instead of making the later 'if' conditional more 
complicated.  With this, adding more "no argument" fnctl commands becomes 
one liner diffs.

Example output with this:
 34617 fsetown  CALL  fcntl(3,F_GETOWN)
 34617 fsetown  RET   fcntl -34617/0xffffffffffff78c7

(It would be nice if we displayed the fnctl command's additional argument 
in the prefered form for its type, such as just decimal for pid/pgid args, 
and ditto for return values, but that requires more thought...)


ok?

Philip Guenther



Index: usr.bin/kdump/mksubr
===================================================================
RCS file: /data/src/openbsd/src/usr.bin/kdump/mksubr,v
retrieving revision 1.32
diff -u -p -r1.32 mksubr
--- usr.bin/kdump/mksubr        28 Apr 2017 13:53:05 -0000      1.32
+++ usr.bin/kdump/mksubr        27 Nov 2017 17:35:03 -0000
@@ -375,18 +375,25 @@ cat <<_EOF_
 void
 fcntlcmdname (int arg)
 {
+       int noarg = 0;
+
        switch (arg1) {
 _EOF_
 egrep 
"^#[[:space:]]*define[[:space:]]+F_[A-Z_]+[[:space:]]+[0-9]+[[:space:]]*" \
        $include_dir/sys/fcntl.h | \
-       awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \
+       awk 'BEGIN { o=0; \
+               noarg["F_GETFD"] = 1; \
+               noarg["F_GETFL"] = 1; \
+               noarg["F_ISATTY"] = 1; \
+               noarg["F_GETOWN"] = 1; \
+            }{ for (i = 1; i <= NF; i++) \
                if ($i ~ /define/) \
                        break; \
                ++i; \
-               if (o <= $(i+1)) \
-                       printf "\tcase 
%s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i; \
-               else \
+               if (o > $(i+1)) \
                        exit; \
+               printf "\tcase %s:\n\t\t(void)printf(\"%s\");%s\n\t\tbreak;\n", 
$i, $i, \
+                       noarg[$i] ? "\n\t\tnoarg = 1;" : ""; \
                o = $(i+1) }'
 cat <<_EOF_
        default: /* Should not reach */
@@ -404,7 +411,7 @@ cat <<_EOF_
        } else if (arg1 == F_SETFL) {
                (void)putchar(',');
                doflagsname(arg, 0);
-       } else if (!fancy || (arg1 != F_GETFD && arg1 != F_GETFL && arg1 != 
F_ISATTY))
+       } else if (!fancy || !noarg)
                (void)printf(",%#x", arg);
 }
 

Reply via email to