Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Displaying of the Stack Trace (http://www.velocityreviews.com/forums/t313763-displaying-of-the-stack-trace.html)

Guenther Sohler 06-24-2003 10:26 AM

Displaying of the Stack Trace
 
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


Zoran Cutura 06-24-2003 01:53 PM

Re: Displaying of the Stack Trace
 
Guenther Sohler <guenther.sohler@newlogic.at> wrote:
> 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

--
Z (Zoran.Cutura@daimlerchrysler.com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond

Ira Baxter 06-25-2003 04:32 PM

Re: Displaying of the Stack Trace
 
"Guenther Sohler" <guenther.sohler@newlogic.at> wrote in message
news:pan.2003.06.24.10.26.40.356751@newlogic.at...
> 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/Produ...age/index.html.


--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


All times are GMT. The time now is 08:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.