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