Bug 17600 - "info thread $_thread" doesn't work
Summary: "info thread $_thread" doesn't work
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: threads (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: 15.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-13 19:49 UTC by Tom Tromey
Modified: 2023-12-12 14:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2014-11-13 19:49:04 UTC
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.
Comment 1 Hannes Domani 2020-04-11 15:18:21 UTC
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).
Comment 2 Tom Tromey 2020-07-13 16:35:45 UTC
I ran into this again today and nearly re-filed it.
Comment 3 Sourceware Commits 2023-12-12 14:54:17 UTC
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>
Comment 4 Hannes Domani 2023-12-12 14:55:38 UTC
Fixed.