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