Linux Programming

Here are some nice programming tools for Ubuntu Linux.

Meld

Meld is a very nice file and directory comparison tool. It will display a tree view of directories, and allow clicking into the files. It will allow moving either differences by individual differences within files, or by moving entire files or directories.

UML Modelling

The Umbrello program can read source code and create UML drawings. It is also possible to make drawings and create source code. The easy way to get it in Ubuntu is to use the synaptic package manager and get the kdesdk package. This means that the recently released version of the KDE SDK for Windows also has Umbrello built in. The download and usage from Windows was very easy. I used this on Vista at work.

The class diagramming seems to work pretty well. Both making classes, and reading classes from source code.

The following notes apply to version 2.0. I have compared to MagicDraw and Rational/IBM and this tool is useful for doing single time code generation from initial objects, and then reverse engineering from code to update the drawings. I don't plan to do multiple code generation passes.

Find in files

One of the missing features of Gedit is the "search in files" functionality. This can be simply added using the following.

Find memory leaks

To find memory leaks, use the following.
   valgrind --leak-check=yes --log-file=valgmem.txt testprogram

Optimize for speed

The following script will display optimization information in a graphical interface. I am using QT, so some of these notes are specific to QT.
   #!/bin/sh
   # depends on packages:  oprofile, kprof
   # this also requires /usr/bin/opcontrol first line to be changed to #!/bin/bash

   #To compile and link with profiling enabled, add these lines to the .pro file:
   #QMAKE_CXXFLAGS_DEBUG += -pg
   #QMAKE_LFLAGS_DEBUG += -pg
   #Rebuild the application in debug mode:
   #$ qmake -config debug
   #$ make clean
   #$ make
   #Run the application as usual. A profile data file called gmon.out is created
   #when the application exits normally (eg. it doesn't crash). Finally, you must
   #run gprof to analyze the profile data:
   #$ gprof executable-file > outfile

   sudo opcontrol --no-vmlinux
   #sudo opcontrol --start-daemon
   sudo opcontrol --start
   bin/testchar manyreps
   sudo opcontrol --stop
   gprof bin/testchar >bin/profreport.txt
   mv gmon.out bin
   #opreport --symbols --debug-info --output-file ./opreport.txt
   kprof -f bin/profreport.txt
   #sudo opcontrol --start ; ./testchar --run ; opcontrol --stop
   #sudo opcontrol --shutdown

Other scripts

This will find and delete all temporary files starting from the parent directory. Simply name the file removetemps.sh, and in Nautilus (File Manager), remember to go to the properties page and change the permissions so that the Execute flag is set.
   #!/bin/sh
   find ../ -name '*.*~' -exec rm '{}' \;
The following will delete all files in all bin directories.
   find ../ -wholename '*/bin/*' -exec rm '{}' \;
The following will change spaces to tabs in an entire directory.

untabifydir.sh
   #!/bin/sh
   find ../ -name '*.cpp' -exec ./untabifyfile.sh '{}' \;
   find ../ -name '*.h' -exec ./untabifyfile.sh '{}' \;
untabifyfile.sh
   #!/bin/sh
   expand $1 >$1.tmp
   mv $1.tmp $1

Xubuntu editor

On Xubuntu, I am using the built in MousePad editor. This editor will allow jumping to a line, but does not appear to display the line numbers. One other problem is that space/tab handling is different than GEdit. I don't think I will find a good lightweight editor for all platforms. Sorry, no VI for me at this time. 1
Hosted by www.Geocities.ws