30
Chapter 6. Running Programs Under gdb
This command is useful if you wish to debug a core dump instead of a running process. gdb ignores
any core dump file while your program is running.
On some operating systems, a program cannot be executed outside gdb while you have breakpoints
set on it inside gdb. You can use the
kill
command in this situation to permit running your program
outside the debugger.
The
kill
command is also useful if you wish to recompile and relink your program, since on many
systems it is impossible to modify an executable file while it is running in a process. In this case, when
you next type
run
, gdb notices that the file has changed, and reads the symbol table again (while trying
to preserve your current breakpoint settings).
6.9. Debugging programs with multiple threads
In some operating systems, such as HP-UX and Solaris, a single program may have more than one
thread
of execution. The precise semantics of threads differ from one operating system to another, but
in general the threads of a single program are akin to multiple processes--except that they share one
address space (that is, they can all examine and modify the same variables). On the other hand, each
thread has its own registers and execution stack, and perhaps private memory.
gdb provides these facilities for debugging multi-thread programs:
•
automatic notification of new threads
•
thread
threadno
, a command to switch among threads
•
info threads
, a command to inquire about existing threads
•
thread apply [
threadno
] [
all
]
args
, a command to apply a command to a list of threads
•
thread-specific breakpoints
Warning:
These facilities are not yet available on every gdb configuration where the operating system sup-
ports threads. If your gdb does not support threads, these commands have no effect. For example, a system
without thread support shows no output from
info threads
, and always rejects the
thread
command,
like this:
(gdb) info threads
(gdb) thread 1
Thread ID 1 not known.
Use the "info threads" command to
see the IDs of currently known threads.
The gdb thread debugging facility allows you to observe all threads while your program runs--but
whenever gdb takes control, one thread in particular is always the focus of debugging. This thread is
called the
current thread
. Debugging commands show program information from the perspective of
the current thread.
Whenever gdb detects a new thread in your program, it displays the target system’s identification for
the thread with a message in the form
[New
systag
]
.
systag
is a thread identifier whose form varies
depending on the particular system. For example, on LynxOS, you might see
[New process 35 thread 27]
when gdb notices a new thread. In contrast, on an SGI system, the
systag
is simply something like
process 368
, with no further qualifier.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......