Displaying of the Stack Trace

G

Guenther Sohler

I have written a program, which is very compicated
and so it happens quite often, that it has to exit itself,
because its handling an invalid index of an array.
(It never crashes, it always nicely exits).
Nevertheless - in that case, It would be very nice
if my program could display the function hierarchy,
how my program reached that exit.
I have already seen programs doing that, before they crashed.
How can I do this on a unix/linux system ?
Are there special functions to read the symbols contained within the ELF
File ?

rds
 
Z

Zoran Cutura

Guenther Sohler said:
I have written a program, which is very compicated
and so it happens quite often, that it has to exit itself,
because its handling an invalid index of an array.
(It never crashes, it always nicely exits).
Nevertheless - in that case, It would be very nice
if my program could display the function hierarchy,
how my program reached that exit.
I have already seen programs doing that, before they crashed.
How can I do this on a unix/linux system ?

The way you asked your question already should have suggested to you
that you want to ask it in a newsgroup related to your system rather
than a language group.
Are there special functions to read the symbols contained within the ELF
File ?

comp.unix.programmer
comp.os.linux.development.apps
 
I

Ira Baxter

Guenther Sohler said:
I have written a program, which is very compicated
and so it happens quite often, that it has to exit itself,
because its handling an invalid index of an array.
(It never crashes, it always nicely exits).
Nevertheless - in that case, It would be very nice
if my program could display the function hierarchy,
how my program reached that exit.

You either have to depend on some specific compiler feature that does this
(your compiler mileage will vary significantly) or you will have to
ensure this yourself.

A compiler-independent way to do it is to decorate each
function entry/exit with instrumentation that keeps track
of this information on your own private stack. You can
do this by hand, with a few macros and lot of editing.

Or, you can use a tool that could automatically place such
probes in all your source files. A white paper on inserting
probes using automated tools can be found on the web page,
http://www.semanticdesigns.com/Products/TestCoverage/index.html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top