Code to print function call backtrace wanted

Code to print function call backtrace wanted

Post by Henk Fictor » Wed, 21 Feb 1996 04:00:00



Hi,

Some weeks (months?) ago source code was posted here to print a function
call backtrace. At that time I didn't think of saving it. Could someone who
did save it send a copy of it to me?

I need it for our application which is C++, multithreaded, running under
Solaris 2.3 (sparc) and compiled with the sun compiler (v4.01). Does the
code work in a 'hostile' environment such as handling a SIGSEGV?

regards,

Henk Fictorie
--

P.O. box 421,                              Phone    : +31 70 3326356
2260 AK Leidschendam, The Netherlands      Fax      : +31 70 3326477

 
 
 

1. how to know the instruction address of calling function within called function?

Suppose function A call B, are there any ways to know the address of last instruction in A just
before calling B from within B? I would like to do some profiling by substituting B by a routine with record
the time spent on B. I also would like to know the time spent on B in different locations of A
where B is called. If I can know the address of last instruction in A just before calling B, from
debuging info of the excutables, I can find its source code address, therefore know the
time spent on B in differnet locations of A.

I don't want to make any changes to A. "-pg" compiler option for profiling is of no use either,
because there is no source code for B, and there is no object code for B with profiling codes in,
so you can't know the total time spent on B, but only the self time spent on B.

Thanks very much.
--



Kingston, Ontario K7L 3N6        Tel: (613) 545-2723 (o)
Canada                           Fax: (613) 545-6463
Home address:
58 1/2 Chatham St.               Tel: (613) 547-1353 (h)
Kingston, ON K7K 4G8

2. ping debugging

3. Browser calls CGI C function which sets an env var and call a c function crashes

4. Redhat 5.2 and Asus P2bds using AIC 7890

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

6. Backing up AIX system

7. How to open/read a file during a function call in the networking kernel codes

8. Slackware Linux Release and Patching it..

9. System call and function error codes

10. glibc backtrace function

11. Seeking stack backtrace function

12. Printing the call stack inside a function?