Skip to content

Commit

Permalink
coredump:Add coredump success log printing to remind you to use coreudmp
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <[email protected]>
  • Loading branch information
anjiahao1 authored and xiaoxiang781216 committed Aug 11, 2024
1 parent 5f4c172 commit 8d0d1f7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions sched/misc/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,23 @@ static void coredump_dump_blkdev(pid_t pid)

if (g_blockstream.inode == NULL)
{
_alert("Coredump Device Not Found\n");
_alert("Coredump device not found\n");
return;
}

ret = g_blockstream.inode->u.i_bops->read(g_blockstream.inode,
g_blockinfo, g_blockstream.geo.geo_nsectors - 1, 1);
if (ret < 0)
{
_alert("Coredump Device Read Fail\n");
_alert("Coredump information read fail\n");
return;
}

info = (FAR struct coredump_info_s *)g_blockinfo;
if (info->magic == COREDUMP_MAGIC)
{
_alert("Coredump Device Already Used\n");
_alert("Coredump exists in %s, skip\n",
CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
return;
}

Expand All @@ -143,16 +144,24 @@ static void coredump_dump_blkdev(pid_t pid)
ret = core_dump(g_regions, stream, pid);
if (ret < 0)
{
_alert("Coredump Fail\n");
_alert("Coredump fail\n");
return;
}

info->magic = COREDUMP_MAGIC;
info->size = g_blockstream.common.nput;
info->time = time(NULL);
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);
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

Expand All @@ -174,7 +183,7 @@ int coredump_initialize(void)
g_regions = alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE);
if (g_regions == NULL)
{
_alert("Memory Region Alloc Fail\n");
_alert("Coredump memory region alloc fail\n");
return -ENOMEM;
}
}
Expand All @@ -184,7 +193,7 @@ int coredump_initialize(void)
CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
if (ret < 0)
{
_alert("%s Coredump Device Not Found\n",
_alert("%s Coredump device not found\n",
CONFIG_BOARD_COREDUMP_BLKDEV_PATH);
free_memory_region(g_regions);
g_regions = NULL;
Expand All @@ -194,7 +203,7 @@ int coredump_initialize(void)
g_blockinfo = kmm_malloc(g_blockstream.geo.geo_sectorsize);
if (g_blockinfo == NULL)
{
_alert("Coredump Device Memory Alloc Fail\n");
_alert("Coredump device memory alloc fail\n");
free_memory_region(g_regions);
g_regions = NULL;
lib_blkoutstream_close(&g_blockstream);
Expand Down

0 comments on commit 8d0d1f7

Please sign in to comment.