Move over to ABSL logging and flags.
Removes gperftools too since that wants gflags.
Here come the fireworks.
Change-Id: I79cb7bcf60f1047fbfa28bfffc21a0fd692e4b1c
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/ipc_lib/signal_stress.cc b/aos/ipc_lib/signal_stress.cc
index b2749af..d5d1323 100644
--- a/aos/ipc_lib/signal_stress.cc
+++ b/aos/ipc_lib/signal_stress.cc
@@ -10,10 +10,12 @@
#include <ratio>
#include <thread>
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "aos/events/epoll.h"
+#include "aos/init.h"
#include "aos/ipc_lib/latency_lib.h"
#include "aos/logging/implementations.h"
#include "aos/realtime.h"
@@ -26,18 +28,18 @@
// To enable function graph:
// echo "function_graph" > current_tracer
-DEFINE_bool(sender, true, "If true, send signals to the other process.");
-DEFINE_int32(other_pid, -1, "PID of other process to ping");
-DEFINE_int32(seconds, 10, "Duration of the test to run");
-DEFINE_int32(
- latency_threshold, 1000,
+ABSL_FLAG(bool, sender, true, "If true, send signals to the other process.");
+ABSL_FLAG(int32_t, other_pid, -1, "PID of other process to ping");
+ABSL_FLAG(int32_t, seconds, 10, "Duration of the test to run");
+ABSL_FLAG(
+ int32_t, latency_threshold, 1000,
"Disable tracing when anything takes more than this many microseoncds");
-DEFINE_int32(core, 7, "Core to pin to");
-DEFINE_int32(sender_priority, 53, "RT priority to send at");
-DEFINE_int32(receiver_priority, 52, "RT priority to receive at");
-DEFINE_int32(timer_priority, 51, "RT priority to spin the timer at");
+ABSL_FLAG(int32_t, core, 7, "Core to pin to");
+ABSL_FLAG(int32_t, sender_priority, 53, "RT priority to send at");
+ABSL_FLAG(int32_t, receiver_priority, 52, "RT priority to receive at");
+ABSL_FLAG(int32_t, timer_priority, 51, "RT priority to spin the timer at");
-DEFINE_bool(log_latency, false, "If true, log the latency");
+ABSL_FLAG(bool, log_latency, false, "If true, log the latency");
const uint32_t kSignalNumber = SIGRTMIN + 1;
const uint32_t kQuitSignalNumber = SIGRTMIN + 2;
@@ -48,7 +50,7 @@
void SenderThread() {
const monotonic_clock::time_point end_time =
- monotonic_clock::now() + chrono::seconds(FLAGS_seconds);
+ monotonic_clock::now() + chrono::seconds(absl::GetFlag(FLAGS_seconds));
// Standard mersenne_twister_engine seeded with 0
::std::mt19937 generator(0);
@@ -56,13 +58,13 @@
::std::uniform_int_distribution<> distribution(1000, 15000);
int pid = getpid();
- if (FLAGS_other_pid != -1) {
- pid = FLAGS_other_pid;
+ if (absl::GetFlag(FLAGS_other_pid) != -1) {
+ pid = absl::GetFlag(FLAGS_other_pid);
}
AOS_LOG(INFO, "Current PID: %d\n", pid);
- SetCurrentThreadAffinity(MakeCpusetFromCpus({FLAGS_core}));
- SetCurrentThreadRealtimePriority(FLAGS_sender_priority);
+ SetCurrentThreadAffinity(MakeCpusetFromCpus({absl::GetFlag(FLAGS_core)}));
+ SetCurrentThreadRealtimePriority(absl::GetFlag(FLAGS_sender_priority));
while (true) {
const monotonic_clock::time_point wakeup_time =
monotonic_clock::now() + chrono::microseconds(distribution(generator));
@@ -137,21 +139,22 @@
max_wakeup_latency = ::std::max(wakeup_latency, max_wakeup_latency);
- if (wakeup_latency > chrono::microseconds(FLAGS_latency_threshold)) {
+ if (wakeup_latency >
+ chrono::microseconds(absl::GetFlag(FLAGS_latency_threshold))) {
t.Stop();
AOS_LOG(INFO, "Stopped tracing, latency %" PRId64 "\n",
static_cast<int64_t>(wakeup_latency.count()));
}
- if (FLAGS_log_latency) {
+ if (absl::GetFlag(FLAGS_log_latency)) {
AOS_LOG(INFO, "signo: %d, sending pid: %d, dt: %8d.%03d\n", si.ssi_signo,
si.ssi_pid, static_cast<int>(wakeup_latency_int64 / 1000),
static_cast<int>(wakeup_latency_int64 % 1000));
}
});
- SetCurrentThreadAffinity(MakeCpusetFromCpus({FLAGS_core}));
- SetCurrentThreadRealtimePriority(FLAGS_receiver_priority);
+ SetCurrentThreadAffinity(MakeCpusetFromCpus({absl::GetFlag(FLAGS_core)}));
+ SetCurrentThreadRealtimePriority(absl::GetFlag(FLAGS_receiver_priority));
epoll.Run();
UnsetCurrentThreadRealtimePriority();
epoll.DeleteFd(signalfd_fd);
@@ -178,8 +181,9 @@
AOS_LOG(INFO, "Main!\n");
::std::thread t([]() {
- TimerThread(monotonic_clock::now() + chrono::seconds(FLAGS_seconds),
- FLAGS_timer_priority);
+ TimerThread(
+ monotonic_clock::now() + chrono::seconds(absl::GetFlag(FLAGS_seconds)),
+ absl::GetFlag(FLAGS_timer_priority));
});
::std::thread st([]() { SenderThread(); });
@@ -194,7 +198,7 @@
} // namespace aos
int main(int argc, char **argv) {
- ::gflags::ParseCommandLineFlags(&argc, &argv, true);
+ aos::InitGoogle(&argc, &argv);
return ::aos::Main(argc, argv);
}