Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 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> |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame^] | 6 | * Copyright (c) 1999-2017 The strace developers. |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 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 | |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 35 | #include DEF_MPERS_TYPE(rusage_t) |
| 36 | |
| 37 | typedef struct rusage rusage_t; |
| 38 | |
| 39 | #include MPERS_DEFS |
| 40 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 41 | MPERS_PRINTER_DECL(void, printrusage, |
| 42 | struct tcb *const tcp, const kernel_ulong_t addr) |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 43 | { |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 44 | rusage_t ru; |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 45 | |
| 46 | if (umove_or_printaddr(tcp, addr, &ru)) |
| 47 | return; |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 48 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 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); |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 53 | if (abbrev(tcp)) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 54 | tprints(", ..."); |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 55 | else { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 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 |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 73 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 74 | tprints("}"); |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | #ifdef ALPHA |
| 78 | void |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 79 | printrusage32(struct tcb *const tcp, const kernel_ulong_t addr) |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 80 | { |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 81 | struct rusage32 { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 82 | timeval32_t ru_utime; /* user time used */ |
| 83 | timeval32_t ru_stime; /* system time used */ |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 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; |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 102 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 103 | tprints("{ru_utime="); |
| 104 | print_timeval32_t(&ru.ru_utime); |
| 105 | tprints(", ru_stime="); |
| 106 | print_timeval32_t(&ru.ru_stime); |
Dmitry V. Levin | 6fb8c6f | 2015-07-18 00:19:50 +0000 | [diff] [blame] | 107 | if (abbrev(tcp)) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 108 | tprints(", ..."); |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 109 | else { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 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 |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 127 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 128 | tprints("}"); |
Dmitry V. Levin | 1e08a16 | 2015-07-17 23:50:02 +0000 | [diff] [blame] | 129 | } |
| 130 | #endif |