From ab21783c59f7bffa1335b30bbf1084d3545c3f1e Mon Sep 17 00:00:00 2001 From: Manoj Takasi <133196374+ManojTakasi@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:50:19 +0530 Subject: [PATCH] Catch all the exceptions when firmware version is not present. (#8505) Signed-off-by: Manoj Takasi Co-authored-by: Manoj Takasi --- .../core/tools/common/XBUtilities.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/runtime_src/core/tools/common/XBUtilities.cpp b/src/runtime_src/core/tools/common/XBUtilities.cpp index 131594e3827..2fe35bbdabc 100755 --- a/src/runtime_src/core/tools/common/XBUtilities.cpp +++ b/src/runtime_src/core/tools/common/XBUtilities.cpp @@ -762,11 +762,17 @@ fill_xrt_versions(const boost::property_tree::ptree& pt_xrt, if (boost::iequals(drv_name, "xclmgmt") && boost::iequals(driver.get("version", "N/A"), "unknown")) output << "WARNING: xclmgmt version is unknown. Is xclmgmt driver loaded? Or is MSD/MPD running?" << std::endl; } - if (!available_devices.empty()) { - const boost::property_tree::ptree& dev = available_devices.begin()->second; - if (dev.get("device_class") == xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::ryzen)) - output << boost::format(" %-20s : %s\n") % "NPU Firmware Version" % available_devices.begin()->second.get("firmware_version"); - else - output << boost::format(" %-20s : %s\n") % "Firmware Version" % available_devices.begin()->second.get("firmware_version"); + + try { + if (!available_devices.empty()) { + const boost::property_tree::ptree& dev = available_devices.begin()->second; + if (dev.get("device_class") == xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::ryzen)) + output << boost::format(" %-20s : %s\n") % "NPU Firmware Version" % available_devices.begin()->second.get("firmware_version"); + else + output << boost::format(" %-20s : %s\n") % "Firmware Version" % available_devices.begin()->second.get("firmware_version"); + } + } + catch (...) { + //no device available } }