This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix memory-region overlapping checking
Given the example you posted,
> Let me correct my previous example. It should be
> (gdb) mem 0x50 0x80 ro
> (gdb) mem 0xffffff00 0 ro
> (gdb) mem 0x100 0x200 ro
> overlapping memory region
>
It is a bug.
On Thursday, August 02, 2012 02:10:40 PM Wei-cheng Wang wrote:
> Wei-cheng
>
> 2012-08-02 Wei-cheng Wang <cole945@gmail.com>
>
> * memattr.c (create_mem_region): Fix memory-region overlapping
> checking in special case.
>
> diff --git a/gdb/memattr.c b/gdb/memattr.c
> --- a/gdb/memattr.c
> +++ b/gdb/memattr.c
> @@ -207,7 +207,7 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
>
> if ((lo >= n->lo && (lo < n->hi || n->hi == 0))
> || (hi > n->lo && (hi <= n->hi || n->hi == 0))
> - || (lo <= n->lo && (hi >= n->hi || hi == 0)))
> + || (lo <= n->lo && ((hi >= n->hi && n->hi != 0) || hi == 0)))
> {
> printf_unfiltered (_("overlapping memory region\n"));
> return;
I read your patch, and draw some charts on paper to show the relationship of
these four variables here for overlapping.
This line is to check the overlapping like,
lo n->lo n->hi hi
However, without your fix, the following case is treated as overlapping by
mistake,
lo hi n->lo n->hi (0)
Your patch looks correct to me, however I am not the people to approve it.
This line of code was written in 2002, so a 10-year-old bug is fixed! :)
--
Yao (éå)