Skip to main content
Alpha Mr
Associate II
Jan 5, 2019 12:16 PM UTC
Solved

Truestudio don't stop at breakpoint

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

This topic has been closed for replies.
S.Ma
S.MaBest answer
Principal
Jan 5, 2019 1:47 PM UTC

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....

4 replies

S.Ma
S.MaBest answer
Principal
Jan 5, 2019 1:47 PM UTC

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....

Alpha Mr
Alpha MrAuthor
Associate II
Jan 7, 2019 4:19 AM UTC

This worked for me! Thanks.

Tesla DeLorean
Guru
Jan 5, 2019 2:46 PM UTC

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
kurta999
Senior
Jan 9, 2019 3:32 PM UTC

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