D. J. Bernstein
Data structures and program structures
MCS 275, Fall 2001

Using icarus

These instructions assume that you have logged into a Windows machine in one of the ACCC labs in SEL. Remember to log out when you leave the room.

Creating a terminal

Click on Start, then Programs, then Network, then icarus (under ssh or telnet; ssh is preferable). A small window will appear; move to that window. This window is an ``icarus terminal.'' Everything you type in the window is sent to icarus, a big UNIX machine run by ACCC.

When the terminal says login, type your netid and press Enter. When it says password, type your password and press Enter. You'll see a few messages and then a > prompt. The terminal is now talking to an ``icarus shell.''

If you make a mistake typing a command for the shell, type ^C (hold down Ctrl, type C, release Ctrl) to cancel the command.

Type exit (and press Enter) when you're done.

Creating an X session

There's a nicer way to interact with icarus, using a program called Exceed. Exceed simulates the graphical interface presented to people sitting down in front of icarus; it lets you use (and write!) graphical UNIX programs.

Click on Start, then Programs, then Network, then Exceed, then Exceed again. A window will appear listing names of machines. Click on icarus. An icarus login window will appear. Enter your netid and password. The login window will disappear, and be replaced by various windows for other programs. This process may take a minute; relax and read your textbook.

If you want to start a terminal inside Exceed after you've logged in, find the Terminal application and click on it.

Creating files

At the icarus shell: Type pico fun.c to create or edit a file named fun.c. The pico editor is reasonably self-explanatory.

Compiling and running C programs

At the icarus shell: Type gcc -o fun fun.c to translate (``compile'') a C program into a machine-language program. The compiler reads the C program from the file fun.c and creates a new file fun with the machine-language program. You can type ./fun to ``run'' the machine-language program, i.e., to tell the computer to follow the instructions in the program.

Debugging C programs

At the icarus shell: Type gcc -g -o fun fun.c to create fun with debugging information. Then type gdb fun to start the debugger.

If you're using a terminal inside Exceed, you can type /homes/home12/koobera/bin/ups fun instead of gdb fun. ups is another debugger, with several advantages over gdb.

Typical debugger commands:
gdb ups
See the program. list It's already on the screen.
Set a ``breakpoint.'' break 7 for a breakpoint at the beginning of line 7. Right-click on the line.
Run the program. Pause the program if it reaches a breakpoint. run Click Start.
While the program is paused, show the value of variable x. print x, or display x to show x after subsequent breakpoints. Click x. Or double-click main under Functions to see all variables inside main.
While the program is paused, show the value of an expression: for example, i+j, or &i. display i+j, or display &i. Click Add expr. Type i+j or &i.
Continue running the program. cont Click Cont.
Continue running the program, but pause at the next line. next Click Next.
Run the program with command-line arguments WE LOVE SALAD. run WE LOVE SALAD Click Target, then middle-click (left and right together) the second line, then type WE LOVE SALAD and press Enter.
Quit the debugger. quit Click Quit.

ups shows only the first element of an array by default. The easiest way to see the remaining elements is to click on the first element, then click Dup as many times as the array has elements.

See http://www.concerto.demon.co.uk/UPS/upsman.html for more information on ups.

Creating shell scripts

At the icarus shell: Use pico debug to create a file with the shell commands
     #!/bin/sh
     gcc -Wall -g -o $1 $1.c && /homes/home12/koobera/bin/ups $1
and then type chmod u+x debug. The file debug is now a ``shell script.'' Typing ./debug 3 has the same effect as typing
     gcc -Wall -g -o 3 3.c && /homes/home12/koobera/bin/ups 3

Sending files by email

You can type
     mail djb-275-hw@cr.yp.to < 3.c
to send a copy of 3.c by email to djb-275-hw@cr.yp.to.