Skip to main content
Knowledgebase
Home
Renesas India - Knowledgebase

How to set a breakpoint in a line in the C source code during debug?

Latest Updated:09/10/2007

Question:

I want to set a breakpoint in a line in the C source code during debug, but I can’t figure out how to do so.

Answer:

There are certain cases in which a breakpoint cannot be set in a line in the code during C source code debug.

Example)

void main(void)

{

    int a;

    int i;

    for ( i = 0 ; i < 10 ; i++ ){

        a++;

    }

}

The above program is built when the optimization is valid.
The result: because the replacement for variable a is optimized, the program is regarded as length and meaningless and a command code for that line is not generated.
In these conditions, a breakpoint cannot be set at a++ line during C source code debug.
You need to either set the break in the reverse-assembler display or inhibit the optimization of variable a. By specifying volatile int a; to inhibit the optimization, the a++; instruction code will be generated and a breakpoint can be set in the code.

Suitable Products
C/C++ Compiler Package for SuperH Family
C/C++ Compiler Package for H8SX, H8S, H8 Family
Simulator Debugger for SuperH Family [for High-performance Embedded Workshop]
Simulator Debugger for H8SX, H8S, and H8 Families [for High-performance Embedded Workshop]