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