• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6  * Copyright (c) 1999-2017 The strace developers.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "defs.h"
33 #include <sys/resource.h>
34 
35 #include DEF_MPERS_TYPE(rusage_t)
36 
37 typedef struct rusage rusage_t;
38 
39 #include MPERS_DEFS
40 
MPERS_PRINTER_DECL(void,printrusage,struct tcb * const tcp,const kernel_ulong_t addr)41 MPERS_PRINTER_DECL(void, printrusage,
42 		   struct tcb *const tcp, const kernel_ulong_t addr)
43 {
44 	rusage_t ru;
45 
46 	if (umove_or_printaddr(tcp, addr, &ru))
47 		return;
48 
49 	tprints("{ru_utime=");
50 	MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime);
51 	tprints(", ru_stime=");
52 	MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime);
53 	if (abbrev(tcp))
54 		tprints(", ...");
55 	else {
56 #define PRINT_RUSAGE_MEMBER(member) \
57 		tprintf(", " #member "=%llu", zero_extend_signed_to_ull(ru.member))
58 		PRINT_RUSAGE_MEMBER(ru_maxrss);
59 		PRINT_RUSAGE_MEMBER(ru_ixrss);
60 		PRINT_RUSAGE_MEMBER(ru_idrss);
61 		PRINT_RUSAGE_MEMBER(ru_isrss);
62 		PRINT_RUSAGE_MEMBER(ru_minflt);
63 		PRINT_RUSAGE_MEMBER(ru_majflt);
64 		PRINT_RUSAGE_MEMBER(ru_nswap);
65 		PRINT_RUSAGE_MEMBER(ru_inblock);
66 		PRINT_RUSAGE_MEMBER(ru_oublock);
67 		PRINT_RUSAGE_MEMBER(ru_msgsnd);
68 		PRINT_RUSAGE_MEMBER(ru_msgrcv);
69 		PRINT_RUSAGE_MEMBER(ru_nsignals);
70 		PRINT_RUSAGE_MEMBER(ru_nvcsw);
71 		PRINT_RUSAGE_MEMBER(ru_nivcsw);
72 #undef PRINT_RUSAGE_MEMBER
73 	}
74 	tprints("}");
75 }
76 
77 #ifdef ALPHA
78 void
printrusage32(struct tcb * const tcp,const kernel_ulong_t addr)79 printrusage32(struct tcb *const tcp, const kernel_ulong_t addr)
80 {
81 	struct rusage32 {
82 		timeval32_t ru_utime;		/* user time used */
83 		timeval32_t ru_stime;		/* system time used */
84 		long	ru_maxrss;		/* maximum resident set size */
85 		long	ru_ixrss;		/* integral shared memory size */
86 		long	ru_idrss;		/* integral unshared data size */
87 		long	ru_isrss;		/* integral unshared stack size */
88 		long	ru_minflt;		/* page reclaims */
89 		long	ru_majflt;		/* page faults */
90 		long	ru_nswap;		/* swaps */
91 		long	ru_inblock;		/* block input operations */
92 		long	ru_oublock;		/* block output operations */
93 		long	ru_msgsnd;		/* messages sent */
94 		long	ru_msgrcv;		/* messages received */
95 		long	ru_nsignals;		/* signals received */
96 		long	ru_nvcsw;		/* voluntary context switches */
97 		long	ru_nivcsw;		/* involuntary " */
98 	} ru;
99 
100 	if (umove_or_printaddr(tcp, addr, &ru))
101 		return;
102 
103 	tprints("{ru_utime=");
104 	print_timeval32_t(&ru.ru_utime);
105 	tprints(", ru_stime=");
106 	print_timeval32_t(&ru.ru_stime);
107 	if (abbrev(tcp))
108 		tprints(", ...");
109 	else {
110 # define PRINT_RUSAGE_MEMBER(member) \
111 		tprintf(", " #member "=%lu", ru.member)
112 		PRINT_RUSAGE_MEMBER(ru_maxrss);
113 		PRINT_RUSAGE_MEMBER(ru_ixrss);
114 		PRINT_RUSAGE_MEMBER(ru_idrss);
115 		PRINT_RUSAGE_MEMBER(ru_isrss);
116 		PRINT_RUSAGE_MEMBER(ru_minflt);
117 		PRINT_RUSAGE_MEMBER(ru_majflt);
118 		PRINT_RUSAGE_MEMBER(ru_nswap);
119 		PRINT_RUSAGE_MEMBER(ru_inblock);
120 		PRINT_RUSAGE_MEMBER(ru_oublock);
121 		PRINT_RUSAGE_MEMBER(ru_msgsnd);
122 		PRINT_RUSAGE_MEMBER(ru_msgrcv);
123 		PRINT_RUSAGE_MEMBER(ru_nsignals);
124 		PRINT_RUSAGE_MEMBER(ru_nvcsw);
125 		PRINT_RUSAGE_MEMBER(ru_nivcsw);
126 # undef PRINT_RUSAGE_MEMBER
127 	}
128 	tprints("}");
129 }
130 #endif
131