Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printrusage.c 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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-2018 The strace developers.
  7. * All rights reserved.
  8. *
  9. * SPDX-License-Identifier: LGPL-2.1-or-later
  10. */
  11. #include "defs.h"
  12. #include <sys/resource.h>
  13. #include DEF_MPERS_TYPE(rusage_t)
  14. typedef struct rusage rusage_t;
  15. #include MPERS_DEFS
  16. MPERS_PRINTER_DECL(void, printrusage,
  17. struct tcb *const tcp, const kernel_ulong_t addr)
  18. {
  19. rusage_t ru;
  20. if (umove_or_printaddr(tcp, addr, &ru))
  21. return;
  22. tprints("{ru_utime=");
  23. MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime);
  24. tprints(", ru_stime=");
  25. MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime);
  26. if (abbrev(tcp))
  27. tprints(", ...");
  28. else {
  29. #define PRINT_RUSAGE_MEMBER(member) \
  30. tprintf(", " #member "=%llu", zero_extend_signed_to_ull(ru.member))
  31. PRINT_RUSAGE_MEMBER(ru_maxrss);
  32. PRINT_RUSAGE_MEMBER(ru_ixrss);
  33. PRINT_RUSAGE_MEMBER(ru_idrss);
  34. PRINT_RUSAGE_MEMBER(ru_isrss);
  35. PRINT_RUSAGE_MEMBER(ru_minflt);
  36. PRINT_RUSAGE_MEMBER(ru_majflt);
  37. PRINT_RUSAGE_MEMBER(ru_nswap);
  38. PRINT_RUSAGE_MEMBER(ru_inblock);
  39. PRINT_RUSAGE_MEMBER(ru_oublock);
  40. PRINT_RUSAGE_MEMBER(ru_msgsnd);
  41. PRINT_RUSAGE_MEMBER(ru_msgrcv);
  42. PRINT_RUSAGE_MEMBER(ru_nsignals);
  43. PRINT_RUSAGE_MEMBER(ru_nvcsw);
  44. PRINT_RUSAGE_MEMBER(ru_nivcsw);
  45. #undef PRINT_RUSAGE_MEMBER
  46. }
  47. tprints("}");
  48. }
  49. #ifdef ALPHA
  50. void
  51. printrusage32(struct tcb *const tcp, const kernel_ulong_t addr)
  52. {
  53. struct rusage32 {
  54. timeval32_t ru_utime; /* user time used */
  55. timeval32_t ru_stime; /* system time used */
  56. long ru_maxrss; /* maximum resident set size */
  57. long ru_ixrss; /* integral shared memory size */
  58. long ru_idrss; /* integral unshared data size */
  59. long ru_isrss; /* integral unshared stack size */
  60. long ru_minflt; /* page reclaims */
  61. long ru_majflt; /* page faults */
  62. long ru_nswap; /* swaps */
  63. long ru_inblock; /* block input operations */
  64. long ru_oublock; /* block output operations */
  65. long ru_msgsnd; /* messages sent */
  66. long ru_msgrcv; /* messages received */
  67. long ru_nsignals; /* signals received */
  68. long ru_nvcsw; /* voluntary context switches */
  69. long ru_nivcsw; /* involuntary " */
  70. } ru;
  71. if (umove_or_printaddr(tcp, addr, &ru))
  72. return;
  73. tprints("{ru_utime=");
  74. print_timeval32_t(&ru.ru_utime);
  75. tprints(", ru_stime=");
  76. print_timeval32_t(&ru.ru_stime);
  77. if (abbrev(tcp))
  78. tprints(", ...");
  79. else {
  80. # define PRINT_RUSAGE_MEMBER(member) \
  81. tprintf(", " #member "=%lu", ru.member)
  82. PRINT_RUSAGE_MEMBER(ru_maxrss);
  83. PRINT_RUSAGE_MEMBER(ru_ixrss);
  84. PRINT_RUSAGE_MEMBER(ru_idrss);
  85. PRINT_RUSAGE_MEMBER(ru_isrss);
  86. PRINT_RUSAGE_MEMBER(ru_minflt);
  87. PRINT_RUSAGE_MEMBER(ru_majflt);
  88. PRINT_RUSAGE_MEMBER(ru_nswap);
  89. PRINT_RUSAGE_MEMBER(ru_inblock);
  90. PRINT_RUSAGE_MEMBER(ru_oublock);
  91. PRINT_RUSAGE_MEMBER(ru_msgsnd);
  92. PRINT_RUSAGE_MEMBER(ru_msgrcv);
  93. PRINT_RUSAGE_MEMBER(ru_nsignals);
  94. PRINT_RUSAGE_MEMBER(ru_nvcsw);
  95. PRINT_RUSAGE_MEMBER(ru_nivcsw);
  96. # undef PRINT_RUSAGE_MEMBER
  97. }
  98. tprints("}");
  99. }
  100. #endif