Add utility for tracking process CPU usage
Being able to log this sort of information can be helpful for debugging
things when something weird happened on the system.
References: PRO-13362
Change-Id: Ie2847536fdc58279f62c9b7b0208d7fe51a90a5c
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/util/BUILD b/aos/util/BUILD
index 3b96cfd..8d21c47 100644
--- a/aos/util/BUILD
+++ b/aos/util/BUILD
@@ -1,3 +1,5 @@
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+
package(default_visibility = ["//visibility:public"])
cc_library(
@@ -272,6 +274,45 @@
],
)
+flatbuffer_cc_library(
+ name = "process_info_fbs",
+ srcs = ["process_info.fbs"],
+ gen_reflections = True,
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "top",
+ srcs = ["top.cc"],
+ hdrs = ["top.h"],
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ ":process_info_fbs",
+ "//aos/containers:ring_buffer",
+ "//aos/events:event_loop",
+ "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/strings",
+ ],
+)
+
+cc_test(
+ name = "top_test",
+ srcs = ["top_test.cc"],
+ data = [
+ "//aos/events:pingpong_config",
+ ],
+ flaky = True,
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ ":top",
+ "//aos/events:shm_event_loop",
+ "//aos/testing:googletest",
+ "//aos/testing:path",
+ "//aos/testing:tmpdir",
+ ],
+)
+
cc_library(
name = "scoped_pipe",
srcs = ["scoped_pipe.cc"],