Netbeans

This guide is intended as an internal reference for RAMCloud Students working with Netbeans over the rcXX cluster. 

Table of Contents

Decision Time (Source Location)

To work on RAMCloud in Netbeans, you'll have to decide whether to store your sources on your local machine and copy it to rcmaster at build time (SFTP) OR store the sources on rcmaster and use a remote mount to operate on the files (SSHFS). You'll have to choose one and the instructions below diverge depending on which you choose. Instructions meant for one or the other will be tagged with SFTP or SSHFS. If you are unsure which one you'd like, pick SFTP. Note that with SFTP, you are restricted making local modifications to your machine only; changes on the server will not be reflected on the client.

Installation

  1. Netbeans
    1. Download the C/C++ version of Netbeans here: https://netbeans.org/downloads/
  2. (Optional) SSHFS Only: Only set this up if you plan to use SSHFS on OSX.
    1. Go to https://osxfuse.github.io
    2. Download and install OSXFuse and SSHFS (in that order)
    3. After install, open Terminal.app (i.e. press Command + Space then type "Terminal")
    4. Create a mount folder on your Desktop (i.e. mkdir ~/Desktop/home )
    5. To mount, type "sshfs <username>@rcmaster.scs.stanford.edu: ~/Desktop/home" where <username? is your username.
    6. (To unmount later, use "umount <folder>")

Setting rcmaster as the BuildHost

  1. Open Netbeans
  2. Open the Remote Tool bar for NetBeans by going to View->Toolbars->Remote
  3. Near the top left of the IDE, there should be an icon of a computer and the words "localhost" to the right of it. Click on "localhost" and drop down to "Manage Hosts"
            ...        
  4. A new window should pop-up, click "Add..."
  5. In the next window, type our host name (rcmaster.scs.stanford.edu) into the hostname and click Next
  6. The next page should be self explanatory, type in your username and select "SSH Key File." Press "Next". If it prompts with a password, enter your password for the SSH file (NOT the one for rcmaster).
  7. On the last page, you will need to change the "Access project files via" depending on how you wish to access your files.
    1. SFTP: Select this option if you wish to store the sources locally
    2. SSHFS: Select "System level file sharing"

Setting up project RAMCloud in Netbeans

  1. Checkout the sources and initialize according to the instructions on General Information for Developers
    1. SFTP: Checkout the sources in a local directory (Note: Win Users, you will have an extra step).
    2. SSHFS: SSH into rcmaster and checkout the sources there
  2. Open Netbeans and click File->New Project
  3. Select "C/C++ Project with Existing Sources" and click Next
  4. In the next window, "Browse" to where you checked out the sources and select rcmaster as the build host
    1. SFTP: Browse to where the RAMCloud folder is are on the local machine
    2. SSHFS: Make sure rcmaster is mounted (see Installation) and browse to the RAMCloud folder
  5. Click "Finish"
  6. Windows Users: For some reason, not everything gets copied over correctly. Please follow the instructions in Troubleshooting - "I'm on Windows and I get a build error!"
  7. SFTP Only: To make life a little easier, you should make a symlink from the copied files to your home directory. 
    1. Notice that when you build, it says that it's copying your files to a location
    2. cd to that location and go down until you reach what looks like the RAMCloud directory
    3. symlink that over to wherever you want.
  8. SSHFS Only: If you are mounted over sshfs, the IDE will ask for your local to remote mappings. Simply click right below "Local Path" and browse to where RAMCloud is locally and then click right below "Remote Path" and browse to where RAMCloud is on rcmaster.

Creating Build and Unit Test Enviroments

After you complete the previous session, Netbeans will try to make the project, but it wont have the correct configuration. Follow these instructions to be able to build and debug unit tests.

  1. Right click on your RAMCloud project and click Properties
  2. Click "Manage Configurations" on the page that pops up
  3. Click "New" and create one called "Debug"  and press OK
  4. Under Build->Make, the following
    1. Build command "make obj.master/test -j16"  (note, change 'master' to your branch name)
    2. Clean Command "make clean"
    3. Build Result "obj.master/test" (note, change 'master' to your branch name)

  5. Under "Debug" change the following:
    1. Run Command: "obj.master/test" (again, change master to branch name)
      1. Note: This is where you can put in --gtest_filter=... to filter the tests
  6. Click "Apply"
  7. Now on the top bar, change your configuration to "Debug" and use the hammer to build
  8. Then to test if it was successful, click the play to run the tests or the one next to play to debug!
  9. Enjoy!

Advanced Tutorial: Debugging on the Cluster

