EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How does H/W and S/W Breakpoints work?

Started by #define December 14, 2005
Hello,

Please help me to understand how does debuggers work in embedded
scenarios? Especially software and hardware breakpoints?

Also, the differences in compiler outputs DEBUG and RELEASE modes?

If u can suggest any books or websites, it'll be great!!!

Thanks in advance,

Best Regards,

#define.

#define wrote:

> Please help me to understand how does debuggers work in embedded > scenarios? Especially software and hardware breakpoints? >
If you're debugging in RAM, the old fashioned method was to replace the breakpoint address code with a software interrupt. The breakpoint restored the opcode before continuing. There also used to be a sort of halfway- house available using EPROM emulators, which could often add breakpoints etc. in the RAM which replaced the EPROM memory, but these have rather dropped out since most embedded systems started to use on-chip flash. These days, it's common to use an on-chip hardware comparator to activate the breakpoint, which has the advantage that you can work directly on the program memory, but often has the downside that the number of breakpoints available is limited. If the IC hasn't got this built-in, you have to either use an in- circuit emulator (usually $$$) or flash an LED, output strings etc. to find out what's gone awry.
> Also, the differences in compiler outputs DEBUG and RELEASE modes? >
DEBUG mode includes information to allow the debugger to display the C (etc.) code for the instruction being executed. In the old days, we generally had to output an assembler listing from the high level code, and bash through that to see where things had gone wrong. The worst sort listed the C and assembler separately, and it was a devil to see where you were up to. Paul Burke #undefine
#define wrote On 12/14/05 08:55,:
> Hello, > > Please help me to understand how does debuggers work in embedded > scenarios? Especially software and hardware breakpoints? >
A breakpoint is an interrupt that goes to a debugger, which then does whatever it needs to do to compensate the program counter or other registers to make it appear as if the software magically halted at the breakpoint. It does not matter whether software or hardware caused the interrupt, although typically with software interrupts, the debugger must place, then remove, a interrupt causing instruction.
> Also, the differences in compiler outputs DEBUG and RELEASE modes? >
Usually, just the number of symbols included with the program. Hard to answer unless you give a specific system.
> If u can suggest any books or websites, it'll be great!!! > > Thanks in advance, > > Best Regards, > > #define. >
Debug mode, turns on the debug switch in the compiler: for example in
GCC (the free GNU compiler)  the switch is "-g"  Turning this switch on
causes the compiler to include:
line number information
variable adress and type information
module/local scope information (when locals are "alive")

This lets a source level debugger show your source by referencing this
debug file.

Hardware break points are typically on-chip these days and can be code
execution type (stop when an address is executed) and data type (stop
when data location is accessed)
So chips even have options for stop on a data value. Hardware breaks
are good for debugging code in FLASH, or in cases where the place in
memory that contains the inserted instruction for a software break
could be overwritten. Two examples would be a boot loader that copies
itself from FLASH to RAM, or a LINUX loadable module, that must be
loaded by linux, then run
hope this helps

Pat


Memfault Beyond the Launch