[PATCH 02/10] Don't update target_dcache if it is not initialized

Yao Qi
2013-11-03T05:56:03Z

After previous patch, 'target_dcache' is initialized lazily. It is
possible that 'target_dcache' is still NULL when GDB writes to memory.
In this case, update to 'target_dcache' can be skipped.

gdb:

2013-11-02 Yao Qi <yao@codesourcery.com>

* target.c (memory_xfer_partial_1): Update 'target_dcache' if
it is initialized.
---
gdb/target.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gdb/target.c b/gdb/target.c
index 6403e86..1a076f3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1667,11 +1667,12 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
if (res > 0
&& inf != NULL
&& writebuf != NULL
+ && target_dcache_init_p ()
&& !region->attrib.cache
&& stack_cache_enabled_p
&& object != TARGET_OBJECT_STACK_MEMORY)
{
- DCACHE *dcache = target_dcache_get_or_init ();
+ DCACHE *dcache = target_dcache_get ();

dcache_update (dcache, memaddr, (void *) writebuf, res);
}
--
1.7.7.6