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. How to compile with debug symbol?
Forum Updated to NodeBB v4.3 + New Features

How to compile with debug symbol?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 4.5k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    Make sure you set the build to be in debug mode.
    alt text

    Q 1 Reply Last reply
    2
    • mrjjM mrjj

      Hi
      Make sure you set the build to be in debug mode.
      alt text

      Q Offline
      Q Offline
      Qingshui Kong
      wrote on last edited by
      #3

      @mrjj
      Thanks. It is in debug mode. But it still doesn't work.

      And sometimes I want it to be release mode. So I can't debug in Release mode?

      And how about this function?
      0_1566980719345_c9c1054c-34d4-4d87-8b66-351e35d8bd28-image.png
      Can it print debug info in release mode?

      I think sometimes we want to know what happened about the application that we released.

      mrjjM 1 Reply Last reply
      0
      • Q Qingshui Kong

        @mrjj
        Thanks. It is in debug mode. But it still doesn't work.

        And sometimes I want it to be release mode. So I can't debug in Release mode?

        And how about this function?
        0_1566980719345_c9c1054c-34d4-4d87-8b66-351e35d8bd28-image.png
        Can it print debug info in release mode?

        I think sometimes we want to know what happened about the application that we released.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @qingshui-kong

        In release mode, there is no debug symbols and it will show assembler.

        Using printf is not related to debug / release mode.
        It's simply your own logging.
        however, if you mean backtrace_symbols, you must consult its docs
        to see if that need debug symbols or not.

        Q 1 Reply Last reply
        3
        • mrjjM mrjj

          @qingshui-kong

          In release mode, there is no debug symbols and it will show assembler.

          Using printf is not related to debug / release mode.
          It's simply your own logging.
          however, if you mean backtrace_symbols, you must consult its docs
          to see if that need debug symbols or not.

          Q Offline
          Q Offline
          Qingshui Kong
          wrote on last edited by
          #5

          @mrjj
          OK. Thanks.

          So I can't know where the error is when segmentation fault happens?

          mrjjM J.HilkJ 2 Replies Last reply
          0
          • Q Qingshui Kong

            @mrjj
            OK. Thanks.

            So I can't know where the error is when segmentation fault happens?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @qingshui-kong
            well you might be able to get a call stack out to see where it was etc.
            So mostly it will have far less info when in release mode.
            depending on the platform, there might also be other tools you can use.

            Q 1 Reply Last reply
            0
            • Q Qingshui Kong

              @mrjj
              OK. Thanks.

              So I can't know where the error is when segmentation fault happens?

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

              @qingshui-kong said in How to compile with debug symbol?:

              So I can't know where the error is when segmentation fault happens?

              if you get a segfault in release but not in debug, than in 95% of all cases, it's due to uninitialized Pointers or variables the other 5 % are race conditions


              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.

              Q 1 Reply Last reply
              4
              • mrjjM mrjj

                @qingshui-kong
                well you might be able to get a call stack out to see where it was etc.
                So mostly it will have far less info when in release mode.
                depending on the platform, there might also be other tools you can use.

                Q Offline
                Q Offline
                Qingshui Kong
                wrote on last edited by
                #8

                @mrjj
                The application runs on Ubuntu. I use backtrace to get the call stack.

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

                  @qingshui-kong said in How to compile with debug symbol?:

                  So I can't know where the error is when segmentation fault happens?

                  if you get a segfault in release but not in debug, than in 95% of all cases, it's due to uninitialized Pointers or variables the other 5 % are race conditions

                  Q Offline
                  Q Offline
                  Qingshui Kong
                  wrote on last edited by
                  #9

                  @j-hilk
                  Thanks.

                  Yes, I know the most reasons. But I don't know where the error is. If there are lots of codes, I think it's hard to locate the error. I don't think it's a good way to check the code line by line.

                  You are right. I should do something to prevent his knid of error. But how about if I didn't do that in advance?

                  Yes. It's my duty to make sure there is no error when I design the code. But I think maybe it is impossible to design a software without error. I want to know how could I locate the error when it happens.

                  J.HilkJ 1 Reply Last reply
                  1
                  • Q Qingshui Kong

                    @j-hilk
                    Thanks.

                    Yes, I know the most reasons. But I don't know where the error is. If there are lots of codes, I think it's hard to locate the error. I don't think it's a good way to check the code line by line.

                    You are right. I should do something to prevent his knid of error. But how about if I didn't do that in advance?

                    Yes. It's my duty to make sure there is no error when I design the code. But I think maybe it is impossible to design a software without error. I want to know how could I locate the error when it happens.

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

                    @qingshui-kong

                    Well in such cases, I would suggest making liberal use of qDebug()

                    void myClass::myFunction(){
                          qDebug() << Q_FUNC_INFO;
                    }
                    

                    you could even reroute the qDebug output to a file if you really need to. The nice thing about this. You can turn the whole qDebug output off with a single line of code, if you want to actually release your application:

                    DEFINES += QT_NO_DEBUG_OUTPUT
                    

                    keep in mind, if your have stuff like

                    qDebug() << "File opend" << file.open();
                    

                    the file will not be opend, when the debug output is turned off


                    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.

                    Q 1 Reply Last reply
                    3
                    • J.HilkJ J.Hilk

                      @qingshui-kong

                      Well in such cases, I would suggest making liberal use of qDebug()

                      void myClass::myFunction(){
                            qDebug() << Q_FUNC_INFO;
                      }
                      

                      you could even reroute the qDebug output to a file if you really need to. The nice thing about this. You can turn the whole qDebug output off with a single line of code, if you want to actually release your application:

                      DEFINES += QT_NO_DEBUG_OUTPUT
                      

                      keep in mind, if your have stuff like

                      qDebug() << "File opend" << file.open();
                      

                      the file will not be opend, when the debug output is turned off

                      Q Offline
                      Q Offline
                      Qingshui Kong
                      wrote on last edited by
                      #11

                      @j-hilk

                      OK. Thank you very much!

                      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