Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 1 | #include "config.h" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 2 | |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 3 | #include "core_manager.hpp" |
| 4 | #include "watch.hpp" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Common/error.hpp" |
| 6 | |
George Liu | 858fbb2 | 2021-07-01 12:25:44 +0800 | [diff] [blame] | 7 | #include <fmt/core.h> |
| 8 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 9 | #include <phosphor-logging/elog-errors.hpp> |
| 10 | #include <sdbusplus/bus.hpp> |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 11 | |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 12 | int main() |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 13 | { |
| 14 | using namespace phosphor::logging; |
| 15 | using InternalFailure = |
| 16 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 17 | |
| 18 | auto bus = sdbusplus::bus::new_default(); |
| 19 | sd_event* event = nullptr; |
| 20 | auto rc = sd_event_default(&event); |
| 21 | if (rc < 0) |
| 22 | { |
George Liu | 858fbb2 | 2021-07-01 12:25:44 +0800 | [diff] [blame] | 23 | log<level::ERR>( |
| 24 | fmt::format("Error occurred during the sd_event_default, rc({})", |
| 25 | rc) |
| 26 | .c_str()); |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 27 | report<InternalFailure>(); |
| 28 | return -1; |
| 29 | } |
| 30 | phosphor::dump::EventPtr eventP{event}; |
| 31 | event = nullptr; |
| 32 | |
| 33 | try |
| 34 | { |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 35 | phosphor::dump::core::Manager manager(eventP); |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 36 | |
| 37 | auto rc = sd_event_loop(eventP.get()); |
| 38 | if (rc < 0) |
| 39 | { |
George Liu | 858fbb2 | 2021-07-01 12:25:44 +0800 | [diff] [blame] | 40 | log<level::ERR>( |
| 41 | fmt::format("Error occurred during the sd_event_loop, rc({})", |
| 42 | rc) |
| 43 | .c_str()); |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 44 | elog<InternalFailure>(); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | catch (InternalFailure& e) |
| 49 | { |
| 50 | commit<InternalFailure>(); |
| 51 | return -1; |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |