473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Function which prints stack trace of the program

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
4 2345
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Charlie | last post by:
I have the first part of the project done but I'm having difficulty deciding how to add an evaluate function to this program. The program asks the user to enter a function in infix notation and...
21
by: Joakim Hove | last post by:
Hello, I have implemented a small library with a function a datatype to manage temporary storage, and handle out correctly casted storage. The function to get a double pointer is for instance: ...
2
by: Matthew Caesar | last post by:
I've written some code in the C# programming language. I have a lot of calls to a function that prints out some debugging information. I would like to occasionally remove all calls to these...
3
by: Mike Schilling | last post by:
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this: class OOM { public static void Main() { try { Object arr = new Object; } catch...
6
by: No_Spam | last post by:
I'm calling a function in .NET (ASP/VB) this way: If Not myFunction(var1, var2) Then .... End If myFunction is declared as: - Function myFunction(var1 as String, var2 as String) As Boolean...
5
by: anirbid.banerjee | last post by:
Hi List, This question can be categorised under "C programming in Linux", but as I didnt find any group of that sort, I post it here. I have a small program to print the stack trace of a...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
3
by: Michel Vanderbeke | last post by:
Hello, While logging the errors in my program, I want to know in which class, function or procedure they occured. Is it possible to know the name of the class, function and / or procedure in...
3
by: jack113256 | last post by:
Hi everyone: I have a question in using Callback function, there is my code: /******* code start *********/ #include <stdio.h> void a(); void b(); void run();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.