When you use the GNAT symbolic traceback feature with gcc 4.4 on Ubuntu 10.04, a segmentation fault occurs. This article explains why and proposes a workaround until the problem is fixed in the distribution.
The GNU Ada Compiler provides a support package to dump the exception traceback with symbols.
with Ada.Exceptions; use Ada.Exceptions; with GNAT.Traceback.Symbolic; use GNAT.Traceback.Symbolic; with Ada.Text_IO; use Ada.Text_IO; ... exception when E : others => Put_Line ("Exception: " & Exception_Name (E)); Put_Line (Symbolic_Traceback (E));
GNAT Symbolic Traceback crash
On Ubuntu 10.04 and probably on other Debian distributions, the symbolic traceback crashes in convert_addresses:
Program received signal SIGSEGV, Segmentation fault. 0xb7ab20a6 in convert_addresses () from /usr/lib/libgnat-4.4.so.1 (gdb) where #0 0xb7ab20a6 in convert_addresses () from /usr/lib/libgnat-4.4.so.1 #1 0xb7ab1f2c in gnat__traceback__symbolic__symbolic_traceback () from /usr/lib/libgnat-4.4.so.1 #2 0xb7ab2054 in gnat__traceback__symbolic__symbolic_traceback__2 () from /usr/lib/libgnat-4.4.so.1
The problem is caused by a patch that was applied on GCC 4.4 sources and which introduces a bug in convert_addresses function. Basically, the function is missing a filename argument which causes other arguments to be incorrect.
void convert_addresses (const char* filename, void* addrs, int n_addr, char* buf, int* len)
Since convert_addresses is provided by the libgnat-4.4.so dynamic library, we can easily replace this function by linking our program with the correct implementation. Get the convert_addresses.c, compile it and add it when you link your program:
$ gcc -c convert_addresses.c $ gnatmake -Pproject -largs convert_addresses.o