From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l34g2000vba.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: With Exceptions Disabled On Windows, How Can I Determine Where A Software Interrupt Occurs Date: Tue, 20 Oct 2009 13:50:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <48671690-8bdc-462c-9ccc-103a7a810476@l34g2000vba.googlegroups.com> References: <7091f995-dd7e-4442-8ca5-158b83e50bec@x5g2000prf.googlegroups.com> <4ade0003$0$966$ba4acef3@news.orange.fr> NNTP-Posting-Host: 82.30.110.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1256071825 22334 127.0.0.1 (20 Oct 2009 20:50:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Oct 2009 20:50:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l34g2000vba.googlegroups.com; posting-host=82.30.110.254; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8761 Date: 2009-10-20T13:50:25-07:00 List-Id: On Oct 20, 7:23=A0pm, Pascal Obry wrote: > Le 20/10/2009 20:01, ChristopherL a =E9crit : > > > I'm looking for a compilable/working example on how to do this. For > > example code to determine where a divide by zero occurs etc. > > With GNAT? > > Nothing, you should get something like this when running your application= : > > =A0 =A0 raised CONSTRAINT_ERROR : buf.adb:12 divide by zero > > > If I can't get the code what can you tell me? > > To have full backtrace and also check for overflow you should compile > your application with -gnato and pass -E on the binder: > > =A0 =A0 $ gnatmake prog -cargs -gnato -bargs -E GNAT doesn't raise numeric overflow exceptions for plain floats, though it will raise CE if you declare the right subtypes: this with Ada.Text_IO; use Ada.Text_IO; procedure Divide_By_Zero is subtype Flt is Float; function Div (Denominator, Numerator : Flt) return Flt is begin return Denominator / Numerator; end Div; begin Put_Line (Float'Image (Div (1.0, 0.0))); Put_Line (Float'Image (Div (-1.0, 0.0))); Put_Line (Float'Image (Div (0.0, 0.0))); end Divide_By_Zero; outputs $ ./divide_by_zero +Inf******* -Inf******* NaN******** but if you replace the declaration of Flt by subtype Flt is Float range Float'Range; you get raised CONSTRAINT_ERROR : divide_by_zero.adb:6 range check failed