Skip to content

Commit

Permalink
coredump: refine coredump info analyse
Browse files Browse the repository at this point in the history
VELAFORCAR-504

Change-Id: I165d2d0dce3f81a8571e2cee2e522b5f6f6c21dc
Signed-off-by: wanggang26 <[email protected]>
  • Loading branch information
wanggang26 committed Aug 18, 2024
1 parent f7adb52 commit c14e40c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sched/misc/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static void coredump_dump_blkdev(pid_t pid)
{
FAR void *stream = &g_blockstream;
FAR struct coredump_info_s *info;
blkcnt_t nsectors;
int ret;

if (g_blockstream.inode == NULL)
Expand All @@ -118,8 +119,12 @@ static void coredump_dump_blkdev(pid_t pid)
return;
}

nsectors = (sizeof(struct coredump_info_s) +
g_blockstream.geo.geo_sectorsize - 1) /
g_blockstream.geo.geo_sectorsize;

ret = g_blockstream.inode->u.i_bops->read(g_blockstream.inode,
g_blockinfo, g_blockstream.geo.geo_nsectors - 1, 1);
g_blockinfo, g_blockstream.geo.geo_nsectors - nsectors, nsectors);
if (ret < 0)
{
_alert("Coredump information read fail\n");
Expand Down Expand Up @@ -149,10 +154,10 @@ static void coredump_dump_blkdev(pid_t pid)

info->magic = COREDUMP_MAGIC;
info->size = g_blockstream.common.nput;
info->time = time(NULL);
info->time = time(NULL);
uname(&info->name);
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 - nsectors, nsectors);
if (ret < 0)
{
_alert("Coredump information write fail\n");
Expand Down Expand Up @@ -191,6 +196,7 @@ int coredump_set_memory_region(FAR struct memory_region_s *region)

int coredump_initialize(void)
{
blkcnt_t nsectors;
int ret = 0;

if (CONFIG_BOARD_MEMORY_RANGE[0] != '\0')
Expand All @@ -216,7 +222,11 @@ int coredump_initialize(void)
return ret;
}

g_blockinfo = kmm_malloc(g_blockstream.geo.geo_sectorsize);
nsectors = (sizeof(struct coredump_info_s) +
g_blockstream.geo.geo_sectorsize - 1) /
g_blockstream.geo.geo_sectorsize;

g_blockinfo = kmm_malloc(g_blockstream.geo.geo_sectorsize * nsectors);
if (g_blockinfo == NULL)
{
_alert("Coredump device memory alloc fail\n");
Expand All @@ -227,6 +237,7 @@ int coredump_initialize(void)
}
#endif

UNUSED(nsectors);
return ret;
}

Expand Down

0 comments on commit c14e40c

Please sign in to comment.