From 3674dbc828042e0ac4ad6b58490e5b3a80326924 Mon Sep 17 00:00:00 2001 From: Steffen Persvold Date: Thu, 5 Oct 2023 14:17:19 +0200 Subject: [PATCH] Added exception handling in utils.cpp:get_cpu_bus() Avoid early termination without any message if a PCI handle fails to open. --- src/utils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils.cpp b/src/utils.cpp index 5bfe3318..872c3881 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1098,6 +1098,7 @@ bool get_cpu_bus(uint32 msmDomain, uint32 msmBus, uint32 msmDev, uint32 msmFunc, uint32 busNo = 0x0; //std::cout << "get_cpu_bus: d=" << std::hex << msmDomain << ",b=" << msmBus << ",d=" << msmDev << ",f=" << msmFunc << std::dec << " \n"; + try { PciHandleType h(msmDomain, msmBus, msmDev, msmFunc); h.read32(SPR_MSM_REG_CPUBUSNO_VALID_OFFSET, &cpuBusValid); @@ -1138,6 +1139,11 @@ bool get_cpu_bus(uint32 msmDomain, uint32 msmBus, uint32 msmDev, uint32 msmFunc, cpuPackageId = sadControlCfg & 0xf; return true; + } catch (...) + { + std::cerr << "Warning: unable to enumerate CPU Buses" << std::endl; + return false; + } } #ifdef __linux__