Sunday, July 15, 2012

Tools

    Obviously first post will be tools needed for reading codes. Earlier I simply
used to untar the source and start reading from some random files, but now
I think tools are equally necessary at-least for beginners. So here is list of
my favorite tools. Most of these are also available on windows with some good
additions (like Visual Studio 2010 editor + symbols search).

1. Geany: http://www.geany.org/ My editor of choice. It is very light-wight,
shows functions, structure, classes and globals on left hand panel. It has a
drawback that it doesn't show symbols from other files, but with it works for me
with combination of other tools.

    I used to use Vim before, and at some point may again go back to it. I still use
it as default browser for Cscope. Vim with plugins may have all capabilities of
geany (with infinite advanced features of-course).

2. Cscope: http://cscope.sourceforge.net/ An awesome tool to extract almost
anything from your code. Works best with C, but as we go to C-like languages
(C++, Java and othrs) it starts giving hitches. There is a tool to generate
python index for Cscope. I haven't tried it yet, but if it is good enough,
Cscope should work smoothly for python too.

3. Cscope-Vim plugin: http://cscope.sourceforge.net/cscope_vim_tutorial.html. Vim already has support for Cscope, but this plugin reduces commands to just a
combination of keys. Also keeps track of your jumps in code.

4. Doxygen: http://www.stack.nl/~dimitri/doxygen/ Call graph generator for all
languages. Perticularly useful when we need to trace path between two points in
code path.

5. grep/perl/python: Very useful for search/modifications which are easily
codable and difficult to do from above tools. I am not very familier with perl,
but it is part of my current in-progress-learnings.

6.GDB: Default linux debugger. Easy to use once we know basic commands. As with
all debuggers, it may miss breakpoints due to non-loaded libraries,
optimizations, multithreading etc.  I perticularly like putting breakpoints
using "INT 3" so that none of them are missed.

About

    This is my first tutorial ever. My inspiration was my own struggle to read src
codes. I am still bad at it, and I hope that I'll find better methods through
comments. But I have learned a few things by now, and I hope sharing them would be useful since as far as I know there are no good articles on this topic yet.

    I'll try to cover how to read src code of any tool or in general any src code
available. Rather than reading whole code in one shot, I'll focus on some feature
(of my interest) and try to tweak it a little or sometimes add new feture
altogether. Given that most of the codes for Linux are written in C/C++, most
of the tutorials will  focus on them. But I'd like to find some python code and
work on it. All suggestions on this are welcome. As I said I'll take source from
linux tools, but if any interesting Windows src is there, I'd love to work on it.

P.S. The name of blog is illogical expansion of my favorite character string ASD.

                                                                                                   ASD
                                                                             (Anonymous Source Dissector)