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. Debugging a Qt-library
Forum Updated to NodeBB v4.3 + New Features

Debugging a Qt-library

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    Rasmunis
    wrote on 18 Nov 2019, 13:30 last edited by
    #1

    Hi!

    Tl;dr:
    How do I make changes to a qt-library's source-code for debugging purposes?


    I am currently using the Q3DScatter of the Data Visualization library to visualize a point-cloud, and it seems that every time I update the point-cloud with new data there is a memory leak. I have analyzed my method for loading the point-cloud data and the problem seems to be elsewhere, which has made me look to the library itself. I have attempted to edit and rebuild the library-code, but it doesn't seem to work. So my question is how to do this? I would prefer to avoid building from the open-source code until I know that the problem is in the library and that a change is necessary.

    J 1 Reply Last reply 18 Nov 2019, 13:33
    0
    • R Rasmunis
      18 Nov 2019, 13:30

      Hi!

      Tl;dr:
      How do I make changes to a qt-library's source-code for debugging purposes?


      I am currently using the Q3DScatter of the Data Visualization library to visualize a point-cloud, and it seems that every time I update the point-cloud with new data there is a memory leak. I have analyzed my method for loading the point-cloud data and the problem seems to be elsewhere, which has made me look to the library itself. I have attempted to edit and rebuild the library-code, but it doesn't seem to work. So my question is how to do this? I would prefer to avoid building from the open-source code until I know that the problem is in the library and that a change is necessary.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 18 Nov 2019, 13:33 last edited by
      #2

      @Rasmunis You don't need to build from sources to be able to debug Qt. Install Qt sources (same version of Qt you're using) and tell QtCreator where it is. Then you should be able to step into Qt code.

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

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rasmunis
        wrote on 18 Nov 2019, 13:40 last edited by
        #3

        Yes, I am able to step into it in debug-mode, but I want to make changes to it so I can test if there's an actual bug there. Sorry if I phrased myself a bit confusingly.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Nov 2019, 13:47 last edited by
          #4

          Hi and welcome to devnet,

          Might be a silly question but after building the module, did you install it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply 18 Nov 2019, 13:52
          1
          • S SGaist
            18 Nov 2019, 13:47

            Hi and welcome to devnet,

            Might be a silly question but after building the module, did you install it ?

            R Offline
            R Offline
            Rasmunis
            wrote on 18 Nov 2019, 13:52 last edited by
            #5

            @SGaist Thank you :)

            If I understand you correctly, yes. I have been using it for the past couple of months.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rasmunis
              wrote on 18 Nov 2019, 14:28 last edited by
              #6

              I'll be a bit more concrete. This is what I am attempting:

              Source-code: https://github.com/qt/qtdatavis3d/blob/dev/src/datavisualization/utils/scatterobjectbufferhelper.cpp

              The fullLoad-method is called on every update of the scatter-graph and seems to be handling the buffers. But m_meshDataLoaded is set to false, and is not changed until it is checked for true (which would delete the old buffers). I suspect this might be the cause of the memory leak.

              void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal dotScale)
              {
                  m_meshDataLoaded = false; <-- set to false
                  m_indexCount = 0;
              
                  ObjectHelper *dotObj = cache->object();
                  const ScatterRenderItemArray &renderArray = cache->renderArray();
                  const uint renderArraySize = renderArray.size();
              
                  if (renderArraySize == 0)
                      return;  // No use to go forward
              
                  uint itemCount = 0;
                  QQuaternion seriesRotation(cache->meshRotation());
              
                  if (m_meshDataLoaded) { <-- checked to be true
                      // Delete old data
                      glDeleteBuffers(1, &m_vertexbuffer);
                      glDeleteBuffers(1, &m_uvbuffer);
                      glDeleteBuffers(1, &m_normalbuffer);
                      glDeleteBuffers(1, &m_elementbuffer);
                      m_vertexbuffer = 0;
                      m_uvbuffer = 0;
                      m_normalbuffer = 0;
                      m_elementbuffer = 0;
                  }
                  .
                  .
                  .
              
              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 18 Nov 2019, 16:36 last edited by
                #7

                Then I am a bit lost with your question.

                So you successfully built and used the custom version of the module yet it seems that your modifications are not taken into account ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                R 1 Reply Last reply 19 Nov 2019, 08:10
                0
                • S SGaist
                  18 Nov 2019, 16:36

                  Then I am a bit lost with your question.

                  So you successfully built and used the custom version of the module yet it seems that your modifications are not taken into account ?

                  R Offline
                  R Offline
                  Rasmunis
                  wrote on 19 Nov 2019, 08:10 last edited by
                  #8

                  @SGaist No. I've been using the standard module for two months and now I wanted to change it, so I made some changes and rebuilt it and then my changes are not taken into account.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 19 Nov 2019, 08:11 last edited by
                    #9

                    Hence my question: did you install your custom built module ? Just building it is not enough.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    R 2 Replies Last reply 19 Nov 2019, 08:20
                    0
                    • S SGaist
                      19 Nov 2019, 08:11

                      Hence my question: did you install your custom built module ? Just building it is not enough.

                      R Offline
                      R Offline
                      Rasmunis
                      wrote on 19 Nov 2019, 08:20 last edited by
                      #10

                      @SGaist I see. I thought you meant if I had ever installed it. Then no, I did not install it.

                      1 Reply Last reply
                      0
                      • S SGaist
                        19 Nov 2019, 08:11

                        Hence my question: did you install your custom built module ? Just building it is not enough.

                        R Offline
                        R Offline
                        Rasmunis
                        wrote on 19 Nov 2019, 08:41 last edited by
                        #11

                        @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                        JonBJ J 2 Replies Last reply 19 Nov 2019, 08:54
                        0
                        • R Rasmunis
                          19 Nov 2019, 08:41

                          @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on 19 Nov 2019, 08:54 last edited by
                          #12

                          @Rasmunis
                          So you have built it but not installed it anywhere that your application will pick up from. You either need to do a full build and go through the installation process for Qt for building from source, or if you are sure you have built exactly the same version of Qt as you presently have in all its shared libraries you could identify the single shared library (.so or .dll) this source file contributes to and just (temporarily) replace that with your newly compiled version. If you intend to debug-step into your new code, you will also have to ensure that your source file is found by the debugger.

                          1 Reply Last reply
                          2
                          • R Rasmunis
                            19 Nov 2019, 08:41

                            @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 19 Nov 2019, 10:00 last edited by
                            #13

                            @Rasmunis said in Debugging a Qt-library:

                            So how do I install it?

                            make install

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

                            R 1 Reply Last reply 19 Nov 2019, 11:34
                            1
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 19 Nov 2019, 10:15 last edited by
                              #14

                              @JonB you don't need a full Qt build to build one module for the Qt version you are currently using however you are right about making a backup of the files related to the module you are going to hack on if you don't have your own build.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              JonBJ 1 Reply Last reply 19 Nov 2019, 10:18
                              0
                              • S SGaist
                                19 Nov 2019, 10:15

                                @JonB you don't need a full Qt build to build one module for the Qt version you are currently using however you are right about making a backup of the files related to the module you are going to hack on if you don't have your own build.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on 19 Nov 2019, 10:18 last edited by JonB
                                #15

                                @SGaist said in Debugging a Qt-library:

                                @JonB you don't need a full Qt build to build one module for the Qt version you are currently using

                                Indeed not, but do you wish to guarantee that the user is rebuilding one library against an existing build/system-supplied which is deffo, deffo the same version, compiled in the same way etc.? :) Because I can hear "version mis-match" in the distance... ;)

                                1 Reply Last reply
                                0
                                • J jsulm
                                  19 Nov 2019, 10:00

                                  @Rasmunis said in Debugging a Qt-library:

                                  So how do I install it?

                                  make install

                                  R Offline
                                  R Offline
                                  Rasmunis
                                  wrote on 19 Nov 2019, 11:34 last edited by Rasmunis
                                  #16

                                  I tried @JonB 's approach and it worked for me. And I did manage to remove the memory-leak, which makes me think that this is a bug in the library. How do you suggest to move forward with this?

                                  @jsulm Where do you execute the make-commands? I have yet to find any makefiles.

                                  Edit: I found the makefile in the build-folder.

                                  J 1 Reply Last reply 19 Nov 2019, 11:47
                                  0
                                  • R Rasmunis
                                    19 Nov 2019, 11:34

                                    I tried @JonB 's approach and it worked for me. And I did manage to remove the memory-leak, which makes me think that this is a bug in the library. How do you suggest to move forward with this?

                                    @jsulm Where do you execute the make-commands? I have yet to find any makefiles.

                                    Edit: I found the makefile in the build-folder.

                                    J Offline
                                    J Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on 19 Nov 2019, 11:47 last edited by jsulm
                                    #17

                                    @Rasmunis said in Debugging a Qt-library:

                                    How do you suggest to move forward with this?

                                    File a bug in Qt bug tracker: https://bugreports.qt.io/projects/QTBUG/issues

                                    "Where do you execute the make-commands?" - where you build Qt.

                                    configure ...
                                    make
                                    make install
                                    

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

                                    1 Reply Last reply
                                    2
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 19 Nov 2019, 13:35 last edited by
                                      #18

                                      After the bug report, since you have a fix, you can submit a patch for inclusion :-)

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      2

                                      1/18

                                      18 Nov 2019, 13:30

                                      • Login

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