There will be times when you need to debug a Master/Coordinator/Client that's running on the the rcXX machines instead of the coordinator. To support debugging these problems, we'll have to (a) setup a new build configuration (b) tunnel through rcmaster to the rcXX machines, (c) create a new build host, and (d) debug of course!

  1. Setup new Build Configuration
    1. Follow Steps 1 and 2 from "Creating Build and Unit Test Environment" For reference it's...
      1. Right click on your project and go to properties
      2. Click "Manage Configurations"
    2. Click "New" and name the configuration "Cluster" and click OK, OK.
    3. Under Build change the following
      1. Build Command: make -j32
      2. Clean Command: make clean
      3. Build Result:
        1. If you are debugging the coordinator, select obj.master/coordinator
        2. If you are debugging a server, select obj.master/master
        3. If you are debugging clusterperf, select obj.master/ClusterPerf
          1. Again, change 'master' to your branch
    4. Click Apply
    5. Build the project with the hammer button
  2. Tunneling through rcmaster
    1. Create a tunnel from rcmaster to an rcXX machine. For example
      1. ssh  -L 2222:rc80:22 <username>@rcmaster.scs.stanford.edu
        1. This will map port 2222 on your local to port 22 on rc80
    2. Test out the port forwarding
      1. If you did my example, you should be able to do "ssh localhost -p 2222" on your computer and instantly be connected to rc80
  3. Create a new fake build host
    1. Follow steps 1-3 on "Setting rcmaster as the Build Host." For reference, they are
      1. Open Netbeans
      2. Click on "Manage Hosts"
      3. Click "Add"
    2. In the window that pops up, fill in the following:
      1. Hostname: localhost
      2. port: 2222
    3. Click next, select SSH
    4. Click Finish
  4. Actual Debugging
    Now at this point, you should have everything setup for debugging. The specifics of what to do next are highly dependent on your project, so I will only outline what to do.
    1. Start up your cluster
    2. In Netbeans, click to the right of the debug button and drop down to "Attach Debugger"
    3. In the new window that pops up,
      1. Select the Host as localhost:2222
      2. Use the filter to filter out your project (i.e. obj.master/server)
      3. Select the process you're interested in
      4. Select RAMCloud as your project
  5. Click Okay and you should be attached
  6. Set your break points and run your test
  7. Enjoy!

Troubleshooting

Q: Netbeans wont parse a file!

A: You can manually specify which files Netbeans should parse. Right click on the file, click "properties," and check the "Add to Parse"

      

 

Q: Netbeans is slow on my Macbook Pro Retina/High Resolution display!

A: The performance bottleneck is actually due to a Java issue (more info https://netbeans.org/bugzilla/show_bug.cgi?id=237724 ). To fix this, update your Java to at least JDK 8u66 and reinstall Netbeans. To be sure Netbeans is using the correct version, launch netbeans and go to Netbeans->About Netbeans. If you updated to 8u66, you should see something like this in your about window:

 

If the Java version does NOT match the one you installed, then you need to set it in the configuration of Netbeans. To do this on OSX, you need to open the following file:

/Applications/NetBeans/NetBeans*.app/Contents/Resources/NetBeans/etc/netbeans.conf

then replace the netbeans_jdkhome path to your jdk installation. For example, mine is

netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre"

 

Q: I'm on Windows and I get a build error!

A: For some reason, on Windows, not all the executables (like bindings/java/gradew) copy over, so you should clone the RAMCloud again on rcmaster and then copy it over manually. This only needs to be done once.

  1. ssh into rcmaster and follow the instructions here General Information for Developers
  2. Look at the build error and find where Netbeans is copying the files (see screenshot).
  3. On rcmaster, copy over your new checkout from step 1 to location found in step 2.
    1. For example, the command for syang on PC is " cp -R RAMCloud/* /home/syang0/.netbeans/remote/rcmaster.scs.stanford.edu/desktop-2tfo897-Windows-x86_64/C/Users/Stephen/Desktop/RAMCloud"
  4. Now press the Hammer (build) and it should work!

 

Legacy Netbeans Tips

Anti-aliasing: http://thomashunter.name/blog/enabling-anti-aliasing-in-the-netbeans-editor/

To fix parsing issues with standard defs (such as size_t) do the following:

  • Right click on the ram cloud project and select properties.
  • Under "Code Assistance -> C++ Compiler -> Include Directories" add the following line.
    • src;obj.master;gtest/include

 

Parsing C++11 Foo<Bar<Baz>> is broken in 7.2. Apparently this is fixed in the dailies: http://netbeans.org/bugzilla/show_bug.cgi?id=179939#c15 . Diego tried this with mixed results. The daily (8/30) seems stable, but it doesn't always parse the >> properly.

Under project build options, make sure you set your C++ standard to C++11. There are some other preprocessor macros you probably want to define so that NetBeans' parser will follow the #ifdefs properly.

  • __GXX_EXPERIMENTAL_CXX0X__
  • _GLIBCXX_USE_C99_STDINT_TR1

 

LogCabin's scons build copies all the source files to the build directory. Then when there are compiler errors, they are at build/Foo/Bar.cc. If you click on them, NetBeans opens the build cc file, which will soon be blown away. A work-around is to set the compile command to: sh -c "scons 2>&1 | sed 's/build\///'"