svd2rust icon indicating copy to clipboard operation
svd2rust copied to clipboard

Add Debug trait implementation

Open newpavlov opened this issue 7 years ago • 3 comments

It would be very helpful to have a Debug traits implemented for register structs. Currently if I am debugging some code or interested in how things work I simply add something like this to memory map crate. It will be mainly useful for read and memory block structs, but some may find it usefull for write structs too.

newpavlov avatar Dec 27 '16 14:12 newpavlov

It would be very helpful to have a Debug traits implemented for register structs.

Are you serializing/printing the registers through UART/ITM? I wonder if this could be handled with GDB pretty printers, then:

(gdb) print block.register
{
    fooen: true,
    baren: false,
    ..
}

would Just Work.

In any case, I'm OK with adding Debug implementations to RegisterRs. The implementation should use the "formatting structs" though, then we get pretty printing ({#?}) for free.

japaric avatar Dec 27 '16 15:12 japaric

I am using ITM. If I am not mistaken this will not work nicely with projects compiled with --release (at least with default options). Also it will be friendlier for user to just use several iprinln!'s to see how registers change without any additional typing in the console.

"formatting structs" will be a great way to do it.

newpavlov avatar Dec 27 '16 15:12 newpavlov

I assume this issue refers to the RegisterBlock structs. In addition, it would be useful to also have Debug implementations for the peripheral structs that dereference to them (the one's with the ptr method).

hannobraun avatar Jul 22 '20 11:07 hannobraun

Fixed by #716

burrbull avatar Nov 24 '23 18:11 burrbull