Single Stepping source code stops on wrong line

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

Single Stepping source code stops on wrong line

2,428 次查看
Frank_Z
Contributor I

Running through my source code, I set a breakpoint, but when single stepping after the break the cursor is off three lines of code and stops on blank lines, comments.

标签 (1)
0 项奖励
回复
7 回复数

2,389 次查看
Frank_Z
Contributor I

Apparently my auto-build setting in tripleDemod_Debug_Segger doesn't build the project. I have to do that manually, then debugging works fine.

0 项奖励
回复

2,386 次查看
ErichStyger
Specialist I

I'm usually not using that feature, but I checked it on my side: it works as expected.

What I'm using otherwise is the global setting here:

ErichStyger_0-1655187551866.png

 

Are you sure you used the correct launch configuration?

0 项奖励
回复

2,404 次查看
bobpaddock
Senior Contributor III

The compiler optimization level can cause that.

Setting optimization to -O0 to turn it off should fix that problem.

However then you are not truly debugging your production code, nor is it a good idea to run with optimization disabled.  That can break some compile-time generated code, it can also cover up problems with missing volatiles or code-motion.

 

 

0 项奖励
回复

2,400 次查看
Frank_Z
Contributor I

Not sure that's a solution or temporary bandaid.

0 项奖励
回复

2,397 次查看
ErichStyger
Specialist I

Could you share a screenshot of what you are seeing?

 

Indeed, if you are using aggressive optimizations, then the compiler might move around code and remove things, so there is no clear indication between source code and generated code. But it should not point to empty lines, or at least I have never seen this. That the current source line jumps around, that is expected if high optimizations are enabled.

0 项奖励
回复

2,412 次查看
Frank_Z
Contributor I
I modify the file either in Kinetis or my editor, save and press debug with auto build.
I have to "Build Project" to get compiled.
0 项奖励
回复

2,421 次查看
ErichStyger
Specialist I

Are you sure you have not modified your source files after having them compiled?

Erich

0 项奖励
回复