armv4_5: prevent segfault when gdb connects to an underinitialised target

This prevents segmentation fault that can occur on cortex_a targets if
gdb connection is established before it's halted and CPSR examined.

Change-Id: Id996200e0fd95440496509c1fecaabbdbf425e23
Tested-by: Henrik Nordstrom <hno@squid-cache.org>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1446
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
__archive__
Paul Fertser 2013-06-16 11:11:32 +04:00 committed by Spencer Oliver
parent a6863e9a52
commit 434afb370f
1 changed files with 5 additions and 1 deletions

View File

@ -429,6 +429,10 @@ struct reg *arm_reg_current(struct arm *arm, unsigned regnum)
if (regnum > 16) if (regnum > 16)
return NULL; return NULL;
if (!arm->map) {
LOG_ERROR("Register map is not available yet, the target is not fully initialised");
r = arm->core_cache->reg_list + regnum;
} else
r = arm->core_cache->reg_list + arm->map[regnum]; r = arm->core_cache->reg_list + arm->map[regnum];
/* e.g. invalid CPSR said "secure monitor" mode on a core /* e.g. invalid CPSR said "secure monitor" mode on a core