for begin we just learn a couple of config parameters for more comfortable debugging with gdb, so let’s do it.

(gdb) set pagination off

Turn the output pagination on or off; the default is on. Turning pagination off is the alternative to set height unlimited. Note that running gdb with the -batch option also automatically disables pagination.

(gdb) set logging file backtrace.txt

Change the name of the current logfile. The default logfile is gdb.txt.

(gdb) set logging on

Enable logging.

(gdb) info threads

Display information about one or more threads. With no arguments displays information about all threads. You can specify the list of threads that you want to display using the thread ID list syntax (see thread ID lists).

gdb displays for each thread (in this order):

  1. the per-inferior thread number assigned by gdb
  2. the global thread number assigned by gdb, if the ‘-gid’ option was specified
  3. the target system’s thread identifier (systag)
  4. the thread’s name, if one is known. A thread can either be named by the user (see thread name, below), or, in some cases, by the program itself.
  5. the current stack frame summary for that thread

An asterisk ‘*’ to the left of the gdb thread number indicates the current thread.

For example,

(gdb) info threads
Id Target Id Frame
* 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
2 process 35 thread 23 0x34e5 in sigpause ()
3 process 35 thread 27 0x34e5 in sigpause ()
at threadtest.c:68
(gdb) thread apply all bt full

generating full backtrace for all threads

Now I would like to show you how you can debug multithread applications via gdb (The GNU Project Debugger). You can download a simply example and try it yourself.

After close gdb, you can look to file which is set via “set logging file <file>”