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
This commit is contained in:
Kyle Evans 2020-12-09 03:24:09 +00:00
parent 3b27074b25
commit c2679dd779
2 changed files with 35 additions and 7 deletions

View File

@ -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("<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);

View File

@ -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;