For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
Any thoughts on pro's/con's of having the Ada standard packages
runtime provide extra information in the message string of exceptions ?
On Monday, June 6, 2022 at 3:02:25 PM UTC+2, roda...@gmail.com wrote:
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
That's a really good idea I would say. Extremely useful during development where I often start the debugger just to know what value triggered a Constraint_Error.
I guess the drawback is performance as formatting string with extra information will have a cost.
But this feature could be activated with a switch only when needed.
On 06.06.22 15:40, Fabien Chouteau wrote:
On Monday, June 6, 2022 at 3:02:25 PM UTC+2, roda...@gmail.com wrote:
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
That's a really good idea I would say. Extremely useful during
development where I often start the debugger just to know what value
triggered a Constraint_Error.
I guess the drawback is performance as formatting string with extra
information will have a cost.
But this feature could be activated with a switch only when needed.
Will it help to have a standard object taking just the data?
Hi all,
Any thoughts on pro's/con's of having the Ada standard packages
runtime provide extra information in the message string of exceptions ?
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
Hi all,
Any thoughts on pro's/con's of having the Ada standard packages
runtime provide extra information in the message string of exceptions ?
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
Regards.
Le 06/06/2022 à 14:59, Rod Kay a écrit :
Hi all,
Any thoughts on pro's/con's of having the Ada standard packages
runtime provide extra information in the message string of exceptions ?
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused the exception.
+1
Regards.
GNAT provides an integrated symbolic trace-back through the -Es switch. Doesn't it work on your Mac setup?
Anyway, it's much trouble for a feature which should be activated by default...
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
GNAT provides an integrated symbolic trace-back through the -Es
switch. Doesn't it work on your Mac setup?
That's a really good idea I would say. Extremely useful during development where I often start the debugger just to know what value triggered a Constraint_Error.
I guess the drawback is performance as formatting string with extra information will have a cost.
But this feature could be activated with a switch only when needed.
Janus/Ada has *always* done this (going all the way back to the original
Z-80 CP/M compiler).
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
space (making the program larger).
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.
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
Of for...
hac ce_3.adb
HAC VM: raised Constraint_Error
Out of range: index (pos: 7) is above upper bound (pos: 5)
Trace-back: approximate location
ce_3.adb: CE_3 at line 4
This is something which could be added to either the language or the compiler.
GNAT does have a dump backtrace call you could use.
But this feature could be activated with a switch only when needed.
On Monday, June 6, 2022 at 3:40:38 PM UTC+2, Fabien Chouteau wrote:Very nice. I love some thing like this.
But this feature could be activated with a switch only when needed.Well, it turns our this is already implemented in GNAT ^^
Example here: https://godbolt.org/z/fcTEaq3xP
On 7/6/22 06:14, Luke A. Guest wrote:
This is something which could be added to either the language or the
compiler.
I'd prefer to see it in the standard (for the usual reasons).
GNAT does have a dump backtrace call you could use.
Ah, does it show more info than just the call stack ?
GNAT provides an integrated symbolic trace-back through the -Es switch. Doesn't it work on your Mac setup?It does not work. My compiler reports "unrecognized command line option '-Es'". Maybe it's a new feature. My GNAT is a few years old.
Anyway, it's much trouble for a feature which should be activated by default...
On Monday, June 6, 2022 at 3:40:38 PM UTC+2, Fabien Chouteau wrote:Indeed. The switch is -GNATeE. It provides additional information for the program at that page,
But this feature could be activated with a switch only when needed.Well, it turns our this is already implemented in GNAT ^^
Example here: https://godbolt.org/z/fcTEaq3xP
On Tuesday, June 7, 2022 at 8:56:00 AM UTC-7, Fabien Chouteau wrote:
On Monday, June 6, 2022 at 3:40:38 PM UTC+2, Fabien Chouteau wrote:Indeed. The switch is -GNATeE. It provides additional information for the program at that page,
But this feature could be activated with a switch only when needed.Well, it turns our this is already implemented in GNAT ^^
Example here: https://godbolt.org/z/fcTEaq3xP
procedure Main is
procedure Test (A : Integer) is
type T is range 0 .. 42;
begin
Ada.Text_IO.Put_Line (T (A)'Img);
end;
begin
Test (-1);
end Main;
But has no effect on this program;
procedure CE_2 is
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
But has no effect on this program;
procedure CE_2 is
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
On 2022-06-08 09:31, Jerry wrote:Hmm.... I get the same "Message" i.e. no extra information and only hex traceback info. Docs say -E is the same as -Ea meaning hex traceback, plus my set-up rejects -Ea (and -Es) as illegal switches. (Not sure at this point if we're chasing symbolic
On Tuesday, June 7, 2022 at 8:56:00 AM UTC-7, Fabien Chouteau wrote:
On Monday, June 6, 2022 at 3:40:38 PM UTC+2, Fabien Chouteau wrote:Indeed. The switch is -GNATeE. It provides additional information for the program at that page,
But this feature could be activated with a switch only when needed.Well, it turns our this is already implemented in GNAT ^^
Example here: https://godbolt.org/z/fcTEaq3xP
procedure Main is
procedure Test (A : Integer) is
type T is range 0 .. 42;
begin
Ada.Text_IO.Put_Line (T (A)'Img);
end;
begin
Test (-1);
end Main;
But has no effect on this program;
procedure CE_2 isThe switches are -E for binder and -g for everything else. Try this:
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
--- test_ce.gpr ----------------------------------------
project Test_CE is
for Source_Files use ("test_ce.adb");
for Main use ("test_ce.adb");
package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;
package Builder is
for Default_Switches ("ada") use ("-g");
end Builder;
package Compiler is
for Default_Switches ("ada") use ("-g");
end Compiler;
package Linker is
for Default_Switches ("ada") use ("-g");
end Linker;
end Test_CE;
--- test_ce.adb ----------------------------------------
with System.Exception_Traces; use System.Exception_Traces;
with System.Traceback.Symbolic;
procedure Test_CE is
i : Positive;
j : Integer := 1;
begin
Trace_On (System.Exception_Traces.Unhandled_Raise);
Set_Trace_Decorator
( System.Traceback.Symbolic.Symbolic_Traceback'Access
);
i := -j;
end Test_CE;
Notes:
1. You can just use Symbolic_Traceback whenever you want. E.g. you can
set an exception handler and dump traceback at the raising point. It is
slow as hell, of course.
2. There are problems getting symbolic traceback working on ARM.
3. This becomes pretty much useless with relocated libraries. I do not
know how to make it work with them.
4. Under Windows you will not get traceback from non-GCC compiled stuff because it does not understand *.pdb files.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Hi all,.
Any thoughts on pro's/con's of having the Ada standard packages
runtime provide extra information in the message string of exceptions ?
For instance, a Constraint_Error message might provide details on
the variable name, the legal range and the erroneous value which caused
the exception.
On 2022-06-08 09:31, Jerry wrote:
But has no effect on this program;
procedure CE_2 is
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
I noticed that it requires a user-defined [sub]type AND nested subprogram:
procedure Test (A : Integer) is
subtype T is Integer range 0 .. 42;
i : T;
begin
i := A; -- This will work
end;
begin
Test (-1);
On 8/6/22 19:08, Dmitry A. Kazakov wrote:
On 2022-06-08 09:31, Jerry wrote:
But has no effect on this program;
procedure CE_2 is
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
I noticed that it requires a user-defined [sub]type AND nested subprogram:
procedure Test (A : Integer) is
subtype T is Integer range 0 .. 42;
i : T;
begin
i := A; -- This will work
end;
begin
Test (-1);
Are you sure about this ?
I tried ...
procedure Example
is
X : Positive := 5;
begin
loop
X := X - 1;
end loop;
end Example;
... with the -gnateE and saw this result ...
[rod@orth example]$ ./example
raised CONSTRAINT_ERROR : example.adb:6:14 range check failed
value 0 not in 1..2147483647
[./example]
0x55916975377f Example at example.adb:6
0x559169753b74 Main at b__example.adb:193
[/usr/lib/libc.so.6]
0x7f9230be728e
0x7f9230be7348
[./example]
0x559169753623 _start at start.S:115
0xfffffffffffffffe
On Thursday, October 27, 2022 at 4:57:08 AM UTC-7, roda...@gmail.comwrote:
subprogram:On 8/6/22 19:08, Dmitry A. Kazakov wrote:
I noticed that it requires a user-defined [sub]type AND nested
Are you sure about this ?
procedure Test (A : Integer) is
subtype T is Integer range 0 .. 42;
i : T;
begin
i := A; -- This will work
end;
begin
Test (-1);
I tried ...
procedure Example
is
X : Positive := 5;
begin
loop
X := X - 1;
end loop;
end Example;
... with the -gnateE and saw this result ...
[rod@orth example]$ ./example
raised CONSTRAINT_ERROR : example.adb:6:14 range check failed
value 0 not in 1..2147483647
[./example]
0x55916975377f Example at example.adb:6
0x559169753b74 Main at b__example.adb:193
[/usr/lib/libc.so.6]
0x7f9230be728e
0x7f9230be7348
[./example]
0x559169753623 _start at start.S:115
0xfffffffffffffffe
So -gnateE works part of the time?
Jerry
One exception is the following ...
procedure Example
is
X : Positive := 0 with Unreferenced;
begin
null;
end Example;
... which shows a compile time warning ...
[...]
I'm a little surprised that the compiler shows a warning rather than
an error but I suppose there must be some reason for that.
I'm a little surprised that the compiler shows a warning rather than an error but I suppose there must be some reason for that.
On Thursday, October 27, 2022 at 4:57:08 AM UTC-7, roda...@gmail.com wrote:
On 8/6/22 19:08, Dmitry A. Kazakov wrote:
On 2022-06-08 09:31, Jerry wrote:
But has no effect on this program;
procedure CE_2 is
i : Positive;
j : Integer := 1;
begin
i := -j;
end CE_2;
I noticed that it requires a user-defined [sub]type AND nested subprogram:
procedure Test (A : Integer) is
subtype T is Integer range 0 .. 42;
i : T;
begin
i := A; -- This will work
end;
begin
Test (-1);
Are you sure about this ?
I tried ...
procedure Example
is
X : Positive := 5;
begin
loop
X := X - 1;
end loop;
end Example;
... with the -gnateE and saw this result ...
I simply do not get the robust results others are reporting, and as I noted earlier in this thread, some of the suggested switches are flagged as illegal on macOS[rod@orth example]$ ./example
raised CONSTRAINT_ERROR : example.adb:6:14 range check failedSo -gnateE works part of the time?
value 0 not in 1..2147483647
[./example]
0x55916975377f Example at example.adb:6
0x559169753b74 Main at b__example.adb:193
[/usr/lib/libc.so.6]
0x7f9230be728e
0x7f9230be7348
[./example]
0x559169753623 _start at start.S:115
0xfffffffffffffffe
Jerry
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 355 |
Nodes: | 16 (2 / 14) |
Uptime: | 05:34:43 |
Calls: | 7,656 |
Files: | 12,812 |
Messages: | 5,700,890 |