Zane Shelley | 65fefb2 | 2021-10-18 15:35:26 -0500 | [diff] [blame^] | 1 | #include <assert.h> |
| 2 | |
| 3 | #include <hei_main.hpp> |
| 4 | |
| 5 | #include <algorithm> |
| 6 | #include <limits> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace analyzer |
| 10 | { |
| 11 | |
| 12 | //------------------------------------------------------------------------------ |
| 13 | |
| 14 | bool filterRootCause(const libhei::IsolationData& i_isoData, |
| 15 | libhei::Signature& o_rootCause) |
| 16 | { |
| 17 | // We'll need to make a copy of the list so that the original list is |
| 18 | // maintained for the log. |
| 19 | std::vector<libhei::Signature> list{i_isoData.getSignatureList()}; |
| 20 | |
| 21 | // START WORKAROUND |
| 22 | // TODO: Filtering should be data driven. Until that support is available, |
| 23 | // use the following isolation rules. |
| 24 | |
| 25 | // Special and host attentions are not supported by this user application. |
| 26 | auto itr = std::remove_if(list.begin(), list.end(), [&](const auto& t) { |
| 27 | return (libhei::ATTN_TYPE_SP_ATTN == t.getAttnType() || |
| 28 | libhei::ATTN_TYPE_HOST_ATTN == t.getAttnType()); |
| 29 | }); |
| 30 | list.resize(std::distance(list.begin(), itr)); |
| 31 | |
| 32 | // TODO: This is a rudimentary filter that first looks for any recoverable |
| 33 | // attention, then any unit checkstop, and then any system checkstop. |
| 34 | // This is built on the premise that recoverable errors could be the |
| 35 | // root cause of an system checkstop attentions. Fortunately, we |
| 36 | // just need to sort the list by the greater attention type value. |
| 37 | std::sort(list.begin(), list.end(), [&](const auto& a, const auto& b) { |
| 38 | return a.getAttnType() > b.getAttnType(); |
| 39 | }); |
| 40 | if (!list.empty()) |
| 41 | { |
| 42 | // The entry at the front of the list will be the root cause. |
| 43 | o_rootCause = list.front(); |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | // END WORKAROUND |
| 48 | |
| 49 | return false; // default, no active attentions found. |
| 50 | } |
| 51 | |
| 52 | //------------------------------------------------------------------------------ |
| 53 | |
| 54 | } // namespace analyzer |