Tuesday, October 25, 2011

gdb-7.3.1 on Snow Leopard

I was updating the default gdb debugger on Snow Leopard (version 6.3.50) to a more current one (7.3.1), because I need better support for the STL.

The source compilation was OK. But, the executable should be signed in order to work (A security measure). This is well explained on http://sourceware.org/gdb/wiki/BuildingOnDarwin . After that, I can call ddd as:

ddd --debugger "/usr/local/bin/gdb-7.3.1" ./test.x

Of course, this implies I have configured/compiled gdb as:
./configure --prefix=/usr/local --with-python


The last flag is to active python pretty printers for stl containers inside gdb.

Tuesday, October 18, 2011

More on ddd : ddd, idb and ifort on Mac Os X

I have been helping somebody else to set up  ddd to work with the intel compiler and debugger on Snow Leopard, although I do not have those on my computer and I do not program in Fortran :P

Basically, we need to take care of two things: the compilation process and the calling procedure for ddd.

  1. Compilation process: During compilation, ifort writes and deletes some temp files which are necessary for information about debugging symbols. The best way to keep that info is to compile in two stages :
    ifort -c -g -o  [object_name].o  [source_name].f90 
    ifort -g  [object_name].o  -o [exe_name].x
  2. Calling ddd: you have to explicitly set the path for the idb debugger as :
    ddd  --debugger  "/opt/intel/composerxe-2011.3.167/bin/idb" [exe_name_or_path].x
Set /opt/intel/composerxe-2011.3.167/bin/idb to the actual path of idb in your system.

ddd on Snow Leopard


I want to use ddd on my macbook pro with Snow Leopard, but it was not an easy task. The most annoying problem was the error related with the 'Ddd defaults application' file:

Error: No `Ddd' application defaults file
To resolve this problem, you can:
* set the XAPPLRESDIR environment variable to the location of the file
`Ddd', or
* set the DDD_HOME environment variable to the location of `ddd/Ddd', or
* install the `Ddd' file in the X application defaults directory, or
* recompile DDD with builtin app-defaults file;
see the `--enable-builtin-app-defaults' option for details.

Even after following each one of this suggestions, ddd still did not work. For example, when I tried to compile by using the flag --enable-builtin-app-defaults , the compilation ended with an error after many lines of cryptic messages. At the end, I discovered that it was much better to recompile using a different extension for the executable, like make EXEEXT=exe .

Fortunately, I am using the amazing package manager homebrew , which a great replacing option for the mess of both macports and/or fink.

To install ddd, I just use :
brew install ddd
The formula for ddd includes fixes for the 'defaults file' problem.

But, of course, this is not the end. After installing with brew, ddd still does not work. It gives a seg fault. The problem is related with the X11 libraries (there are at least 3 different directories with X11 libraries!). I would like to tell brew to use some specific x-includes, but I was not not able to find a way to do that without editing the formula, which was what I did at the end. I just wrote

brew edit ddd

and I added

, "--x-includes=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/include", "--x-libraries=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib"

to the configure line. It now looks like:

def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--enable-builtin-app-defaults", "--enable-builtin-manual",
"--prefix=#{prefix}", "--x-includes=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/include", "--x-libraries=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib"

It is horrible, but it works. After that, I was able to compile again and succesfully use ddd on the mac. I am not sure if this modification to the formula is the best way to proceed, but at least if worked. If you have any suggestion, please fell free to make it. (I hope somebody reads this entry sometime in the close future :) )