Any comments on how breakpoints work on external targets, running bare-metal, and you can't replace instructions? Ex. debugging an 8-bit AVR, say atmega1280 over JTAG. I am guessing it has to do with the JTAG doing a simple compare of the PC with the breakpoint address, just want confirmation and more details.
TickleSteve|9 years ago
The breakpoint registers are accessed via JTAG/SWD using your j-link/FET/whatever.
Quite often, when you're debugging embedded systems, you run out of "hardware" breakpoints and have to resort to software-style breakpoints described in the article.
sigill|9 years ago
The situation is kinda OK when you don't often change breakpoints and your CPU has an instruction register writable by the debug probe via JTAG/SWD/etc. Upon stepping or continuing from a breakpoint, the debugger will write the actual instruction at the breakpoint into the instruction register and tell the CPU "run again, but don't load the instruction from memory as I have already loaded it into your instruction register.".
Another option is to emulate the effects of the instruction in the debugger and write the results back into registers/RAM/I/O. This is not always possible.
If you don't have the options above, your flash will wear down quickly, as stepping away or continuing from a breakpoint entails writing the actual instruction back, stepping, then writing the breakpoint again.
cnvogel|9 years ago
For AVR specifically, have a look at e.g. https://github.com/raimue/avarice/blob/master/src/jtagbp.cc (just random find on github, likely not the official repository).
This is, by the way, also possible on a typical PC (as in "personal computer" not program counter), also x86/64 has debug registers.
http://www.codeproject.com/Articles/28071/Toggle-hardware-da...
...and very likely also on ARM, m68k, MIPS, Sparc, PPC, ... I just didn't look it up.
garaetjjte|9 years ago
sigill|9 years ago