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