Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Missing RISC-V debug guard #1684

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/include/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,22 @@
#define DEBUG_INFO(...) PLATFORM_PRINTF(__VA_ARGS__)
#else
#define DEBUG_ERROR(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WARN(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_INFO(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_ERROR_IS_NOOP
#define DEBUG_WARN(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WARN_IS_NOOP
#define DEBUG_INFO(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_INFO_IS_NOOP
#endif
#define DEBUG_GDB(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_GDB(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_GDB_IS_NOOP
#define DEBUG_TARGET(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROTO(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROBE(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WIRE(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_TARGET_IS_NOOP
#define DEBUG_PROTO(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROTO_IS_NOOP
#define DEBUG_PROBE(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROBE_IS_NOOP
#define DEBUG_WIRE(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WIRE_IS_NOOP

void debug_serial_send_stdout(const uint8_t *data, size_t len);
#else
Expand Down
6 changes: 6 additions & 0 deletions src/target/riscv32.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ void riscv32_mem_read(target_s *const target, void *const dest, const target_add

#if ENABLE_DEBUG
DEBUG_PROTO("%s: @ %08" PRIx32 " len %zu:", __func__, src, len);
#ifndef DEBUG_PROTO_IS_NOOP
const uint8_t *const data = (const uint8_t *)dest;
#endif
for (size_t offset = 0; offset < len; ++offset) {
if (offset == 16U)
break;
Expand All @@ -576,8 +578,11 @@ void riscv32_mem_read(target_s *const target, void *const dest, const target_add

void riscv32_mem_write(target_s *const target, const target_addr_t dest, const void *const src, const size_t len)
{
#if ENABLE_DEBUG
DEBUG_PROTO("%s: @ %" PRIx32 " len %zu:", __func__, dest, len);
#ifndef DEBUG_PROTO_IS_NOOP
const uint8_t *const data = (const uint8_t *)src;
#endif
for (size_t offset = 0; offset < len; ++offset) {
if (offset == 16U)
break;
Expand All @@ -586,6 +591,7 @@ void riscv32_mem_write(target_s *const target, const target_addr_t dest, const v
if (len > 16U)
DEBUG_PROTO(" ...");
DEBUG_PROTO("\n");
#endif
/* If we're asked to do a 0-byte read, do nothing */
if (!len)
return;
Expand Down