This is a customization of Harvard University's CS161, Operating Systems web page
made more suitable for the CSC369 class at University of Toronto.
 

CSC 369. Operating Systems

Angela Demke Brown
Fall 2004

Using screen(1) for Debugging

By Philip Zeyliger

[CSC369 Home Page]

You're going to be spending a lot of time in front of GDB this semester. It's worthwhile to invest some time now into your environment. I found it frustrating to setup the two windows needed for connecting gdb to a kernel, so I used screen(1) to split one (bigger) terminal into two, thereby enabling me to interact with kernel and gdb in one window, like so:

Here's how to set it up:

  1. Put the following (adjust directories as necessary) into ~/.screenrc.161:
  2. bindkey -k k1 screen 1
    bindkey -k k2 screen 2
    bind q quit
    bind j focus down
    bind k focus up
    startup_message off
    deflogin off
    
    screen -t "sys161" 1
    stuff "pushd ~/cs161/root^M"
    stuff "sys161 -w kernel^M"
    split
    focus down
    screen -t "GDB" 2 
    stuff "pushd ~/cs161/root^M"
    stuff "cs161-gdb kernel^M"
    sleep 1
    stuff "db161^M"
  3. Put the following into ~/.gdbinit (replace U/S/USERNAME):
  4. cd /nfs/home/U/S/USERNAME/cs161/src/kern/compile/ASST5
    define db161
    target remote unix:/nfs/home/U/S/USERNAME/cs161/root/.sockets/gdb
    b panic
    end
  5. Make an alias. For example, I did: "alias debug screen -c /home/U/S/USERNAME/.screenrc.161", and put that in my .tcshrc.
  6. Now you can type "debug" and get a cool split-screen debug window.
You'll need to navigate around it. Ctrl-A puts you into screen's "command" mode for one command. Then you can type "j" for down and "k" for up. "q" quits. If you type ESC, you can navigate through a scrollback buffer. Read screen's man page for more info.