Single Stepping source code stops on wrong line

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

Single Stepping source code stops on wrong line

2,421 Views
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.

Labels (1)
0 Kudos
Reply
7 Replies

2,382 Views
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 Kudos
Reply

2,379 Views
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 Kudos
Reply

2,397 Views
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 Kudos
Reply

2,393 Views
Frank_Z
Contributor I

Not sure that's a solution or temporary bandaid.

0 Kudos
Reply

2,390 Views
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 Kudos
Reply

2,405 Views
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 Kudos
Reply

2,414 Views
ErichStyger
Specialist I

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

Erich

0 Kudos
Reply