提交 55e5e290 编写于 作者: D Denny 提交者: Gitee

回退 'Pull Request !401 : 【DFX子系统】【BBoxDetector】LiteOS_A死机重启维测框架'

上级 feae60c8
......@@ -61,8 +61,6 @@ source "../../kernel/liteos_a/arch/Kconfig"
source "../../kernel/liteos_a/kernel/common/Kconfig"
######################### config options of patchfs #####################
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
######################### config options of blackbox #####################
source "../../kernel/liteos_a/kernel/common/blackbox/Kconfig"
config QUICK_START
bool "Enable QUICK_START"
......@@ -177,7 +175,7 @@ config PLATFORM_DVFS
config SAVE_EXCINFO
bool "Enable Saving Exception Information"
default y if BLACKBOX
default n
help
Answer Y to enable LiteOS support saving exception information to storage medium.
......
......@@ -62,9 +62,6 @@
#ifdef LOSCFG_FS_VFS
#include "console.h"
#endif
#ifdef LOSCFG_BLACKBOX
#include "los_blackbox.h"
#endif
#define INVALID_CPUID 0xFFFF
......@@ -592,9 +589,6 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
/* Exception handling All operations should be kept prior to that operation */
OsExcRestore();
/* kill user exc process */
#ifdef LOSCFG_BLACKBOX
BBoxNotifyError("USER_CRASH", MODULE_SYSTEM, "Crash in user", 0);
#endif
LOS_Exit(OS_PRO_EXIT_OK);
}
......@@ -1064,9 +1058,6 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
{
#ifdef LOSCFG_BLACKBOX
SetExcInfoIndex(0);
#endif
#ifdef LOSCFG_KERNEL_VM
/* You are not allowed to add any other print information before this exception information */
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
......@@ -1134,9 +1125,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
if (g_curNestCount[ArchCurrCpuid()] == 1) {
#ifdef LOSCFG_SAVE_EXCINFO
if (func != NULL) {
#ifndef LOSCFG_BLACKBOX
SetExcInfoIndex(0);
#endif
OsSysStateSave(&intCount, &lockCount);
OsRecordExcInfoTime();
OsSysStateRestore(intCount, lockCount);
......@@ -1165,9 +1154,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
}
#endif
#ifdef LOSCFG_BLACKBOX
BBoxNotifyError(EVENT_PANIC, MODULE_SYSTEM, "Crash in kernel", 1);
#endif
while (1) {}
}
......
......@@ -85,18 +85,12 @@ STATIC UINT32 *taskWaterLine = NULL;
#define OS_TASK_ALL_INFO_LEN (g_taskMaxNum * (sizeof(LosTaskCB) + sizeof(UINT32)))
#ifdef LOSCFG_FS_VFS
#ifdef LOSCFG_BLACKBOX
#define SaveExcInfo(arg, ...) WriteExcInfoToBuf(arg, ##__VA_ARGS__)
#else
#define SaveExcInfo(arg, ...)
#endif
#define PROCESS_INFO_SHOW(seqBuf, arg...) do { \
if (seqBuf != NULL) { \
(void)LosBufPrintf((struct SeqBuf *)seqBuf, ##arg); \
} else { \
PRINTK(arg); \
} \
SaveExcInfo(arg); \
} while (0)
#else
#define PROCESS_INFO_SHOW(seqBuf, arg...) PRINTK(arg)
......
config BLACKBOX
bool "Enable BlackBox"
default y
help
Answer Y to enable LiteOS support blackbox
config LOG_ROOT_PATH
string
default "/storage/data/log" if BLACKBOX
help
define the default log path of blackbox
\ No newline at end of file
include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard *.c)
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/common \
-I $(LITEOSTOPDIR)/kernel/common/blackbox \
-I $(LITEOSTOPDIR)/syscall \
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOS_BLACKBOX_H
#define LOS_BLACKBOX_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifndef __user
#define __user
#endif
#include "stdarg.h"
#include "los_typedef.h"
#define PATH_MAX_LEN 256
#define EVENT_MAX_LEN 32
#define MODULE_MAX_LEN 32
#define ERROR_DESC_MAX_LEN 512
#ifndef LOSCFG_LOG_ROOT_PATH
#define LOSCFG_LOG_ROOT_PATH "/storage/data/log"
#endif
#define KERNEL_FAULT_LOG_PATH LOSCFG_LOG_ROOT_PATH "/kernel_fault.log"
#define USER_FAULT_LOG_PATH LOSCFG_LOG_ROOT_PATH "/user_fault.log"
#define MODULE_SYSTEM "SYSTEM"
#define EVENT_SYSREBOOT "SYSREBOOT"
#define EVENT_LONGPRESS "LONGPRESS"
#define EVENT_COMBINATIONKEY "COMBINATIONKEY"
#define EVENT_SUBSYSREBOOT "SUBSYSREBOOT"
#define EVENT_POWEROFF "POWEROFF"
#define EVENT_PANIC "PANIC"
#define EVENT_SYS_WATCHDOG "SYSWATCHDOG"
#define EVENT_HUNGTASK "HUNGTASK"
#define EVENT_BOOTFAIL "BOOTFAIL"
struct ErrorInfo {
char event[EVENT_MAX_LEN];
char module[MODULE_MAX_LEN];
char errorDesc[ERROR_DESC_MAX_LEN];
};
struct ModuleOps {
char module[MODULE_MAX_LEN];
void (*Dump)(const char *logDir, struct ErrorInfo *info);
void (*Reset)(struct ErrorInfo *info);
int (*GetLastLogInfo)(struct ErrorInfo *info);
int (*SaveLastLog)(const char *logDir, struct ErrorInfo *info);
};
int BBoxRegisterModuleOps(struct ModuleOps *ops);
int BBoxNotifyError(const char event[EVENT_MAX_LEN],
const char module[MODULE_MAX_LEN],
const char errorDesc[ERROR_DESC_MAX_LEN],
int needSysReset);
int OsBBoxDriverInit(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif
\ No newline at end of file
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* ------------ includes ------------ */
#include "los_blackbox_common.h"
#ifdef LOSCFG_LIB_LIBC
#include "stdlib.h"
#include "unistd.h"
#endif
#include "fs/fs.h"
#include "securec.h"
#include "los_memory.h"
/* ------------ local macroes ------------ */
/* ------------ local prototypes ------------ */
/* ------------ local function declarations ------------ */
/* ------------ global function declarations ------------ */
/* ------------ local variables ------------ */
/* ------------ function definitions ------------ */
int FullWriteFile(const char *filePath, const char *buf, size_t bufSize, int isAppend)
{
int fd;
int totalToWrite = (int)bufSize;
int totalWrite = 0;
if (filePath == NULL || buf == NULL || bufSize == 0) {
BBOX_PRINT_ERR("filePath: %p, buf: %p, bufSize: %lu!\n", filePath, buf, bufSize);
return -1;
}
fd = open(filePath, O_CREAT | O_RDWR | (isAppend ? O_APPEND : O_TRUNC), 0644);
if (fd < 0) {
BBOX_PRINT_ERR("Create file [%s] failed, fd: %d!\n", filePath, fd);
return -1;
}
while (totalToWrite > 0) {
int writeThisTime = write(fd, buf, totalToWrite);
if (writeThisTime < 0) {
BBOX_PRINT_ERR("Failed to write file [%s]!\n", filePath);
(void)close(fd);
return -1;
}
buf += writeThisTime;
totalToWrite -= writeThisTime;
totalWrite += writeThisTime;
}
(void)close(fd);
return (totalWrite == (int)bufSize) ? 0 : -1;
}
int SaveBasicErrorInfo(const char *filePath, struct ErrorInfo *info)
{
char *buf;
if (filePath == NULL || info == NULL) {
BBOX_PRINT_ERR("filePath: %p, event: %p!\n", filePath, info);
return -1;
}
buf = LOS_MemAlloc(m_aucSysMem1, ERROR_INFO_MAX_LEN);
if (buf == NULL) {
BBOX_PRINT_ERR("LOS_MemAlloc failed!\n");
return -1;
}
(void)memset_s(buf, ERROR_INFO_MAX_LEN, 0, ERROR_INFO_MAX_LEN);
(void)snprintf_s(buf, ERROR_INFO_MAX_LEN, ERROR_INFO_MAX_LEN - 1,
ERROR_INFO_HEADER ERROR_INFO_HEADER_FORMAT, info->event, info->module, info->errorDesc);
*(buf + ERROR_INFO_MAX_LEN - 1) = '\0';
(void)FullWriteFile(filePath, buf, strlen(buf), 0);
(void)LOS_MemFree(m_aucSysMem1, buf);
return 0;
}
\ No newline at end of file
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOS_BLACKBOX_COMMON_H
#define LOS_BLACKBOX_COMMON_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifndef __user
#define __user
#endif
#include "los_blackbox.h"
#include "los_printf.h"
#include "los_typedef.h"
#define ERROR_INFO_HEADER "#### error info ####\n"
#define ERROR_INFO_HEADER_FORMAT "event: %s\nmodule: %s\nerrorDesc: %s\n"
#define ERROR_INFO_MAX_LEN 768
#define Min(a, b) (((a) > (b)) ? (b) : (a))
#define BBOX_PRINT_ERR(format, ...) PRINTK("bbox: func: %s, line: %d, Err: " \
format, __func__, __LINE__, ##__VA_ARGS__)
#define BBOX_PRINT_INFO(format, ...) PRINTK("bbox: Info: " format, ##__VA_ARGS__)
int FullWriteFile(const char *filePath, const char *buf, size_t bufSize, int isAppend);
int SaveBasicErrorInfo(const char *filePath, struct ErrorInfo *info);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif
\ No newline at end of file
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* ------------ includes ------------ */
#include "los_blackbox.h"
#include "los_blackbox_common.h"
#include "los_blackbox_detector.h"
#ifdef LOSCFG_LIB_LIBC
#include "stdlib.h"
#include "unistd.h"
#endif
#include "los_base.h"
#include "los_config.h"
#include "los_excinfo_pri.h"
#include "los_hw.h"
#include "los_init.h"
#include "los_memory.h"
#include "los_sem.h"
#include "los_syscall.h"
#include "securec.h"
#include "sys/reboot.h"
/* ------------ local macroes ------------ */
#define LOG_WAIT_TIMES 10
#define LOG_PART_WAIT_TIME 1000
/* ------------ local prototypes ------------ */
typedef struct BBoxOps {
LOS_DL_LIST opsList;
struct ModuleOps ops;
} BBoxOps;
/* ------------ local function declarations ------------ */
/* ------------ global function declarations ------------ */
/* ------------ local variables ------------ */
static UINT32 g_opsListSem = 0;
static UINT32 g_tempErrInfoSem = 0;
static LOS_DL_LIST_HEAD(g_opsList);
struct ErrorInfo *g_tempErrInfo;
/* ------------ function definitions ------------ */
static void FormatErrorInfo(struct ErrorInfo *info,
const char event[EVENT_MAX_LEN],
const char module[MODULE_MAX_LEN],
const char errorDesc[ERROR_DESC_MAX_LEN])
{
if (info == NULL || event == NULL || module == NULL || errorDesc == NULL) {
BBOX_PRINT_ERR("info: %p, event: %p, module: %p, errorDesc: %p!\n", info, event, module, errorDesc);
return;
}
(void)memset_s(info, sizeof(*info), 0, sizeof(*info));
(void)strncpy_s(info->event, sizeof(info->event), event, Min(strlen(event), sizeof(info->event) - 1));
info->event[sizeof(info->event) - 1] = '\0';
(void)strncpy_s(info->module, sizeof(info->module), module, Min(strlen(module), sizeof(info->module) - 1));
info->module[sizeof(info->module) - 1] = '\0';
(void)strncpy_s(info->errorDesc, sizeof(info->errorDesc), errorDesc,
Min(strlen(errorDesc), sizeof(info->errorDesc) - 1));
info->errorDesc[sizeof(info->errorDesc) - 1] = '\0';
}
#ifdef LOSCFG_FS_VFS
static bool IsLogPartReady(void)
{
return access(LOSCFG_LOG_ROOT_PATH, 0) == 0;
}
static void WaitForLogPart(void)
{
BBOX_PRINT_INFO("wait for log part [%s] begin!\n", LOSCFG_LOG_ROOT_PATH);
while (!IsLogPartReady()) {
LOS_Msleep(LOG_PART_WAIT_TIME);
}
BBOX_PRINT_INFO("wait for log part [%s] end!\n", LOSCFG_LOG_ROOT_PATH);
}
#else
static bool IsLogPartReady(void)
{
return TRUE;
}
static void WaitForLogPart(void)
{
int i = 0;
BBOX_PRINT_INFO("wait for log part [%s] begin!\n", LOSCFG_LOG_ROOT_PATH);
while (i++ < LOG_WAIT_TIMES) {
LOS_Msleep(LOG_PART_WAIT_TIME);
}
BBOX_PRINT_INFO("wait for log part [%s] end!\n", LOSCFG_LOG_ROOT_PATH);
}
#endif
static bool FindModuleOps(struct ErrorInfo *info, BBoxOps **ops)
{
bool found = false;
if (info == NULL || ops == NULL) {
BBOX_PRINT_ERR("info: %p, ops: %p!\n", info, ops);
return found;
}
LOS_DL_LIST_FOR_EACH_ENTRY(*ops, &g_opsList, BBoxOps, opsList) {
if (*ops != NULL && strcmp((*ops)->ops.module, info->module) == 0) {
found = true;
break;
}
}
if (!found) {
BBOX_PRINT_ERR("[%s] hasn't been registered!\n", info->module);
}
return found;
}
static void InvokeModuleOps(struct ErrorInfo *info, BBoxOps *ops)
{
if (info == NULL || ops == NULL) {
BBOX_PRINT_ERR("info: %p, ops: %p!\n", info, ops);
return;
}
if (ops->ops.Dump != NULL) {
BBOX_PRINT_INFO("[%s] starts dumping log!\n", ops->ops.module);
ops->ops.Dump(LOSCFG_LOG_ROOT_PATH, info);
BBOX_PRINT_INFO("[%s] ends dumping log!\n", ops->ops.module);
}
if (ops->ops.Reset != NULL) {
BBOX_PRINT_INFO("[%s] starts resetting!\n", ops->ops.module);
ops->ops.Reset(info);
BBOX_PRINT_INFO("[%s] ends resetting!\n", ops->ops.module);
}
}
static void SaveLastLog(const char *logDir)
{
struct ErrorInfo *info;
BBoxOps *ops;
info = LOS_MemAlloc(m_aucSysMem1, sizeof(*info));
if (info == NULL) {
BBOX_PRINT_ERR("LOS_MemAlloc failed!\n");
return;
}
if (LOS_SemPend(g_opsListSem, LOS_WAIT_FOREVER) != LOS_OK) {
BBOX_PRINT_ERR("Request g_opsListSem failed!\n");
(void)LOS_MemFree(m_aucSysMem1, info);
return;
}
LOS_DL_LIST_FOR_EACH_ENTRY(ops, &g_opsList, BBoxOps, opsList) {
if (ops == NULL) {
BBOX_PRINT_ERR("ops: NULL, please check it!\n");
continue;
}
if (ops->ops.GetLastLogInfo != NULL && ops->ops.SaveLastLog != NULL) {
(void)memset_s(info, sizeof(*info), 0, sizeof(*info));
if (ops->ops.GetLastLogInfo(info) != 0) {
BBOX_PRINT_ERR("[%s] failed to get log info!\n", ops->ops.module);
continue;
}
BBOX_PRINT_INFO("[%s] starts saving log!\n", ops->ops.module);
if (ops->ops.SaveLastLog(logDir, info) != 0) {
BBOX_PRINT_ERR("[%s] failed to save log!\n", ops->ops.module);
} else {
BBOX_PRINT_INFO("[%s] ends saving log!\n", ops->ops.module);
BBOX_PRINT_INFO("[%s] starts uploading event [%s]\n", info->module, info->event);
#ifdef LOSCFG_FS_VFS
(void)UploadEventByFile(KERNEL_FAULT_LOG_PATH);
#else
BBOX_PRINT_INFO("LOSCFG_FS_VFS isn't defined!\n");
#endif
BBOX_PRINT_INFO("[%s] ends uploading event [%s]\n", info->module, info->event);
}
} else {
BBOX_PRINT_ERR("module [%s], GetLastLogInfo: %p, SaveLastLog: %p!\n",
ops->ops.module, ops->ops.GetLastLogInfo, ops->ops.SaveLastLog);
}
}
(void)LOS_SemPost(g_opsListSem);
(void)LOS_MemFree(m_aucSysMem1, info);
}
static void SaveLogWithoutReset(struct ErrorInfo *info)
{
BBoxOps *ops;
if (info == NULL) {
BBOX_PRINT_ERR("info: %p!\n", info);
return;
}
if (LOS_SemPend(g_opsListSem, LOS_WAIT_FOREVER) != LOS_OK) {
BBOX_PRINT_ERR("Request g_opsListSem failed!\n");
return;
}
if (!FindModuleOps(info, &ops)) {
(void)LOS_SemPost(g_opsListSem);
return;
}
if (ops->ops.Dump == NULL && ops->ops.Reset == NULL) {
(void)LOS_SemPost(g_opsListSem);
if (SaveBasicErrorInfo(USER_FAULT_LOG_PATH, info) == 0) {
BBOX_PRINT_INFO("[%s] starts uploading event [%s]\n", info->module, info->event);
#ifdef LOSCFG_FS_VFS
(void)UploadEventByFile(USER_FAULT_LOG_PATH);
#else
BBOX_PRINT_INFO("LOSCFG_FS_VFS isn't defined!\n");
#endif
BBOX_PRINT_INFO("[%s] ends uploading event [%s]\n", info->module, info->event);
}
return;
}
InvokeModuleOps(info, ops);
(void)LOS_SemPost(g_opsListSem);
}
static void SaveTempErrorLog(void)
{
if (LOS_SemPend(g_tempErrInfoSem, LOS_WAIT_FOREVER) != LOS_OK) {
BBOX_PRINT_ERR("Request g_tempErrInfoSem failed!\n");
return;
}
if (g_tempErrInfo == NULL) {
BBOX_PRINT_ERR("g_tempErrInfo: %p!\n", g_tempErrInfo);