summaryrefslogtreecommitdiff
path: root/runtime/exec_utils.h
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2023-12-06 14:58:01 +0000
committer Jiakai Zhang <jiakaiz@google.com> 2023-12-07 15:27:50 +0000
commitd358b579a98f8dcc5e1ba6678649543df51f7af5 (patch)
treebb5b6186696c67483d04875f0ffb3d97663ee99c /runtime/exec_utils.h
parent27e688ccbaa6dfc8260e7c2905df98e6b86ec764 (diff)
Make ProcessStat collection more robust.
- Handle the case where start time is 0. - Handle the case where getting uptime failed. - Use 64bit int. (32bit is enough to record a time less than 24 days, but just in case.) Bug: 315061143 Test: m test-art-host-gtest-art_runtime_tests Change-Id: I3ac546f6921b8d6add2491170b5d8f50cc7169c1
Diffstat (limited to 'runtime/exec_utils.h')
-rw-r--r--runtime/exec_utils.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h
index b83722fd62..e09f285961 100644
--- a/runtime/exec_utils.h
+++ b/runtime/exec_utils.h
@@ -19,7 +19,9 @@
#include <time.h>
+#include <cstdint>
#include <functional>
+#include <optional>
#include <string>
#include <vector>
@@ -29,10 +31,10 @@ namespace art {
struct ProcessStat {
// The total wall time, in milliseconds, that the process spent, or 0 if failed to get the value.
- int wall_time_ms = 0;
+ int64_t wall_time_ms = 0;
// The total CPU time, in milliseconds, that the process and any waited-for children spent, or 0
// if failed to get the value.
- int cpu_time_ms = 0;
+ int64_t cpu_time_ms = 0;
};
struct ExecCallbacks {
@@ -105,7 +107,7 @@ class ExecUtils {
// Returns the content of `/proc/<pid>/stat`, or an empty string if failed.
virtual std::string GetProcStat(pid_t pid) const;
- virtual int64_t GetUptimeMs() const;
+ virtual std::optional<int64_t> GetUptimeMs(std::string* error_msg) const;
virtual int64_t GetTicksPerSec() const;