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. QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...
QtWS25 Last Chance

QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtcreatordebug windowarrayindexdisplay
11 Posts 5 Posters 1.2k Views
  • 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.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #2

    @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

    For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array.

    Do you know of any C++ debugger which does this? (I certainly do not, C/C++ arrays are indexed by integer not enumerated types.)

    Are you making a suggestion for the devs to change the behaviour of Creator (or even of gdb)? In which case be aware that posting here is not going to cause that.

    C 1 Reply Last reply
    0
    • JonBJ JonB

      @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

      For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array.

      Do you know of any C++ debugger which does this? (I certainly do not, C/C++ arrays are indexed by integer not enumerated types.)

      Are you making a suggestion for the devs to change the behaviour of Creator (or even of gdb)? In which case be aware that posting here is not going to cause that.

      C Offline
      C Offline
      Cedric-air
      wrote on last edited by
      #3

      @JonB said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

      @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

      For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array.

      Do you know of any C++ debugger which does this?

      I don't know any C nor C++ debugger which does this.

      Are you making a suggestion for the devs to change the behaviour of Creator (or even of gdb)? In which case be aware that posting here is not going to cause that.

      I am indeed making a suggestion for the devs to change the behavior of QtCreator (or even of gdb). What can I do to cause such a change? What's a better place to post this suggestion?

      jsulmJ JonBJ 2 Replies Last reply
      0
      • C Cedric-air

        @JonB said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

        @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

        For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array.

        Do you know of any C++ debugger which does this?

        I don't know any C nor C++ debugger which does this.

        Are you making a suggestion for the devs to change the behaviour of Creator (or even of gdb)? In which case be aware that posting here is not going to cause that.

        I am indeed making a suggestion for the devs to change the behavior of QtCreator (or even of gdb). What can I do to cause such a change? What's a better place to post this suggestion?

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

        @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

        What can I do to cause such a change

        Post it here https://cc-github.bmwgroup.net/swh/adp/pull/154534 if it is for QtCreator.
        If it is for GDB, then research where to post change requests for GDB.

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

        C 1 Reply Last reply
        0
        • C Cedric-air

          @JonB said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

          @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

          For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array.

          Do you know of any C++ debugger which does this?

          I don't know any C nor C++ debugger which does this.

          Are you making a suggestion for the devs to change the behaviour of Creator (or even of gdb)? In which case be aware that posting here is not going to cause that.

          I am indeed making a suggestion for the devs to change the behavior of QtCreator (or even of gdb). What can I do to cause such a change? What's a better place to post this suggestion?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #5

          @Cedric-air
          For a change to Creator you would need to raise it at https://bugreports.qt.io/, or even join the developers' discussion group to pre-discuss your suggestion. [ @jsulm's post crossed with this, you may use whatever link he supplies.]

          For gdb you would need to do similar in a gdb developers forum.

          I would suggest neither of these are going to change their behaviour at this point, but that's for you to discover.

          I am not sure that the Creator debugging could do this even if it wanted to. Creator does not have its own debugger, it sits atop gdb/gdbserver. And I don't think those would supply any information along the lines of "the source code declared the array size using a value from an enumerated type" (as opposed to an integer, which it got converted to) for the debugging engine to even be aware of.

          1 Reply Last reply
          1
          • jsulmJ jsulm

            @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

            What can I do to cause such a change

            Post it here https://cc-github.bmwgroup.net/swh/adp/pull/154534 if it is for QtCreator.
            If it is for GDB, then research where to post change requests for GDB.

            C Offline
            C Offline
            Cedric-air
            wrote on last edited by
            #6

            @jsulm said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

            @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

            What can I do to cause such a change

            Post it here https://cc-github.bmwgroup.net/swh/adp/pull/154534 if it is for QtCreator.
            If it is for GDB, then research where to post change requests for GDB.

            https://cc-github.bmwgroup.net/swh/adp/pull/154534 is a dead link. I've posted it here instead:
            https://bugreports.qt.io/browse/QTCREATORBUG-30160

            Christian EhrlicherC 1 Reply Last reply
            0
            • C Cedric-air

              @jsulm said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

              @Cedric-air said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

              What can I do to cause such a change

              Post it here https://cc-github.bmwgroup.net/swh/adp/pull/154534 if it is for QtCreator.
              If it is for GDB, then research where to post change requests for GDB.

              https://cc-github.bmwgroup.net/swh/adp/pull/154534 is a dead link. I've posted it here instead:
              https://bugreports.qt.io/browse/QTCREATORBUG-30160

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by Christian Ehrlicher
              #7

              @Cedric-air t.b.h. I would expect that the debugger is using the enum types as it does now - an array is indexed by an integral, not an enum. And it's for sure not a QtCreator bug as @JonB already explained to you.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              Axel SpoerlA 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                @Cedric-air t.b.h. I would expect that the debugger is using the enum types as it does now - an array is indexed by an integral, not an enum. And it's for sure not a QtCreator bug as @JonB already explained to you.

                Axel SpoerlA Offline
                Axel SpoerlA Offline
                Axel Spoerl
                Moderators
                wrote on last edited by
                #8

                @Cedric-air
                IMHO the issue is very simple.
                You are using a standard array, which most likely has an index of the type size_t. Whatever you use as a replacement for that type, will be implicitly cast to size_t. The debugger will debug a size_t value, because the array index is of that type. That is how gdb is implemented, and I don’t see an alternative suggestion could have any merits. How should the array know about the enum?

                What can be done, is implementing your own array as a template. Its index could be typed to your enum and would be debugged accordingly.

                Software Engineer
                The Qt Company, Oslo

                JonBJ 1 Reply Last reply
                1
                • Axel SpoerlA Axel Spoerl

                  @Cedric-air
                  IMHO the issue is very simple.
                  You are using a standard array, which most likely has an index of the type size_t. Whatever you use as a replacement for that type, will be implicitly cast to size_t. The debugger will debug a size_t value, because the array index is of that type. That is how gdb is implemented, and I don’t see an alternative suggestion could have any merits. How should the array know about the enum?

                  What can be done, is implementing your own array as a template. Its index could be typed to your enum and would be debugged accordingly.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #9

                  @Axel-Spoerl said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

                  What can be done, is implementing your own array as a template. Its index could be typed to your enum and would be debugged accordingly.

                  Have you actually tried this (not saying you haven't) to address what the OP is asking for? I might have a look at it tomorrow....

                  It's not a question of showing a value as an enumerated value, the OP wants the indexes into an array to be shown as such in the debugger's Watch pane. I imagine that handling of showing the available indexes as a sub-list of an array-type variable must be a feature of debugger code, and I would have thought (guess) it would be constrained to showing integers increasing from 0, no?

                  Axel SpoerlA 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Axel-Spoerl said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

                    What can be done, is implementing your own array as a template. Its index could be typed to your enum and would be debugged accordingly.

                    Have you actually tried this (not saying you haven't) to address what the OP is asking for? I might have a look at it tomorrow....

                    It's not a question of showing a value as an enumerated value, the OP wants the indexes into an array to be shown as such in the debugger's Watch pane. I imagine that handling of showing the available indexes as a sub-list of an array-type variable must be a feature of debugger code, and I would have thought (guess) it would be constrained to showing integers increasing from 0, no?

                    Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by
                    #10

                    @JonB
                    Qt Creator uses ptrace and gdb/lldb for that purpose. And an array index is just an int, or size_t, depending on C++ version and compiler. Re-translating that back into an enum, goes a long way. I doubt it will be implemented. But I may be wrong…

                    Software Engineer
                    The Qt Company, Oslo

                    JonBJ 1 Reply Last reply
                    0
                    • Axel SpoerlA Axel Spoerl

                      @JonB
                      Qt Creator uses ptrace and gdb/lldb for that purpose. And an array index is just an int, or size_t, depending on C++ version and compiler. Re-translating that back into an enum, goes a long way. I doubt it will be implemented. But I may be wrong…

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #11

                      @Axel-Spoerl said in QtCreator debugger: display enum texts when used as array indexes, instead of 0,1,2...:

                      Re-translating that back into an enum, goes a long way. I doubt it will be implemented.

                      Which is all I said :)

                      1 Reply Last reply
                      1

                      • Login

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