Main menu:

Site search

Categories

Archive

MXR your Dehydra

MXR is cool. I use it all the time. But those of us that have been using or creating Dehydra know that Dehydra could be used to make MXR a lot cooler. I don’t seem to have time to work on it, though, so I thought I’d throw some ideas out here, to see if someone thinks it sounds fun and wants to run with it, or (cue ominous chords) if popular demand requires me to do it.

As an example of why Dehydra is needed, look at some random line of source code, like nsHTMLImageAccessible.cpp:238. To know what this does, I want to navigate to the code for SetParent. I can click on it, but then I get a page with links to a dozen or so different SetParent functions, and I don’t know which ones can actually be called on line 238.

To get the right answer, first I have to look up the type variable, privatePrevAccessible, which turns out to be nsPIAccessible. I used MXR to do that, but I had to scan the page for my file name and then pick one of two possible variable definitions (one of which was actually not a definition). So then I can use MXR on SetParent again and search for nsPIAccessible, but I don’t find anything. I try nsPIAccessible in MXR, but I get nothing for that. It would be way too boring to read everything I did after that, but another 10-15 minutes of find, grep, and MXR to find and verify (tracing the ancestry of nsListBulletAccessible was especially tedious) that the SetParent methods that can get called are at

accessible/src/base/nsAccessible.cpp:457
accessible/src/html/nsHTMLTextAccessible.cpp:338

(I know you wouldn’t have been able to sleep tonight until you got the answer.)

Dehydra can do all this automatically. Dehydra knows the type of every variable. Dehydra knows the class hiearchy, so it can find all the concrete classes that that variable can be, and all the SetParent methods those classes have. Dehydra can also look up local variables, parameters, and fields.

So what would I like to see? How about, in MXR, when you click on a reference to a variable or class member, you navigate to the definition(s). And when you click the name in the definition, you get a page listing all the uses. As a starting point, if MXR integration is hard, it would be fine to give, say an MXR URL (which has file name and line number) to some web page, which would then give links for the names on that line of code. One copy/paste is a lot better than 15 minutes of grep. Some AJAX goodness could make the UI easier, too, I imagine. And the identifier search could get an option for whether the input is a function, local variable, etc. (A crazier idea is to get the information in a form Emacs understands to make a smarter tags function.)

(Or does something like this already exist? A quick Google found a program for C, with no plans to produce a C++ version. Has anyone run CScope on Firefox?)

A nice bonus is that because Dehydra is a gcc plugin, the cross-reference builder can run whenever you recompile, so you potentially have your own code immediately added to a local cross-reference database.

Comments

Comment from fredrik (nossralf)
Time: March 4, 2008, 12:21 am

Ever since Taras started working on the Elsa stuff, this has been a vision of mine. Though I have to admit, I was thinking more along the lines of a WSGI-based setup (Python, probably Pylons). I’ve plowed through both LXR/MXR and Bonsai and feel suitably impressed by the people who maintain those snake-pits (vipers, no cuddly boas there). I also have some worry for their mental health.

OpenGrok uses ctags, which is pretty much as “bad” as MXR, and its interface is a bit different as well. Though I expect it’s (much) easier to extend than MXR. But then one would have to code Java…

make -f client.mk gen-xref would be neat. Or gen-doc (I have an IDL parser that spits out DevMo wiki markup.) Heh. It would be cool to have the build system generate an MSDN-type documentation package automagically.

Comment from Zbyněk Winkler
Time: March 4, 2008, 3:24 am

There is this OpenGrok http://opensolaris.org/os/project/opengrok/ – I always wanted to test but all the Java requirements kind of scared me away.

Comment from tmielczarek
Time: March 4, 2008, 4:19 am

I also thought about this recently, and I stuck it on the potential projects list for Seneca student projects:
http://zenit.senecac.on.ca/wiki/index.php/Potential_Projects#gcc_plugin_for_better_mxr_code_parsing

I’m not sure if it’s really a feasible student project or not, but Seneca students have impressed me enough in the past that I believe anything is possible. :)

Pingback from BSBlog » Blog Archive » Statically Checking the Mozilla Codebase
Time: March 5, 2008, 8:19 am

[…] Implement a webtool that allows users to browse code exactly […]

Pingback from Statically Checking the Mozilla Codebase · Get Latest Mozilla Firefox Browsers
Time: March 5, 2008, 10:47 am

[…] Implement a webtool that allows users to browse code exactly […]

Comment from Josh Matthews
Time: March 5, 2008, 12:29 pm

