Search code examples
c++debugginggdbqt-creatorbreakpoints

QtCreator: breakpoints not working (in debug mode)


I am running QtCreator 2.4.1 and certain breakpoints are skipped when I am working on a 'Plain c project' in the debug mod. I can reproduce the problem with the following code:

#include <stdio.h>
void foo()
{
  //statement 1
  //statement 2
  ...
  //End of function
}

int main(void)
{
  printf("String1!\n");
  printf("String2!\n");
  printf("String3!\n");
  foo();
  return 0;
}

If I set a breakpoint on the line that prints "String1" in the main() function, the debugger just ignores it and goes on to execute all the below statements and run foo, but when I set the breakpoint anywhere inside function foo, the results are as expected(it does break). Can anyone explain/give fix to this behavior? Additionally, I also noted that if I place the breakpoint in the main() after giving any scanf statement, it still works as expected..


Solution

  • I recently found that this was a reported bug with qtcreator, they seem to have fixed this in the latest stable build.