Using SoftBench Debugger

Interacting with Your Program

Use the scroll bar at the right of the User Program I/O Area to see previous output or input. You can edit lines in this area (see Chapter 4, “Using SoftBench Editors,” on page 117). When you press Return, SoftBench Debugger sends the line where the text cursor is located as input to the program. For example, to repeat a previous input, move the cursor to that line and press Return.

To redirect standard input, output, or error (for example to read stdin from a file), choose "Options: Default Load/Rerun Settings…". See “Specifying the Runtime Environment” on page 165.

Interacting with a Terminal-Smart Program

The User Program I/O Area is not a full-function terminal emulator. Some programs use ioctl(2) or curses(3x) to manage a terminal screen. These programs do not run as expected in the User Program I/O Area.

As one way to debug such a program, you can run it in a terminal window and then adopt it. See “Attaching the Debugger to a Running Program” on page 222 for more information. You can also debug programs that use lower-level I/O with I/O redirection. For example, follow these steps:

1.Create a terminal emulator window (hpterm& or xterm&) with a running shell.

2.Run the tty(1) command in the terminal window to get the device name of the terminal (for example, "/dev/pty/ttyp5").

3.Run the sleep(1) command in the terminal window to keep the shell from intercepting any input (for example, "sleep 100000").

4.Redirect standard I/O to the terminal window. Choose "File:

Rerun…", and specify the device name of the terminal window (which is /dev/pty/ttyp5 in this example) as the stdin, stdout, and stderr.

5.Select OK. Your program runs with the new I/O redirections. SoftBench Debugger removes the User I/O area, since all standard I/O has been redirected.

Interacting with a Window-Smart Program

Your program should operate in synchronous mode so that window events (for example, mouse operations) are not queued. This ensures

Chapter 7

175