#include "dump_utils.hpp" #include namespace phosphor { namespace dump { std::string getService(sdbusplus::bus::bus& bus, const std::string& path, const std::string& interface) { constexpr auto objectMapperName = "xyz.openbmc_project.ObjectMapper"; constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper"; using namespace phosphor::logging; auto method = bus.new_method_call(objectMapperName, objectMapperPath, objectMapperName, "GetObject"); method.append(path); method.append(std::vector({interface})); std::vector>> response; try { auto reply = bus.call(method); reply.read(response); if (response.empty()) { log("Error in mapper response for getting service name", entry("PATH=%s", path.c_str()), entry("INTERFACE=%s", interface.c_str())); return std::string{}; } } catch (const sdbusplus::exception::SdBusError& e) { log("Error in mapper method call", entry("ERROR=%s", e.what()), entry("PATH=%s", path.c_str()), entry("INTERFACE=%s", interface.c_str())); return std::string{}; } return response[0].first; } } // namespace dump } // namespace phosphor