Saturday, April 21, 2012

Source code browsing

I've implemented the source code viewing. Here's a screenshot:

You simply click a node, it turns orange and appears in the source code viewer, it also has some really basic syntax highlighting. With right click, you can expand nodes.You can also select expanded nodes for source code viewing. It also automatically scrolls near the function definition in the source file, the method name is also highlighted.

What I've been up to lately

Yes, it's been a year again and while writing yearly blogposts is not my intention, this is how it happened.

I've been busy.Now that I check my blog and see all the C++/Perl posts it may come as a surprise to some that I have a new job. For the last 8 months I've been working as a Java Developer at ISDC. We do enterprise web development, yeah, I know what you're thinking, but you're wrong. It's not boring at all, I've had the chance to work on some really interesting projects, one of them was recreating a simpler version of google earth using HTML5 and canvas and laying out some geographical data on it, it was a really interesting R&D project.Other than that it's still challenging, enterprise needs are very different from standard, traditional web application needs. What I like the most is, that we try to do things by the book, reviews are strict, business processes are a priority, our aim is quality.I feel like I'm a lot more disciplined coder.

So if work (part time, 20 hours a week), school (3rd year, final) wasn't enough to keep me busy, I've started to work on my thesis project.

Ever had the heart warming experience of maintaining a huge project you haven't worked on ? Thousands of modules, packages, classes of unfamiliar code. It's hard to decide even where to start. Well this is what my thesis project would like to address. Using the JVMTI a profiling agent attaches itself to the execution of a java program and gathers data about the execution. This data, for now, is limited to all the function calls that match a specific ruleset.This process is done using the ASM API, which lets you hook into the JVM class loading process, and rewrite the classes at runtime, before they are executed.

The gathered data is stored in a huge XML file and a 3D visualizer, written in JMonkey, reads it and allows you to visualize the callgraph, jumping to the relevant source-code portion. This allows you to execute a very simple use case and follow the execution path, without going through every detail a debugging process would force you to. You can give regular expressions matching the classes you would like to record, the rest is ignored. This lets you focus on your code.

The project is called Symbion (because of the Symbiosis-like relationship between the profiling agent and the profiled program). While it's heavily work in progress, you can check it out here: http://sourceforge.net/p/symbion/

I've attached a few screenshots below:

I've made an artificial starting node, so I won't have multiple trees.You can expand each function node and get what functions it calls. The source code display is not implemented yet.

I've taken a week off to work on this project, but it's not expected to be stable anytime soon.I'll have to defend my thesis in June,so it should be done by then.

Here's a pic of the profiler and the console, you can see each class that matched your rules.It's profiling a very simple application I had as homework for school back in the second year.

So yeah, this concludes my little adventure in software visualization.The finer details are yet to be dealt with.I hope it will be actually useful.