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>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
32 #include <sys/resource.h>
34 #include DEF_MPERS_TYPE(rusage_t)
36 typedef struct rusage rusage_t;
40 MPERS_PRINTER_DECL(void, printrusage, struct tcb *tcp, long addr)
44 if (umove_or_printaddr(tcp, addr, &ru))
47 tprints("{ru_utime=");
48 MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime);
49 tprints(", ru_stime=");
50 MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime);
54 #define PRINT_RUSAGE_MEMBER(member) \
55 tprintf(", " #member "=%llu", zero_extend_signed_to_ull(ru.member))
56 PRINT_RUSAGE_MEMBER(ru_maxrss);
57 PRINT_RUSAGE_MEMBER(ru_ixrss);
58 PRINT_RUSAGE_MEMBER(ru_idrss);
59 PRINT_RUSAGE_MEMBER(ru_isrss);
60 PRINT_RUSAGE_MEMBER(ru_minflt);
61 PRINT_RUSAGE_MEMBER(ru_majflt);
62 PRINT_RUSAGE_MEMBER(ru_nswap);
63 PRINT_RUSAGE_MEMBER(ru_inblock);
64 PRINT_RUSAGE_MEMBER(ru_oublock);
65 PRINT_RUSAGE_MEMBER(ru_msgsnd);
66 PRINT_RUSAGE_MEMBER(ru_msgrcv);
67 PRINT_RUSAGE_MEMBER(ru_nsignals);
68 PRINT_RUSAGE_MEMBER(ru_nvcsw);
69 PRINT_RUSAGE_MEMBER(ru_nivcsw);
70 #undef PRINT_RUSAGE_MEMBER
77 printrusage32(struct tcb *tcp, long addr)
80 timeval32_t ru_utime; /* user time used */
81 timeval32_t ru_stime; /* system time used */
82 long ru_maxrss; /* maximum resident set size */
83 long ru_ixrss; /* integral shared memory size */
84 long ru_idrss; /* integral unshared data size */
85 long ru_isrss; /* integral unshared stack size */
86 long ru_minflt; /* page reclaims */
87 long ru_majflt; /* page faults */
88 long ru_nswap; /* swaps */
89 long ru_inblock; /* block input operations */
90 long ru_oublock; /* block output operations */
91 long ru_msgsnd; /* messages sent */
92 long ru_msgrcv; /* messages received */
93 long ru_nsignals; /* signals received */
94 long ru_nvcsw; /* voluntary context switches */
95 long ru_nivcsw; /* involuntary " */
98 if (umove_or_printaddr(tcp, addr, &ru))
101 tprints("{ru_utime=");
102 print_timeval32_t(&ru.ru_utime);
103 tprints(", ru_stime=");
104 print_timeval32_t(&ru.ru_stime);
108 # define PRINT_RUSAGE_MEMBER(member) \
109 tprintf(", " #member "=%lu", ru.member)
110 PRINT_RUSAGE_MEMBER(ru_maxrss);
111 PRINT_RUSAGE_MEMBER(ru_ixrss);
112 PRINT_RUSAGE_MEMBER(ru_idrss);
113 PRINT_RUSAGE_MEMBER(ru_isrss);
114 PRINT_RUSAGE_MEMBER(ru_minflt);
115 PRINT_RUSAGE_MEMBER(ru_majflt);
116 PRINT_RUSAGE_MEMBER(ru_nswap);
117 PRINT_RUSAGE_MEMBER(ru_inblock);
118 PRINT_RUSAGE_MEMBER(ru_oublock);
119 PRINT_RUSAGE_MEMBER(ru_msgsnd);
120 PRINT_RUSAGE_MEMBER(ru_msgrcv);
121 PRINT_RUSAGE_MEMBER(ru_nsignals);
122 PRINT_RUSAGE_MEMBER(ru_nvcsw);
123 PRINT_RUSAGE_MEMBER(ru_nivcsw);
124 # undef PRINT_RUSAGE_MEMBER