[1/3] gdbsupport: move run_time_clock::now(user, system) out of run_time_clock

Message ID 20250411182151.1427430-1-simon.marchi@polymtl.ca
State New
Headers
Series [1/3] gdbsupport: move run_time_clock::now(user, system) out of run_time_clock |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Simon Marchi April 11, 2025, 6:21 p.m. UTC
  From: Simon Marchi <simon.marchi@polymtl.ca>

It is completely unrelated to run_time_clock, so I don't think it makes
sense to have it as a static function there.

Move it to be a free function named "get_run_time".

Change-Id: I0c3e4d3cc44ca37e523c94d72f7cd66add95645e
---
 gdb/mi/mi-main.c             |  2 +-
 gdbsupport/run-time-clock.cc |  4 ++--
 gdbsupport/run-time-clock.h  | 13 +++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)


base-commit: 7fa205d2fe280f331ff08de24198229fa864014f
  

Patch

diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 850a9ab33418..aea8fa9a02e8 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2218,7 +2218,7 @@  timestamp (struct mi_timestamp *tv)
   using namespace std::chrono;
 
   tv->wallclock = steady_clock::now ();
-  run_time_clock::now (tv->utime, tv->stime);
+  get_run_time (tv->utime, tv->stime);
 }
 
 static void
diff --git a/gdbsupport/run-time-clock.cc b/gdbsupport/run-time-clock.cc
index 43da1d9b07fd..d8de0313148a 100644
--- a/gdbsupport/run-time-clock.cc
+++ b/gdbsupport/run-time-clock.cc
@@ -38,8 +38,8 @@  timeval_to_microseconds (struct timeval *tv)
 #endif
 
 void
-run_time_clock::now (user_cpu_time_clock::time_point &user,
-		     system_cpu_time_clock::time_point &system) noexcept
+get_run_time (user_cpu_time_clock::time_point &user,
+	      system_cpu_time_clock::time_point &system) noexcept
 {
 #ifdef HAVE_GETRUSAGE
   struct rusage rusage;
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index a961f4cff6ef..c789e9dcf799 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -51,6 +51,13 @@  struct system_cpu_time_clock
   static time_point now () noexcept = delete;
 };
 
+/* Return the user/system time as separate time points, if
+   supported.  If not supported, then the combined user+kernel time
+   is returned in USER and SYSTEM is set to zero.  */
+
+void get_run_time (user_cpu_time_clock::time_point &user,
+		   system_cpu_time_clock::time_point &system) noexcept;
+
 /* Count the total amount of time spent executing in userspace+kernel
    mode.  */
 
@@ -64,12 +71,6 @@  struct run_time_clock
   static constexpr bool is_steady = true;
 
   static time_point now () noexcept;
-
-  /* Return the user/system time as separate time points, if
-     supported.  If not supported, then the combined user+kernel time
-     is returned in USER and SYSTEM is set to zero.  */
-  static void now (user_cpu_time_clock::time_point &user,
-		   system_cpu_time_clock::time_point &system) noexcept;
 };
 
 #endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */