Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Printing backtrace on abort()

Kacper_Kowalik
Beginner
436 Views
I'm interested if it would be possible to make ifort dump stack when calling abort()? It is useful information when you gracefully kill your own program due to e.g. unfulfilled logical check in deeply nested function. Similar functionality is already available in gfortran. Currently, I work it around by forcing SIGSEGV in a proper place of the code. Beforementioned functionality is shown in the following snippets:

$ cat ~/foo.f90
program ala
call foo()
contains
subroutine foo
call bar()
end subroutine foo
subroutine bar
call abort()
end subroutine bar
end program ala

$ gfortran-4.7.1 foo.f90 -g ; ./a.out
Backtrace for this error:
#0 0x7F4520FD1767
#1 0x7F4520FD2D96
#2 0x7F452109B818
#3 0x400709 in bar at foo.f90:10
#4 0x40071D in foo at foo.f90:6
#5 0x400712 in ala at foo.f90:2
Aborted
0 Kudos
1 Reply
Kacper_Kowalik
Beginner
436 Views
I've just RTFM and found TRACEBACKQQ(), sorry for the noise...
0 Kudos
Reply