By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

Function which prints stack trace of the program

P: n/a
Hi

I am in need to write a function which prints the stack trace of
current program

The need is that if any exception occurs then apart from error message
we want to print the stack trace of the program

Has any one does something like this
if yes please share your experience with us

thanks in advance

from
khan

Nov 8 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
khan wrote:
Hi

I am in need to write a function which prints the stack trace of
current program

The need is that if any exception occurs then apart from error message
we want to print the stack trace of the program

Has any one does something like this
if yes please share your experience with us
Yes (on an embedded target), but it is very system specific, there isn't
a portable way to do this.

I guess one answer is to use a debugger, or some other wrapper
application that can examine the state of yours when it bombs.

--
Ian Collins.
Nov 8 '07 #2

P: n/a
On Nov 8, 10:42 am, khan <d.nayeem.k...@gmail.comwrote:
I am in need to write a function which prints the stack trace of
current program
The need is that if any exception occurs then apart from error message
we want to print the stack trace of the program
Has any one does something like this
if yes please share your experience with us
There's no portable solution, but I have code at my site
(kanze.james.neuf.fr) for PC (under Windwos or Linux) and Sparc
(both 32 bit and 64 bit).

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 8 '07 #3

P: n/a
khan <d.***********@gmail.comwrites:
I am in need to write a function which prints the stack trace of
current program
[...]

Funny you mention that, I was just reading this article on how to do
this under Linux:

http://www-128.ibm.com/developerwork...-cppexcep.html

That's Linux-specific. The only portable way I know of is to hack
some macros together which use __FILE__ and __LINE__, and at each step
catch the exception, add their stack trace information, then re-throw
it.

Good luck!

----Scott.
Nov 8 '07 #4

P: n/a
Brendon Costa wrote:
Getting a stack trace is not simple cross platform. I have written a
class that will get it for, Windows, Linux and Other UNIX'es (Compiled
With GCC)
[..] If interested i will post more information about
this later.
I recommend doing it in the platform newsgroup[s].

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 9 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.