Placing breakpoint

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Placing breakpoint

Jump to solution
2,627 Views
etolocka
Contributor I
Hi

I´m using CW 5.1 to program a GT60 micro using C. Sometimes, I can´t place a breakpoint where I want in the code, and CW moves it to a near instruction. Why?

Thankfully,
Ernesto.

Labels (1)
Tags (1)
0 Kudos
1 Solution
564 Views
BlackNight
NXP Employee
NXP Employee
Hello,
well, that really depends a little bit of that source code. Maybe you just did a mistake like
if (ui == -1) ....
and if the variable is unsigned, the compiler may have optimized the whole block away? In such a case, the compiler would have you warned about that (with a message). I suggest that you check the compiler messages around the code in question (maybe you simply did an error in the source code?).

If this is not the reason, you may switch off optimizations, and here are some options you could try:
-Onu
-Onf
-O0
-Ona
-Onb
-Ont

If the code is around a variable, you can enforce disabling optimizations making the variable volatile (but this is really only something as a last resort: typically the compiler is right optimizing code).

BK

View solution in original post

0 Kudos
5 Replies
564 Views
Witztronics
Contributor IV
Many times this happens when you try to place a breakpoint at a label, comment or on code that has been stripped out by the compiler as dead (not used) code.
 
 
 
0 Kudos
564 Views
BlackNight
NXP Employee
NXP Employee
Hello,
a good tip is to enable Marks in the debugger (source window context menu, or menu Source > Marks): then the debugger shows with marks in the source window where line debug information is available  (where you can set a breakpoint). I have this enabled by default.

BK
0 Kudos
564 Views
etolocka
Contributor I
Hi!

I´m trying to place the breakpoint at a executable instruction, not a label or dead code.

Regards,
Ernesto.

0 Kudos
564 Views
etolocka
Contributor I
Enabling "marks" I can see that there is no debugging info where I want to place the breakpoint. Why? Can I force the compiler to do this?

Regards,
Ernesto.

0 Kudos
565 Views
BlackNight
NXP Employee
NXP Employee
Hello,
well, that really depends a little bit of that source code. Maybe you just did a mistake like
if (ui == -1) ....
and if the variable is unsigned, the compiler may have optimized the whole block away? In such a case, the compiler would have you warned about that (with a message). I suggest that you check the compiler messages around the code in question (maybe you simply did an error in the source code?).

If this is not the reason, you may switch off optimizations, and here are some options you could try:
-Onu
-Onf
-O0
-Ona
-Onb
-Ont

If the code is around a variable, you can enforce disabling optimizations making the variable volatile (but this is really only something as a last resort: typically the compiler is right optimizing code).

BK

0 Kudos