Author: kevans
Date: Wed Dec  9 03:24:09 2020
New Revision: 368481
URL: https://svnweb.freebsd.org/changeset/base/368481

Log:
  kdump/truss: decode new _umtx_op flags
  
  In both cases, print the flag bits first followed by the command.
  
  Output now looks something like this:
  
  (ktrace)
  _umtx_op(0x8605f7008,0xf<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0)
  _umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,0x1,0,0)
  
  (truss)
  _umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)
  _umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)
  
  Reviewed by:  kib
  Differential Revision:        https://reviews.freebsd.org/D27325

Modified:
  head/usr.bin/kdump/kdump.c
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/kdump/kdump.c
==============================================================================
--- head/usr.bin/kdump/kdump.c  Wed Dec  9 03:22:44 2020        (r368480)
+++ head/usr.bin/kdump/kdump.c  Wed Dec  9 03:24:09 2020        (r368481)
@@ -254,14 +254,21 @@ print_integer_arg_valid(const char *(*decoder)(int), i
        }
 }
 
+static bool
+print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem)
+{
+
+       printf("%#x<", value);
+       return (decoder(stdout, value, rem));
+}
+
 static void
 print_mask_arg(bool (*decoder)(FILE *, int, int *), int value)
 {
        bool invalid;
        int rem;
 
-       printf("%#x<", value);
-       invalid = !decoder(stdout, value, &rem);
+       invalid = !print_mask_arg_part(decoder, value, &rem);
        printf(">");
        if (invalid)
                printf("<invalid>%u", rem);
@@ -1455,10 +1462,16 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
                                ip++;
                                narg--;
                                break;
-                       case SYS__umtx_op:
+                       case SYS__umtx_op: {
+                               int op;
+
                                print_number(ip, narg, c);
                                putchar(',');
-                               print_integer_arg(sysdecode_umtx_op, *ip);
+                               if (print_mask_arg_part(sysdecode_umtx_op_flags,
+                                   *ip, &op))
+                                       putchar('|');
+                               print_integer_arg(sysdecode_umtx_op, op);
+                               putchar('>');
                                switch (*ip) {
                                case UMTX_OP_CV_WAIT:
                                        ip++;
@@ -1478,6 +1491,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
                                ip++;
                                narg--;
                                break;
+                       }
                        case SYS_ftruncate:
                        case SYS_truncate:
                                print_number(ip, narg, c);

Modified: head/usr.bin/truss/syscalls.c
==============================================================================
--- head/usr.bin/truss/syscalls.c       Wed Dec  9 03:22:44 2020        
(r368480)
+++ head/usr.bin/truss/syscalls.c       Wed Dec  9 03:24:09 2020        
(r368481)
@@ -888,12 +888,20 @@ print_integer_arg(const char *(*decoder)(int), FILE *f
                fprintf(fp, "%d", value);
 }
 
+static bool
+print_mask_arg_part(bool (*decoder)(FILE *, int, int *), FILE *fp, int value,
+    int *rem)
+{
+
+       return (decoder(fp, value, rem));
+}
+
 static void
 print_mask_arg(bool (*decoder)(FILE *, int, int *), FILE *fp, int value)
 {
        int rem;
 
-       if (!decoder(fp, value, &rem))
+       if (!print_mask_arg_part(decoder, fp, value, &rem))
                fprintf(fp, "0x%x", rem);
        else if (rem != 0)
                fprintf(fp, "|0x%x", rem);
@@ -2303,9 +2311,15 @@ print_arg(struct syscall_args *sc, unsigned long *args
        case Procctl:
                print_integer_arg(sysdecode_procctl_cmd, fp, args[sc->offset]);
                break;
-       case Umtxop:
-               print_integer_arg(sysdecode_umtx_op, fp, args[sc->offset]);
+       case Umtxop: {
+               int rem;
+
+               if (print_mask_arg_part(sysdecode_umtx_op_flags, fp,
+                   args[sc->offset], &rem))
+                       fprintf(fp, "|");
+               print_integer_arg(sysdecode_umtx_op, fp, rem);
                break;
+       }
        case Atfd:
                print_integer_arg(sysdecode_atfd, fp, args[sc->offset]);
                break;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to