1 #include <sdbusplus/bus.hpp>
2 #include <phosphor-logging/elog-errors.hpp>
3 
4 #include "xyz/openbmc_project/Common/error.hpp"
5 #include "config.h"
6 #include "dump_manager.hpp"
7 #include "dump_internal.hpp"
8 
9 int main(int argc, char* argv[])
10 {
11     using namespace phosphor::logging;
12     using InternalFailure =
13         sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
14 
15     auto bus = sdbusplus::bus::new_default();
16     sd_event* event = nullptr;
17     auto rc = sd_event_default(&event);
18     if (rc < 0)
19     {
20         log<level::ERR>("Error occurred during the sd_event_default",
21                         entry("rc=%d", rc));
22         report<InternalFailure>();
23         return rc;
24     }
25     phosphor::dump::EventPtr eventP{event};
26     event = nullptr;
27 
28     // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager.
29     sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH);
30     bus.request_name(DUMP_BUSNAME);
31 
32     try
33     {
34         phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
35         phosphor::dump::internal::Manager mgr(bus, OBJ_INTERNAL);
36         bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
37         auto rc = sd_event_loop(eventP.get());
38         if (rc < 0)
39         {
40             log<level::ERR>("Error occurred during the sd_event_loop",
41                             entry("rc=%d", rc));
42             elog<InternalFailure>();
43         }
44     }
45     catch (InternalFailure& e)
46     {
47         commit<InternalFailure>();
48         return -1;
49     }
50 
51     return 0;
52 }
53