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.7Debugging 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-idThis 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.

44 Running Programs Under GDB

Page 44
Image 44
HP gnu source-level debugger 5992-4701 manual Debugging a Running Process