[patch] only update dcache after write succeeds

Doug Evans dje@google.com
Tue Sep 15 06:58:00 GMT 2009


On Mon, Sep 14, 2009 at 12:16 PM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> Marc, Greg: Can you see if this patch fixes things for you?
>
> 2009-09-14  Doug Evans  <dje@google.com>
>
>        * target.c (memory_xfer_partial): Only update dcache after we know
>        the write succeeded.
>
> Index: target.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/target.c,v
> retrieving revision 1.223
> diff -u -p -r1.223 target.c
> --- target.c    8 Sep 2009 23:52:45 -0000       1.223
> +++ target.c    14 Sep 2009 19:11:38 -0000
> @@ -1289,19 +1289,6 @@ memory_xfer_partial (struct target_ops *
>        }
>     }
>
> -  /* Make sure the cache gets updated no matter what - if we are writing
> -     to the stack, even if this write is not tagged as such, we still need
> -     to update the cache. */
> -
> -  if (inf != NULL
> -      && readbuf == NULL
> -      && !region->attrib.cache
> -      && stack_cache_enabled_p
> -      && object != TARGET_OBJECT_STACK_MEMORY)
> -    {
> -      dcache_update (target_dcache, memaddr, (void *) writebuf, reg_len);
> -    }
> -
>   /* If none of those methods found the memory we wanted, fall back
>      to a target partial transfer.  Normally a single call to
>      to_xfer_partial is enough; if it doesn't recognize an object
> @@ -1331,6 +1318,20 @@ memory_xfer_partial (struct target_ops *
>   if (readbuf && !show_memory_breakpoints)
>     breakpoint_restore_shadows (readbuf, memaddr, reg_len);
>
> +  /* Make sure the cache gets updated no matter what - if we are writing
> +     to the stack.  Even if this write is not tagged as such, we still need
> +     to update the cache.  */
> +
> +  if (res > 0
> +      && inf != NULL
> +      && writebuf != NULL
> +      && !region->attrib.cache
> +      && stack_cache_enabled_p
> +      && object != TARGET_OBJECT_STACK_MEMORY)
> +    {
> +      dcache_update (target_dcache, memaddr, (void *) writebuf, reg_len);
> +    }
> +
>   /* If we still haven't got anything, return the last error.  We
>      give up.  */
>   return res;
>

Of course I did forget to pass the correct length.

009-09-14  Doug Evans  <dje@google.com>

        * target.c (memory_xfer_partial): Pass correct length to dcache_update.

Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.225
diff -u -p -r1.225 target.c
--- target.c    15 Sep 2009 03:30:06 -0000      1.225
+++ target.c    15 Sep 2009 06:54:16 -0000
@@ -1333,7 +1333,7 @@ memory_xfer_partial (struct target_ops *
       && stack_cache_enabled_p
       && object != TARGET_OBJECT_STACK_MEMORY)
     {
-      dcache_update (target_dcache, memaddr, (void *) writebuf, reg_len);
+      dcache_update (target_dcache, memaddr, (void *) writebuf, res);
     }

   /* If we still haven't got anything, return the last error.  We



More information about the Gdb-patches mailing list