All pastes #2130803 Raw Edit

Unnamed

public text v1 · immutable
#2130803 ·published 2012-03-20 18:38 UTC
rendered paste body
Subject:Re: Exceptions Propagated from Attribute Functions
From:
Robert Dewar <dewar@adacore.com>
Date:
10/20/2011 12:56 PM

>
> When an exception is propagated from an attribute function,
> such as Integer'Value, the exception message ("s-valint.adb:61
> explicit raise") references the place in the run-time code
> where the exception is raised. We would find it helpful if the
> exception message could refer to the place in our code where
> the attribute function is called.

There is no way to do this in the simple message generated by
the compiler, you have to use the traceback for this purpose.
The exception machinery at that level has no way of unwinding
the stack. Stack unwinding requires heavy machinery, which is
available in the stack traceback routines, but not otherwise.
>
> As a comparison, consider the case when an array is indexed
> with an out-of-bound value. This is probably implemented with
> a call to a run-time subprogram to check the index, but the
> exception message references the place where the array was
> indexed, not the checking subprogram.

Wrong assumption, as you can see from the -gnatG output, these
checks are generated inline with the right information right
there in the generated code.

> Attribute functions are
> also "compiler magic" and their exception messages should be
> similar, if possible.

The only way to do that would be to actually pass the source
location to the run-time routine, but that would greatly increase
the overhead for no functional purpose, so is not reasonable.

To get exception propagation information, either run under GDB
(note you can do that routinely since GDB is non-intrusive), or
incorporate the traceback units from the GNAT library.