comp.lang.ada
 help / color / mirror / Atom feed
* Determining exception name in DEC Ada
@ 1995-04-06  0:00 RWTMS1::SSEVAX::GRAZIANIA
  1995-04-07  0:00 ` DavPatrick
  0 siblings, 1 reply; 4+ messages in thread
From: RWTMS1::SSEVAX::GRAZIANIA @ 1995-04-06  0:00 UTC (permalink / raw)


        Using DEC Ada on VAX/VMS systems, is there a way to determine which
exception has occurred without having to specifically trap it within the
exception handler.
        For example, I'd like to be able to do something like:
begin
    [blah]
    [blah]
    [blah]
exception
    when others =>
        text_io.put_line ("A " & exception_name & " has occurred.");
end;



        I don't want to have to do something like:
begin
    [blah]
    [blah]
    [blah]
exception
    when constraint_error =>
        text_io.put_line ("A constraint_error has occurred.");
    when numeric_error =>
        text_io.put_line ("A numeric_error has occurred.");
    when program_error =>
        text_io.put_line ("A program_error has occurred.");
    when others =>
        text_io.put_line ("A exception occurred and I have no idea which one.");
end;



Thanks in advance.
Alain Graziani
graziani%rwtms1.ssevax.decnet@consrt.rockwell.com
"I feel the need for speed."

International Space Station Alpha
Rocketdyne Division
Rockwell International




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Determining exception name in DEC Ada
@ 1995-04-07  0:00 Ken Balmy
  0 siblings, 0 replies; 4+ messages in thread
From: Ken Balmy @ 1995-04-07  0:00 UTC (permalink / raw)


>
>       Using DEC Ada on VAX/VMS systems, is there a way to determine which
> exception has occurred without having to specifically trap it within the
> exception handler.

ditto for VADSworks (or any/all other Ada compilers for that matter)




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Determining exception name in DEC Ada
  1995-04-06  0:00 RWTMS1::SSEVAX::GRAZIANIA
@ 1995-04-07  0:00 ` DavPatrick
  1995-04-07  0:00   ` DavPatrick
  0 siblings, 1 reply; 4+ messages in thread
From: DavPatrick @ 1995-04-07  0:00 UTC (permalink / raw)


Yes .. sort of. I just did this for my current project. 

First it should be noted that in DEC Ada, exceptions are implemented using
the exception mechanism built into VMS. What I did was first write a
routine ( actually modify a routine written by somebody else ) that was,
using VMS system services, added to the chain of procedures that are
called in response to an exception ( I'll get into this in detail in a
second ). When this procedure is called ( in response to an exception (
ada, VMS or other ) ) it saves off two parameters from the call stack. One
of these parameters is the PC of instruction that caused the exception and
the second one is a 32 bit value indicating the exception. If its a VMS
predefined exception then you can use one of the system servies to convert
the number to a string identifying the exception, if its a user-defined
exception ( ie an exception defined in the ada code ) then the number is a
pointer to a string that contains the name of the package. Anyhow, this
first routine stores these values off in a package-body level variable and
then I have two other procedures that I can call from with-in the "when
others =>" exception handler branch that references these global variables
and return strings indicating the exception name and PC. 

 I recommend looking at the VMS documation for how the condition handling
& chaining works. I could provide you with detail and source code ( I'd
have to do some work on my own time to strip any references to my project
).

The real question is .. does anybody know how to convert the PC to a
source module & line # the way the debugger does ?

e-mail me at DavPatrick@aol.com and we can continue this further, in
greater detail when I have my resources in front of me.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Determining exception name in DEC Ada
  1995-04-07  0:00 ` DavPatrick
@ 1995-04-07  0:00   ` DavPatrick
  0 siblings, 0 replies; 4+ messages in thread
From: DavPatrick @ 1995-04-07  0:00 UTC (permalink / raw)


I have been unable to e-mail you .. please e-mail me at
DavPatrick@aol.com, provide a name and fax number and I will fax you the
source code.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1995-04-07  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-04-07  0:00 Determining exception name in DEC Ada Ken Balmy
  -- strict thread matches above, loose matches on Subject: below --
1995-04-06  0:00 RWTMS1::SSEVAX::GRAZIANIA
1995-04-07  0:00 ` DavPatrick
1995-04-07  0:00   ` DavPatrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox