Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is the correct debug steps ?
Forum Updated to NodeBB v4.3 + New Features

What is the correct debug steps ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VincentLiu
    wrote on last edited by
    #1

    Hello,

    Can anyone share with the correct debugging steps with Qt creator? What I already know is opening the debug mode and run, then the program will stop at the place where it unexpectedly crashed. However, the debugging tool shows the page with assembly code which is not easily to trace the root cause. Is there any UI in the debugging tool which is more friendly and providing more information ? If not, what would you do when the program unexpectedly exit without any error message?

    Thanks.

    J.HilkJ 1 Reply Last reply
    0
    • BjornWB Offline
      BjornWB Offline
      BjornW
      wrote on last edited by
      #2

      Did you build in Debug mode? You can't really debug a release build.

      V 1 Reply Last reply
      0
      • V VincentLiu

        Hello,

        Can anyone share with the correct debugging steps with Qt creator? What I already know is opening the debug mode and run, then the program will stop at the place where it unexpectedly crashed. However, the debugging tool shows the page with assembly code which is not easily to trace the root cause. Is there any UI in the debugging tool which is more friendly and providing more information ? If not, what would you do when the program unexpectedly exit without any error message?

        Thanks.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @VincentLiu

        well, thats a very big topic there.

        but the following should get you startet:

        with a right-mouse-click in the creater -Mouse over the linecounter preferably - you can set Breakpoints.

        Wenn this line of code is called, your program will stop at this breakpoint. You than can look into all local and global variables and see their current values - usualy on the right hand side- with F10 you can continue one more line, with F5 you resume the program untill the next breakpoint


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        V 1 Reply Last reply
        0
        • BjornWB BjornW

          Did you build in Debug mode? You can't really debug a release build.

          V Offline
          V Offline
          VincentLiu
          wrote on last edited by
          #4

          @BjornW

          Excuse me, what do you mean "debug a release build" ? I usually choose the "debug", and then "run" (Ctrl + R) every time I changed my code and wanted to see the result. Is that correct?

          jsulmJ J.HilkJ 2 Replies Last reply
          0
          • J.HilkJ J.Hilk

            @VincentLiu

            well, thats a very big topic there.

            but the following should get you startet:

            with a right-mouse-click in the creater -Mouse over the linecounter preferably - you can set Breakpoints.

            Wenn this line of code is called, your program will stop at this breakpoint. You than can look into all local and global variables and see their current values - usualy on the right hand side- with F10 you can continue one more line, with F5 you resume the program untill the next breakpoint

            V Offline
            V Offline
            VincentLiu
            wrote on last edited by kshegunov
            #5

            @J.Hilk said in What is the correct debug steps ?:

            over

            Thanks, Hilk. Sometimes the code didn't crash at the same line. That is, sometimes it runs correctly in one iteration, while it fails somewhere in another iteration. Since I cannot catch or say guess the possible line. I have no idea where to set the breakpoint. Maybe simply set a lot of breakpoints is the most simple but workable way?

            1 Reply Last reply
            0
            • V VincentLiu

              @BjornW

              Excuse me, what do you mean "debug a release build" ? I usually choose the "debug", and then "run" (Ctrl + R) every time I changed my code and wanted to see the result. Is that correct?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @VincentLiu In which file do you see the assembler code if you app is crashing? Is it some library?
              If you see assembler that means you are in a binary which was build in release mode (without debug information).

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • V VincentLiu

                @BjornW

                Excuse me, what do you mean "debug a release build" ? I usually choose the "debug", and then "run" (Ctrl + R) every time I changed my code and wanted to see the result. Is that correct?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by J.Hilk
                #7

                @VincentLiu

                You have the option to build your project in a release and a debug build.

                To use the QT-Debug-Tool you have to build your project in the debug build and start the Debuger with your program.

                To start the your program and the debugger, click on the "Play"button left hand side with the little "Bug" on the right side :) or F5 alternatively

                Edit
                to answer you question, when you run your program with the debugger(F5) it very rarely shows you assamble code as the crash-point.
                But if it does, I personly place a

                qDebug() << "Funktion start";
                
                qDebug() << "Funktion stop";
                

                at start and end, of the function I assume has the error.
                9/10 times culprit is a not initialized pointer....


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                kshegunovK 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @VincentLiu

                  You have the option to build your project in a release and a debug build.

                  To use the QT-Debug-Tool you have to build your project in the debug build and start the Debuger with your program.

                  To start the your program and the debugger, click on the "Play"button left hand side with the little "Bug" on the right side :) or F5 alternatively

                  Edit
                  to answer you question, when you run your program with the debugger(F5) it very rarely shows you assamble code as the crash-point.
                  But if it does, I personly place a

                  qDebug() << "Funktion start";
                  
                  qDebug() << "Funktion stop";
                  

                  at start and end, of the function I assume has the error.
                  9/10 times culprit is a not initialized pointer....

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  @J.Hilk said in What is the correct debug steps ?:

                  it very rarely shows you assamble code as the crash-point.

                  It will show you the assembly, if there's no associated source code, for example trying to debug release builds.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved