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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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-2020 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 "print_fields.h"
  14. #include DEF_MPERS_TYPE(rusage_t)
  15. struct kernel_old_timeval {
  16. kernel_long_t tv_sec;
  17. long tv_nsec;
  18. };
  19. typedef struct {
  20. struct kernel_old_timeval ru_utime;
  21. struct kernel_old_timeval ru_stime;
  22. kernel_long_t ru_maxrss;
  23. kernel_long_t ru_ixrss;
  24. kernel_long_t ru_idrss;
  25. kernel_long_t ru_isrss;
  26. kernel_long_t ru_minflt;
  27. kernel_long_t ru_majflt;
  28. kernel_long_t ru_nswap;
  29. kernel_long_t ru_inblock;
  30. kernel_long_t ru_oublock;
  31. kernel_long_t ru_msgsnd;
  32. kernel_long_t ru_msgrcv;
  33. kernel_long_t ru_nsignals;
  34. kernel_long_t ru_nvcsw;
  35. kernel_long_t ru_nivcsw;
  36. } rusage_t;
  37. #include MPERS_DEFS
  38. MPERS_PRINTER_DECL(void, printrusage,
  39. struct tcb *const tcp, const kernel_ulong_t addr)
  40. {
  41. rusage_t ru;
  42. if (umove_or_printaddr(tcp, addr, &ru))
  43. return;
  44. tprints("{ru_utime=");
  45. MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime);
  46. tprints(", ru_stime=");
  47. MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime);
  48. if (abbrev(tcp)) {
  49. tprints(", ...");
  50. } else {
  51. PRINT_FIELD_U(", ", ru, ru_maxrss);
  52. PRINT_FIELD_U(", ", ru, ru_ixrss);
  53. PRINT_FIELD_U(", ", ru, ru_idrss);
  54. PRINT_FIELD_U(", ", ru, ru_isrss);
  55. PRINT_FIELD_U(", ", ru, ru_minflt);
  56. PRINT_FIELD_U(", ", ru, ru_majflt);
  57. PRINT_FIELD_U(", ", ru, ru_nswap);
  58. PRINT_FIELD_U(", ", ru, ru_inblock);
  59. PRINT_FIELD_U(", ", ru, ru_oublock);
  60. PRINT_FIELD_U(", ", ru, ru_msgsnd);
  61. PRINT_FIELD_U(", ", ru, ru_msgrcv);
  62. PRINT_FIELD_U(", ", ru, ru_nsignals);
  63. PRINT_FIELD_U(", ", ru, ru_nvcsw);
  64. PRINT_FIELD_U(", ", ru, ru_nivcsw);
  65. }
  66. tprints("}");
  67. }
  68. #ifdef ALPHA
  69. void
  70. printrusage32(struct tcb *const tcp, const kernel_ulong_t addr)
  71. {
  72. struct rusage32 {
  73. timeval32_t ru_utime; /* user time used */
  74. timeval32_t ru_stime; /* system time used */
  75. long ru_maxrss; /* maximum resident set size */
  76. long ru_ixrss; /* integral shared memory size */
  77. long ru_idrss; /* integral unshared data size */
  78. long ru_isrss; /* integral unshared stack size */
  79. long ru_minflt; /* page reclaims */
  80. long ru_majflt; /* page faults */
  81. long ru_nswap; /* swaps */
  82. long ru_inblock; /* block input operations */
  83. long ru_oublock; /* block output operations */
  84. long ru_msgsnd; /* messages sent */
  85. long ru_msgrcv; /* messages received */
  86. long ru_nsignals; /* signals received */
  87. long ru_nvcsw; /* voluntary context switches */
  88. long ru_nivcsw; /* involuntary " */
  89. } ru;
  90. if (umove_or_printaddr(tcp, addr, &ru))
  91. return;
  92. tprints("{ru_utime=");
  93. print_timeval32_t(&ru.ru_utime);
  94. tprints(", ru_stime=");
  95. print_timeval32_t(&ru.ru_stime);
  96. if (abbrev(tcp)) {
  97. tprints(", ...");
  98. } else {
  99. PRINT_FIELD_U(", ", ru, ru_maxrss);
  100. PRINT_FIELD_U(", ", ru, ru_ixrss);
  101. PRINT_FIELD_U(", ", ru, ru_idrss);
  102. PRINT_FIELD_U(", ", ru, ru_isrss);
  103. PRINT_FIELD_U(", ", ru, ru_minflt);
  104. PRINT_FIELD_U(", ", ru, ru_majflt);
  105. PRINT_FIELD_U(", ", ru, ru_nswap);
  106. PRINT_FIELD_U(", ", ru, ru_inblock);
  107. PRINT_FIELD_U(", ", ru, ru_oublock);
  108. PRINT_FIELD_U(", ", ru, ru_msgsnd);
  109. PRINT_FIELD_U(", ", ru, ru_msgrcv);
  110. PRINT_FIELD_U(", ", ru, ru_nsignals);
  111. PRINT_FIELD_U(", ", ru, ru_nvcsw);
  112. PRINT_FIELD_U(", ", ru, ru_nivcsw);
  113. }
  114. tprints("}");
  115. }
  116. #endif