Apply resolutions based on analysis type

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I85837e4256d29b88289c377cef99345418b4044c
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index b569852..3be26bc 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -128,24 +128,47 @@
     libhei::Signature rootCause{};
     bool attnFound = filterRootCause(isoData, rootCause);
 
-    if (!attnFound)
+    // If a root cause attention was found, or if this was a system checkstop,
+    // generate a PEL.
+    if (attnFound || AnalysisType::SYSTEM_CHECKSTOP == i_type)
     {
-        // It is possible for TI handling, or manually initiated analysis via
-        // the command line, that there will not be an active attention. In
-        // which case, we will do nothing and let the caller of this function
-        // determine if this is the expected behavior.
-        trace::inf("No active attentions found");
-    }
-    else
-    {
-        trace::inf("Root cause attention: %s 0x%0" PRIx32 " %s",
-                   util::pdbg::getPath(rootCause.getChip()),
-                   rootCause.toUint32(), __attn(rootCause.getAttnType()));
+        if (attnFound)
+        {
+            trace::inf("Root cause attention: %s 0x%0" PRIx32 " %s",
+                       util::pdbg::getPath(rootCause.getChip()),
+                       rootCause.toUint32(), __attn(rootCause.getAttnType()));
+        }
+        else
+        {
+            // This is bad. Analysis should have found a root cause attention
+            // for a system checkstop. Issues could range from code bugs to SCOM
+            // errors. Regardless, generate a PEL with FFDC to assist with
+            // debug.
+            trace::err("System checkstop with no root cause attention");
+            rootCause = libhei::Signature{}; // just in case
+        }
 
-        // Resolve any service actions required by the root cause.
-        RasDataParser rasData{};
+        // Start building the service data.
         ServiceData servData{rootCause, isoData.queryCheckstop()};
-        rasData.getResolution(rootCause)->resolve(servData);
+
+        // Apply any service actions, if needed. Note that there are no
+        // resolutions for manual analysis.
+        if (AnalysisType::MANUAL != i_type)
+        {
+            if (attnFound)
+            {
+                // Resolve the root cause attention.
+                RasDataParser rasData{};
+                rasData.getResolution(rootCause)->resolve(servData);
+            }
+            else
+            {
+                // Analysis failed so apply the Level 2 Support resolution.
+                ProcedureCalloutResolution res{callout::Procedure::NEXTLVL,
+                                               callout::Priority::HIGH};
+                res.resolve(servData);
+            }
+        }
 
         // Create and commit a PEL.
         o_plid = createPel(isoData, servData);
@@ -167,6 +190,14 @@
             o_dump.dumpType = attn::DumpType::Hardware;
         }
     }
+    else
+    {
+        // It is possible for TI handling, or manually initiated analysis via
+        // the command line, that there will not be an active attention. In
+        // which case, we will do nothing and let the caller of this function
+        // determine if this is the expected behavior.
+        trace::inf("No active attentions found");
+    }
 
     // All done, clean up the isolator.
     trace::inf("Uninitializing isolator...");