stack trace: something equivalent to printstack?

hello all,i'm in search of something equivalent to printstack for C progrs.On intel compiler, it exists tracebackqq()Thanks in advance,gerard
[177 byte] By [screen1984] at [2007-11-26 10:55:51]
# 1
On Solaris there is "printstack". Try "man printstack". Not sure about Linux.It's a libc function, not a specific compiler feature.--chris
ChrisQuenelle at 2007-7-7 3:09:01 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
And if you need any more sophisticated things consider dbx as the reflection tool for C programs. Something in the spirit of:sprintf(buf, "dbx -q -s /dev/null -c \"where;quit\" - %d", getpid());system(buf);
horsh at 2007-7-7 3:09:01 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

thanks for replies.

But i forgot to precise that i need something usable in Fortran program, not in C.

printstack is usable in C program, is there an equivalent for fortran programs?

I'm not a fortran developper, someone just showed me that intel fortran compiler had a function "tracebackqq()" and it's very useful.

however, I'll give a try to printstack() and dbx in fortran programs if it is possible

gerard

screen1984 at 2007-7-7 3:09:01 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
Check the fortran manual to see if there is information abouthow to call C functions from a fortran program. It should bepretty easy. On Solaris the "libc" library is automatically available in allC, C++ and Fortran programs.--chris
ChrisQuenelle at 2007-7-7 3:09:01 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5

Here's an example (I can't get the "code" tag to work, so there's no indententation):

$ cat stack.f90

subroutine print_my_stack()

interface

function printstack(fd)

bind(c) printstack

integer, value :: fd

integer printstack

end function printstack

end interface

integer n

n = printstack(1)

print *, "printstack returned ", n

end subroutine print_my_stack

call print_my_stack()

end

$ f90 stack.f90

$ a.out

.../a.out:print_my_stack_+0xd

.../a.out:MAIN_+0x8

.../a.out:main+0x45

.../a.out:_start+0x7d

printstack returned 0

$

igb at 2007-7-7 3:09:01 > top of Java-index,Development Tools,Solaris and Linux Development Tools...