Author: jhb
Date: Sat Jun  3 14:22:15 2017
New Revision: 319520
URL: https://svnweb.freebsd.org/changeset/base/319520

Log:
  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...@citrin.ru>
  MFC after:    1 month

Modified:
  head/lib/libsysdecode/Makefile
  head/lib/libsysdecode/flags.c
  head/lib/libsysdecode/mktables
  head/lib/libsysdecode/sysdecode.h
  head/lib/libsysdecode/sysdecode_enum.3
  head/usr.bin/kdump/kdump.c
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c

Modified: head/lib/libsysdecode/Makefile
==============================================================================
--- head/lib/libsysdecode/Makefile      Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/lib/libsysdecode/Makefile      Sat Jun  3 14:22:15 2017        
(r319520)
@@ -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 \

Modified: head/lib/libsysdecode/flags.c
==============================================================================
--- head/lib/libsysdecode/flags.c       Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/lib/libsysdecode/flags.c       Sat Jun  3 14:22:15 2017        
(r319520)
@@ -487,6 +487,13 @@ sysdecode_getfsstat_mode(int mode)
 }
 
 const char *
+sysdecode_getrusage_who(int who)
+{
+
+       return (lookup_value(rusage, who));
+}
+
+const char *
 sysdecode_kldsym_cmd(int cmd)
 {
 

Modified: head/lib/libsysdecode/mktables
==============================================================================
--- head/lib/libsysdecode/mktables      Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/lib/libsysdecode/mktables      Sat Jun  3 14:22:15 2017        
(r319520)
@@ -114,6 +114,7 @@ gen_table "quotactlcmds"    "Q_[A-Z]+[[:space:]]+0x[0-
 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"

Modified: head/lib/libsysdecode/sysdecode.h
==============================================================================
--- head/lib/libsysdecode/sysdecode.h   Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/lib/libsysdecode/sysdecode.h   Sat Jun  3 14:22:15 2017        
(r319520)
@@ -55,6 +55,7 @@ bool  sysdecode_filemode(FILE *_fp, int _mode, int *_re
 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);

Modified: head/lib/libsysdecode/sysdecode_enum.3
==============================================================================
--- head/lib/libsysdecode/sysdecode_enum.3      Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/lib/libsysdecode/sysdecode_enum.3      Sat Jun  3 14:22:15 2017        
(r319520)
@@ -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
 .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

Modified: head/usr.bin/kdump/kdump.c
==============================================================================
--- head/usr.bin/kdump/kdump.c  Sat Jun  3 14:15:14 2017        (r319519)
+++ head/usr.bin/kdump/kdump.c  Sat Jun  3 14:22:15 2017        (r319520)
@@ -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(',');

Modified: head/usr.bin/truss/syscall.h
==============================================================================
--- head/usr.bin/truss/syscall.h        Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/usr.bin/truss/syscall.h        Sat Jun  3 14:22:15 2017        
(r319520)
@@ -42,8 +42,8 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHe
        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,

Modified: head/usr.bin/truss/syscalls.c
==============================================================================
--- head/usr.bin/truss/syscalls.c       Sat Jun  3 14:15:14 2017        
(r319519)
+++ head/usr.bin/truss/syscalls.c       Sat Jun  3 14:22:15 2017        
(r319520)
@@ -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,
@@ -1595,6 +1595,9 @@ print_arg(struct syscall_args *sc, unsigned long *args
                break;
        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);
_______________________________________________
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