I wanted to show "info threads" output for just the current thread. I tried: (gdb) info thread $_thread Convenience variable must have integer value. Args must be numbers or '$' variables. But: (gdb) p $_thread $1 = 48 It seems "info thread" is confused.
To get the value of convenience variables in this case, get_internalvar_integer is used. But this only works for types INTERNALVAR_INTEGER and INTERNALVAR_VALUE, and not for INTERNALVAR_MAKE_VALUE (which $_thread is).
I ran into this again today and nearly re-filed it.
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=52e0b52e6f2dc1dc5a7b95740d22fd616241db67 commit 52e0b52e6f2dc1dc5a7b95740d22fd616241db67 Author: Hannes Domani <ssbssa@yahoo.de> Date: Tue Dec 12 15:53:12 2023 +0100 Support dynamically computed convenience variables in get_internalvar_integer When using $_thread in info threads to showonly the current thread, you get this error: ``` (gdb) info thread $_thread Convenience variable must have integer value. Args must be numbers or '$' variables. ``` It's because $_thread is a dynamically computed convenience variable, which isn't supported yet by get_internalvar_integer. Now the output looks like this: ``` (gdb) info threads $_thread Id Target Id Frame * 1 Thread 10640.0x2680 main () at C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.base/gdbvars.c:21 ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17600 Approved-By: Tom Tromey <tom@tromey.com>
Fixed.