Chapter 6. Running Programs Under gdb
29
tty /dev/ttyb
directs that processes started with subsequent
run
commands default to do input and output on the
terminal
/dev/ttyb
and have that as their controlling terminal.
An explicit redirection in
run
overrides the
tty
command’s effect on the input/output device, but not
its effect on the controlling terminal.
When you use the
tty
command or redirect input in the
run
command, only the input
for your
program
is affected. The input for gdb still comes from your terminal.
6.7. Debugging an already-running process
attach
process-id
This command attaches to a running process--one that was started outside gdb. (
info files
shows your active targets.) The command takes as argument a process ID. The usual way to find
out the process-id of a Unix process is with the
ps
utility, or with the
jobs -l
shell command.
attach
does not repeat if you press [RET] a second time after executing the command.
To use
attach
, your program must be running in an environment which supports processes; for
example,
attach
does not work for programs on bare-board targets that lack an operating system.
You must also have permission to send the process a signal.
When you use
attach
, the debugger finds the program running in the process first by looking in
the current working directory, then (if the program is not found) by using the source file search path
(refer to Section 9.4
Specifying source directories
). You can also use the
file
command to load the
program. Refer to Section 17.1
Commands to specify files
.
The first thing gdb does after arranging to debug the specified process is to stop it. You can examine
and modify an attached process with all the gdb commands that are ordinarily available when you start
processes with
run
. You can insert breakpoints; you can step and continue; you can modify storage. If
you would rather the process continue running, you may use the
continue
command after attaching
gdb to the process.
detach
When you have finished debugging the attached process, you can use the
detach
command to
release it from gdb control. Detaching the process continues its execution. After the
detach
command, that process and gdb become completely independent once more, and you are ready
to
attach
another process or start one with
run
.
detach
does not repeat if you press [RET]
again after executing the command.
If you exit gdb or use the
run
command while you have an attached process, you kill that process. By
default, gdb asks for confirmation if you try to do either of these things; you can control whether or not
you need to confirm by using the
set confirm
command (refer to Section 21.7
Optional warnings
and messages
).
6.8. Killing the child process
kill
Kill the child process in which your program is running under gdb.
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: ......