Remove unused directories and files in video_in_hal
[staging/basesystem.git] / systemservice / system_manager / server / src / ss_system_manager_error_event.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SystemManager
19 /// \brief    This file provides support for IAT error event logging.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <fcntl.h>
25 #include <dirent.h>
26 #include <sys/mman.h>
27 #include <sys/procfs.h>
28 #include <libgen.h>
29 #include <spawn.h>
30 #include <errno.h>
31 #include <sys/timeb.h>
32 #include <system_service/ss_system_manager_notifications.h>
33 #include <native_service/frameworkunified_framework_if.h>
34 #include <native_service/frameworkunified_multithreading.h>
35 #include <system_service/ss_services.h>
36 #include <system_service/ss_client_names.h>
37 #include <system_service/ss_power_service_if.h>
38 #include <processlauncher/ProcessLauncher_if.h>
39 #include <processlauncher/ss_sm_process_launcher_protocol.h>
40 #include <processlauncher/ss_sm_process_launcher.h>
41 #include <heartbeat/ss_hb_if.h>
42 #include <system_service/ss_heartbeat_service_protocol.h>
43 #include <system_service/ss_power_service_notifications.h>
44 #include <system_service/ss_power_service_protocol.h>
45 #include <stub/ss_diag.h>
46 #include <system_service/ss_test_clients.h>
47 #include <native_service/ns_np_service_protocol.h>
48 #include <native_service/frameworkunified_application.h>
49
50 #include <system_service/ss_sm_thread_names.h>
51 #include <system_service/ss_templates.h>
52 #include <native_service/ns_plogger_if.h>
53 #include <native_service/frameworkunified_thread_priority.h>
54 #include <native_service/ns_np_service_nor_persistence.h>
55 #include <boost/bind.hpp>
56 #include <string>
57 #include "ss_system_manager.h"
58 #include "ss_sm_systemmanagerlog.h"
59 #include "ss_sm_default_paths.h"
60 #include "ss_sm_version.h"
61
62 template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)>
63   EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) {  // LCOV_EXCL_START 6: Can not set condition
64   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
65   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
66   C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
67   if (pObj) {
68     l_eStatus = (pObj->*M)(hApp);
69   }
70   return l_eStatus;
71 }
72 // LCOV_EXCL_STOP
73
74 //******************************************************************************
75 void Init_EErrorEventReset_StrMap(std::map<EErrorEventResetType, SS_String> & m_strMap) {  // NOLINT
76   MAP_ENTRY(m_strMap, eErrorEventResetTypeNone);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
77   MAP_ENTRY(m_strMap, eErrorEventResetTypeHard);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
78 }
79 class EnumStringMap<EErrorEventResetType, Init_EErrorEventReset_StrMap> m_oEErrorEventResetTypeMap;
80 SS_String GetStr(EErrorEventResetType f_enum) {  // LCOV_EXCL_START 6: Can not set condition
81   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
82   return m_oEErrorEventResetTypeMap.GetStr(f_enum);
83 }
84 // LCOV_EXCL_STOP
85
86 ///////////////////////////////////////////////////////////////////////////////
87 /// \ingroup ErrorEventInit
88 ///          This function initializes the error event handling subsystem.
89 ///          This function MUST be called by System Manager initialization.
90 ///
91 /// \param HANDLE  f_hApp  AGL FW application handle.
92 ///
93 /// \return Status
94 ///         EFrameworkunifiedStatus - success or error
95 ///////////////////////////////////////////////////////////////////////////////
96 EFrameworkunifiedStatus CSystemManager::ErrorEventInit(HANDLE f_hApp) {
97   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
98   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
99   Timer *l_pTimer;
100
101   m_isPrevErrEventCompleted = TRUE;
102   m_errorEventResult = eFrameworkunifiedStatusOK;
103   m_errorEventQueueLocked = FALSE;
104   m_errorEventCurrentIter = m_errorEventQueue.end();
105
106   l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ];
107   l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_LOGGER_START_REQ,
108       boost::bind(&CSystemManager::OnErrorEventLoggerStartRequestTimeout, this, _1));  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
109
110   l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN];
111   l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_DEBUG_DUMP_RSPN,
112       boost::bind(&CSystemManager::OnDebugDumpCompleteTimeout, this, _1));  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
113
114   l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN];
115   l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_BOOT_MICRO_LOG_RSPN,
116       boost::bind(&CSystemManager::OnErrorEventBootMicroLogResponseTimeout, this, _1));  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
117
118   l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_CORE_FILE_POLL];
119   l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_CORE_FILE_POLL,
120       boost::bind(&CSystemManager::OnErrorEventCoreFilePollTimeout, this, _1));  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
121
122   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
123   return (l_eStatus);
124 }
125
126 ///////////////////////////////////////////////////////////////////////////////
127 /// \ingroup ErrorEventEnqueue
128 /// Conditional queue error events for processing by the error event state
129 /// machine.
130 ///
131 /// \param f_hApp               Handle to AGL application.
132 ///
133 /// \param f_eventType          Error event type.
134 ///
135 /// \param f_moduleQueueName    Error event trigger module queue name.
136 ///
137 /// \param f_resetType          Error event reset type (none, hard).
138 ///
139 /// \param f_loggingInfo        Logging information if applicable (optional).
140 ///
141 /// \return EFrameworkunifiedStatus
142 /// Success ==> eFrameworkunifiedStatusOK
143 /// Failure ==> Other values
144 ///////////////////////////////////////////////////////////////////////////////
145 EFrameworkunifiedStatus CSystemManager::ErrorEventEnqueue(HANDLE f_hApp,
146         EErrorEventType f_eventType, std::string &f_moduleQueueName,
147         EErrorEventResetType f_resetType, const SMLoggingInfo &f_loggingInfo) {
148   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
149   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
150   ERROR_EVENT_INFO l_errorEventInfo;
151   ERROR_EVENT_QUEUE_ITER l_errorEventIter;
152   ERROR_EVENT_QUEUE_RET l_retVal;
153   BOOL isErrorReset = FALSE;
154
155   if (eErrorEventResetTypeHard == f_resetType) {
156     // Forced reset if shutdown process is not completed after Reboot requesting
157     m_GroupLaunchTimer->StartTimer(
158         m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR],
159         SM_SHUTDOWN_COMPLETE_MONITOR_TIMEOUT, 0, 0, 0);
160
161       switch (f_loggingInfo.resetReason) {
162       case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
163       case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
164         isErrorReset = TRUE;
165         break;
166       default:
167         break;
168       }
169     // LCOV_EXCL_START 6:This variable cannot be modified by external API
170     if ((m_ResetCount > SS_SM_ERR_NAVI_RESET_LIMIT) && isErrorReset) {
171     // LCOV_EXCL_BR_STOP
172       // LCOV_EXCL_START 6:This variable cannot be modified by external API (evaluated only initial value)
173       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
174       fprintf(stderr,
175           "SS_SysManager/%s:will NAVIDET as continuous error(%d) \n", __FUNCTION__, m_ResetCount);
176       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "will NAVIDET as continuous error(%d)", m_ResetCount);
177       m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager, &CSystemManager::perform_force_reset>);
178       // LCOV_EXCL_STOP
179     }
180   }
181
182   if (TRUE == m_errorEventQueueLocked) {
183     l_eStatus = eFrameworkunifiedStatusAccessError;
184     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
185         " Warning. The Error Event Queue has been locked. No further items may be enqueued. System reset pending.");  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
186   } else {
187     GetTimeStamp(l_errorEventInfo.m_eventEnqueueTimeStamp);
188
189     l_errorEventInfo.m_moduleQueueName = f_moduleQueueName;
190     l_errorEventInfo.m_eventType = f_eventType;
191     l_errorEventInfo.m_errorEventResetType = f_resetType;
192     l_errorEventInfo.m_loggingInfo = f_loggingInfo;
193     l_errorEventInfo.m_prio = eErrorEventPrioDefault;  // Make Prios of all ErrorEvent first-win as default
194                               // It needs to add eErrorEventPrioxxx properly if design modification about priority required
195
196     if (eErrorEventResetTypeNone != f_resetType) {
197       FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " System will reset after logging");
198     }
199
200     l_retVal = m_errorEventQueue.insert(l_errorEventInfo);
201     if (FALSE == l_retVal.second) {
202       std::string l_errorEventName = GetStr(l_errorEventInfo.m_eventType);
203       TEXT(__FUNCTION__,  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
204           " ERROR EVENT: %s is already queued or is in progress. Event dropped.",  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
205           l_errorEventName.c_str());  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
206     }
207
208     l_eStatus = ErrorEventProcessNext(f_hApp);
209     LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
210   }
211
212   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
213   return (l_eStatus);
214 }
215
216 ///////////////////////////////////////////////////////////////////////////////
217 /// \ingroup PerformResetAfterLogging
218 /// perform CPU reset after logging complete
219 ///
220 /// \param f_hApp             Handle to AGL application.
221 ///        f_eCpuResetReason  CPU reset reason
222 ///        f_messageStr       Error message string
223 ///
224 /// \return EFrameworkunifiedStatus
225 /// Success ==> eFrameworkunifiedStatusOK
226 /// Failure ==> Other values
227 ///
228 ///
229 ///////////////////////////////////////////////////////////////////////////////
230 EFrameworkunifiedStatus CSystemManager::PerformResetAfterLogging(HANDLE f_hApp,
231         ESMCpuResetReason f_eCpuResetReason, std::string f_messageStr) {
232     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
233     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
234
235     l_eStatus = PerformCpuReset(f_hApp, f_eCpuResetReason, f_messageStr);
236     LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformCpuReset()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
237     // LCOV_EXCL_BR_START 200: Can not satisfy the condition for calling from caller
238     if (eFrameworkunifiedStatusOK != l_eStatus) {
239     // LCOV_EXCL_BR_STOP
240       // LCOV_EXCL_START 200: Can not satisfy the condition for calling from caller
241       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
242       SS_ASERT_LOG(0, "PerformCpuReset() : %d", l_eStatus);
243       // Erasing ErrorEvent only if resetting process is failed
244       m_errorEventQueue.erase(m_errorEventCurrentIter);  // Erase last processed event.
245       // LCOV_EXCL_STOP
246     } else {
247       m_errorEventQueueLocked = TRUE;  // Permanent lock until post reset.
248       m_errorEventQueue.clear();  // Drop queued events.
249       SendDeferMsg(f_hApp);
250     }
251
252     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
253     return (l_eStatus);
254 }
255
256 ///////////////////////////////////////////////////////////////////////////////
257 /// \ingroup ErrorEventProcessNext
258 /// Process the next error event from error event queue.
259 ///
260 /// \param f_hApp  Handle to AGL application.
261 ///
262 /// \return EFrameworkunifiedStatus
263 /// Success ==> eFrameworkunifiedStatusOK
264 /// Failure ==> Other values
265 ///
266 /// \Notes (1) Removal from the queue occurs AFTER the entry has been processed
267 ///            AND just before the NEXT entry is to be obtained.  Therefore,
268 ///            the first item enqueued MUST not be removed since it has not
269 ///            been processed.  This is ensured by setting the iterator to END
270 ///            during module initialization. After processing the first event,
271 ///            the iterator will no longer be END until all events have been
272 ///            processed.
273 ///////////////////////////////////////////////////////////////////////////////
274 EFrameworkunifiedStatus CSystemManager::ErrorEventProcessNext(HANDLE f_hApp) {
275   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
276   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
277   ERROR_EVENT_QUEUE_ITER l_errorEventIter;
278   SMErrorEventNtfData l_errorEventNtfData;
279
280   if (TRUE == m_isPrevErrEventCompleted) {  // Remove last completed item from front of queue.
281     // See Note #1.
282     if ((0 != m_errorEventQueue.size()) &&
283         (m_errorEventQueue.end() != m_errorEventCurrentIter)) {
284       // Completed logging by ErrorEvent
285       switch (m_errorEventCurrentIter->m_errorEventResetType) {
286       case eErrorEventResetTypeNone:
287         switch (m_errorEventCurrentIter->m_eventType) {
288         case eErrorEventTypeInterfaceunifiedEmmcLogs:
289         case eErrorEventTypeUserInvokedClearLogs:
290           if (eFrameworkunifiedStatusOK == m_errorEventResult) {
291             if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, 0)) {
292               // Logging only.
293               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
294                       "Could not reset AGL_ERRLOG_COUNTER");
295             }
296           }
297           break;
298         default:
299           break;
300         }
301
302         if (eErrorEventTypeInterfaceunifiedEmmcLogs == m_errorEventCurrentIter->m_eventType) {
303           HANDLE hSession = FrameworkunifiedMcOpenSender(f_hApp,
304               m_errorEventCurrentIter->m_moduleQueueName.c_str());
305
306           if (hSession == NULL) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
307             // LCOV_EXCL_START 4: NSFW error case
308             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
309             SS_ASERT(0);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
310             // LCOV_EXCL_STOP
311           } else {
312             if (eFrameworkunifiedStatusOK  // LCOV_EXCL_BR_LINE 4: NSFW error case
313                 != FrameworkunifiedSendMsg(hSession,
314                     SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_RSPN,
315                     sizeof(m_errorEventResult),
316                     &m_errorEventResult)) {
317               // LCOV_EXCL_START 4: NSFW error case
318               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
319               SS_ASERT(0);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
320               // LCOV_EXCL_STOP
321             }
322             if (eFrameworkunifiedStatusOK != FrameworkunifiedMcClose(hSession)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
323               // LCOV_EXCL_START 4: NSFW error case
324               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
325               SS_ASERT(0);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
326               // LCOV_EXCL_STOP
327             }
328           }
329         }
330         m_errorEventQueue.erase(m_errorEventCurrentIter);  // Erase last processed event.
331         break;
332       case eErrorEventResetTypeHard:
333         TEXT(__FUNCTION__, "ERROR EVENT: Hard reset required for previously processed error event."  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
334             "Initiating reset and flushing logging queue.");  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
335
336         if (eFrameworkunifiedStatusOK != m_errorEventResult) {
337           // Logging at next launching by setting L to NaviDet if logging failed before rebooting
338           fprintf(stderr,
339               "SS_SysManager/%s:will NAVIDET as LOG save failed\n", __FUNCTION__);
340           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
341               "will NAVIDET as LOG save failed");
342           m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager,
343               &CSystemManager::perform_force_reset>);
344         }
345
346         if ((m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR) ||
347             (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_GENERIC_ERR) ||
348             (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_DSP_ERR) ||
349             (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET)) {
350           BOOL l_user_reset = FALSE;
351           if (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET) {
352             l_user_reset = TRUE;
353           }
354           m_ResetFactor = GetResetFactor(m_errorEventCurrentIter->m_moduleQueueName.c_str(), l_user_reset);
355         }
356
357         l_eStatus = PerformResetAfterLogging(f_hApp,
358             m_errorEventCurrentIter->m_loggingInfo.resetReason,
359             m_errorEventCurrentIter->m_loggingInfo.messageStr);  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
360         LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus,  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
361             "PerformResetAfterLogging()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
362
363         break;
364       // LCOV_EXCL_START 6:Can not satisfy condition to branch
365       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
366       default:
367         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
368             " Error. Unknown reset type encountered: 0x%X/%d. No action taken.",
369             m_errorEventCurrentIter->m_errorEventResetType,
370             m_errorEventCurrentIter->m_errorEventResetType);
371         break;
372       // LCOV_EXCL_STOP
373       }
374     }
375
376     // Check if a new work item exists.
377     if (0 != m_errorEventQueue.size()) {
378       // ErrorEvent startup process
379       m_errorEventCurrentIter = m_errorEventQueue.begin();
380
381       l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
382
383       if (eErrorEventResetTypeHard == m_errorEventCurrentIter->m_errorEventResetType) {
384         l_errorEventNtfData.isNeedReboot = TRUE;
385       } else {
386         l_errorEventNtfData.isNeedReboot = FALSE;
387       }
388
389       // Check BufferSize
390       size_t modl_len = sizeof(l_errorEventNtfData.ModuleName) - 1;
391
392       // SS Logger uses the l_errorEventNtfData.ModuleName as the LOGGERSERVICE_EMMC_LOGS and
393       // EEL_EXPORT destination path. eErrorEventTypeDiagEvent sends the destination path.
394       // For all other event types, the binary name is sent to logger.
395       // LCOV_EXCL_BR_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
396       if ((eErrorEventTypeInterfaceunifiedEmmcLogs
397           == m_errorEventCurrentIter->m_eventType) ||
398           (eErrorEventTypeEelExport
399               == m_errorEventCurrentIter->m_eventType) ||
400           (eErrorEventTypeDiagEvent
401               == m_errorEventCurrentIter->m_eventType)) {
402       // LCOV_EXCL_BR_STOP
403         strncpy(l_errorEventNtfData.ModuleName,
404             m_errorEventCurrentIter->m_loggingInfo.path.c_str(),
405             sizeof(l_errorEventNtfData.ModuleName) - 1);
406
407         size_t path_len = strlen(m_errorEventCurrentIter->m_loggingInfo.path.c_str());
408         if (path_len > modl_len) {
409           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
410               "Input buffer size over. input : %ld, enable : %ld",
411               path_len, modl_len);
412         }
413         l_errorEventNtfData.ModuleName[sizeof(l_errorEventNtfData.ModuleName) - 1] = 0;
414       } else {
415         strncpy(l_errorEventNtfData.ModuleName,
416             m_errorEventCurrentIter->m_loggingInfo.suffixStr.c_str(),
417             sizeof(l_errorEventNtfData.ModuleName) - 1);
418       }
419
420       // When the Reboot process is started during the execution of the LOG save sequence, an undefined value was set
421       // in m_errorEventCurrentIter. Therefore, the Reboot start timing due to an error in SS_Loger was changed from
422       // the time of ErrorEvent queuing to the time of dequeuing.
423
424       // LCOV_EXCL_BR_START 6: Because the following conditions cannot be satisfied when called from an external API
425       if ((SERVICE_LOGGER == m_errorEventCurrentIter->m_moduleQueueName)
426           && ((eErrorEventTypeProcessCrash
427               == m_errorEventCurrentIter->m_eventType)
428               || (eErrorEventTypeProcessExit
429                   == m_errorEventCurrentIter->m_eventType)
430               || (eErrorEventTypeHeartBeatFailure
431                   == m_errorEventCurrentIter->m_eventType)
432               || (eErrorEventTypeModConnFailed
433                   == m_errorEventCurrentIter->m_eventType)
434               || (eErrorEventTypeStartRespFailed
435                   == m_errorEventCurrentIter->m_eventType))) {
436       // LCOV_EXCL_BR_STOP
437         // LCOV_EXCL_START 6: Because the following conditions cannot be satisfied when called from an external API
438         // Note: If logger crashes, a core file will exist.
439         std::string l_hmiDispStr;
440         l_hmiDispStr = SERVICE_LOGGER;
441         if (eErrorEventResetTypeNone != m_errorEventCurrentIter->m_errorEventResetType) {
442           l_hmiDispStr += " - Shutting down, check for core file.";
443
444           // Since LOG save cannot be performed when an SSL error is detected, the LOG is saved at the next startup
445           // by rebooting with NaviDet = L after completion of the process.
446           fprintf(stderr, "SS_SysManager/%s:will NAVIDET as SSL dead\n", __FUNCTION__);
447           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "will NAVIDET as SSL dead");
448           m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager,
449               &CSystemManager::perform_force_reset>);
450
451           m_ResetFactor = GetResetFactor(SERVICE_LOGGER, FALSE);
452
453           l_eStatus = PerformResetAfterLogging(f_hApp,
454               e_SS_SM_CPU_RESET_REASON_GENERIC_ERR);
455           LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()");
456         } else {
457           l_hmiDispStr += " - Check for core file.";
458         }
459
460         SMErrorEventNtfData l_errorEventNtfData;
461         l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
462         l_errorEventNtfData.isNeedReboot = FALSE;
463         snprintf(l_errorEventNtfData.ModuleName,
464             sizeof(l_errorEventNtfData.ModuleName), "%s",
465             l_hmiDispStr.c_str());
466
467         l_eStatus = FrameworkunifiedPublishEvent(f_hApp,  // Show indication on HMI.
468             SS_SM_EVENT_ERROR,
469             NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData));
470
471         LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
472             "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)");
473       } else if (m_errorEventCurrentIter->m_eventType == eErrorEventTypeModuleInvokedResetRequest
474           && (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_NORMAL
475               || m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_DATA_RESET)) {
476         l_eStatus = PerformResetAfterLogging(f_hApp,
477             m_errorEventCurrentIter->m_loggingInfo.resetReason,
478             m_errorEventCurrentIter->m_loggingInfo.messageStr);  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
479         LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
480       } else {
481         BOOL bIsNeedLogging = TRUE;
482
483         {
484           UI_32 l_ErrLogCount = 0;
485           if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) {
486             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
487               "Could not get AGL_ERRLOG_COUNTER form power_hal, assume to 0.");
488             l_ErrLogCount = 0;
489           }
490
491           {
492             if ((l_ErrLogCount >= SS_SM_ERR_LOGGING_LIMIT)
493                 && (eErrorEventResetTypeHard == m_errorEventCurrentIter->m_errorEventResetType)) {
494               fprintf(stderr, "SS_SysManager/%s:Skip Logging by continuous error \n", __FUNCTION__);
495               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Skip Logging by continuous error ");
496
497               m_ResetFactor = PSM_FACTOR_AGL_WITH_HISTORY;
498
499               l_eStatus =
500                   PerformResetAfterLogging(f_hApp,
501                       m_errorEventCurrentIter->m_loggingInfo.resetReason,
502                       m_errorEventCurrentIter->m_loggingInfo.messageStr);
503               LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()");
504               bIsNeedLogging = FALSE;
505             } else if (eErrorEventResetTypeHard
506                 == m_errorEventCurrentIter->m_errorEventResetType) {
507               l_ErrLogCount++;
508               if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, l_ErrLogCount)) {
509                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
510                   "Could not set AGL_ERRLOG_COUNTER to power_hal.");
511               }
512             }
513           }
514         }
515
516         if (bIsNeedLogging) {
517           m_isPrevErrEventCompleted = FALSE;
518           m_errorEventResult = eFrameworkunifiedStatusOK;
519           BOOL result =
520               m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Start(
521                   SS_ERROR_EVENT_START_REQ_TO_SEC, 0, 0, 0);
522           if (FALSE == result) {  // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
523             // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
524             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
525             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
526                 " Error. Failed to start timer eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ.");
527             // LCOV_EXCL_STOP
528           }
529
530           l_eStatus = FrameworkunifiedPublishEvent(f_hApp,
531               SS_SM_EVENT_ERROR_TO_SSL,
532               NULL, &l_errorEventNtfData,
533               sizeof(l_errorEventNtfData));
534
535           if (l_eStatus != eFrameworkunifiedStatusOK) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.
536             // LCOV_EXCL_START 4: NSFW error case.
537             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
538             FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
539                 " FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR_TO_SSL, "
540                     "module name (optional): '%s', "
541                     "event type: %d) returned '%d'/'%s'",
542                 l_errorEventNtfData.ModuleName,
543                 l_errorEventNtfData.EventType, l_eStatus,
544                 GetStr(l_eStatus).c_str());
545             // LCOV_EXCL_STOP 4: NSFW error case.
546           }
547         }
548       }
549     }
550
551     // If Reboot has been started up to this point, m_errorEventQueue is cleared and checking is performed at the end because m_errorEventQueue is cleared.
552     if (0 == m_errorEventQueue.size()) {
553       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
554           " Info. Error Event queue empty. Error logging complete.");
555       m_errorEventCurrentIter = m_errorEventQueue.end();  // Invalidate iterator in case of spurious events.
556       SendDeferMsg(f_hApp);
557     }
558   }
559
560   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
561   return (l_eStatus);
562 }
563
564 ///////////////////////////////////////////////////////////////////////////////
565 /// \ingroup OnLoggingStartRequestFromSL
566 ///          This function gets called when System Logger initiates artifact
567 ///          collection for a trigger source that originates within System
568 ///          Logger or as a result of System Manager raising a logging
569 ///          event notification to System Logger.
570 ///
571 /// \param [in] hApp
572 ///         HANDLE - Handle of the Client Application
573 ///
574 /// \return Status
575 ///         EFrameworkunifiedStatus - success or error
576 ///////////////////////////////////////////////////////////////////////////////
577 EFrameworkunifiedStatus CSystemManager::OnLoggingStartRequest(HANDLE f_hApp) {
578   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
579   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
580   ModuleLaunchListIter l_ModuleListIter;
581   HANDLE l_hLoggerServiceSession;
582   EErrorEventType l_eventType;
583   SMErrorEventNtfData l_errorEventNtfData;
584
585   m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Stop();
586
587   INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp);
588
589   if (eFrameworkunifiedStatusOK
590       != (l_eStatus = ReadMsg < EErrorEventType > (f_hApp, l_eventType))) {
591     LOG_ERROR("ReadMsg()");
592   } else {
593     if (0 == m_errorEventQueue.size()) {
594       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
595           " Error. Logging start request received for event type: %d/'%s', "
596               "but the logging queue is empty.!", l_eventType,
597           GetStr(l_eventType).c_str());
598       l_eStatus = eFrameworkunifiedStatusFail;
599     } else if (m_errorEventCurrentIter == m_errorEventQueue.end()) {
600       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
601           " Error. Logging start request received for event type: %d/'%s', "
602               "but the current event iterator is invalid.",
603           l_eventType, GetStr(l_eventType).c_str());
604       l_eStatus = eFrameworkunifiedStatusFail;
605     } else if (m_errorEventCurrentIter->m_eventType != l_eventType) {
606       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
607           " Error. Logging start request received for event type: %d/'%s', "
608               "but current work item is for event type: %d/'%s'.",
609           l_eventType, GetStr(l_eventType).c_str(),
610           m_errorEventCurrentIter->m_eventType,
611           GetStr(m_errorEventCurrentIter->m_eventType).c_str());
612       l_eStatus = eFrameworkunifiedStatusFail;
613     } else {
614       l_errorEventNtfData.EventType = l_eventType;
615       l_errorEventNtfData.isNeedReboot = FALSE;
616
617       // For boot micro reset, customize the string as per the reset reason.
618       if (l_eventType == eErrorEventTypeBootMicroReset) {
619         switch (m_BootMicroResetReason) {
620         case SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET:
621           (void) snprintf(l_errorEventNtfData.ModuleName,
622               sizeof(l_errorEventNtfData.ModuleName),
623               "Boot Micro Reset. Reason: %d, Self Reset",
624               m_BootMicroResetReason);
625           break;
626
627         case SS_SM_BOOT_MICRO_RESET_REASON_USER_FORCE_RESET:  // User Force Reset timeout.
628           (void) snprintf(l_errorEventNtfData.ModuleName,
629               sizeof(l_errorEventNtfData.ModuleName),
630               "Boot Micro Reset. Reason: %d, UFR Timeout",
631               m_BootMicroResetReason);
632           break;
633
634         case SS_SM_BOOT_MICRO_RESET_REASON_DSP_RESET:
635           (void) snprintf(l_errorEventNtfData.ModuleName,
636               sizeof(l_errorEventNtfData.ModuleName),
637               "Boot Micro Reset. Reason: %d, DSP Reset",
638               m_BootMicroResetReason);
639           break;
640
641         case SS_SM_BOOT_MICRO_RESET_REASON_HB_TIMEOUT:
642           (void) snprintf(l_errorEventNtfData.ModuleName,
643               sizeof(l_errorEventNtfData.ModuleName),
644               "Boot Micro Reset. Reason: %d, HB Timeout",
645               m_BootMicroResetReason);
646           break;
647
648         default:
649           (void) snprintf(l_errorEventNtfData.ModuleName,
650               sizeof(l_errorEventNtfData.ModuleName),
651               "Boot Micro Reset. Reason: %d, Unknown",
652               m_BootMicroResetReason);
653           break;
654         }
655       } else {
656         // All other error event types format =
657         //     Binary Name <circumstantial> PID: TID: Additional info: </circumstantial>
658         std::string l_hmiDispStr = ErrorEventCreateHmiDisplayString();
659
660         (void) snprintf(l_errorEventNtfData.ModuleName,
661             sizeof(l_errorEventNtfData.ModuleName), "%s",
662             l_hmiDispStr.c_str());
663       }
664
665       l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_SM_EVENT_ERROR,  // To HMI
666           NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData));
667
668       LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
669           "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)");
670     }
671
672     if (eFrameworkunifiedStatusOK
673         != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
674       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
675           " Error: GetModuleIterator(%s) errored: %d/'%s'",
676           SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
677     } else {
678       l_hLoggerServiceSession = l_ModuleListIter->hsession;
679
680       l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
681           SS_SM_ERROR_EVENT_LOGGING_START_RSPN, 0, NULL);
682
683       LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
684           "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_LOGGING_START_RSPN)");
685     }
686   }
687
688   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
689   return (l_eStatus);
690 }
691
692 ///////////////////////////////////////////////////////////////////////////////
693 /// \ingroup OnErrorEventLoggerStartRequestTimeout
694 ///
695 /// \brief This function is called if System Logger fails to respond in a
696 ///        timely fashion to the published logger start request event
697 ///        SS_SM_EVENT_ERROR_TO_SSL. See OnLoggingStartRequest() which
698 ///        is the expected path should the timer period NOT expire.
699 ///
700 /// \param [in] hApp
701 ///         HANDLE - Handle of the Client Application
702 ///
703 /// \return Status
704 ///         EFrameworkunifiedStatus - success or error
705 ///////////////////////////////////////////////////////////////////////////////
706 EFrameworkunifiedStatus CSystemManager::OnErrorEventLoggerStartRequestTimeout(HANDLE f_hApp) {
707   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
708   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
709   SMErrorEventNtfData l_errorEventNtfData;
710
711   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
712     " Error. Logger failed to respond to message SS_SM_EVENT_ERROR_TO_SSL in a timely fashion.  Logging aborted.");
713
714   // Publish to HMI even if the error event will not be processed.
715   // In this way, developers can be made aware of the error condition
716   // and determine why logging did not proceed as expected.
717   if (m_errorEventCurrentIter != m_errorEventQueue.end()) {
718     l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
719     l_errorEventNtfData.isNeedReboot = FALSE;
720
721     std::string l_hmiDispStr = ErrorEventCreateHmiDisplayString();
722     snprintf(l_errorEventNtfData.ModuleName,
723         sizeof(l_errorEventNtfData.ModuleName), "%s.", l_hmiDispStr.c_str());
724
725     l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_SM_EVENT_ERROR,  // To HMI
726         NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData));  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
727
728     LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
729   }
730
731   m_isPrevErrEventCompleted = TRUE;
732   m_errorEventResult = eFrameworkunifiedStatusFail;
733   l_eStatus = ErrorEventProcessNext(f_hApp);
734   LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
735
736   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
737   return (l_eStatus);
738 }
739
740 EFrameworkunifiedStatus CSystemManager::OnErrorEventLoggingComplete(HANDLE f_hApp) {
741   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
742   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
743   HANDLE l_hLoggerServiceSession;
744   ModuleLaunchListIter l_ModuleListIter;
745
746   // If logger does not send a logging start and instead immediately
747   // sends a logging complete response, then the start timer must be
748   // stopped to prevent a start response timeout from occuring.
749   m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Stop();
750
751   m_errorEventResult = eFrameworkunifiedStatusFail;
752   if (sizeof(m_errorEventResult) != FrameworkunifiedGetMsgLength(f_hApp)) {
753     LOG_ERROR("DataSize mismatch");
754   } else if (eFrameworkunifiedStatusOK
755       != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &m_errorEventResult,
756           sizeof(m_errorEventResult), eSMRRelease))) {
757     LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()");
758   } else {
759     FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "m_errorEventResult = %d", m_errorEventResult);
760   }
761   m_isPrevErrEventCompleted = TRUE;
762
763   if (eFrameworkunifiedStatusOK
764       != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
765     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
766         " Error: GetModuleIterator(%s) errored: %d/'%s'",
767         SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
768   } else {
769     l_hLoggerServiceSession = l_ModuleListIter->hsession;
770
771     l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
772         SS_SM_ERROR_EVENT_LOGGING_COMPLETE_RSPN, 0, NULL);
773
774     LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
775         "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_LOGGING_START_RSPN)");
776   }
777
778   FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " Info. Done processing error event %s.",
779       GetStr(m_errorEventCurrentIter->m_eventType).c_str());
780
781   l_eStatus = ErrorEventProcessNext(f_hApp);
782   LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()");
783
784   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
785   return (l_eStatus);
786 }
787
788 ///////////////////////////////////////////////////////////////////////////////
789 /// \ingroup ActOnModuleFailure
790 ///          This function is called to take appropriate action of the failure
791 ///          reported by heart beat or crash detector. Attributes set in
792 ///          Launch configuration file are considered while taking action
793 ///          on the failed module.
794 ///
795 /// \param  f_hApp                  AGL FW application handle.
796 ///         f_moduleName            Failed module name.
797 ///         f_refSoftResetRequired  Return parameter indicating if a
798 ///                                 soft reset will be required.
799 /// \return Status
800 ///         EFrameworkunifiedStatus - success or error
801 ///////////////////////////////////////////////////////////////////////////////
802 const CHAR RestartModule[] = "me";
803
804 EFrameworkunifiedStatus CSystemManager::ActOnModuleFailure(HANDLE f_hApp,
805         SS_String f_moduleName, BOOL &f_refResetRequired) {
806   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
807   ModuleLaunchListIter l_ModuleListIter;
808   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
809   ESMPLThreadCommandIds l_PLCmd = ePLThrdCmd_NONE;
810   SS_String l_PLCmdStr = "";
811
812   f_refResetRequired = FALSE;
813
814   l_eStatus = GetModuleIterator(f_moduleName.c_str(), l_ModuleListIter);
815   if (l_eStatus != eFrameworkunifiedStatusOK) {
816     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
817         " Error: Module %s not found in Group Launch Map", f_moduleName.c_str());
818
819     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
820     return (eFrameworkunifiedStatusDbRecNotFound);
821   }
822
823   // LCOV_EXCL_BR_START 6: Because the condition cannot be set
824   if (eFrameworkunifiedStatusOK
825       != (l_eStatus = RemoveModuleEntryFromHB(f_hApp,
826           l_ModuleListIter->name.c_str()))) {
827   // LCOV_EXCL_BR_STOP
828     // LCOV_EXCL_START 6: Because the condition cannot be set
829     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
830     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
831         " Error: RemoveModuleEntryFromHB(%s) errored: %d/'%s'",
832         l_ModuleListIter->name.c_str(), l_eStatus,
833         GetStr(l_eStatus).c_str());
834     // LCOV_EXCL_STOP
835   }
836
837   if (TRUE == l_ModuleListIter->critical
838       && (l_ModuleListIter->relaunch_count >= l_ModuleListIter->retry_cnt)) {
839     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
840         " Error: Critical module '%s' re-launch counter exceeded limit (%d).",
841         l_ModuleListIter->name.c_str(), l_ModuleListIter->retry_cnt);
842
843     l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
844
845     // Module has crossed re-launched limit and is not going to be re-launched.
846     // It must however still be terminated.
847     l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
848     l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
849
850     // Module is critical. Restart system.
851     f_refResetRequired = TRUE;
852   // Restart required?
853   } else if (0 == std::strcmp(l_ModuleListIter->restart.c_str(), RestartModule)) {  // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
854     // LCOV_EXCL_START 6: Because the condition cannot be set
855     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
856     FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Module: %s, relaunch_count: %d",
857         l_ModuleListIter->name.c_str(),
858         l_ModuleListIter->relaunch_count);
859
860     if (l_ModuleListIter->relaunch_count < l_ModuleListIter->retry_cnt) {
861       SS_String l_ModulePath = (m_BinaryFilesPath + l_ModuleListIter->path);
862
863       FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
864           " Requesting ReLaunch of '%s' '%s'",
865           l_ModuleListIter->name.c_str(), l_ModulePath.c_str());
866
867       l_PLCmd = ePLThrdCmd_RELAUNCH_MODULE_REQST;
868       l_PLCmdStr = "ePLThrdCmd_RELAUNCH_MODULE_REQST";
869       l_ModuleListIter->relaunch_count++;
870       l_ModuleListIter->relaunch_status = RelaunchErr;
871     } else if ((FALSE == l_ModuleListIter->critical)
872         && (l_ModuleListIter->relaunch_count
873             >= l_ModuleListIter->retry_cnt)) {
874       FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
875           " Warning: Skipping re-launch of non-critical %s module, "
876               "re-launch counter exceeded limit(%d). Terminating module.",
877           l_ModuleListIter->name.c_str(),
878           l_ModuleListIter->retry_cnt);
879
880       l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
881
882       // non critical module has crossed re-launched limit and is not going to be re-launched.
883       // We must terminate the module in the event that it has become non responsive.
884       l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
885       l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
886     }
887     // LCOV_EXCL_STOP
888   } else {  // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
889     // LCOV_EXCL_START 6: Because the condition cannot be set
890     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
891     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
892         " Warning: %s is not required to be re-launched, "
893             "skipping re-launch and terminating module.",
894         l_ModuleListIter->name.c_str());
895
896     l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
897
898     // Module restart not required.
899     // We must terminate the module in the event that it has become non responsive.
900     l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
901     l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
902     // LCOV_EXCL_STOP
903   }
904
905
906   if (ePLThrdCmd_NONE != l_PLCmd) {
907     l_eStatus = SendRequestToLauncher(f_hApp, l_ModuleListIter, l_PLCmd, l_PLCmdStr);  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
908
909     LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToLauncher()");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h  // NOLINT(whitespace/line_length)
910   }
911
912   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
913   return (l_eStatus);
914 }
915
916 ///////////////////////////////////////////////////////////////////////////////
917 /// \ingroup ErrorEventCreateHmiDisplayString
918 ///
919 /// \brief  Create error event HMI colored square display string.
920 ///
921 /// \return Error Display String.
922 ///////////////////////////////////////////////////////////////////////////////
923 std::string CSystemManager::ErrorEventCreateHmiDisplayString(void) {
924   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
925   std::stringstream l_displayNamess;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
926   std::stringstream l_pidss;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
927   std::stringstream l_hmiDispStr;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
928
929   if (0 != strncmp("",
930           m_errorEventCurrentIter->m_loggingInfo.binaryFileName,
931           sizeof(m_errorEventCurrentIter->m_loggingInfo.binaryFileName))) {
932     l_displayNamess << m_errorEventCurrentIter->m_loggingInfo.binaryFileName;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
933   } else {
934     l_displayNamess << m_errorEventCurrentIter->m_moduleQueueName;
935   }
936
937   if (m_errorEventCurrentIter->m_loggingInfo.pid != 0) {
938     l_pidss << " PID: " << m_errorEventCurrentIter->m_loggingInfo.pid;
939   }
940
941
942   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
943   return (l_hmiDispStr.str());
944 }  // LCOV_EXCL_BR_LINE 10:The final line
945