diff options
author | Liming Sun <lsun@mellanox.com> | 2018-11-05 10:26:05 -0500 |
---|---|---|
committer | Matthias Welwarsky <matthias@welwarsky.de> | 2018-12-18 13:23:07 +0000 |
commit | 651998e33771bdad56873e3e70bd875104ca1d12 (patch) | |
tree | 7d1d79cbae3eba3e8086adb84198e72e69bbc3ec /src/target/armv8.c | |
parent | bff87a7f28fb60b40f14a91ed3bef982bdc8db92 (diff) | |
download | riscv-openocd-651998e33771bdad56873e3e70bd875104ca1d12.zip riscv-openocd-651998e33771bdad56873e3e70bd875104ca1d12.tar.gz riscv-openocd-651998e33771bdad56873e3e70bd875104ca1d12.tar.bz2 |
target: armv8: Add TARGET_HALTED check for gdb connect
This commit adds TARGET_HALTED check in armv8_get_core_reg32()
and armv8_set_core_reg32() to void a crash issue when gdb connects
but fails to halt the ARM core. Similar logic can be found in
armv8_get_core_reg() and armv8_set_core_reg().
Below is the call stack information of this case when gdb connects.
(gdb) bt
regnum=regnum@entry=0, dpm=0x990110) at src/target/armv8_dpm.c:657
r=0x9c7240, regnum=0, mode=<optimized out>) at src/target/armv8_dpm.c:974
at src/target/armv8.c:1487
packet=0x8ec8e0 <gdb_packet_buffer.9962> "g",
packet_size=<optimized out>, connection=<optimized out>)
at src/server/gdb_server.c:1200
at src/server/gdb_server.c:3180
command_context=command_context@entry=0x935010)
at src/server/server.c:566
...
Change-Id: I159837b533f110998184f910a0abe48409bd58f1
Signed-off-by: Liming Sun <lsun@mellanox.com>
Reviewed-on: http://openocd.zylin.com/4758
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'src/target/armv8.c')
-rw-r--r-- | src/target/armv8.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/target/armv8.c b/src/target/armv8.c index 75ada89..887e21d 100644 --- a/src/target/armv8.c +++ b/src/target/armv8.c @@ -1477,6 +1477,9 @@ static int armv8_get_core_reg32(struct reg *reg) struct reg *reg64; int retval; + if (target->state != TARGET_HALTED) + return ERROR_TARGET_NOT_HALTED; + /* get the corresponding Aarch64 register */ reg64 = cache->reg_list + armv8_reg->num; if (reg64->valid) { @@ -1500,6 +1503,9 @@ static int armv8_set_core_reg32(struct reg *reg, uint8_t *buf) struct reg *reg64 = cache->reg_list + armv8_reg->num; uint32_t value = buf_get_u32(buf, 0, 32); + if (target->state != TARGET_HALTED) + return ERROR_TARGET_NOT_HALTED; + if (reg64 == arm->cpsr) { armv8_set_cpsr(arm, value); } else { |