Next: , Previous: , Up: GDB/MI   [Contents][Index]


27.11 GDB/MI Thread Commands

The -thread-info Command

Synopsis

 -thread-info [ thread-id ]

Reports information about either a specific thread, if the thread-id parameter is present, or about all threads. When printing information about all threads, also reports the current thread.

GDB Command

The ‘info thread’ command prints the same information about all threads.

Result

The result is a list of threads. The following attributes are defined for a given thread:

current

This field exists only for the current thread. It has the value ‘*’.

id

The identifier that GDB uses to refer to the thread.

target-id

The identifier that the target uses to refer to the thread.

details

Extra information about the thread, in a target-specific format. This field is optional.

name

The name of the thread. If the user specified a name using the thread name command, then this name is given. Otherwise, if GDB can extract the thread name from the target, then that name is given. If GDB cannot find the thread name, then this field is omitted.

frame

The stack frame currently executing in the thread.

state

The thread’s state. The ‘state’ field may have the following values:

stopped

The thread is stopped. Frame information is available for stopped threads.

running

The thread is running. There’s no frame information for running threads.

core

If GDB can find the CPU core on which this thread is running, then this field is the core identifier. This field is optional.

Example

-thread-info
^done,threads=[
{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
   frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",
           args=[]},state="running"},
{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
   frame={level="0",addr="0x0804891f",func="foo",
           args=[{name="i",value="10"}],
           file="/tmp/a.c",fullname="/tmp/a.c",line="158"},
           state="running"}],
current-thread-id="1"
(gdb)

The -thread-list-ids Command

Synopsis

 -thread-list-ids

Produces a list of the currently known GDB thread ids. At the end of the list it also prints the total number of such threads.

This command is retained for historical reasons, the -thread-info command should be used instead.

GDB Command

Part of ‘info threads’ supplies the same information.

Example

(gdb)
-thread-list-ids
^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
current-thread-id="1",number-of-threads="3"
(gdb)

The -thread-select Command

Synopsis

 -thread-select threadnum

Make threadnum the current thread. It prints the number of the new current thread, and the topmost frame for that thread.

This command is deprecated in favor of explicitly using the ‘--thread’ option to each command.

GDB Command

The corresponding GDB command is ‘thread’.

Example

(gdb)
-exec-next
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="2",line="187",
file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
(gdb)
-thread-list-ids
^done,
thread-ids={thread-id="3",thread-id="2",thread-id="1"},
number-of-threads="3"
(gdb)
-thread-select 3
^done,new-thread-id="3",
frame={level="0",func="vprintf",
args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
{name="arg",value="0x2"}],file="vprintf.c",line="31"}
(gdb)

Next: , Previous: , Up: GDB/MI   [Contents][Index]