xref: /openbmc/phosphor-debug-collector/core_manager_main.cpp (revision d73a663c79943ae97194347ca1ee3f8d454f6bfa)
1 #include "config.h"
2 
3 #include "core_manager.hpp"
4 #include "watch.hpp"
5 #include "xyz/openbmc_project/Common/error.hpp"
6 
7 #include <phosphor-logging/elog-errors.hpp>
8 #include <phosphor-logging/lg2.hpp>
9 #include <sdbusplus/bus.hpp>
10 
11 int main()
12 {
13     using namespace phosphor::logging;
14     using InternalFailure =
15         sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
16 
17     auto bus = sdbusplus::bus::new_default();
18     sd_event* event = nullptr;
19     auto rc = sd_event_default(&event);
20     if (rc < 0)
21     {
22         lg2::error("Error occurred during the sd_event_default, rc: {RC}", "RC",
23                    rc);
24         report<InternalFailure>();
25         return -1;
26     }
27     phosphor::dump::EventPtr eventP{event};
28     event = nullptr;
29 
30     try
31     {
32         phosphor::dump::core::Manager manager(eventP);
33 
34         auto rc = sd_event_loop(eventP.get());
35         if (rc < 0)
36         {
37             lg2::error("Error occurred during the sd_event_loop, rc: {RC}",
38                        "RC", rc);
39             elog<InternalFailure>();
40         }
41     }
42 
43     catch (const InternalFailure& e)
44     {
45         commit<InternalFailure>();
46         return -1;
47     }
48 
49     return 0;
50 }
51