[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9250.0. "Secondary Exception Vector in Digital UNIX?" by RDGENG::HAQUE (Shaheed R. Haque, 830-3531, reo2-f/b3) Fri Mar 21 1997 05:56

Is there some way within Digital UNIX to have exceptions (for example, C++
"throw"n exceptions) to cause some user-defined code to be executed as the stack
is unwound?

I want to achieve an equivalent to a traceback, under program control. For
example, on VMS (and with Ada exceptions) it was possible to use the "secondary
exception vector" defined in the context of the "Condition Handling Facility"
for this.

The idea is that a random piece of code can throw an exception with a string,
e.g.

	throw "some explanatory text";  // at __LINE__ 6 in __FILE__ file9.cxx

and I'd like to be able to write a handler an arbitary number of callers up the
stack which could generate the following when caught:

	file6.cxx[6]: not handled
	file7.cxx[13]: not handled
	file8.cxx[23]: not handled
	file9.cxx[6]: some explanatory text

Ideally, the catcher would just be another piece of C++ that uses the "catch"
statement. It would be nice if this could potentially co-exist with threads. I
only need it in V4.0B or later, earlier would be a bonus.

Any help greatly appreciated!

	Thanks, Shaheed

P.S. This is not X-posted in the C++ conference as I figured that this was the
right place to start - if not, I'll take it there.
T.RTitleUserPersonal
Name
DateLines
9250.1COL01::LINNARTZMon Mar 24 1997 08:4424
    Hi Shaheed,
    
    rgd exception, C++ and threads. There had been a cleanup between
    V3.2 and V4.0 in that the thread package uses the libexc.so now
    for threads exception, so this works fine. unfortunatly the C++
    exception package shouldn't be mixed with the thread exception package,
    (reason's are named in the c_plus_plus conference) under V4.0. This
    cleanup is planned for the next major release. 
    
    regarding the stackdump, I'll sent you a mail later on. I've just asked 
    somebody to mail me the module which contains some functionality you've 
    requested. essentially, we're using the sigwaiter thread. If we send 
    the signal from outside, it takes our control structures sets a
    variable, walks about all threads and sent a pthread_kill(SIGBUS)
    to those threads. in case of the variable being set, we then dump
    out the stacktrace (using virtual_unwind and PC adjustment) and unset
    the variable and return.
    It works in general. We've discovered two reasons until now where it
    fails (one I have to report) the other also fails with othre OS's
    (ex HP's stackdump). It also fails if you're using assembler routines
    which aren't conformant to the calling standard, but this is a nice
    sideeffect, as you'll see those and can clean em up.
    
    Pit 
9250.2SMURF::DENHAMDigital UNIX KernelMon Mar 24 1997 09:034
    Not sure how applicable this is, but there's code going into
    PTMIN (the V4.0D release) that provides stack trace routines.
    Not sure of the details. I can get you a development contact
    if you're interested...