Congratulations to our 2022 Qt Champions!

QML Debugging doesn't start QML profiler and don't stop at breakpoints

  • Hi everyone,
    I've been trying to debug qml code (especially using breakpoints) for the two pas days unsuccessfully. I was wondering if someone could tell me what i did wrong.

    What i've done :
    First I'm using make and not qmake so i've added -DQT_QML_DEBUG to the CXXFLAGS variable in my makefile.
    Secondly, the program is quite huge and Qt is just a part of it. It doesn't start the QApp first. It's mainly c++ stuff loading modules and files before launching the QApp for the UI. Also, it has it's own param parser (and do not accept -qmljsdebugger as a valid param ^^ ) so passing the -qmljsdebugger option was quite tricky but i manage to did it in two different ways :

    1. Debugging without QML Debugging option enabled (in the Project panel) so QtCreator Debugger doesn't add the -qmljsdebugger option at startup.
      When the QApp is created I've hard coded (it's only for debug so it won't stay in final version) -qmljsdebugger=port:55000,block,services:DebugMessages,QmlDebugger,V8Debugger,QmlInspector into the argv variable and the application seems to start well outputting : QML Debugger: Waiting for connection on port 55000...
      Then I quickly start the QML debugging (Debugging > Start Debug > Attach to QML port) on port 55000 and it successfuly connects showing me various graph in the Debug panel.

    2. Debugging with QML Debugging option enabled : I'm catching the parameter -qmljsdebugger before it's interpreted as multiple short parameters (-q, -m, -l, ...) and relaying the port number up to the point where the QApp is created. At that point i'm adding -qmljsdebugger=port:<portnumber>,block,services:DebugMessages,QmlDebugger,V8Debugger,QmlInspector into the argv variable. I've double checked the parameter i'm writing, it's the right one with the same port number as the one caught earlier.
      Then everything seems alright the QMLDebug panel can show me some graphs about memory usage and statistics as with case (1)

    But nevertheless, in both case, the execution doesn't stop at breakpoints even if the QML profiler seems up.
    And also, i've tried to use the console.profile() and console.profileEnd() functions but the program outputs in the two cases Cannot start profiling because debug service is disabled. Start with -qmljsdebugger=port:XXXXX. . I'm not sure but if the qml debug interface can show me stats isn't the debug service supposed to be enabled ?

    So there is my problem. Can anyone help me to get the debug working properly or see an error in what i did ? Maybe i need more than just passing the -qmljsdebugger option and starting the QMLProfiler ?

    QtCreator 4.2.0
    Qt 5.7.1

Log in to reply