Wednesday, October 14, 2015

DOT Debug View

In my past post I presented a small hack that used the returned value of the toDOT() method of a variable in the debug view (in Eclipse) to generate a graph in the eclipsegraphviz  view. Today I am presenting the new, improved, version of this.

No more hacking into the Eclipsegraphviz view

After discussing my idea with Rafael Chaves (@abstratt), the author of Eclipsegraphviz, he was kind enough to provide a nicer method to access the view provided by his plugin. Thanks a lot Rafael!

The DOT Debug View plugin

My initial hack didn't play nicely with with the thread management principles of both the Elcipse UI and the JDT. Hopefully this has been corrected, and thus using the new plugin should not had adverse effects on the debugger or the UI.

Providing an Eclipse Update Site


When developing plugins I always had the issue of distribution and subsequent updates. Eclipse provides a very solid update framework through via its p2 component. However, if you don't own a domain or hosting space, making your updatesite available might be tricky. 

Luckily, I fumbled upon bintray while looking for alternatives. Based on the script provided by Lars Vogel, you can read this post about it, I came up with a Python version to help me (and hopefully others) publish their update sites to bintray. You can find the script here: py_bintray-publish-p2-updatesite

Using DOT Debug View plugin

As before, all you need to do is provide a method with the signature "String toDOT()" in your class, and return a valid DOT graph string of a representation/view of your object. Of course you need to install Eclipsegraphviz too!.

You can find more details on the project's gitbub page, but basically you can add the following url to your update sites and install it:

https://dl.bintray.com/arcanefoam/DOTDebugView



Monday, July 13, 2015

Using EclipseGraphviz as a debugging aid

My current area of interest is Model Driven Architecture. In this field, and I assume in many others too, our [data] models can be usually represented as graphs. In this scenarios, being able to view our model as an actual graph can be of great help to quickly identify errors in our model.

Come in EclipseGraphviz

Graphviz is a Graph Visualization Software that can produce graph visualizations from a graph representation in a text file (using the DOT language). EclipseGraphviz is a plugin for Eclipse that adds a view in which files with the dot extension will be rendered using Graphviz dot tool.

However, having the need to have a dot file requires you to somehow serialize your model into a file. This limits the use of the viewer for debugging purposes. Surely you can use the console to output a graph in DOT language, then copy the text, paste it to a file... or modify your code to serialize directly into a file...

Wouldn't it be nice to click on a variable in the Variable View during a debug session and have the graph representation of it shown in a nice graph?

EclipseGraphviz + debug

I have extended EclipseGraphviz to make this happen. All you have to do is add a
String toDOT();
method to any class. If the returned string is a valid DOT graph, then you will see it in the View. Simple as that...

This lets you rapidly instrument classes to have a graph representation during debug and doesn't make your projects depend on any of the EclipseGraphviz plugins. It also allows you to keep the toString() method independent if you have a string representation that might be used for other purposes. Having a toDOT() method will also provide you with a means to serialize your model if it needs be.

Bellow you can see a snapshot of how it works. I have selected variable p in the Variables view. The ExecutionPlan class has a toDOT() method. In this case the toString() method just calls toDOT() so you can see the DOT representation of the class in the Variables view.



Installing

The source code is available from GitHub (EclipseGraphviz  fork). I think the easiest way is to follow EclipseGraphviz  installation instructions and then build and export my version to your dropins folder in Eclipse.