cancel
Showing results for 
Search instead for 
Did you mean: 

Truestudio don't stop at breakpoint

Alpha Mr
Associate II

I am trying to debug the program using ST link on the board STM32F0308-DISCO. But after adding a breakpoint the Truestudio don't stop at the break point

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.

And if you need to keep the optimizations on?

  • Add an asm("nop/n");
  • Make some global variables volatile and put a conditional if(myvolatilevar) asm("nop/n"); will enable you to even activate code post compile using the debugger because the compiler won't optimize as much.

volatile uint8_t always_zero = 0;
 
(...)
your code
if(always_zero)
 { asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....

View solution in original post

4 REPLIES 4
S.Ma
Principal

Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.

And if you need to keep the optimizations on?

  • Add an asm("nop/n");
  • Make some global variables volatile and put a conditional if(myvolatilevar) asm("nop/n"); will enable you to even activate code post compile using the debugger because the compiler won't optimize as much.

volatile uint8_t always_zero = 0;
 
(...)
your code
if(always_zero)
 { asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....

Or the code simply doesn't get there?

__asm("BKPT #0\n"); 

Perhaps add telemetry via a USART so you can establish flow and function.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This worked for me! Thanks.

In TrueStudio I'm unable to step to next line when using software breakpoints? Is that OK?