While attempting to implement SPI in zig on an STM32G4 I got the error "Cannot access memory at address 0x40013000".
For reasons I don't understand gdb / the debug server (pyOCD) is not properly mapping the peripheral memory on the stm32g474re.
(gdb) p self.instance.CR1
Cannot access memory at address 0x40013000
After some searching, the simple hack/fix is to tell GDB to map that region:
mem 0x40000000 0x42000000 32 rw
Then the whole typedef can easily be printed out:
(gdb) p *self.instance
$6 = {CR1 = 260, CR2 = 1792, SR = 2, DR = 0, CRCPR = 7, RXCRCR = 0, TXCRCR = 0, I2SCFGR = 0, I2SPR = 0}
Cheers!