This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: traceback feature for gfortran


Hi gfortranners,

This proposed patch adds a traceback feature: for code compiled with the -ftrace function, a backtrace of function called is printed after a runtime failure. For now, this is only enable in conjunction of the -ffpe-trap function (by adding a signal handler for SIGFPE), but the framework can be used for any kind of error.

All kinds of comments appreciated. This is not yet a formal patch proposal, I'm just asking for feedback about the feature, the way it is implemented, the english, anything!

A testcase to play with:

$ cat trace.f
      subroutine CeciCela
      integer i
      real x

      x = 1
      do i = 1, 50
        x = exp(x)
        print *, x
      end do

end

      subroutine truc1
        call truc2
        call truc3
      end
      subroutine truc2
        call truc3
      end
      subroutine truc3
      end
      subroutine truc4
        call truc5
        call truc5
        call truc6
      end
      subroutine truc5
      end
      subroutine truc6
        call CeciCela
      end

      program test
      call truc1
      call truc2
      call truc3
      call truc4
      end
$ gfortran trace.f -ffpe-trap=overflow -ftrace=frame && ./a.out
   2.718282
   15.15426
   3814273.
Floating point exception

Trace of last functions (innermost first):
  - cecicela (in file trace.f)
  - truc6 (in file trace.f)
  - truc4 (in file trace.f)
  - MAIN program (in file trace.f)



FX


Attachment: trace.ChangeLog
Description: Binary data

Attachment: trace.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]