adamgreen / mri

MRI - Monitor for Remote Inspection. The gdb compatible debug monitor for Cortex-M devices.
Apache License 2.0
155 stars 58 forks source link

Check parameters for memory operations #36

Closed anjiahao1 closed 1 year ago

anjiahao1 commented 1 year ago

In this way, we can give gdb the simplest memory xml Just use 0x00000000-0xffffffff on ram, then we trust gdb won't Access an unsafe address other than zero.

The advantage is simplicity, And it's easier to debug without some memory xml.

Signed-off-by: anjiahao anjiahao@xiaomi.com

anjiahao1 commented 1 year ago

@adamgreen hi,i use MRI in many of device. it works very well. could you review the code?

adamgreen commented 1 year ago

@anjiahao1 I don't really understand the purpose of this change. It just seems to ignore accesses to address 0x00000000. What does that help? What if I want to read out the word located at address 0 since it usually contains the initial stack pointer value? When is it easier to debug without memory XML? If you want to access something like a memory mapped peripheral register that isn't in the XML then send GDB the set mem inaccessible-by-default off command to have it ignore the memory XML. The reason to use the XML is that when you are debugging a hard fault there are certain scenarios where GDB attempting to access an invalid address will result in a double fault leading to hard locking the CPU. Most of the time MRI can detect invalid accesses though and will just let GDB know by returning an error.

anjiahao1 commented 1 year ago

@anjiahao1 I don't really understand the purpose of this change. It just seems to ignore accesses to address 0x00000000. What does that help? What if I want to read out the word located at address 0 since it usually contains the initial stack pointer value? When is it easier to debug without memory XML? If you want to access something like a memory mapped peripheral register that isn't in the XML then send GDB the set mem inaccessible-by-default off command to have it ignore the memory XML. The reason to use the XML is that when you are debugging a hard fault there are certain scenarios where GDB attempting to access an invalid address will result in a double fault leading to hard locking the CPU. Most of the time MRI can detect invalid accesses though and will just let GDB know by returning an error.

Thanks for your reply, I don't know much about gdb's set mem inaccessible-by-default off before, i will try use it, and close this PR.

adamgreen commented 1 year ago

👍🏻