From c2679dd779bb75f51682cde5eb55a291b72d7900 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 9 Dec 2020 03:24:09 +0000 Subject: [PATCH] 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,0,0,0) _umtx_op(0x9fffdce8,0x80000003,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 --- usr.bin/kdump/kdump.c | 22 ++++++++++++++++++---- usr.bin/truss/syscalls.c | 20 +++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 3b5975333596..05988f43133e 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -254,14 +254,21 @@ print_integer_arg_valid(const char *(*decoder)(int), int value) } } +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("%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); diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index c32f46b10464..03c6acf04e63 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -888,12 +888,20 @@ print_integer_arg(const char *(*decoder)(int), FILE *fp, int value) 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, register_t *retval, 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;