comp.lang.ada
 help / color / mirror / Atom feed
* Exception handler question
@ 1993-03-11 20:17 Timothy J. Barton
  1993-03-12 20:01 ` Brian Hanafee
  0 siblings, 1 reply; 2+ messages in thread
From: Timothy J. Barton @ 1993-03-11 20:17 UTC (permalink / raw)


Please help me in my ignorance of Ada exception handlers.  I am using Sun
Ada and am trying to trap the usage of an out of range value being passed
to another program unit.  I have an exception handler with
"when CONSTRAINT_ERROR" and "when others", but the exception handler is not
getting called.  When I run the program in the Sun Ada debugger, I get the
message:

  "Illegal instruction" [4] Software trap: range check

Program execution is halted, I can't single step any further.  In other
cases where I trap an exception, a single step would take me to the
exception hanlder source lines.  If I run the program outside the debugger,
very bad things happen (and happen so fast I can't read the message which
flashes by) and then my program and xterm go away.

Program looks like the following:
---------------------------------

  subtype COLUMN is INTEGER range 0..100;

  procedure example is
  begin
    OtherFunction(  COLUMN(101) );   -- CONSTRAINT error here!
  exception
    when CONSTRAINT_ERROR => do something
    when others           => do something
  end example;

---------------------------------
What am I doing wrong?  Why doesn't my exception handler get called?  Any
help would be greatly appreciated.

----------------------------------------------------------------------------
Timothy J. Barton                         tim@trident.datasys.swri.edu
Senior Research Analyst                   (210) 522-3540
Southwest Research Institute (SwRI)       (210) 522-5499  (Fax)   
San Antonio, Texas  78228-0510



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

* Re: Exception handler question
  1993-03-11 20:17 Exception handler question Timothy J. Barton
@ 1993-03-12 20:01 ` Brian Hanafee
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Hanafee @ 1993-03-12 20:01 UTC (permalink / raw)



In article <318@trident.datasys.swri.edu> tim@trident.datasys.swri.edu (Timothy J. Barton) writes:
>Please help me in my ignorance of Ada exception handlers.
That's not (quite) where the problem lies.

>  I am using Sun
>Ada and am trying to trap the usage of an out of range value being passed
>to another program unit.  I have an exception handler with
>"when CONSTRAINT_ERROR" and "when others", but the exception handler is not
>getting called.  When I run the program in the Sun Ada debugger, I get the
>message:
>
>  "Illegal instruction" [4] Software trap: range check
>
>Program execution is halted, I can't single step any further.  In other
>cases where I trap an exception, a single step would take me to the
>exception hanlder source lines.

This is the result of an incompatibility between the SunAda compiler
and its debugger.  The generated code is set up to send signal 4 when
the exception is raised, and that is supposed to take you to the
exception handler.  The problem is that the debugger intercepts all of
the signals.  The workaround is relatively simple, though.  When you
get the prompt, type "set signal 4 gx".  This tells the debugger to
pass signal 4 on to your program and continue execution.

--
Brian Hanafee                         Advanced Decision Systems
bhanafee@ads.com                      1500 Plymouth Street
(415) 960-7300                        Mountain View, CA 94043-1230



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

end of thread, other threads:[~1993-03-12 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-03-11 20:17 Exception handler question Timothy J. Barton
1993-03-12 20:01 ` Brian Hanafee

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