Improve PyPerf sample handling and output (#2260)
* Add common interface for PyPerf sample handling
* Better printing for enum values
diff --git a/examples/cpp/pyperf/PyPerfDefaultPrinter.h b/examples/cpp/pyperf/PyPerfDefaultPrinter.h
new file mode 100644
index 0000000..89c8153
--- /dev/null
+++ b/examples/cpp/pyperf/PyPerfDefaultPrinter.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) Facebook, Inc.
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ */
+
+#pragma once
+
+#include "PyPerfSampleProcessor.h"
+
+namespace ebpf {
+namespace pyperf {
+
+class PyPerfDefaultPrinter : public PyPerfSampleProcessor {
+ public:
+ PyPerfDefaultPrinter(bool showGILState, bool showThreadState,
+ bool showPthreadIDState)
+ : showGILState_(showGILState),
+ showThreadState_(showThreadState),
+ showPthreadIDState_(showPthreadIDState) {}
+
+ void processSamples(const std::vector<PyPerfSample>& samples,
+ PyPerfUtil* util) override;
+
+ private:
+ bool showGILState_;
+ bool showThreadState_;
+ bool showPthreadIDState_;
+};
+
+} // namespace pyperf
+} // namespace ebpf