Seeking stack backtrace function

Seeking stack backtrace function

Post by Alan L. Wen » Thu, 02 Nov 1995 04:00:00



Does anyone know of a function that I could call to print
out a backtrace of the call stack?  I wrote a version for
Xenix but I haven't had the energy to update it for Linux.

Actually, better yet would be some standard library routines
that would

(a) give me the stack frame address of the current function;
(b) give me the calling stack frame of any stack frame;
(c) give me the program counter within any stack frame;
(d) translate program counter values into filenames and line numbers.

Such routines could be also be used for other purposes, for
example, to write fancy profilers.

I looked at cannabilizing gdb source but that task did not appeal.

Alan Wendt

 
 
 

1. call stack backtrace from a C program

I'm trying to get a call stack trace in a C program
under Solaris 2.6 or later.  Does anyone know how
to do it?

The info I'm looking for would be similar to this:
...
(10)  0x00045e08   integ + 0x408  [./two_brn.e]
(11)  0x0006468c   trajcem + 0x128  [./two_brn.e]
(12)  0x00055490   fly_traj + 0xf58  [./two_brn.e]
(13)  0x0004052c   top_level + 0x14  [./two_brn.e]
(14)  0x000567e4   _start + 0x34  [./two_brn.e]

which shows what the code was doing when it dies.

Under HP-UX and IRIX, a printout like the above can
be obtained by calling U_STACK_TRACE() and
trace_back_stack_and_print(), respectively.

TIA,

--G

Sent via Deja.com
http://www.deja.com/

2. Logitech serial mouse probmlem

3. Stack backtrace from signal handler

4. Top 10 posters comp.os.linux.misc (last 7 days)

5. Stack Backtrace for Solaris 2.3/SunPro C 2.0

6. App question - psnup

7. How to backtrace stack frames?

8. netscape server password

9. adb and dbx gives different stack backtraces

10. call stack backtrace from a C program (Solaris)

11. How to backtrace stack frames?

12. Interpreting the results from backtrace()/ backtrace() usability

13. glibc backtrace function