This is the mail archive of the
mailing list for the GNU Fortran project.
Re: [fortran, patch] Allow displaying backtraces from user code
- From: Tobias Burnus <burnus at net-b dot de>
- To: FX <fxcoudert at gmail dot com>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Jun 2012 14:15:09 +0200
- Subject: Re: [fortran, patch] Allow displaying backtraces from user code
- References: <61B50068-0CDB-48AF-95D8-1139D6283FF8@gmail.com>
On 03/03/2012 08:44 AM, FX wrote :
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
- Lahey has "call ERRTRA()"
- SGI has "call Trace_Back_Stack_and_Print()"
- IBM has "call xl__trbk()"
FX suggest to do (a).
Steve  is for (b)
Janus  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 .
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?