1 #include "dump_utils.hpp" 2 3 #include <phosphor-logging/lg2.hpp> 4 5 namespace phosphor 6 { 7 namespace dump 8 { 9 10 std::string getService(sdbusplus::bus_t& bus, const std::string& path, 11 const std::string& interface) 12 { 13 constexpr auto objectMapperName = "xyz.openbmc_project.ObjectMapper"; 14 constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper"; 15 16 auto method = bus.new_method_call(objectMapperName, objectMapperPath, 17 objectMapperName, "GetObject"); 18 19 method.append(path); 20 method.append(std::vector<std::string>({interface})); 21 22 std::vector<std::pair<std::string, std::vector<std::string>>> response; 23 24 try 25 { 26 auto reply = bus.call(method); 27 reply.read(response); 28 if (response.empty()) 29 { 30 lg2::error( 31 "Error in mapper response for getting service name, PATH: " 32 "{PATH}, INTERFACE: {INTERFACE}", 33 "PATH", path, "INTERFACE", interface); 34 return std::string{}; 35 } 36 } 37 catch (const sdbusplus::exception_t& e) 38 { 39 lg2::error("Error in mapper method call, errormsg: {ERROR}, " 40 "PATH: {PATH}, INTERFACE: {INTERFACE}", 41 "ERROR", e, "PATH", path, "INTERFACE", interface); 42 throw; 43 } 44 return response[0].first; 45 } 46 47 } // namespace dump 48 } // namespace phosphor 49