aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fertser <fercerpav@gmail.com>2016-12-12 11:50:17 +0300
committerPaul Fertser <fercerpav@gmail.com>2016-12-25 09:23:56 +0000
commitd491b88dd94afb7c796dbe89ea52aecdefebf1cc (patch)
tree3f33353fe0e4ea0911b8697b915c317eb170f481
parentee4f11dd6822608b60363766646c96c5290ab7ba (diff)
target: cortex_a: fix segfault when SPSR is not properly handled
OpenOCD doesn't (yet) know how to handle HYP mode properly so spsr register is not getting initialised when OpenOCD connects to a target stopped in this mode. Reported on IRC by thinkfat and nearffxx. Change-Id: I4bda9ba0c582c8e9cacefe708cc4a3d947151f84 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/3906 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de> Reviewed-by: Chengyu Zheng <chengyu.zheng@polimi.it>
-rw-r--r--src/target/cortex_a.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index d0eac751..8c8a2b79 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -1241,16 +1241,18 @@ static int cortex_a_debug_entry(struct target *target)
reg->dirty = reg->valid;
}
- /* read Saved PSR */
- retval = cortex_a_dap_read_coreregister_u32(target, &spsr, 17);
- /* store current spsr */
- if (retval != ERROR_OK)
- return retval;
+ if (arm->spsr) {
+ /* read Saved PSR */
+ retval = cortex_a_dap_read_coreregister_u32(target, &spsr, 17);
+ /* store current spsr */
+ if (retval != ERROR_OK)
+ return retval;
- reg = arm->spsr;
- buf_set_u32(reg->value, 0, 32, spsr);
- reg->valid = 1;
- reg->dirty = 0;
+ reg = arm->spsr;
+ buf_set_u32(reg->value, 0, 32, spsr);
+ reg->valid = 1;
+ reg->dirty = 0;
+ }
#if 0
/* TODO, Move this */