Skip to content

Commit 12d8468

Browse files
committed
implemented facilities to inject ubsan/valgrind workarounds in the codebase
this commit adds a new define that allows to inject code with various workarounds we don't want to see in prodcution but are still desired to mask known issues with ubsan/valgrind. Signed-off-by: Parshintsev Anatoly <[email protected]>
1 parent 7854d70 commit 12d8468

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/target/riscv/riscv_reg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ static int resize_reg(const struct target *target, uint32_t regno, bool exist,
586586
reg->size = size;
587587
reg->exist = exist;
588588
if (reg->exist) {
589+
#ifdef ENABLE_UB_WORKAROUNDS
590+
reg->value = calloc(1, DIV_ROUND_UP(reg->size, 8));
591+
#else
589592
reg->value = malloc(DIV_ROUND_UP(reg->size, 8));
593+
#endif
590594
if (!reg->value) {
591595
LOG_ERROR("Failed to allocate memory.");
592596
return ERROR_FAIL;

0 commit comments

Comments
 (0)