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/utils.cpp b/utils.cpp
index efb7abd..6498dbd 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -247,6 +247,39 @@
return false;
}
+// Convert vector to hex dump string
+std::vector<std::string> hex_dump(const std::vector<std::uint8_t>& data,
+ const unsigned int data_len)
+{
+ unsigned int dump_length = data.size();
+ if ((data_len > 0) && (data_len < dump_length))
+ {
+ dump_length = data_len;
+ }
+ std::vector<std::string> dumpString;
+ std::string s;
+ for (uint32_t i = 0; i < dump_length; i++)
+ {
+ if (i % 16 == 0)
+ {
+ s += std::format("{:04X}: ", i);
+ }
+ else if (i % 4 == 0)
+ {
+ s += " ";
+ }
+
+ s += std::format("{:02X}", data.at(i));
+
+ if ((i % 16 == 15) || (i == (dump_length - 1)))
+ {
+ dumpString.push_back(s);
+ s.clear();
+ }
+ }
+ return dumpString;
+}
+
} // namespace utils
} // namespace occ
} // namespace open_power