CS 161: Operating Systems

Tuesday/Thursday 1:00-2:30

Pierce 301


Home Syllabus Assignments Resources Piazza

OS/161 Eclipse and DDD

Eclipse

Eclipse is a relatively widely used, open source integrated development environment (IDE). If you have ever programmed on Windows, it is similar in spirit to Visual Studio. IDE's typically attempt to facilitate your development by automating as many tasks as possible and making it easier to navigate and analyze your code. Use of Eclipse is entirely optional, but you may find it useful in helping to manage the complexity of a large codebase like OS/161. If you want to learn how to use Eclipse in general, there are many tutorials on the web. You might start with the Eclipse Workbench user guide which should help orient you on how Eclipse structures itself.

WARNING: Eclipse (with OS/161 configurations) is hard to setup, and you may get annoying red underlined syntax errors (e.g. NULL is undefined) that do not go away. Keep in mind that you will still need to configure and build your kernel in the CS50 appliance (or via SSHing into your appliance).

If you want to try using Eclipse with OS/161, you have two options:

  1. Download and use Eclipse inside of the CS50 appliance
  2. Download and use Eclipse on your native OS, which requires a shared directory between your native OS and the CS50 appliance

Downloading Eclipse and CDT

These instructions are relevant for those using Eclipse in the CS50 appliance and those using Eclipse on their native OSes.

  1. Download and install Eclipse (standard, 32-bit)
  2. Open Eclipse
  3. Set any directory as your workspace (we'll come back to this later)
  4. Install CDT ("The CDT Project provides a fully functional C and C++ Integrated Development Environment based on the Eclipse platform"):
    1. Help > Install New Software > Add
    2. In the window that pops up, type “cdt” as the name, and enter http://download.eclipse.org/tools/cdt/releases/kepler/ in the second box (NOTE: if you have a different version of eclipse other than kepler, change “kepler” to match the version of Eclipse you have)
  5. Select the main features, then keep hitting next/finish.
  6. Restart Eclipse, and close the welcome dialogue. There should be + sign on top of a square in the top-right. Click it, and you should see a window pop up where C/C++ appears as an option.
  7. Follow the rest of the instructions depending on whether you are:
    1. using Eclipse in the CS50 appliance
    2. using Eclipse on a Mac
    3. using Eclipse on a Windows PC

Option 1: Using Eclipse in the CS50 appliance

  1. Restart Eclipse
  2. Select “~/cs161” as your workspace
  3. See “Adding OS/161 to Eclipse” below

Option 2a: Using Eclipse on a Mac

These instructions describe how to create a shared directory between your CS50 appliance and your native Mac using sshfs. Eclipse will access OS/161 source files from this shared directory.

  1. Install homebrew if you don’t already have it
  2. If you are using Mac OS 10.10 (Yosemite) or later, run brew install Caskroom/cask/sshfs, else run brew install sshfs in Terminal
  3. Skip this step on Mac OS 10.10 or later. Run brew info fuse4x-kext in Terminal. You should see two commands that start with sudo. Run both of them.
  4. Create a 'cs161' directory on your Mac where you want your CS161 stuff to go
  5. Create an 'os161' directory in the cs161 directory you created in the step above
  6. While in the cs161 directory in Terminal run sshfs jharvard@APPLIANCE_IP:/home/jharvard/cs161/os161 os161 where APPLIANCE_IP is the IP address on the bottom right corner of the CS50 appliance. “crimson” is the password you are prompted for unless you changed it in your appliance.
  7. cd os161 in your Terminal window
  8. You should see your source tree! Note that os161 is now a shared directory between your Mac and the CS50 appliance.
  9. Restart Eclipse
  10. Set the cs161 directory you made as the workspace
  11. See “Adding OS/161 to Eclipse” below

Option 2b: Using Eclipse on a Windows PC

Warning: the appliance currently has a bug with the shared directory feature described below. While that gets fixed, use a version of sshfs for Windows to created a shared directory between the appliance and your native OS. These instructions have proven useful for Windows 8 users. If Eclipse tells you it cannot use anything in your shared drive as a workspace, see this StackOverflow page.

On the latest version of the CS50 appliance, there is a shared directory between your Windows machine and the appliance set up already! To get to the shared directory on your windows, go to \\APPLIANCE_IP where APPLIANCE_IP is the IP address on the bottom right corner of the appliance (e.g. \\192.0.0.1\home\jharvard\cs161\os161). Then:

  1. Restart Eclipse
  2. Set \\APPLIANCE_IP\home\jharvard\cs161 as your workspace
  3. See “Adding OS/161 to Eclipse” below

Adding OS/161 to Eclipse

  1. File > Import
  2. C/C++ > Existing Code as Makefile Project
  3. Use “os161” as the project name. For “Existing Code Location”: Make sure to de-select C++ and select <\none\> as the toolchain. Hit Finish.
  4. Right click the project, and click Properties
  5. Go to C/C++ General > Paths and Symbols. Make your Includes match the ones in the image below, selecting them as workspace directories.
  6. Click the Symbols tabs, and make your symbols match the ones in the image below
  7. Hit “Apply” (select OK when Eclipse prompts you to rebuild the index). Then Hit “OK.”

Opening up your appliance's terminal within Eclipse

Since you'll still have to configure, compile, build, run, and debug OS/161 from your appliance, it may be useful to have an ssh terminal for your appliance accessible within Eclipse.

Some versions of Eclipse come with Remote Systems Explorer already included, and on others you'll need to install it. Try navigating to Window -> Show View -> Other -> Remote Systems. If a "Remote Systems" folder appears then you don't need to install anything; else, navigate to Help -> Install New Software and install "Remote Systems Explorer." Once your install is complete, navigate to Window -> Show View -> Other -> Remote Systems again.

In the options under the "Remote Systems" folder, double click on "Remote Systems." A window should pop up next to your console. In that window, right-click on the connection "Local" and navigate to New -> Connection. Select "SSH Only" as your connection type, enter your appliance's IP address as the hostname and establish your connection. When this is done, your appliance's IP address should be listed along with the "Local" connection that was originally displayed. Expand the menu under the IP address, and right click "Ssh Terminals." Then click "Launch Terminal" and use the terminal that pops open.

DDD

Unfortunately, there's not a good way right now to debug your kernel from within Eclipse, which is a shame as it has a very nice debugging environment. What you can do instead is use one of the many front-ends for gdb. One of these is called DDD, and instructions on getting it to work with OS/161 are below.

  1. Download and install DDD.

  2. The easiest way to use DDD is to change your directory to the directory where your kernel was built (e.g., ~/cs161/os161/kern/compile/ASST0). From there, launch DDD with the following options:

    ddd --debugger mips-harvard-os161-gdb --gdb <location of your kernel>

  3. As usual, launch sys161 with:

    sys161 -w <location of your kernel>

  4. Once within DDD, you will need to type:

    target remote unix:<path to your root directory>/.sockets/gdb