Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ equivalent of Java Exception.printStackTrace()

202 views
Skip to first unread message

rlecocq

unread,
Dec 29, 1999, 3:00:00 AM12/29/99
to
Hello,

1- Does someone know if there is an equivalent, in Visibroker 3.3 C++,
of the Java Exception.printStackTrace() ?
2- More, I would like to get all this in a string instead of printing to
stdout: is there a way to do this ?

Thanks for your help.

Rodolphe.

gre...@cibc.ca

unread,
Jan 1, 2000, 3:00:00 AM1/1/00
to
In article <3869FE47...@club-internet.fr>,

rlecocq <rle...@club-internet.fr> wrote:
> Hello,
>
> 1- Does someone know if there is an equivalent, in Visibroker 3.3 C++,
> of the Java Exception.printStackTrace() ?

Unless there is special support for this in Visibroker, there is
nothing like this in C++. Exception mechanisms in C++ do not mandate
any standard Exception object, and in general do not seem (in my
experience) to provide a stack trace.

There are ways of simulating this, however, if you are a diciplined
programmer. Just recently on comp.lang.c++.moderated I mentioned
under a similar thread some macros that were built in to the Blaze
(formerly Neruon Data) Open Interface Toolkit - a cross platform GUI
toolkit. Basically you added a couple of macros to your code as shown
below.

Obj::method()
{
ERR_TRACEIN;
... code ...
ERR_TRACEOUT; // does return;
// or use ERR_TRACERET(val) to return a value
}

These macros manage a linked list of the __FILE__ and __LINE__ macros,
not quite a stack trace, but you get the idea of what could be done.

BUT - as I mentioned, it is a programmer dicipline, and not mandated,
or given to you for free.

Hope this helps.
gre...@cibc.ca


Sent via Deja.com http://www.deja.com/
Before you buy.

Steve Vinoski

unread,
Jan 1, 2000, 3:00:00 AM1/1/00
to
gre...@cibc.ca wrote in message <84kv5u$ec$1...@nnrp1.deja.com>...

>In article <3869FE47...@club-internet.fr>,
> rlecocq <rle...@club-internet.fr> wrote:
>> Hello,
>>
>> 1- Does someone know if there is an equivalent, in Visibroker 3.3
C++,
>> of the Java Exception.printStackTrace() ?
>
>Unless there is special support for this in Visibroker, there is
>nothing like this in C++. Exception mechanisms in C++ do not mandate
>any standard Exception object, and in general do not seem (in my
>experience) to provide a stack trace.

Right. This really has nothing to do with CORBA, but has instead to do
with the programming language and operating system you're using. On
HP-UX, for example, you can get a stack trace printed to the standard
error output by calling the function

extern "C" void U_STACK_TRACE();

--steve

--
Steve Vinoski vinoski at iona.com
Chief Architect 1-800-ORBIX-4U
IONA Technologies, Inc. Waltham, MA USA 02451
200 West St. http://www.iona.com/hyplan/vinoski/
Copyright 1999 Stephen B. Vinoski. All Rights Reserved.


Michi Henning

unread,
Jan 1, 2000, 3:00:00 AM1/1/00
to
On Sat, 1 Jan 2000 gre...@cibc.ca wrote:

> In article <3869FE47...@club-internet.fr>,
> rlecocq <rle...@club-internet.fr> wrote:
> > Hello,
> >
> > 1- Does someone know if there is an equivalent, in Visibroker 3.3 C++,
> > of the Java Exception.printStackTrace() ?

Most UNIXes allow you to attach a debugger to a running process and take
a stack trace with that.

Some UNIX also have a stack_trace() call or some such in their C library.
However, if it's there, it's non-standard.

Cheers,

Michi.
--
Michi Henning +61 7 3891 5744
Object Oriented Concepts +61 4 1118 2700 (mobile)
Suite 4, 904 Stanley St +61 7 3891 5009 (fax)
East Brisbane 4169 mi...@ooc.com.au
AUSTRALIA http://www.ooc.com.au/staff/michi-henning.html


tbk

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
If worse comes to worse, you can also generate a "core" file (if on unix) or
an assert() on a win32 platform and then use the debugger to get the stack
trace. It's a pain, but it works.

0 new messages