Debugging OpenDaylight controller in Eclipse

********************************************************************************

This post is no longer valid.  Please see http://alagalah.wordpress.com/2013/12/14/debugging-opendaylight-in-eclipse/ for currently usable instructions.

********************************************************************************

 

One of the fundamental development activities that you need to be able to perform for any software you are working with is to run it in a debugger. OpenDaylight controller is no different.

The OpenDaylight controller is an OSGI application, which means its an assembly of many OSGI bundles running in an OSGI container, so it’s not quite as simple as debugging a simple Java app with a main() method, but it’s not really all that much harder 🙂

First, you will need to set up your target. In Eclipse, open:

controller/opendaylight/distribution/opendaylight/opendaylight.target

And click on ‘Set as Target Platform’:

Setting up the 'target' for OpenDaylight Controller in Eclipse.

Setting up the ‘target’ for OpenDaylight Controller in Eclipse.

Second, let’s set a breakpoint so we can see the debugger in action. In this example, I’m setting a break point in the arphandler project in
org.opendaylight.controller.arphandler.internal.Activator at line 78. Since the Activator for a bundle is always called during startup of that bundle, this breakpoint will get tripped during the startup of the controller. You set a break point in Eclipse by double clicking next to the line where you want the breakpoint:

Set a breakpoint in arphandler project at org.opendaylight.controller.arphandler.internal.Activator line 78.

Set a breakpoint in arphandler project at org.opendaylight.controller.arphandler.internal.Activator line 78.

Third, we need to run the Debugger configuration for opendaylight. To do this, in the menu for Eclipse select ‘Run’->’Debug Configuration…’ which will bring up the ‘Debug Configuration’ dialog. Select ‘OSGI Framework’->’opendaylight-osgi-launcher’ and click ‘Debug’:

Launching the 'opendaylight-osgi-launcher' for debugging.

Launching the ‘opendaylight-osgi-launcher’ for debugging.

This will run the controller. You will be able to see the progress in the ‘Console’ view:

OSGI console.  Yes, you can type OSGI console commands here.

OSGI console. Yes, you can type OSGI console commands here.

When the ArpHandler bundle is loaded, and it’s Activator run, you will see the debugger stop at the breakpoint we set:

Debugger stopping on breakpoint in Arphandlers Activator.

Debugger stopping on breakpoint in Arphandlers Activator.

There are other very good introductions to the power of the Eclipse Debugger here and many more here.

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: