Placing breakpoint

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Placing breakpoint

跳至解决方案
3,229 次查看
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.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,166 次查看
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 项奖励
回复
5 回复数
1,166 次查看
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 项奖励
回复
1,166 次查看
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 项奖励
回复
1,166 次查看
etolocka
Contributor I
Hi!

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

Regards,
Ernesto.

0 项奖励
回复
1,166 次查看
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 项奖励
回复
1,167 次查看
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 项奖励
回复