This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Re: Flash memory size not aligned to address


On Sat, Oct 7, 2017 at 3:42 PM, Kevin Buettner <kevinb@redhat.com> wrote:
>
> Hi Mark,
>
> I did notice, however, that you added [PATCH] to the subject line,
> so perhaps you were just getting the subject line formatted in
> such a way so that it might be noticed?


Indeed, that was my plan.

>
> Do you have an FSF Copyright Assignment?
>

No.

> ChangeLog entries are generally not posted as patches.  It is unlikely
> that this portion of the patch will cleanly apply once it's approved.

Ok.  Thank you for pointing me to the wiki.  I was going off of
gdb/CONTRIBUTE.  Which one is authoritative?

> It occurs to me that address_in_region might be better named
> offset_in_region.

Updated patch follows.

> It seems to me that there will be no difference in behavior for
> targets whose region boundaries are already aligned to the block size.
> I do wonder, however, about behavior on other targets that don't meet
> this criteria.  I'm hoping that someone else who has more experience in
> this area will comment.

The only situation I can think of would be a device that begins a
section of flash unaligned, but requires an aligned address for the
erase command.  I'm not aware of such, but it's a big world.

Anyway, thanks for looking it over. Here goes second try:

gdb/ChangeLog:

        * target-memory.c (block_boundaries): Fix for block address not
        aligned on block size.

diff --git a/gdb/target-memory.c b/gdb/target-memory.c
index 1c8faa8..7f048de 100644
--- a/gdb/target-memory.c
+++ b/gdb/target-memory.c
@@ -138,14 +138,18 @@ block_boundaries (CORE_ADDR address, CORE_ADDR
*begin, CORE_ADDR *end)
 {
   struct mem_region *region;
   unsigned blocksize;
+  CORE_ADDR offset_in_region;

   region = lookup_mem_region (address);
   gdb_assert (region->attrib.mode == MEM_FLASH);
   blocksize = region->attrib.blocksize;
+
+  offset_in_region = address - region->lo;
+
   if (begin)
-    *begin = address / blocksize * blocksize;
+    *begin = region->lo + offset_in_region / blocksize * blocksize;
   if (end)
-    *end = (address + blocksize - 1) / blocksize * blocksize;
+    *end = region->lo + (offset_in_region + blocksize - 1) /
blocksize * blocksize;
 }

-- 
Regards,
Mark
markrages@gmail


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]