comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Extra information in the message string of exceptions.
Date: Mon, 6 Jun 2022 21:33:44 -0500	[thread overview]
Message-ID: <t7mde9$th0$1@dont-email.me> (raw)
In-Reply-To: 1353f387-bb5a-4dc5-853f-a74d40f9237dn@googlegroups.com

"Gautier write-only address" <gautier_niouzes@hotmail.com> wrote in message 
news:1353f387-bb5a-4dc5-853f-a74d40f9237dn@googlegroups.com...
>> Any thoughts on pro's/con's of having the Ada standard packages
>> runtime provide extra information in the message string of exceptions ?
>
> It depends on the compiler. And of course it is advantage to provide more 
> details.
> For instance HAC issues for...
>
> procedure CE_2 is
>  i : Positive;
>  j : Integer := 1;
> begin
>  i := -j;
> end CE_2;
>
> the message:
> hac ce_2.adb
> HAC VM: raised Constraint_Error
> Out of range: pos, -1, is below (sub)type's lower bound, 1
> Trace-back: approximate location
> ce_2.adb: CE_2 at line 5

Janus/Ada has *always* done this (going all the way back to the original 
Z-80 CP/M compiler). This particular case is not very expensive, since one 
can use the fact that the out-of-range value is certainly in a register to 
be tested in order to construct the message. And no real program cares about 
the performance of raising Constraint_Error -- the main issue is one of 
space (making the program larger).

For example, from a recent bug report:

** Unhandled CONSTRAINT_ERROR
   Index or Subtype out of bounds - Pos of Error Value =  197807
On Line Number 37 In XCB_MAIN.DETERMINE_FILE_SIZE
Called from line number 40 In XCB_MAIN

It's possible to turn this off, but there hasn't been much need to do so 
this century.

                               Randy.

P.S. I'd quibble with the OP, in that the vast majority of Constraint_Errors 
have nothing to do with the standard library; their checks are compiled 
directly into the code of your application; the only use of a library is to 
raise an exception. We use special library calls for specific checks (like 
the discrete range error discussed here); no strings are created in the user 
code. An implementation would certainly have to do that as the alternative 
would be to duplicate lots of complex code for each failed check -- but in 
the absence of such information, the implementation probably uses the same 
library call to raise all exceptions. Ergo, such a change probably isn't 
easy for any implementation that doesn't do something like it already.


  reply	other threads:[~2022-06-07  2:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 12:59 Extra information in the message string of exceptions Rod Kay
2022-06-06 13:40 ` Fabien Chouteau
2022-06-06 18:40   ` G.B.
2022-06-06 19:24     ` Dmitry A. Kazakov
2022-06-07 11:26   ` Rod Kay
2022-06-07 15:55   ` Fabien Chouteau
2022-06-07 16:41     ` Anh Vo
2022-06-08  7:31     ` Jerry
2022-06-08  8:04       ` Dmitry A. Kazakov
2022-06-09  2:39         ` Jerry
2022-06-08  9:08       ` Dmitry A. Kazakov
2022-10-27 11:56         ` Rod Kay
2022-10-29  0:35           ` Jerry
2022-10-29  3:10             ` Rod Kay
2022-10-29  6:30               ` Gautier write-only address
2022-10-29  8:59               ` G.B.
2022-11-01  0:05             ` Jerry
2022-06-06 14:31 ` Gautier write-only address
2022-06-07  2:33   ` Randy Brukardt [this message]
2022-06-07 11:47     ` Rod Kay
2022-06-07 11:29   ` Rod Kay
2022-06-06 20:14 ` Luke A. Guest
2022-06-07 11:51   ` Rod Kay
2022-06-07 21:06     ` Luke A. Guest
2022-06-06 20:49 ` DrPi
2022-06-06 23:17   ` Jerry
2022-06-07  1:53     ` Gautier write-only address
2022-06-07  2:35       ` Randy Brukardt
2022-06-07  8:07       ` Simon Wright
2022-06-08  7:14       ` Jerry
2022-06-09  8:21 ` Robin Vowels
replies disabled

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