From b5bbd05923f11ae2c593da006abf6cda7ce214b2 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 28 Aug 2017 15:19:41 -0700 Subject: [PATCH] Add a nice debug printf for debug_module_t::store --- riscv/debug_module.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 17ec616..53df8a4 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -110,6 +110,19 @@ bool debug_module_t::load(reg_t addr, size_t len, uint8_t* bytes) bool debug_module_t::store(reg_t addr, size_t len, const uint8_t* bytes) { + D( + switch (len) { + case 4: + fprintf(stderr, "store(addr=0x%lx, len=%d, bytes=0x%08x); " + "hartsel=0x%x\n", addr, (unsigned) len, *(uint32_t *) bytes, + dmcontrol.hartsel); + break; + default: + fprintf(stderr, "store(addr=0x%lx, len=%d, bytes=...); " + "hartsel=0x%x\n", addr, (unsigned) len, dmcontrol.hartsel); + break; + } + ); uint8_t id_bytes[4]; uint32_t id = 0; @@ -126,7 +139,6 @@ bool debug_module_t::store(reg_t addr, size_t len, const uint8_t* bytes) } if (addr >= debug_progbuf_start && ((addr + len) <= (debug_progbuf_start + sizeof(program_buffer)))) { - D(fprintf(stderr, "Successful write to program buffer %d bytes at %x\n", (int) len, (int) addr)); memcpy(program_buffer + addr - debug_progbuf_start, bytes, len); return true; -- 2.30.2