Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Several problems with data breakpoint



  • The data breakpoint in Qt Creator doesn't behave the way I want. The code snippet is as follows:

    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        //qDebug("6! is %lu", MathFunctions::factorial(6));
        int values[] = { 6, 7, 8 };
        for(unsigned int i = 0; i < sizeof(values)/sizeof(int); i++)
        {
            qDebug() << values[i] << "! = "
                << MathFunctions::factorial(values[i]);
        }
    
        return a.exec();
    }
    

    I first set a normal breakpoint at QCoreApplication a(argc, argv); Then step over until the for line. Right click over i in the Local tab, Add Data Breakpoint -> Add Data Breakpoint at Object's Address (0x...), then press F5 to continue.

    Problem 1.
    The execution breaks twice instead of once at the for line. My understanding of data breakpoint is that it causes the execution to stop wherever the code changes the value of the variable (i here). But i is only changed at i++ at this line. Why does the debugger break twice?

    Problem 2.
    The execution also breaks inside the for loop (at qDebug() << line) which does not change i at all. According to my understanding above, the debugger shouldn't break because the value of i is not changed. Why does the debugger break here?

    Problem 3.
    I stopped the debugging and restart it using the steps described above. The data breakpoint does not work this time. The program just runs ahead over the for loop. The data breakpoint is still listed in the breakpoints pane and I have enabled it. Why is the data breakpoint not hit?

    My environment

    • Windows 10, 64 bit
    • Desktop Qt 5.10.1 for Visual Studio 2015 (default kit) and 2017, Qt Creator 4.6.1
    • Visual Studio 2015 and 2017
    • CDB installed
      alt text

    If you need any other information for troubleshooting, please let me know. Thank you.


Log in to reply