Add support for collecting data for BMC dumps

When occ-control receives a USR1 signal, it will trigger the code to
collect the following data:
- number of OCC objects created
- for each active OCC: state, role, hwmon path, poll response, and WOF
data

The data will be written in JSON format to a file which can be collected
and added to a dump. (/tmp/occ_control_dump.json)

To force the data collection:
  killall -s SIGUSR1 openpower-occ-control

Change-Id: I7a304f7ce0eb1c9109f630f187adf9c95722652e
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/app.cpp b/app.cpp
index f0929d7..24f24fb 100644
--- a/app.cpp
+++ b/app.cpp
@@ -7,6 +7,8 @@
 
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/lg2.hpp>
+#include <sdeventplus/source/signal.hpp>
+#include <stdplus/signal.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 using namespace sdbusplus::org::open_power::OCC::Device::Error;
@@ -44,6 +46,22 @@
     open_power::occ::Manager mgr(eventP);
     mgr.createPldmHandle();
 
+    try
+    {
+        // Enable SIGUSR1 handling to collect data on dump request
+        stdplus::signal::block(SIGUSR1);
+        sdeventplus::source::Signal sigUsr1(
+            eventP.get(), SIGUSR1,
+            std::bind(&open_power::occ::Manager::collectDumpData, &mgr,
+                      std::placeholders::_1, std::placeholders::_2));
+        sigUsr1.set_floating(true);
+        lg2::info("USR1 signal handler enabled");
+    }
+    catch (const std::exception& e)
+    {
+        lg2::error("Failed to enable SIGUSR1 handler: {ERR}", "ERR", e.what());
+    }
+
     // Claim the bus since all the house keeping is done now
     bus.request_name(OCC_CONTROL_BUSNAME);