coredump:Add coredump success log printing to remind you to use coreudmp

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-02-02 11:20:52 +08:00 committed by Xiang Xiao
parent 5f4c1721ff
commit 8d0d1f7571

View File

@ -115,7 +115,7 @@ static void coredump_dump_blkdev(pid_t pid)
if (g_blockstream.inode == NULL) if (g_blockstream.inode == NULL)
{ {
_alert("Coredump Device Not Found\n"); _alert("Coredump device not found\n");
return; return;
} }
@ -123,14 +123,15 @@ static void coredump_dump_blkdev(pid_t pid)
g_blockinfo, g_blockstream.geo.geo_nsectors - 1, 1); g_blockinfo, g_blockstream.geo.geo_nsectors - 1, 1);
if (ret < 0) if (ret < 0)
{ {
_alert("Coredump Device Read Fail\n"); _alert("Coredump information read fail\n");
return; return;
} }
info = (FAR struct coredump_info_s *)g_blockinfo; info = (FAR struct coredump_info_s *)g_blockinfo;
if (info->magic == COREDUMP_MAGIC) if (info->magic == COREDUMP_MAGIC)
{ {
_alert("Coredump Device Already Used\n"); _alert("Coredump exists in %s, skip\n",
CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
return; return;
} }
@ -143,7 +144,7 @@ static void coredump_dump_blkdev(pid_t pid)
ret = core_dump(g_regions, stream, pid); ret = core_dump(g_regions, stream, pid);
if (ret < 0) if (ret < 0)
{ {
_alert("Coredump Fail\n"); _alert("Coredump fail\n");
return; return;
} }
@ -151,8 +152,16 @@ static void coredump_dump_blkdev(pid_t pid)
info->size = g_blockstream.common.nput; info->size = g_blockstream.common.nput;
info->time = time(NULL); info->time = time(NULL);
uname(&info->name); uname(&info->name);
g_blockstream.inode->u.i_bops->write(g_blockstream.inode, ret = g_blockstream.inode->u.i_bops->write(g_blockstream.inode,
(FAR void *)info, g_blockstream.geo.geo_nsectors - 1, 1); (FAR void *)info, g_blockstream.geo.geo_nsectors - 1, 1);
if (ret < 0)
{
_alert("Coredump information write fail\n");
return;
}
_alert("Finish coredump, write %d bytes to %s\n",
info->size, CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
} }
#endif #endif
@ -174,7 +183,7 @@ int coredump_initialize(void)
g_regions = alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE); g_regions = alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE);
if (g_regions == NULL) if (g_regions == NULL)
{ {
_alert("Memory Region Alloc Fail\n"); _alert("Coredump memory region alloc fail\n");
return -ENOMEM; return -ENOMEM;
} }
} }
@ -184,7 +193,7 @@ int coredump_initialize(void)
CONFIG_BOARD_COREDUMP_BLKDEV_PATH); CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
if (ret < 0) if (ret < 0)
{ {
_alert("%s Coredump Device Not Found\n", _alert("%s Coredump device not found\n",
CONFIG_BOARD_COREDUMP_BLKDEV_PATH); CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
free_memory_region(g_regions); free_memory_region(g_regions);
g_regions = NULL; g_regions = NULL;
@ -194,7 +203,7 @@ int coredump_initialize(void)
g_blockinfo = kmm_malloc(g_blockstream.geo.geo_sectorsize); g_blockinfo = kmm_malloc(g_blockstream.geo.geo_sectorsize);
if (g_blockinfo == NULL) if (g_blockinfo == NULL)
{ {
_alert("Coredump Device Memory Alloc Fail\n"); _alert("Coredump device memory alloc fail\n");
free_memory_region(g_regions); free_memory_region(g_regions);
g_regions = NULL; g_regions = NULL;
lib_blkoutstream_close(&g_blockstream); lib_blkoutstream_close(&g_blockstream);