给exc_info等dumpfile的文件名添加时间戳
authorSnickerSun <snickersun@163.com>
Fri, 7 Jun 2024 13:20:35 +0000 (21:20 +0800)
committerSnickerSun <snickersun@163.com>
Fri, 7 Jun 2024 13:20:35 +0000 (21:20 +0800)
code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c
code/sdk/middleware/chips/brandy/exception/exception_riscv.c
code/sdk/middleware/utils/dfx/preserve/private/preserve.c

index ea74ec4..42b0f16 100755 (executable)
@@ -56,7 +56,7 @@ typedef struct diag_msg_para {
 } diag_msg_para_t;\r
 \r
 #if defined(SAVE_EXC_INFO) && (CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES)\r
-static const char *g_bt_exc_info_path = "/user/exc/bt_exc_info.bin";\r
+static const char *g_bt_exc_info_path = "/user/exc/bt_exc_info_%d.bin";\r
 #endif\r
 oam_cmd_handle_callback g_diag_debug_proc = NULL;\r
 uint8_t g_recv_msg_step = SDT_MSG_STEP_HEAD;\r
@@ -267,7 +267,11 @@ static bool zdiag_adapt_sdt_short_msg_report(uint8_t *data, uint32_t data_len)
         } else if (om_msg_header->func_type == OM_MSG_TYPE_LAST) {\r
             zdiag_adapt_sdt_om_last_parse(data, (uint16_t)data_len, &para);\r
 #if defined(SAVE_EXC_INFO) && (CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES)\r
-            if (exc_info_write(g_bt_exc_info_path, 0, para.buf, (uint32_t)para.buf_size) < 0) {\r
+            uint32_t timestamp = get_local_timestamp();\r
+            char *str = (char *)malloc(200);\r
+            memset_s(str, 200, 0, 200);\r
+            sprintf(str, g_bt_exc_info_path, timestamp);\r
+            if (exc_info_write(str, 0, para.buf, (uint32_t)para.buf_size) < 0) {\r
                 dfx_log_err("exc_info_write error.\r\n");\r
             }\r
 #endif\r
index 0a0e6d1..d5d4119 100755 (executable)
@@ -131,7 +131,7 @@ static const uint8_t g_xregs_map[] = {
     6,  5,  4,  19, 18, 17, 16\r
 };\r
 #if CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES\r
-static const char *g_exc_info_path = "/user/exc/exc_info.bin";\r
+static const char *g_exc_info_path = "/user/exc/exc_info_%d.bin";\r
 #endif\r
 #endif\r
 \r
@@ -803,8 +803,11 @@ errcode_t emmc_exc_info_write(void)
         osal_kfree(exc_info_buffer);\r
         return ERRCODE_SUCC;\r
     }\r
-\r
-    int32_t ret = exc_info_write(g_exc_info_path, 0, (const uint8_t *)exc_info_buffer, ONE_SECTOR_SIZE);\r
+    uint32_t timestamp = get_local_timestamp();\r
+    char *str = (char *)malloc(200);\r
+    memset_s(str, 200, 0, 200);\r
+    sprintf(str, g_exc_info_path, timestamp);\r
+    int32_t ret = exc_info_write(str, 0, (const uint8_t *)exc_info_buffer, ONE_SECTOR_SIZE);\r
     if (ret < 0) {\r
         osal_kfree(exc_info_buffer);\r
         return ERRCODE_FAIL;\r
@@ -829,7 +832,11 @@ static errcode_t exc_info_write_local(exc_info_save_t *exc_info_save, uint32_t e
 #ifdef CFG_DRIVERS_NANDFLASH\r
     nand_driver_init(SPEED_SLOW);\r
     set_trans_type(TRANS_BY_CPU_SINGLE_LINE);\r
-    ret = exc_info_write(g_exc_info_path, 0, (const uint8_t *)exc_info_save, exc_size);\r
+    uint32_t timestamp = get_local_timestamp();\r
+    char *str = (char *)malloc(200);\r
+    memset_s(str, 200, 0, 200);\r
+    sprintf(str, g_exc_info_path, timestamp);\r
+    ret = exc_info_write(str, 0, (const uint8_t *)exc_info_save, exc_size);\r
     dump_all_to_file();\r
 #endif\r
 #ifdef CFG_DRIVERS_MMC\r
index e26b6d8..6325d42 100755 (executable)
@@ -113,16 +113,25 @@ void save_preserve_file_to_nand(void)
 
 void save_btram_file_to_nand(void)
 {
-    const char *btram_info_path = "/user/exc/bt_ram_info.bin";
+    const char *btram_info_path = "/user/exc/bt_ram_info_%d.bin";
+    uint32_t timestamp = get_local_timestamp();
+    char *str = (char *)malloc(200);
+    memset_s(str, 200, 0, 200);
+    sprintf(str, btram_info_path, timestamp);
+
     int32_t ret =
-        exc_info_write(btram_info_path, 0, (uint8_t *)BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH);
+        exc_info_write(str, 0, (uint8_t *)BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH);
     printf("save_btram_file_to_nand ret:%d.\r\n", ret);
 }
 
 void save_btrace_file_to_nand(void)
 {
-    const char *btrace_info_path = "/user/exc/btrace_info.bin";
-    int32_t ret = exc_info_write(btrace_info_path, 0, (uint8_t *)BTRACE_ADDR_EXEC, BTRACE_ADDR_EXEC_LEN);
+    const char *btrace_info_path = "/user/exc/btrace_info_%d.bin";
+    uint32_t timestamp = get_local_timestamp();
+    char *str = (char *)malloc(200);
+    memset_s(str, 200, 0, 200);
+    sprintf(str, btrace_info_path, timestamp);
+    int32_t ret = exc_info_write(str, 0, (uint8_t *)BTRACE_ADDR_EXEC, BTRACE_ADDR_EXEC_LEN);
     printf("save_btrace_file_to_nand ret:%d.\r\n", ret);
 }
 #endif