comp.lang.ada
 help / color / mirror / Atom feed
* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
       [not found] <7091f995-dd7e-4442-8ca5-158b83e50bec@x5g2000prf.googlegroups.com>
@ 2009-10-20 18:23 ` Pascal Obry
  2009-10-20 18:37   ` Dmitry A. Kazakov
  2009-10-20 20:50   ` sjw
  0 siblings, 2 replies; 7+ messages in thread
From: Pascal Obry @ 2009-10-20 18:23 UTC (permalink / raw)


Le 20/10/2009 20:01, ChristopherL a �crit :
> 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:

    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:

    $ gnatmake prog -cargs -gnato -bargs -E

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
  2009-10-20 18:23 ` With Exceptions Disabled On Windows, How Can I Determine Where A Software Interrupt Occurs Pascal Obry
@ 2009-10-20 18:37   ` Dmitry A. Kazakov
  2009-10-20 18:43     ` Pascal Obry
  2009-10-21 10:53     ` Georg Bauhaus
  2009-10-20 20:50   ` sjw
  1 sibling, 2 replies; 7+ messages in thread
From: Dmitry A. Kazakov @ 2009-10-20 18:37 UTC (permalink / raw)


On Tue, 20 Oct 2009 20:23:15 +0200, Pascal Obry wrote:

> Le 20/10/2009 20:01, ChristopherL a �crit :
>> 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:
> 
>     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:
> 
>     $ gnatmake prog -cargs -gnato -bargs -E

Though the subject's text could be read as if the OP meant the case when
the corresponding check were suppressed. I.e.,.how do we detect something
that does not occur... (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
  2009-10-20 18:37   ` Dmitry A. Kazakov
@ 2009-10-20 18:43     ` Pascal Obry
  2009-10-20 19:04       ` Dmitry A. Kazakov
  2009-10-21 10:53     ` Georg Bauhaus
  1 sibling, 1 reply; 7+ messages in thread
From: Pascal Obry @ 2009-10-20 18:43 UTC (permalink / raw)


Le 20/10/2009 20:37, Dmitry A. Kazakov a �crit :
> Though the subject's text could be read as if the OP meant the case when
> the corresponding check were suppressed. I.e.,.how do we detect something
> that does not occur... (:-))

I hadn't read that this way. But if the checks are suppressed then we 
will get a signal for divide by 0 and we should get a proper backtrace 
in this case with GNAT.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
  2009-10-20 18:43     ` Pascal Obry
@ 2009-10-20 19:04       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry A. Kazakov @ 2009-10-20 19:04 UTC (permalink / raw)


On Tue, 20 Oct 2009 20:43:56 +0200, Pascal Obry wrote:

> Le 20/10/2009 20:37, Dmitry A. Kazakov a �crit :
>> Though the subject's text could be read as if the OP meant the case when
>> the corresponding check were suppressed. I.e.,.how do we detect something
>> that does not occur... (:-))
> 
> I hadn't read that this way. But if the checks are suppressed then we 
> will get a signal for divide by 0 and we should get a proper backtrace 
> in this case with GNAT.

That depends on the hardware. But if zero divide indeed generates a
hardware interrupt, then, it is reasonable to suggest that the pragma
Suppress will have no effect on Constraint_Error propagation.

In which sense, the *software* (so the OP writes) exceptions were
"disabled"? Did he mean so-called Windows "Structured Exceptions"?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
       [not found] <b0d7911b-cb10-4fb2-a977-da865b8b2001@u16g2000pru.googlegroups.com>
@ 2009-10-20 19:31 ` Keith Thompson
  0 siblings, 0 replies; 7+ messages in thread
From: Keith Thompson @ 2009-10-20 19:31 UTC (permalink / raw)


ChristopherL <clusardi2k@aol.com> writes:
> 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.

Two suggestions:

1. Put the question in the body of your message, not just in the
subject header.

2. Explain exactly what you mean by "with exceptions disabled".  Do
you mean "with checks suppressed"?  (If so, the answer may be simply
"Don't do that"; if you want to know where a software interrupt
occurs, why did you suppress checks?)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A Software Interrupt Occurs
  2009-10-20 18:23 ` With Exceptions Disabled On Windows, How Can I Determine Where A Software Interrupt Occurs Pascal Obry
  2009-10-20 18:37   ` Dmitry A. Kazakov
@ 2009-10-20 20:50   ` sjw
  1 sibling, 0 replies; 7+ messages in thread
From: sjw @ 2009-10-20 20:50 UTC (permalink / raw)


On Oct 20, 7:23 pm, Pascal Obry <pas...@obry.net> wrote:
> Le 20/10/2009 20:01, ChristopherL a écrit :
>
> > 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:
>
>     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:
>
>     $ 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



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

* Re: With Exceptions Disabled On Windows, How Can I Determine Where A  Software Interrupt Occurs
  2009-10-20 18:37   ` Dmitry A. Kazakov
  2009-10-20 18:43     ` Pascal Obry
@ 2009-10-21 10:53     ` Georg Bauhaus
  1 sibling, 0 replies; 7+ messages in thread
From: Georg Bauhaus @ 2009-10-21 10:53 UTC (permalink / raw)


Dmitry A. Kazakov schrieb:

> Though the subject's text could be read as if the OP meant the case when
> the corresponding check were suppressed. I.e.,.how do we detect something
> that does not occur... (:-))

In this case the program is political.
Being political, the program can be rewritten as needed.
The new program manages to not detect anything that has occured.



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

end of thread, other threads:[~2009-10-21 10:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7091f995-dd7e-4442-8ca5-158b83e50bec@x5g2000prf.googlegroups.com>
2009-10-20 18:23 ` With Exceptions Disabled On Windows, How Can I Determine Where A Software Interrupt Occurs Pascal Obry
2009-10-20 18:37   ` Dmitry A. Kazakov
2009-10-20 18:43     ` Pascal Obry
2009-10-20 19:04       ` Dmitry A. Kazakov
2009-10-21 10:53     ` Georg Bauhaus
2009-10-20 20:50   ` sjw
     [not found] <b0d7911b-cb10-4fb2-a977-da865b8b2001@u16g2000pru.googlegroups.com>
2009-10-20 19:31 ` Keith Thompson

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