coredump: fix issue that calculated dump region range is

smaller than it should be.

0x21000000    0x210105e8    0x210105f8      0x21044000
  |----------------|-------------|--------------|

If there is already a range of 0x210105e8 - 0x210105f8, adding another
range of 0x21000000 - 0x21044000 would result in an incorrect range of
0x210105e8 - 0x21044000.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
wanggang26 2024-09-24 17:42:35 +08:00 committed by Xiang Xiao
parent bf70cd2bce
commit 2414fc91ff

View file

@ -777,11 +777,12 @@ int coredump_add_memory_region(FAR const void *ptr, size_t size)
return 0;
}
else if ((uintptr_t)ptr < region->end &&
else if ((uintptr_t)ptr < region->start &&
(uintptr_t)ptr + size >= region->end)
{
/* start in region, end out of region */
/* start out of region, end out of region */
region->start = (uintptr_t)ptr;
region->end = (uintptr_t)ptr + size;
return 0;
}
@ -793,12 +794,11 @@ int coredump_add_memory_region(FAR const void *ptr, size_t size)
region->start = (uintptr_t)ptr;
return 0;
}
else if ((uintptr_t)ptr < region->start &&
else if ((uintptr_t)ptr < region->end &&
(uintptr_t)ptr + size >= region->end)
{
/* start out of region, end out of region */
/* start in region, end out of region */
region->start = (uintptr_t)ptr;
region->end = (uintptr_t)ptr + size;
return 0;
}