Decode the 'who' argument passed to getrusage().

Add a new sysdecode_getrusage_who() which decodes the RUSAGE_* constant
passed as the first argument to getrusage().  Use this function in both
kdump and truss to decode the first argument to getrusage().

PR:		215448
Submitted by:	Anton Yuzhaninov <citrin+pr@citrin.ru>
MFC after:	1 month
This commit is contained in:
John Baldwin 2017-06-03 14:22:15 +00:00
parent 4cbc378c61
commit ee8aa41dca
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=319520
8 changed files with 28 additions and 4 deletions

View File

@ -32,6 +32,7 @@ MLINKS+=sysdecode_enum.3 sysdecode_acltype.3 \
sysdecode_enum.3 sysdecode_fadvice.3 \
sysdecode_enum.3 sysdecode_fcntl_cmd.3 \
sysdecode_enum.3 sysdecode_getfsstat_mode.3 \
sysdecode_enum.3 sysdecode_getrusage_who.3 \
sysdecode_enum.3 sysdecode_idtype.3 \
sysdecode_enum.3 sysdecode_ipproto.3 \
sysdecode_enum.3 sysdecode_kldsym_cmd.3 \

View File

@ -486,6 +486,13 @@ sysdecode_getfsstat_mode(int mode)
return (lookup_value(getfsstatmode, mode));
}
const char *
sysdecode_getrusage_who(int who)
{
return (lookup_value(rusage, who));
}
const char *
sysdecode_kldsym_cmd(int cmd)
{

View File

@ -114,6 +114,7 @@ gen_table "quotactlcmds" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/
gen_table "rebootopt" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
gen_table "rforkflags" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
gen_table "rlimit" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
gen_table "rusage" "RUSAGE_[A-Z]+[[:space:]]+[-0-9]+" "sys/resource.h"
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
gen_table "sendfileflags" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"

View File

@ -55,6 +55,7 @@ bool sysdecode_filemode(FILE *_fp, int _mode, int *_rem);
bool sysdecode_flock_operation(FILE *_fp, int _operation, int *_rem);
int sysdecode_freebsd_to_abi_errno(enum sysdecode_abi _abi, int _error);
const char *sysdecode_getfsstat_mode(int _mode);
const char *sysdecode_getrusage_who(int _who);
const char *sysdecode_idtype(int _idtype);
const char *sysdecode_ioctlname(unsigned long _val);
const char *sysdecode_ipproto(int _protocol);

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 2, 2017
.Dd June 3, 2017
.Dt sysdecode_enum 3
.Os
.Sh NAME
@ -36,6 +36,7 @@
.Nm sysdecode_fadvice ,
.Nm sysdecode_fcntl_cmd ,
.Nm sysdecode_getfsstat_mode ,
.Nm sysdecode_getrusage_who ,
.Nm sysdecode_idtype ,
.Nm sysdecode_ipproto ,
.Nm sysdecode_kldsym_cmd ,
@ -89,6 +90,8 @@
.Ft const char *
.Fn sysdecode_getfsstat_mode "int mode"
.Ft const char *
.Fn sysdecode_getrusage_who "int who"
.Ft const char *
.Fn sysdecode_idtype "int idtype"
.Ft const char *
.Fn sysdecode_ipproto "int protocol"
@ -188,6 +191,7 @@ Most of these functions decode an argument passed to a system call:
.It Fn sysdecode_ptrace_request Ta Xr ptrace 2 Ta Fa request
.It Fn sysdecode_rlimit Ta Xr getrlimit 2 Ta Fa resource
.It Fn sysdecode_rtprio_function Ta Xr rtprio 2 Ta Fa function
.It Fn sysdecode_getrusage_who Ta Xr getrusage 2 Ta Fa who
.It Fn sysdecode_scheduler_policy Ta Xr sched_setscheduler 2 Ta Fa policy
.It Fn sysdecode_semctl_cmd Ta Xr semctl 2 Ta Fa cmd
.It Fn sysdecode_shmctl_cmd Ta Xr shmctl 2 Ta Fa cmd

View File

@ -1190,6 +1190,13 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
narg--;
c = ',';
break;
case SYS_getrusage:
putchar('(');
print_integer_arg(sysdecode_getrusage_who, *ip);
ip++;
narg--;
c = ',';
break;
case SYS_quotactl:
print_number(ip, narg, c);
putchar(',');

View File

@ -42,8 +42,8 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval,
Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open,
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
Fcntlflag, Rusage, RusageWho, BinString, Shutdown, Resource, Rlimit,
Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,

View File

@ -176,7 +176,7 @@ static struct syscall decoded_syscalls[] = {
{ .name = "getrlimit", .ret_type = 1, .nargs = 2,
.args = { { Resource, 0 }, { Rlimit | OUT, 1 } } },
{ .name = "getrusage", .ret_type = 1, .nargs = 2,
.args = { { Int, 0 }, { Rusage | OUT, 1 } } },
.args = { { RusageWho, 0 }, { Rusage | OUT, 1 } } },
{ .name = "getsid", .ret_type = 1, .nargs = 1,
.args = { { Int, 0 } } },
{ .name = "getsockname", .ret_type = 1, .nargs = 3,
@ -1596,6 +1596,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
case Resource:
print_integer_arg(sysdecode_rlimit, fp, args[sc->offset]);
break;
case RusageWho:
print_integer_arg(sysdecode_getrusage_who, fp, args[sc->offset]);
break;
case Pathconf:
fputs(xlookup(pathconf_arg, args[sc->offset]), fp);
break;