Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Viewing vectors in the debugger?

Viewing vectors in the debugger?

Scheduled Pinned Locked Moved Qt Creator and other tools
13 Posts 4 Posters 11.2k 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi, all –

    I hope this question is considered on-topic. I've been using Creator as my IDE for several months now. In debugging sessions, it appears that visibility into vector objects is limited (not to mention cumbersome). Has anyone found a way to deal with this? It's greatly slowing down my debugging efforts.

    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      what do you mean by limited?
      COuld you specify it a bit more detailed?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        Sure...so, I'm sure you know how arrays look: you can see the contents of each element. Well, with vectors, I can only see the first and the final elements, as the picture shows. I'm having some kind of problem with my constructors, and all I know is that the first element in the vector is properly initialized, and the last isn't. With my limited knowledge of the debugger, I have no way to view the elements in between.

        !http://www.scopedin.com/images/vectors.jpg(vectors in debugger)!

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          The vector you are using is a template. The template's structure is not, as you expect, just an array.
          It is also the same, if you are using another IDE such as msvc.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            OK, fair enough. So, two questions:

            1. aren't all vectors templates?
            2. is there any "trick" for viewing its contents in the debugger?

            Thanks.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              to your question 1:
              as you are using them yes, but not necessarily in general.

              to your question 2:
              I would love to know the trick myself. Aren't vectors having all elements in sequence in memory? Then you could use a memory window, but this will work only for the basic types.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                You might try updating Qt Creator... I read something about std::vector support in the commit logs, so it might work with a newer version;-) I am tracking master, so this might or might not be in 2.3...

                In general the GDB debugger (used for mingw binaries) tends to be a bit more complete than the CDB one, mostly since GDB sees much more action (and thus testing;-), being used by linux, mac and windows/mingw. So switching to mingw might be a quick way to improve debugging for you.

                Please "file bug reports":http://bugreports.qt.nokia.com/ if something works in gdb but not cdb:-) Feel free to request features in the bug tracker, too.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  [quote author="koahnig" date="1317845048"]to your question 2:
                  I would love to know the trick myself. Aren't vectors having all elements in sequence in memory? Then you could use a memory window, but this will work only for the basic types. [/quote]

                  This is not enforced. For the clients, they look like a block of memory, as you just access via index, but it might have any implementation behind, e.g. for optimizing moving of objects, inserting them etc.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #9

                    Hi, Tobias –

                    I'm running the latest (stable) Creator already. I think I'm using GDB...please remind me where that setting is, so I can confirm it?

                    Thanks.

                    EDIT: I just took a closer look at your comment regarding mingw. I don't believe that's an option for me, since I'm running on a Mac.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      [quote author="Gerolf" date="1317891713"][quote author="koahnig" date="1317845048"]to your question 2:
                      I would love to know the trick myself. Aren't vectors having all elements in sequence in memory? Then you could use a memory window, but this will work only for the basic types. [/quote]

                      This is not enforced. For the clients, they look like a block of memory, as you just access via index, but it might have any implementation behind, e.g. for optimizing moving of objects, inserting them etc.
                      [/quote]
                      Gerolf, I am certainly not arguing that this is a good solution and one should do it. However, in principle, you may do it for build-in data types also supported by the debugger. For vector they should allocate continuous memory according to "this":http://www.cplusplus.com/reference/stl/vector/ . However, you need to be very desperate to do so.

                      Tobias, I am certainly will keep an eye on this next time when using creator. That is an interesting feedback.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tobias.hunger
                        wrote on last edited by
                        #11

                        If you are on the Mac then you are using GDB, alright:-)

                        1 Reply Last reply
                        0
                        • mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #12

                          OK...so, does anyone have an idea for how to resolve this? I realize I'm still a beginner at this, but...it seems borderline insanity that we can't examine the contents of an STL vector object while in the debugger.

                          Any suggestions?

                          1 Reply Last reply
                          0
                          • mzimmersM Offline
                            mzimmersM Offline
                            mzimmers
                            wrote on last edited by
                            #13

                            OK, I've discovered a partial workaround. Not perfect, but helpful. Adding an iterator for the vector, and assigning it to the "current" element will at least allow you to see an element other than the first one.

                            Also, from my ongoing tinkering, it appears that the _M_finish element is not (as I first thought) the last valid element in the vector. It appears to be more of a sentinel element...I'm getting the impression that vectors are sort of a cross between arrays and linked lists.

                            Hope this helps someone.

                            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