[fortran, patch] Allow displaying backtraces from user code

Tobias Burnus burnus@net-b.de
Thu Jun 21 12:35:00 GMT 2012


On 03/03/2012 08:44 AM, FX wrote [1]:
> PR 36044 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36044) is an enhancement request for a way to display backtraces from user code.

I wanted to come back to that patch for some while. I think it makes 
sense to offer this feature in some why and as the PR but also a 
question on #gfortran shows, there is a need to do so.

There are two possibilities:
a) Making _gfortran_show_backtrace accessible from the outside (via 
manual C binding from Fortran)
b) Adding a new intrinsic

The latter is done by other vendors:
- Intel via DEC/Digital has in the module IFCORE the subroutine 
TRACEBACKQQ [3]
- Lahey has "call ERRTRA()"
- SGI has "call Trace_Back_Stack_and_Print()"
- IBM has "call xl__trbk()"

FX suggest to do (a).
Steve [4] is for (b)
Janus [3] seems to be fine with (a) but favours (b)
While I have to admit that I am happy either choice.

It seems as if there is a small majority for adding another intrinsic. 
The big question is the name and whether it should be available by 
default or - as with ifort - via an intrinsic module. One possibility 
would be to take the name of and the arguments from Intel's version [3].


Tobias

[1] http://gcc.gnu.org/ml/fortran/2012-03/msg00015.html
[2] http://gcc.gnu.org/ml/fortran/2012-04/msg00131.html
[3] 
http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/lin/compiler_f/lref_for/source_files/rftrace.htm
[4] http://gcc.gnu.org/ml/fortran/2012-03/msg00022.html

> I'm against adding yet another nonstandard intrinsic for this purpose (which is how Intel Fortran does it), but I would like to offer the following solution to the issue, as I think it can be useful in some cases (and the way I suggest should not be a maintainance burden for us):
>
>    -- export _gfortran_show_backtrace() from libgfortran (instead of it being an internal function)
>    -- add documentation on how to call this function from user-code using BIND(C)
>
> Patch was bootstrapped and regtested on x86_64-apple-darwin11, also tested with "make info html pdf". OK for trunk?
> FX
>
>




More information about the Gcc-patches mailing list