SF: Clean up dumpsys for Scheduler
Split dump into three flags corresponding to Scheduler, EventThread, and
VsyncReactor. Expand utils::Dumper to automate more types.
Bug: 241285191
Test: dumpsys SurfaceFlinger --scheduler
Test: dumpsys SurfaceFlinger --events
Test: dumpsys SurfaceFlinger --vsync
Change-Id: I17b3b772cd164305e2fe0239638b1a08236c12a2
diff --git a/services/surfaceflinger/Utils/Dumper.h b/services/surfaceflinger/Utils/Dumper.h
index 39642ff..ee94217 100644
--- a/services/surfaceflinger/Utils/Dumper.h
+++ b/services/surfaceflinger/Utils/Dumper.h
@@ -16,10 +16,11 @@
#pragma once
-#include <optional>
#include <string>
#include <string_view>
+#include <ftl/optional.h>
+
namespace android::utils {
// Dumps variables by appending their name and value to the output string. A variable is formatted
@@ -44,16 +45,48 @@
eol();
}
+ void dump(std::string_view name, const std::string& value) {
+ dump(name, static_cast<const std::string_view&>(value));
+ }
+
void dump(std::string_view name, bool value) {
using namespace std::string_view_literals;
dump(name, value ? "true"sv : "false"sv);
}
template <typename T>
- void dump(std::string_view name, const std::optional<T>& value) {
- using namespace std::string_view_literals;
+ void dump(std::string_view name, const std::optional<T>& opt) {
+ if (opt) {
+ dump(name, *opt);
+ } else {
+ using namespace std::string_view_literals;
+ dump(name, "nullopt"sv);
+ }
+ }
+
+ template <typename T>
+ void dump(std::string_view name, const ftl::Optional<T>& opt) {
+ dump(name, static_cast<const std::optional<T>&>(opt));
+ }
+
+ template <typename T, typename... Ts>
+ void dump(std::string_view name, const T& value, const Ts&... rest) {
+ std::string string;
+
+ constexpr bool kIsTuple = sizeof...(Ts) > 0;
+ if constexpr (kIsTuple) {
+ string += '{';
+ }
+
using std::to_string;
- dump(name, value ? to_string(*value) : "nullopt"sv);
+ string += to_string(value);
+
+ if constexpr (kIsTuple) {
+ string += ((", " + to_string(rest)) + ...);
+ string += '}';
+ }
+
+ dump(name, string);
}
struct Indent {