Summer of Code project, anybody? It actually sounds quite similar to what I’ve been playing with at work. I had to learn the Jam build language, and get up to speed with about 100k of build infrastructure code alone, and the source browser (based on LXR) is not set up to deal with Jam code very well. I’ve been writing a tool in Python that annotates where rules (and variables) and their corresponding actions are defined or invoked, and I plan to put it into a nice Jam browser that can easily punt you around the gigantic build infrastructure, while still remembering where you previously were.

Comment from Sylvain
Time: March 5, 2008, 3:53 pm

@Zbyněk: OpenGrok is very easy to setup: You just need a JVM, ctags package and a Tomcat instance (or other servlet containers). On Linux, I had to raise the max open files limit in /etc/security/limits.conf. That’s much faster than MXR when run locally.

Pingback from Bread and Circuits » Toward a Dehydra-MXR love child
Time: May 16, 2008, 3:53 pm

[…] been following my progress, you’ll know that I’ve been trying to solve Dave’s mxr-dehydra challenge, looking for all possible methods that SetParent could be in […]

Pingback from Bread and Circuits » DXR pre-alpha: Source Code Lexicography
Time: May 15, 2009, 11:51 am

[…] morning I was able to solve the “Dave Mandelin MXR Problem,” and I’m so happy I had to pause to blog about it. The “Dave Mandelin […]

Comment from MXR
Time: May 6, 2010, 4:13 pm

Great discussion, seems intriguing but not catching on.

Comment from college papers
Time: July 14, 2010, 2:08 am

It’s really a nice bonus is that because Dehydra is a gcc plugin, the cross-reference builder can run whenever you recompile, so you potentially have your own code immediately added to a local cross-reference database.

Comment from free coloring pages
Time: July 17, 2010, 2:26 pm

Thanks for the ideas, I was also wondering if anyone run CScope on Firefox. Maybe the discussion can pick up again.

Comment from Reisen
Time: July 24, 2010, 2:51 am

This is really cool, I love Dehydra and MXR. A great combination.

Comment from frases
Time: August 22, 2010, 3:20 am

I envision it as a box that appears when you hover over an identifier that is AJAX-ically loaded with the conxtextual information from Dehydra. There could basically be a keybinding to toggle the hints in the event that they keep getting in the way, & this way would avoid slowing down page load times with all of the additional information. What kind of links or text would be best to place in the hint

Comment from texas general liability insurance
Time: August 30, 2010, 10:30 am

This is really cool, I love Dehydra and MXR. A great combination.

Comment from wholesale wine bags
Time: September 13, 2010, 7:11 am

Great site, Very informative…

Comment from weight loss tips for women
Time: September 16, 2010, 11:07 am

Great site !
You explain well as a developer i can say you put great effort here. As Dehydra is gcc plugin then compilation become too easy because of taking local intraction with database

Comment from purity rings for girls
Time: September 22, 2010, 1:19 pm

Dehydra is so awesome. I’ve been using it for a while now and can’t figure out how I ever lived without it. Us devs love our tools! MXR FTW.

Comment from persuasive essay
Time: September 30, 2010, 11:40 pm

Thanks for a great time visiting your site. It’s really a pleasure knowing a
site like this packed with great information.

Persuasive Essay

Comment from Cole
Time: October 2, 2010, 3:46 pm

I’m a little bit puzzled by how Dehyadra is going to help me. I understand that it is a general purpose static analysis tool, but I’m not certain how that will help me with my daily scripting chores.

Comment from brisbane makeup artist
Time: October 4, 2010, 8:09 pm

Thank you for providing the perspective. I just read a part of the article,so I don’t know much what to say. Good luck for the new member!

Comment from brisbane makeup artist
Time: October 4, 2010, 8:09 pm

Nice post to hang on..I really loved it the way of the stuff provided in this article..This has given very useful information..

Comment from vicky
Time: October 22, 2010, 5:40 pm

Great site !
You explain well as a developer i can say you put great effort here. As Dehydra is gcc plugin then compilation become too easy because of taking local intraction with database

Comment from auto insurance quote
Time: October 31, 2010, 7:03 pm

Thank you for this, it’s a bit confusing but I will just have to piece the puzzle together.

Comment from testking ccie
Time: November 1, 2010, 2:56 am

I want to share my feeling about the certification that is Microsoft certification exams, check it and i hope you find it excellent one.

Comment from Term Papers
Time: November 1, 2010, 4:01 am

This is quite fantastic information to collect, MXR is a very useful tool to collect, while using or creating Dehydra know that Dehydra could be used to make MXR a lot cooler. It also saves time much.

Comment from HH0-110
Time: November 11, 2010, 1:25 am

Nice work! Your post is an excellent example of why I keep coming back to read your excellent quality content that is forever updated.

Comment from Custom Research Paper
Time: November 24, 2010, 4:46 am

This is interesting information about MXR and Dehydra, I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!