CS45 Weekly Lab: week 4

Kernel Debugging, strace, /proc
  1. Each group is going to change the port number they use for connecting to their virtualbox VM (right now everyone's is set to 10022). Your new port number will be based on your cs45X account. Using the letter in your account, add a number to 10022 to get your new port number (a:1, b:2, c:3, ...).
    cs45a: +1   # your new port number is 10023
    cs45b: +2   # your new port number is 10024
    cs45c: +3   # your new port number is 10025
    ..
    
    Now, setup virtualbox to use your port number. Start virtualbox, click on Network:Advanced:PortForwarding then change the HostPort box to your port number.

    This is the new port number you will use for ssh and scp into your VM:

    ssh -p 10024 ... 
    scp -P 10024 ...
    

    If you have problems with your new port number, pick another one outside of the range of your classmates' and also one that is above 1024. You can see the ports that are currently in use on your machine by running the following script:

     
    $ ~newhall/bin/findports                                                     
    

  2. Together we are going to try out debugging the linux kernel running on your VirtualBox VM.

    ssh into your assigned machine using your cs45 account:

    ssh -X cs45X@your_assigned_machine_name
    
    Then following along the "Kernel Debugging using kgdb" steps from the: VirtualBox guide for CS45

    Here are some example functions you in which you can put breakpoints, and examples of how to trigger them:

     breakpoint            command to trigger it 
     ----------            -----------------------
     sys_kill              kill -9 PID 
     sys_sync              sync 
     sys_getuid            sudo ls
    

  3. Try out strace.

    To get an idea of what system calls are invoked when you run a program, try running strace on some applications:

    # to list all strace command line options
    strace
    # (ex) summary info about system calls invoked during program's execution:
    strace -c ./a.out
    strace -c ls
    

  4. Try out /proc.

    The /proc file system contains information about every process in the system and information about system-wide resources. Each process has its own subdirectory in /proc/pid, and its state is accessed by reading /proc files (try 'cat status' for example). ps -A will list all processes and their ids. Try cat'ing out some of the files in one of your /proc/pid subdirectories to see what type of information is available via /proc.

    System-wide information is also available via /proc files. Try cat'ing out some of these files to see what types of information you get.

    See my Tools for examining system state for lots more information about finding out information about the running system and about processes on the system.