blob: 7294cb2b94c496b3cd7fd378f34192131e2f20b7 [file] [log] [blame]
Jayanth Othayothd02153c2017-07-02 22:29:42 -05001#include "config.h"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05002
Jayanth Othayothd02153c2017-07-02 22:29:42 -05003#include "core_manager.hpp"
4#include "watch.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05005#include "xyz/openbmc_project/Common/error.hpp"
6
George Liu858fbb22021-07-01 12:25:44 +08007#include <fmt/core.h>
8
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05009#include <phosphor-logging/elog-errors.hpp>
10#include <sdbusplus/bus.hpp>
Jayanth Othayothd02153c2017-07-02 22:29:42 -050011
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050012int main()
Jayanth Othayothd02153c2017-07-02 22:29:42 -050013{
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 Liu858fbb22021-07-01 12:25:44 +080023 log<level::ERR>(
24 fmt::format("Error occurred during the sd_event_default, rc({})",
25 rc)
26 .c_str());
Jayanth Othayothd02153c2017-07-02 22:29:42 -050027 report<InternalFailure>();
28 return -1;
29 }
30 phosphor::dump::EventPtr eventP{event};
31 event = nullptr;
32
33 try
34 {
Jayanth Othayothbf6ec602017-08-28 01:48:49 -050035 phosphor::dump::core::Manager manager(eventP);
Jayanth Othayothd02153c2017-07-02 22:29:42 -050036
37 auto rc = sd_event_loop(eventP.get());
38 if (rc < 0)
39 {
George Liu858fbb22021-07-01 12:25:44 +080040 log<level::ERR>(
41 fmt::format("Error occurred during the sd_event_loop, rc({})",
42 rc)
43 .c_str());
Jayanth Othayothd02153c2017-07-02 22:29:42 -050044 elog<InternalFailure>();
45 }
46 }
47
Patrick Williams9d2d7222021-10-06 12:44:44 -050048 catch (const InternalFailure& e)
Jayanth Othayothd02153c2017-07-02 22:29:42 -050049 {
50 commit<InternalFailure>();
51 return -1;
52 }
53
54 return 0;
55}