simavr
simavr copied to clipboard
AVR_MCU_VCD_SYMBOL only supports addresses in the IO space - and causes UB if used with other addresses
I thought I'd use AVR_MCU_VCD_SYMBOL
to trace the value of a variable in my program. It didn't do anything. So I dug into it more.
In sim_elf.c
, avr_load_firmware
calls avr_iomem_getirq
with the address contained in the AVR_MCU_VCD_SYMBOL
directive, but neither it nor avr_iomem_getirq
check the address for validity.
So if you give the directive the address of a variable in your program, avr_iomem_getirq
will silently access past the end of the avr->io
array. Oops.