Breakpoint not working

Discuss how to use the features of Atollic TrueSTUDIO, including the editor, assembler, C/C++ compiler, linker, debugger, static code analysis and team collaboration tools.

Moderators: Markus Girdland, Mattias Norlander

Posts: 0
Joined: Sat Dec 12, 2015 10:41 am

Breakpoint not working

Postby apex » Fri Dec 18, 2015 5:43 am

Hello, i am using atollic lite and sometime before the breakpoint function ok.

But starting from yesterday,
it didnot work again.

I make a simple code

/* Includes */
#include <stddef.h>
#include "stm32f10x.h"

/* Private macro */
/* Private variables */
USART_InitTypeDef USART_InitStructure;

/* Private function prototypes */
/* Private functions */

** Abstract: main program
int main(void)
int i = 0;
i = 0;

i put the breakpoint in i=0; but it didnt go there,


Mattias Norlander
Posts: 273
Joined: Fri Apr 29, 2016 10:01 am

Hi Jeff, Which build configuration are

Postby Mattias Norlander » Fri Dec 18, 2015 6:35 am

Hi Jeff,

Which build configuration are you using?
Debug - uses Optimization level -O0
Release - uses Optimization level -Os (s=size)

Using Release when debugging is not very useful, partly because there will be less debug symbols in the elf-file and partly because the C code may be optimized in a way where C code and assembly instructions does not match well. So use "DEBUG" build configuration when debugging.

If I try your code example using DEBUG and RELEASE build configurations, this is the assembly instructions generated resepectively:

"DEBUG" build configuration, I get these assembly instructions:
80003dc: b480 push {r7}
80003de: b083 sub sp, #12
80003e0: af00 add r7, sp, #0
int j = 0;
80003e2: 2300 movs r3, #0
80003e4: 603b str r3,
int i = 0;
80003e6: 2300 movs r3, #0
80003e8: 607b str r3,
{ i++;
80003ea: 687b ldr r3,
80003ec: 3301 adds r3, #1
80003ee: 607b str r3,
80003f0: 687b ldr r3,
80003f2: f5b3 7f7a cmp.w r3, #1000 ; 0x3e8
80003f6: dd02 ble.n 80003fe
i = 0;
80003f8: 2300 movs r3, #0
80003fa: 607b str r3,
80003fc: e7f5 b.n 80003ea
80003fe: e7f4 b.n 80003ea

"RELEASE" build configuration, I get these assembly instructions:
8000330: e7fe b.n 8000330

Quite a difference... Why?

One possible problem source here is that you are not using volatile for your local variable. Omitting the volatile keyword will allow the compiler to do various optimizations on your code to improve the size (if -Os)

Adding the volatile will result in no differences for "DEBUG" build configuraiton, but big differences for "RELEASE" build configuration:

8000330: b082 sub sp, #8
volatile int i = 0;
8000332: 2300 movs r3, #0
8000334: 9301 str r3,
{ i++;
8000336: 9b01 ldr r3,
8000338: 3301 adds r3, #1
800033a: 9301 str r3,
800033c: 9b01 ldr r3,
800033e: f5b3 7f7a cmp.w r3, #1000 ; 0x3e8
8000342: ddf8 ble.n 8000336
8000344: e7f5 b.n 8000332

My best guess is that you need volatile!

Return to “Atollic TrueSTUDIO tool discussions”

Who is online

Users browsing this forum: No registered users and 2 guests