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 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.
-
@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?
-
@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. -
@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.
-
@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 Ehrlicher Lifetime Qt Championreplied to Cedric-air on last edited by 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.
-
@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.
-
@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?
-
@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… -
@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 :)