From 45b5178b1a0e8d66fa436c4cce48e1959e9b7326 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Mon, 20 May 2019 21:35:58 +0100 Subject: [PATCH] RISC-V compliance test: target must be examined (#367) The test assumes that the target has been examined. If that fails (for whatever reason) the test will segfault: Program received signal SIGSEGV, Segmentation fault. register_cache_invalidate (cache=0x0) at ../src/target/register.c:109 109 struct reg *reg = cache->reg_list; (gdb) bt 0 register_cache_invalidate (cache=0x0) at ../src/target/register.c:109 1 0x0000000000520735 in riscv_invalidate_register_cache (target=target@entry=0x779b50) at ../src/target/riscv/riscv.c:2160 2 0x000000000052224f in riscv_halt_all_harts (target=target@entry=0x779b50) at ../src/target/riscv/riscv.c:2022 3 0x0000000000574e82 in riscv013_test_compliance (target=0x779b50) at ../src/target/riscv/riscv-013.c:3600 --- src/target/riscv/riscv-013.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 41af8156a..a3381b655 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -3723,6 +3723,12 @@ int riscv013_test_compliance(struct target *target) return ERROR_FAIL; } + if (!target_was_examined(target)) { + LOG_ERROR("Cannot run compliance test, because target has not yet " + "been examined, or the examination failed.\n"); + return ERROR_FAIL; + } + int total_tests = 0; int passed_tests = 0;