static int srecorder_debug_modem_err(srecorder_reserved_mem_info_t *pmem_info) { char *x; int size; int i = 0; int bytes_read = 0; int max = MIN(MODEM_CRASH_LOG_MAX_LENGTH, pmem_info->bytes_left - (DMESG_MAX_LENGTH + SZ_1K)); x = srecorder_smem_find(ID_DIAG_ERR_MSG, SZ_DIAG_ERR_MSG); if (NULL != x) { x[SZ_DIAG_ERR_MSG - 1] = 0; bytes_read = SRECORDER_SNPRINTF(pmem_info->start_addr + pmem_info->bytes_read, max - i, "smem: DIAG '%s'\n", x); srecorder_renew_meminfo(pmem_info, bytes_read); i += bytes_read; } x = srecorder_smem_get_entry(SMEM_ERR_CRASH_LOG, &size); if (NULL != x) { x[size - 1] = 0; bytes_read = SRECORDER_SNPRINTF(pmem_info->start_addr + pmem_info->bytes_read, max - i, "smem: CRASH LOG\n'%s'\n", x); srecorder_renew_meminfo(pmem_info, bytes_read); i += bytes_read; } /* 删除此处3行 */ return i; }
/** @function: int srecorder_get_crash_time(srecorder_reserved_mem_info_for_log_t *pmem_info) @brief: 记录死机发生的时间,顺便记录死机的原因。 @param: pmem_info SRecorder的保留内存信息 @return: 0 - 成功;-1-失败 @note: */ int srecorder_get_crash_time(srecorder_reserved_mem_info_t *pmem_info) { struct timeval tv; /* struct timex txc; */ struct rtc_time tm; int bytes_read = 0; char *pbuf = NULL; psrecorder_info_header_t pinfo_header = NULL; if (unlikely(NULL == pmem_info)) { SRECORDER_PRINTK("File [%s] line [%d] invalid param or kernel symbol addr!\n", __FILE__, __LINE__); return -1; } if (srecorder_get_bit(CRASH_REASON_TIME)) { SRECORDER_PRINTK("Crash reason and time have been dumped successfully!\n"); return 0; } memset(&tv, 0, sizeof(struct timeval)); /* memset(&txc, 0, sizeof(struct timex)); */ memset(&tm, 0, sizeof(struct rtc_time)); if (0 != srecorder_write_info_header(pmem_info, CRASH_REASON_TIME, &pinfo_header)) { return -1; } do_gettimeofday(&tv); tv.tv_sec -= sys_tz.tz_minuteswest * 60; /* 一分钟=60秒 */ rtc_time_to_tm(tv.tv_sec, &tm); pbuf = pmem_info->start_addr + pmem_info->bytes_read; bytes_read = SRECORDER_SNPRINTF(pmem_info->start_addr + pmem_info->bytes_read, pmem_info->bytes_left, "Crash reason: %s %s Crash Time: %04d%02d%02d-%02d:%02d:%02d\n", (NULL == pmem_info->crash_reason1) ? ("") : (pmem_info->crash_reason1), (NULL == pmem_info->crash_reason2) ? ("") : (pmem_info->crash_reason2), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); srecorder_renew_meminfo(pmem_info, bytes_read); srecorder_validate_info_header(pinfo_header, pmem_info->bytes_per_type); return 0; }
/** @function:int srecorder_write_info_header(srecorder_reserved_mem_info_for_log_t *pmem_info, srecorder_info_type_e type, psrecorder_info_header_t *pinfo_header) @brief: 初始化给类信息的头部数据结构 @param: pmem_info SRecorder的保留内存信息 @param: type 信息类型 @param: pinfo_header 信息头部校验数据结构 @return: 0 - 成功;-1-失败 @note: */ int srecorder_write_info_header(srecorder_reserved_mem_info_t *pmem_info, srecorder_info_type_e type, psrecorder_info_header_t *pinfo_header) { int bytes_read = 0; /* 删除此处定义 */ #ifndef CONFIG_SRECORDER_DUMP_LOG_TO_STORAGECARD int info_header_size = sizeof(srecorder_info_header_t); #endif if (unlikely(NULL == pmem_info || NULL == pmem_info->start_addr || NULL == pinfo_header || (LOG_TYPE_COUNT <= (int)type || (int)type < 0))) { SRECORDER_PRINTK("File [%s] line [%d] invalid param!\n", __FILE__, __LINE__); return -1; } #ifndef CONFIG_SRECORDER_DUMP_LOG_TO_STORAGECARD /*把校验信息的头部结构留出来*/ /* 删除此处 */ if ((pmem_info->bytes_read + info_header_size) > pmem_info->mem_size) { return -1; } *pinfo_header = (psrecorder_info_header_t)(pmem_info->start_addr + pmem_info->bytes_read); memset(*pinfo_header, 0, info_header_size); ((psrecorder_info_header_t)*pinfo_header)->type = type; pmem_info->bytes_read += (info_header_size); #endif pmem_info->bytes_per_type = 0; bytes_read = SRECORDER_SNPRINTF(pmem_info->start_addr + pmem_info->bytes_read, pmem_info->bytes_left, "%s\n", s_srecorder_head_info[type].desciprion); srecorder_renew_meminfo(pmem_info, bytes_read); return 0; }