Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
info terminal Displays information recorded by GDB about the terminal modes
your program is using.
tty Another way to specify where your program should do input and
output is with the tty command. This command accepts a file
name as argument, and causes this file to be the default for future
run commands. It also resets the controlling terminal for the child
process, for future run commands. For example,
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.
NOTE:
You can redirect your program input and output using shell redirection with the run
command. For example,
run > outfile
starts your program, diverting its output to the file 'outfile'.
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.
4.7 Debugging a Running Process
You can use GDB to debug a running process by specifying the process ID. Following
commands are used to debug a running process:
attach process-id dev-file 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 or a device file. 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.
4.7 Debugging a Running Process 39