getting a backtrace on crash (signal)

Hey,

I have a very large program (~1k subroutines) that is mostly fortran, compiled with pgf77, and some c, compiled with gcc. The main subroutine is in c (in main.c) and it calls the initial fortran subroutine that then does all the work.

In the main.c file, I also use feenableexcept to turn on floating point exceptions, and install a signal handler to catch sigsegv & sigpfe. The handler then uses glibc’s backtrace() function to get a backtrace of the crash location. I tested this (backtrace stuff) using pure c, and a c/fortran setup using gfortran/gcc, and both produced a backtrace. When I try (with simple test code) with pgf77/gcc, the backtrace doesn’t return any info except the address for the signal handler.

Is there a way to get this information? Do I have to have a certain compiler flag? I’m compiling with:
c file:
gcc -g -c file.c
f file:
pgf77 -g -c file.f

and I’m linking with:
pgf77 -g -lm -Mnomain *.o


Also, is there a library I can include to link with gcc? For gfortran I can just link with -lgfortran.

Thanks

Hi ephq,

We added back tracing by default to version 7.1 and later (see the flag “-Mtraceback”) so your code most likely is compiled with traceback already. To see this information, you need to set the environment variable “PGI_TERM” to “debug”, “trace”, “signal”, or “abort”. “trace” will give a backtrace while “debug” will launch the PGI debugger.

Please see the PGI User’s Guide for mode details.

Hope this helps,
Mat

Ahh nice, unfortunately it looks like the cluster I am using only has 7.0.