2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup SS_SM_Logging
19 /// \brief This file supports SM logging.
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <native_service/frameworkunified_types.h>
23 #include <native_service/ns_plogger_if.h>
24 #include <stub/ss_diag.h>
25 #include <system_service/ss_ver.h>
26 #include <system_service/ss_services.h>
27 #include <system_service/ss_templates.h>
28 #include <system_service/ss_client_names.h>
29 #include <system_service/ss_sm_client_if.h>
33 #include <sys/types.h>
34 #include <sys/statvfs.h>
39 #include <boost/algorithm/string.hpp>
46 #include "ss_system_manager.h"
48 ///////////////////////////////////////////////////////////////////////////
49 // Function : OnObtainLoggerserviceLogRequest
50 // brief : Collect frameworkunifiedlog artifact and return a response to
52 ///////////////////////////////////////////////////////////////////////////
53 static int getExecedString(char* const argv[], std::stringstream &ss) {
55 int pipeFd[2]; // 0:read, 1:write
58 if (ret != 0) { // LCOV_EXCL_BR_LINE 5:pipe's error case
59 // LCOV_EXCL_START 5:pipe's error case
60 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
61 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
67 if (pid == -1) { // LCOV_EXCL_BR_LINE 5:fork's error case
68 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
69 SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
70 } else if (pid == 0) {
71 close(pipeFd[0]); // unnecessary pile (closing read)
72 close(1); // closing stdout
73 dup2(pipeFd[1], 1); // take stdout to pipe
74 execve(argv[0], argv, environ);
75 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
80 SS_ASERT_ERRNO(0 == close(pipeFd[1])); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
83 FD_ZERO(&rfds); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
84 FD_SET(pipeFd[0], &rfds); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
85 struct timeval timeout;
89 int selRet = select(pipeFd[0] + 1, &rfds, NULL, NULL, &timeout);
92 if (FD_ISSET(pipeFd[0], &rfds)) {
94 rs = read(pipeFd[0], readBuf, sizeof(readBuf) - 1);
98 } else if (rs == -1) { // LCOV_EXCL_BR_LINE 5:read's error case
99 // LCOV_EXCL_START 5:read's error case
100 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
101 if (errno != EINTR) {
102 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
110 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
114 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
117 // LCOV_EXCL_START 5:never be this case
118 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
120 ss << "timeout" << std::endl;
122 ss << "ERR:rslt=" << selRet << std::endl;
128 // SM leaves processing to OnProcessExitDetected when using child process
129 // SS_ASERT_ERRNO(-1 != waitpid(pid,&status,0));
131 SS_ASERT_ERRNO(0 == close(pipeFd[0])); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
136 static int saveProcsMemInfo(std::ofstream &fo) {
141 struct dirent dent, *next;
142 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
144 fo << "******** mem info **********" << std::endl;
145 std::ifstream fin("/proc/meminfo");
147 while (fin && std::getline(fin, line)) {
153 fo << "******** slab info **********" << std::endl;
154 std::ifstream fin("/proc/slabinfo");
156 while (fin && std::getline(fin, line)) {
162 fo << "******** zone info **********" << std::endl;
163 std::ifstream fin("/proc/zoneinfo");
165 while (fin && std::getline(fin, line)) {
171 // Linux dependency codes
172 dir = opendir("/proc"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
173 if (dir == NULL) { // LCOV_EXCL_BR_LINE 5:opendir's error case
174 // LCOV_EXCL_START 11:opendir's error case
175 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
176 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
177 throw eFrameworkunifiedStatusFail;
181 fo << "******** proc status **********" << std::endl;
182 while (0 == readdir_r(dir, &dent, &next) && next) {
183 if (DT_DIR == dent.d_type) {
185 std::string statPath("/proc/"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
186 statPath += dent.d_name;
187 statPath += "/status";
189 if (stat(statPath.c_str(), &statbuf) == 0) {
190 std::ifstream fin(statPath.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
192 while (fin && std::getline(fin, line)) {
193 if (strstr(line.c_str(), "Name") != NULL
194 || strstr(line.c_str(), "Pid") != NULL
195 || strstr(line.c_str(), "Vm") != NULL) {
199 fo << "************************************" << std::endl;
203 SS_ASERT_ERRNO(0 == closedir(dir)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
205 if (dir) { // LCOV_EXCL_BR_LINE 5:opendir's error case
206 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
207 SS_ASERT_ERRNO(0 == closedir(dir)); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
214 ///////////////////////////////////////////////////////////////////////////
215 // Function : OnObtainLoggerserviceLogRequest
216 // brief : Collect frameworkunifiedlog artifact and return a response to
218 ///////////////////////////////////////////////////////////////////////////
219 EFrameworkunifiedStatus CSystemManager::SendLogArtifactResponseToLogger(HANDLE f_hApp,
220 EArtifactId f_artifactId, std::string f_artifactFilePathAndName) {
221 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
222 EFrameworkunifiedStatus l_eStatus;
223 HANDLE l_hLoggerServiceSession;
224 ModuleLaunchListIter l_ModuleListIter;
225 ARTIFACT_RESPONSE l_artifactResponse;
227 l_artifactResponse.ArtifactId = f_artifactId;
229 strncpy(l_artifactResponse.FilePathAndName,
230 f_artifactFilePathAndName.c_str(),
231 sizeof(l_artifactResponse.FilePathAndName) - 1);
233 if (eFrameworkunifiedStatusOK
234 != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
235 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
236 " Error: GetModuleIterator(%s) errored: %d/'%s'",
237 SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
239 l_hLoggerServiceSession = l_ModuleListIter->hsession;
241 l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
242 SS_SM_ERROR_EVENT_ARTIFACT_RSPN, sizeof(l_artifactResponse),
243 &l_artifactResponse);
245 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
246 "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_ARTIFACT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
249 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
253 ///////////////////////////////////////////////////////////////////////////////
254 /// \ingroup OnErrorEventArtifactRequest
255 /// Dispatch logging requests to the various handlers.
257 /// \param f_hApp Framework application handle.
259 /// \return EFrameworkunifiedStatus
260 /// Success ==> eFrameworkunifiedStatusOK
261 /// Failure ==> Other values
262 ///////////////////////////////////////////////////////////////////////////////
263 EFrameworkunifiedStatus CSystemManager::OnErrorEventArtifactRequest(HANDLE hApp) {
264 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
265 EFrameworkunifiedStatus l_eStatus;
266 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
268 if (eFrameworkunifiedStatusOK
269 != (l_eStatus = ReadMsg < EArtifactId
270 > (hApp, m_requestedArtifactId))) { // LCOV_EXCL_BR_LINE 200:NSFW error case
271 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
272 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
274 switch (m_requestedArtifactId) {
275 case eArtifactIdBootMicroLog:
276 l_eStatus = OnObtainBootMicroLog(hApp);
277 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainBootMicroLog()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
280 case eArtifactIdSystemDataCsv:
281 l_eStatus = OnObtainSystemmanagerSystemDataCsv(hApp);
282 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainSystemmanagerSystemDataCsv()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
285 case eArtifactIdShowMemTxt:
286 l_eStatus = OnObtainShowMemTxt(hApp);
287 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainShowMemTxt()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
290 case eArtifactIdProcessCore:
291 SS_ASERT(0); // Never called in Linux PF // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
294 case eArtifactIdDebugDumpLog:
295 l_eStatus = OnObtainDebugDumpLog(hApp);
296 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainDebugDumpLog()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
300 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
301 " Error: Unsupported logging artifact requested: %d.",
302 m_requestedArtifactId);
307 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
311 ///////////////////////////////////////////////////////////////////////////////
312 /// \ingroup OnObtainBootMicroLog
313 /// Obtain the boot micro log content, write file to disk, and send filename to SL.
315 /// \param [in] f_hApp - Application handle.
317 /// \return EFrameworkunifiedStatus
318 /// Success ==> eFrameworkunifiedStatusOK
319 /// Failure ==> Other values
320 ///////////////////////////////////////////////////////////////////////////////
321 EFrameworkunifiedStatus CSystemManager::OnObtainBootMicroLog(HANDLE f_hApp) {
322 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
323 EFrameworkunifiedStatus l_eStatus;
324 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
325 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(f_hApp));
327 l_eStatus = RequestBootMicroLog(f_hApp);
328 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "RequestBootMicroLog"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
330 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
334 ///////////////////////////////////////////////////////////////////////////////
335 /// \ingroup OnBootMicroLogResponse
336 /// Boot micro log response sent from the logging shadow.
338 /// \param [in] f_hApp - Application handle.
340 /// \return EFrameworkunifiedStatus
341 /// Success ==> eFrameworkunifiedStatusOK
342 /// Failure ==> Other values
343 ///////////////////////////////////////////////////////////////////////////////
344 EFrameworkunifiedStatus CSystemManager::OnBootMicroLogResponse(HANDLE f_hApp) {
345 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
346 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
348 std::string l_artifactFilePathAndName;
350 m_errorEventTimers[eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN].Stop(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
352 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
353 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(f_hApp));
355 if (0 == strcmp(TIMER_SERVICE_NAME, FrameworkunifiedGetMsgSrc(f_hApp))) {
356 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
357 " Info. Timer expired while waiting for the boot micro log.");
358 } else if (0 == (l_len = FrameworkunifiedGetMsgLength(f_hApp))) { // LCOV_EXCL_BR_LINE 200:restricted by ss_sm_client
359 // LCOV_EXCL_START 200:restricted by ss_sm_client
360 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
361 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
362 " Error: Invalid log response received. Length cannot be 0.");
365 char l_buf[l_len]; // NOLINT
366 l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, l_buf, static_cast<UI_32>(sizeof(l_buf)), eSMRRelease); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
367 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:NSFW error case
368 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
369 LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
371 l_artifactFilePathAndName = "/tmp/bootmicro.log";
372 l_len = static_cast<UI_32>(strlen((const char *) l_buf));
373 std::ofstream l_stream(l_artifactFilePathAndName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
374 l_stream.write(l_buf, l_len); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
375 l_stream.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
379 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
380 l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
382 if (l_eStatus != eFrameworkunifiedStatusOK) {
383 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
384 " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
385 "errored: %d/'%s'", m_requestedArtifactId,
386 l_artifactFilePathAndName.c_str(), l_eStatus,
387 GetStr(l_eStatus).c_str());
393 ///////////////////////////////////////////////////////////////////////////////
394 /// \ingroup OnErrorEventBootMicroLogResponseTimeout
395 /// Called when the boot micro log request timer expires (e.g. no response).
397 /// \param [in] f_hApp - Application handle.
399 /// \return EFrameworkunifiedStatus
400 /// Success ==> eFrameworkunifiedStatusOK
401 /// Failure ==> Other values
402 ///////////////////////////////////////////////////////////////////////////////
403 EFrameworkunifiedStatus CSystemManager::OnErrorEventBootMicroLogResponseTimeout(HANDLE f_hApp) {
404 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
405 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
406 std::string l_artifactFilePathAndName = "";
408 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
409 " Error: Boot micro log response timed out. Sending empty artifact response to SSL.");
411 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
412 l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
414 if (l_eStatus != eFrameworkunifiedStatusOK) {
415 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
416 " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
417 "errored: %d/'%s'", m_requestedArtifactId,
418 l_artifactFilePathAndName.c_str(), l_eStatus,
419 GetStr(l_eStatus).c_str());
422 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
426 ///////////////////////////////////////////////////////////////////////////////
427 /// \ingroup OnObtainSystemmanagerSystemDataCsv
428 /// Obtain system content, write file to disk, and send filename to SL.
430 /// \param [in] f_hApp - Application handle.
432 /// \return EFrameworkunifiedStatus
433 /// Success ==> eFrameworkunifiedStatusOK
434 /// Failure ==> Other values
435 ///////////////////////////////////////////////////////////////////////////////
436 EFrameworkunifiedStatus CSystemManager::OnObtainSystemmanagerSystemDataCsv(HANDLE f_hApp) {
437 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
438 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
439 // std::string l_artifactFilePathAndName = "/tmp/frameworkunified_systemdata.csv";
440 // std::ofstream l_stream(l_artifactFilePathAndName.c_str());
441 std::stringstream l_stream;
443 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
445 // Output version info
447 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
449 l_stream << "********** PACKAGE VERSIONS **********\n";
451 l_stream << setw(16) << "PACKAGE" << setw(24) << "VERSION" << setw(10)
453 for (SSVerPkgListIter ite = ver.begin(); ite != ver.end(); ite++) {
454 l_stream << setw(16) << ite->first;
455 l_stream << setw(24) << ite->second.version;
456 l_stream << setw(10) << ite->second.date << std::endl;
459 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
460 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
461 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
464 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
465 l_stream << "********** Error Description Start ***********" << endl;
466 l_stream << "Error Event Type,"
467 << GetStr(m_errorEventCurrentIter->m_eventType) << endl;
468 l_stream << m_errorEventCurrentIter->m_eventEnqueueTimeStamp.c_str() << endl;
469 l_stream << "MessageStr,"
470 << m_errorEventCurrentIter->m_loggingInfo.messageStr.c_str() << endl;
474 UI_32 l_ErrLogCount = 0;
475 if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
476 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__,
477 "Could not get AGL_ERRLOG_COUNTER from power_hal.");
481 l_stream << "ErrLogCount," << l_ErrLogCount << "/"
482 << SS_SM_ERR_LOGGING_LIMIT << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
486 switch (m_errorEventCurrentIter->m_eventType) {
487 case eErrorEventTypeProcessCrash:
488 l_stream << "Crash Failure Binary Name,"
489 << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
490 l_stream << "Module PID," << m_errorEventCurrentIter->m_loggingInfo.pid << endl;
491 l_stream << "Exit Value,"
492 << m_errorEventCurrentIter->m_loggingInfo.exitValue << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
494 l_pSignalName = strsignal(
495 m_errorEventCurrentIter->m_loggingInfo.signalNumber);
496 if (NULL != l_pSignalName) {
497 l_stream << "Exit Signal,"
498 << m_errorEventCurrentIter->m_loggingInfo.signalNumber // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
499 << "," << l_pSignalName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
504 case eErrorEventTypeProcessExit:
505 l_stream << "Exit Binary Name,"
506 << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
507 l_stream << "Module PID," << m_errorEventCurrentIter->m_loggingInfo.pid << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
508 l_stream << "Exit Value,"
509 << m_errorEventCurrentIter->m_loggingInfo.exitValue << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
512 case eErrorEventTypeHeartBeatFailure:
513 l_stream << "HB Failure Module Queue Name,"
514 << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
515 l_stream << "***************** HB Information Start *******************" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
516 l_stream << "Entire State," << m_HBReport.eEntireState << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
517 l_stream << "Module Name,HB State,Retry Count" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
519 for (UI_32 i = 0; i < m_HBReport.nNumOfModules; i++) {
520 if (0 != m_HBReport.tModuleList[i].HeartBeatRetryCount) {
521 l_stream << m_HBReport.tModuleList[i].ProcQueueName << "," // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
522 << m_HBReport.tModuleList[i].ProcHBState << "," // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
523 << m_HBReport.tModuleList[i].HeartBeatRetryCount // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
524 << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
527 l_stream << "***************** HB Information End *******************" << endl;
530 case eErrorEventTypeSystemLowMemory:
531 l_stream << "Free Memory Available (Byte)," << m_FreeMemAvailable << endl;
534 case eErrorEventTypeBootMicroReset:
535 l_stream << "Boot Micro Reset Reason," << m_BootMicroResetReason << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
538 case eErrorEventTypeModConnFailed:
539 l_stream << "Failed Module Queue Name,"
540 << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
543 case eErrorEventTypeStartRespFailed:
544 l_stream << "Failed Module Queue Name,"
545 << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
548 // No additional event specific log information to add.
549 case eErrorEventTypeUserInvokedCollectAllLogs:
550 case eErrorEventTypeUserInvokedCollectScreenShot:
551 case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
552 case eErrorEventTypeUserInvokedUserForceReset:
553 case eErrorEventTypeUserInvokedCollectDevLogs:
559 std::ifstream finNum("/proc/sys/vm/nr_oom_kill_process");
561 if (finNum && std::getline(finNum, strNum)) { // LCOV_EXCL_BR_LINE 200:will not be this case
562 // LCOV_EXCL_START 200:will not be this case
563 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
565 long lNum = strtol(strNum.c_str(), &endptr, 10); // NOLINT
566 if (('\0' != *endptr) || (lNum < 0)) {
567 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
569 l_stream << "nr_oom_kill_process," << strNum.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
571 std::ifstream finLast("/proc/sys/vm/last_oom_kill_victim"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
573 if (finLast && std::getline(finLast, strLast)) {
574 l_stream << "last_oom_kill_victim," << strLast.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
582 l_stream << "********** Error Description End ***********" << endl << endl;
583 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
585 fprintf(stderr, "SS_SysManager/\n%s", l_stream.str().c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
587 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
588 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
590 l_stream << "********** Variant Code Start ***********" << endl;
591 if (NULL != m_pVarCodeStr) {
592 l_stream << m_pVarCodeStr << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
594 l_stream << "Variant coding not available." << endl;
596 l_stream << "********** Variant Code End ***********" << endl << endl;
597 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
598 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
599 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
601 l_stream << "********** File System Information Start ***********" << endl;
602 l_stream << "== mounts info start==" << endl;
604 std::ifstream fin("/proc/mounts"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
606 while (fin && std::getline(fin, line)) {
607 l_stream << line << endl;
610 l_stream << "== mounts info end ==" << endl;
611 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
612 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
613 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
615 l_stream << "== DF info start==" << endl;
617 char* const argv[] = { const_cast<char*>("/bin/df"), const_cast<char*>("-a"), static_cast<char*>(NULL), };
618 SS_ASERT(0 == getExecedString(argv, l_stream)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
620 l_stream << "== DF info end==" << endl;
622 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
623 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
624 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
626 #if 0 // Need to install lsblk if requested so that it is not installed
627 l_stream << "== lsblk info start==" << endl;
629 char* const argv[] = {
630 const_cast<char*>("/usr/debug/bin/lsblk"),
631 const_cast<char*>("-o"),
632 const_cast<char*>("NAME,KNAME,MAJ:MIN,FSTYPE,PARTLABEL,MODEL,SERIAL,REV,VENDOR"),
633 const_cast<char*>(NULL),
635 SS_ASERT(0 == getExecedString(argv, l_stream));
637 l_stream << "== lsblk info end==" << endl;
638 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
643 l_stream << "== proc info start==" << endl;
645 char* const argv[] = { const_cast<char*>("/bin/ps"), const_cast<char*>("auxc"),
646 const_cast<char*>("-L"), static_cast<char*>(NULL), };
647 SS_ASERT(0 == getExecedString(argv, l_stream)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
649 l_stream << "== proc info end==" << endl;
651 // Output is splitted so that the FRAMEWORKUNIFIEDLOG can not write data over 4K Bytes at a time
652 std::list<std::string> strList;
653 boost::split(strList, static_cast<const std::string>(l_stream.str()),
654 boost::is_any_of("\n")); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
657 std::stringstream ss; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
658 for (std::list<std::string>::iterator ite = strList.begin();
659 ite != strList.end(); ite++) {
663 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", ss.str().c_str());
664 ss.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
665 ss.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
669 FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", ss.str().c_str());
671 l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
672 l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
674 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId, ""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
676 if (l_eStatus != eFrameworkunifiedStatusOK) {
677 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
678 " Error: SendLogArtifactResponseToLogger(Artifact '%d') "
679 "errored: %d/'%s'", m_requestedArtifactId, l_eStatus,
680 GetStr(l_eStatus).c_str());
683 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
687 ///////////////////////////////////////////////////////////////////////////////
688 /// \ingroup OnObtainShowMemTxt
689 /// Obtain showmem content, write file to disk, and send filename to SL.
691 /// \param [in] f_hApp - Application handle.
693 /// \return EFrameworkunifiedStatus
694 /// Success ==> eFrameworkunifiedStatusOK
695 /// Failure ==> Other values
696 ///////////////////////////////////////////////////////////////////////////////
697 EFrameworkunifiedStatus CSystemManager::OnObtainShowMemTxt(HANDLE f_hApp) {
698 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
699 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
700 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
702 std::string l_artifactFilePathAndName = "/tmp/showmem.txt";
704 std::ofstream fo(l_artifactFilePathAndName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
705 saveProcsMemInfo(fo); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
708 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
709 l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
711 if (l_eStatus != eFrameworkunifiedStatusOK) {
712 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
713 " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
714 "errored: %d/'%s'", m_requestedArtifactId,
715 l_artifactFilePathAndName.c_str(), l_eStatus,
716 GetStr(l_eStatus).c_str());
719 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
723 ///////////////////////////////////////////////////////////////////////////////
724 /// \ingroup OnErrorEventCoreFilePollTimeout
725 /// Called periodically to verify whether the process core file has completed
726 /// being written to disk. When complete, this function sends an artifact
729 /// \param [in] f_hApp - Application handle.
731 /// \return EFrameworkunifiedStatus
732 /// Success ==> eFrameworkunifiedStatusOK
733 /// Failure ==> Other values
734 ///////////////////////////////////////////////////////////////////////////////
735 EFrameworkunifiedStatus CSystemManager::OnErrorEventCoreFilePollTimeout(HANDLE f_hApp) { // LCOV_EXCL_START 8:dead code
736 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
737 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
738 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
739 BOOL l_sendResponse = FALSE;
740 std::string l_artifactFilePathAndName = "";
741 std::ostringstream l_coreFilePathAndName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
743 // struct stat l_fileInfo;
744 struct stat64 l_fileInfo;
746 off_t l_coreFileSize;
747 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
749 l_coreFilePathAndName << "/debug/"
750 << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << ".core.gz"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
753 // l_result = stat(l_coreFilePathAndName.str().c_str(), &l_fileInfo);
754 l_result = stat64(l_coreFilePathAndName.str().c_str(), &l_fileInfo);
756 l_coreFileSize = l_fileInfo.st_size;
757 if ((l_coreFileSize > m_coreFileSizeBytes) || // Core file grew from last read.
758 (l_coreFileSize == 0)) { // Core file not yet updated externally.
759 m_coreFileSizeBytes = l_coreFileSize; // Wait until file stops growing.
761 m_errorEventTimers[eSM_ERROR_EVENT_TIMER_CORE_FILE_POLL].Start( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
762 0, SS_ERROR_EVENT_CORE_FILE_POLL_TO_MS, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
763 if (FALSE == result) {
764 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
765 " Error: Failed to start timer SS_ERROR_EVENT_CORE_FILE_POLL_TO_MS.");
766 l_sendResponse = TRUE;
768 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
769 " Info. Core file: %s, size: %ld still growing.",
770 l_coreFilePathAndName.str().c_str(),
771 m_coreFileSizeBytes);
773 l_sendResponse = FALSE;
775 } else { // File has stopped growing.
776 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
777 " Info. Core file: %s, size: %ld write complete. Sending artifact response.",
778 l_coreFilePathAndName.str().c_str(), m_coreFileSizeBytes);
780 l_artifactFilePathAndName = l_coreFilePathAndName.str();
781 l_sendResponse = TRUE;
784 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
785 " Info. Core file: %s, unable to determine size. Sending empty artifact response to SSL.",
786 l_coreFilePathAndName.str().c_str());
788 l_sendResponse = TRUE;
791 if (TRUE == l_sendResponse) {
792 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, // Error getting file size. Send empty path to SSL.
793 m_requestedArtifactId, l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
795 if (l_eStatus != eFrameworkunifiedStatusOK) {
796 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
797 " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
798 "errored: %d/'%s'", m_requestedArtifactId,
799 l_artifactFilePathAndName.c_str(), l_eStatus,
800 GetStr(l_eStatus).c_str());
804 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
809 ///////////////////////////////////////////////////////////////////////////////
810 /// \ingroup OnObtainDebugDumpLog
811 /// Obtain debug dump content, write file to disk, and send filename to SL.
812 /// See OnModuleDebugDumpResponse().
814 /// \param [in] f_hApp - Application handle.
816 /// \return EFrameworkunifiedStatus
817 /// Success ==> eFrameworkunifiedStatusOK
818 /// Failure ==> Other values
819 ///////////////////////////////////////////////////////////////////////////////
820 EFrameworkunifiedStatus CSystemManager::OnObtainDebugDumpLog(HANDLE f_hApp) {
821 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
822 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
823 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
825 ModuleLaunchListIter l_moduleIter;
827 m_NbrDebugDumpRspnRecv = 0;
829 for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
830 l_GroupIter != m_MapProclaunchGrps.end(); l_GroupIter++) {
831 for (l_moduleIter = l_GroupIter->second.modules.begin();
832 l_moduleIter != l_GroupIter->second.modules.end();
834 const BOOL isModuleConnected = l_moduleIter->IsModuleConnected(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
835 if ((SERVICE_NS_NPP != l_moduleIter->name) && // NPP is a special case and does NOT session connect with SM.
836 (TRUE == isModuleConnected)) {
837 l_eStatus = FrameworkunifiedSendMsg(l_moduleIter->hsession, SS_SM_DEBUG_DUMP,
840 if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:NSFW error case
841 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
842 " Info. FrameworkunifiedSendMsg(SS_SM_DEBUG_DUMP) to %s succeeded.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
843 l_moduleIter->name.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
845 // LCOV_EXCL_START 200:NSFW error case
846 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
847 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
848 " Error: FrameworkunifiedSendMsg(%p, SS_SM_DEBUG_DUMP) to %s errored: %d/'%s'",
849 (void *) l_moduleIter->hsession,
850 l_moduleIter->name.c_str(), l_eStatus,
851 GetStr(l_eStatus).c_str());
858 // Call debug dump handler for SM.
859 l_eStatus = OnSystemManagerDebugDump(f_hApp);
860 LOG_STATUS(l_eStatus, "OnSystemManagerDebugDump()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
862 // Refresh debug dump timeout timer after each debug dump response received.
863 // Non AGL framework modules will have the remaining time after the last
864 // received response to complete their debug dump.
866 m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Start(
867 SS_ERROR_EVENT_DEBUG_DUMP_RSPN_TO_SEC, 0, 0, 0);
868 if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:will not be this case
869 // LCOV_EXCL_START 200:will not be this case
870 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
871 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
872 " Error: Failed to start timer eSM_TIMER_DEBUG_DUMP_RSPN_MONITOR.");
876 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
880 ///////////////////////////////////////////////////////////////////////////////
881 /// \ingroup OnDebugDumpResponseReceived
882 /// Debug Dump complete Response handler.
883 /// See OnDebugDumpCompleteTimeout().
885 /// \param [in] f_hApp - Application handle.
887 /// \return EFrameworkunifiedStatus
888 /// Success ==> eFrameworkunifiedStatusOK
889 /// Failure ==> Other values
890 ///////////////////////////////////////////////////////////////////////////////
891 EFrameworkunifiedStatus CSystemManager::OnDebugDumpResponseReceived(HANDLE f_hApp) {
892 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
893 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
894 ModuleLaunchListIter l_ModuleListIter;
896 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
898 std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp);
899 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", l_moduleName.c_str());
901 SetCmdHist("SS_SM_DEBUG_DUMP_RSPN", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(f_hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
903 // SM is not launched by SM and is therefore not in the process list.
904 // SM does however use the same debug dump mechanism as other processes.
905 if (l_moduleName != SERVICE_SYSMANAGER) {
906 l_eStatus = GetModuleIterator(l_moduleName.c_str(), l_ModuleListIter);
907 if (eFrameworkunifiedStatusOK != l_eStatus) {
908 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
909 " Error: Module %s not found in Group Launch Map", l_moduleName.c_str());
911 l_ModuleListIter->SetModuleDebugDumpState(MODULE_DEBUG_DUMP_STATE_RESPONSE_RECEIVED);
915 if (0 == (l_len = FrameworkunifiedGetMsgLength(f_hApp))) { // LCOV_EXCL_BR_LINE 200:restricted by ss_sm_client
916 // LCOV_EXCL_START 200:restricted by ss_sm_client
917 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
918 l_eStatus = eFrameworkunifiedStatusInvldBufSize;
919 LOG_ERROR("0 == FrameworkunifiedGetMsgLength(f_hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
922 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
923 " Received debug dump response from %s, size: %d bytes. "
924 "Total number of responses received: %d",
925 l_moduleName.c_str(), l_len, m_NbrDebugDumpRspnRecv);
927 UI_8 l_buf[l_len]; // NOLINT
928 l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, l_buf, static_cast<UI_32>(sizeof(l_buf)),
930 if (eFrameworkunifiedStatusOK != l_eStatus) {
931 LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
933 ios_base::openmode l_mode;
934 if (0 == m_NbrDebugDumpRspnRecv) {
936 l_mode = std::ios_base::trunc;
938 // Append existing file.
939 l_mode = std::ios_base::app;
942 std::ofstream l_stream("/tmp/systemmanager_debugdump.log", l_mode); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
943 l_stream << l_buf << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
944 l_stream.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
947 m_NbrDebugDumpRspnRecv++;
949 // Refresh debug dump timeout timer after each debug dump response received.
950 // Non AGL framework modules will have the remaining time after the last
951 // received response to complete their debug dump.
953 m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Start( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
954 SS_ERROR_EVENT_DEBUG_DUMP_RSPN_TO_SEC, 0, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
955 if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:will not be this case
956 // LCOV_EXCL_START 200:will not be this case
957 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
958 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
959 " Error: Failed to start timer eSM_TIMER_DEBUG_DUMP_RSPN_MONITOR.");
960 l_eStatus = OnDebugDumpCompleteTimeout(f_hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
961 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
962 "OnDebugDumpCompleteTimeout()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
967 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
971 ///////////////////////////////////////////////////////////////////////////////
972 /// \ingroup OnDebugDumpCompleteTimeout
973 /// Called after the last debug dump message is received, or when the debug
974 /// dump monitor timer expires.
976 /// \param [in] f_hApp - Application handle.
978 /// \return EFrameworkunifiedStatus
979 /// Success ==> eFrameworkunifiedStatusOK
980 /// Failure ==> Other values
981 ///////////////////////////////////////////////////////////////////////////////
982 EFrameworkunifiedStatus CSystemManager::OnDebugDumpCompleteTimeout(HANDLE f_hApp) {
983 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
984 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
985 std::string l_artifactFilePathAndName = "/tmp/systemmanager_debugdump.log";
986 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
988 m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Stop(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
990 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Received '%d' Debug Dump responses.",
991 m_NbrDebugDumpRspnRecv);
993 l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
994 l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
996 if (l_eStatus != eFrameworkunifiedStatusOK) {
997 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
998 " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
999 "errored: %d/'%s'", m_requestedArtifactId,
1000 l_artifactFilePathAndName.c_str(), l_eStatus,
1001 GetStr(l_eStatus).c_str());
1004 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");