Gdb how many threads




















GDB displays for each thread in this order : Thread number assigned by GDB Target system's thread identifier systag Current stack frame summary for that thread. The command argument threadno is the internal GDB thread number, as shown in the first field of the info threads display. GDB responds by displaying the system identifier of the thread you selected and its current stack frame summary: gdb thread 2 [Switching to process 35 thread 23] 0x34e5 in sigpause thread apply [ threadno ] [ all ] args The thread apply command lets you apply a command to one or more threads.

Specify the numbers of the threads that you want affected with the command argument threadno. To apply a command to all threads, use thread apply all args. An extreme example: if you define a variable, but never use it, GDB never sees that variable--because the compiler optimizes it out of existence. See section Program variables , for more information about debugging optimized code.

GDB knows about preprocessor macros and can show you their expansion see section C Preprocessor Macros. If you are running your program in an execution environment that supports processes, run creates an inferior process and makes that process run your program.

In environments without processes, run jumps to the start of your program. The execution of a program is affected by certain information it receives from its superior. GDB provides ways to specify this information, which you must do before starting your program.

You can change it after starting your program, but such changes only affect your program the next time you start it. This information may be divided into four categories:. When you issue the run command, your program begins to execute immediately.

See section Stopping and Continuing , for discussion of how to arrange for your program to stop. Once your program has stopped, you may call functions in your program, using the print or call commands. See section Examining Data. If the modification time of your symbol file has changed since the last time GDB read its symbols, GDB discards its symbol table, and reads it again.

When it does this, GDB tries to retain your current breakpoints. The arguments to your program can be specified by the arguments of the run command. The environment consists of a set of environment variables and their values. Environment variables conventionally record such things as your user name, your home directory, your terminal type, and your search path for programs to run. Usually you set up environment variables with the shell and they are inherited by all the other programs you run.

When debugging, it can be useful to try running your program with a modified environment without having to start GDB over again. Each time you start your program with run , it inherits its working directory from the current working directory of GDB. The GDB working directory is initially whatever it inherited from its parent process typically the shell , but you can specify a new working directory in GDB with the cd command. See section Commands to specify files. Sometimes you need to interrupt one thread and switch to another.

These can be achieved through gdb. The latter ID refers to this ID. Brea FileName. Off, not locking any threads, default value. Note that the command info threads provides a summary of the program's threads and some details about their current state. In this case there is only one thread that has been created so far. Here, two more threads are created. The star indicates the thread currently under focus. Also, the newly created threads have hit the breakpoint set for them in their initialization functions.



0コメント

  • 1000 / 1000