From 90c0c28327c26514b0f5a3f4169c2f700cad32e8 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Thu, 23 Jun 2016 10:27:43 +1200 Subject: [PATCH] cortexa: Redirect read of PC through r0. MCR is unpredictable for r15. --- src/cortexa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cortexa.c b/src/cortexa.c index d1b23dd..51b546f 100644 --- a/src/cortexa.c +++ b/src/cortexa.c @@ -380,9 +380,12 @@ static void cortexa_regs_read_internal(target *t) { struct cortexa_priv *priv = (struct cortexa_priv *)t->priv; /* Read general purpose registers */ - for (int i = 0; i < 16; i++) { + for (int i = 0; i < 15; i++) { priv->reg_cache.r[i] = read_gpreg(t, i); } + /* Read PC, via r0. MCR is UNPREDICTABLE for Rt = r15. */ + apb_write(t, DBGITR, 0xe1a0000f); /* mov r0, pc */ + priv->reg_cache.r[15] = read_gpreg(t, 0); /* Read CPSR */ apb_write(t, DBGITR, 0xE10F0000); /* mrs r0, CPSR */ priv->reg_cache.cpsr = read_gpreg(t, 0);