plugin for LPC timeout callouts

Change-Id: I39fed3c1ba5a16283c33c5072479f24c9c69a208
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/util/meson.build b/util/meson.build
index d72f515..4d99e51 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -4,6 +4,7 @@
     'dbus.cpp',
     'ffdc_file.cpp',
     'pdbg.cpp',
+    'pdbg-no-sim.cpp',
     'temporary_file.cpp',
 )
 
diff --git a/util/pdbg-no-sim.cpp b/util/pdbg-no-sim.cpp
new file mode 100644
index 0000000..8237052
--- /dev/null
+++ b/util/pdbg-no-sim.cpp
@@ -0,0 +1,49 @@
+//------------------------------------------------------------------------------
+// IMPORTANT:
+// This file will NOT be built in CI test and should be used for any functions
+// that require addition support to simulate in CI test. Any functions that will
+// work out-of-the-box in CI test with use of the fake device tree should be put
+// in `pdbg.cpp`.
+//------------------------------------------------------------------------------
+
+#include <assert.h>
+
+extern "C"
+{
+#include <libpdbg_sbe.h>
+}
+
+#include <util/pdbg.hpp>
+#include <util/trace.hpp>
+
+using namespace analyzer;
+
+namespace util
+{
+
+namespace pdbg
+{
+
+//------------------------------------------------------------------------------
+
+bool queryLpcTimeout(pdbg_target* target)
+{
+    // Must be a processor target.
+    assert(TYPE_PROC == getTrgtType(target));
+
+    uint32_t result = 0;
+    if (0 != sbe_lpc_timeout(util::pdbg::getPibTrgt(target), &result))
+    {
+        trace::err("sbe_lpc_timeout() failed: target=%s", getPath(target));
+        result = 0; // just in case
+    }
+
+    // 0 if no timeout, 1 if LPC timeout occurred.
+    return (0 != result);
+}
+
+//------------------------------------------------------------------------------
+
+} // namespace pdbg
+
+} // namespace util
diff --git a/util/pdbg.cpp b/util/pdbg.cpp
index c8c8a4f..a69d079 100644
--- a/util/pdbg.cpp
+++ b/util/pdbg.cpp
@@ -1,3 +1,10 @@
+//------------------------------------------------------------------------------
+// IMPORTANT:
+// This file will be built in CI test and should work out-of-the-box in CI test
+// with use of the fake device tree. Any functions that require addition support
+// to simulate in CI test should be put in `pdbg_no_sim.cpp`.
+//------------------------------------------------------------------------------
+
 #include <assert.h>
 #include <config.h>
 
diff --git a/util/pdbg.hpp b/util/pdbg.hpp
index 1dea6ae..b8af56f 100644
--- a/util/pdbg.hpp
+++ b/util/pdbg.hpp
@@ -145,6 +145,12 @@
  */
 std::vector<uint8_t> getPhysBinPath(pdbg_target* trgt);
 
+/**
+ * @brief  Uses an SBE chip-op to query if there has been an LPC timeout.
+ * @return True, if there was an LPC timeout. False, otherwise.
+ */
+bool queryLpcTimeout(pdbg_target* target);
+
 } // namespace pdbg
 
 } // namespace util