comp.lang.ada
 help / color / mirror / Atom feed
* writing on terminal before an exception
@ 2009-08-02 17:47 Mark Fabbri
  2009-08-03  1:13 ` Yannick Duchêne Hibou57
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Mark Fabbri @ 2009-08-02 17:47 UTC (permalink / raw)


i have a problem with text_io and exception:

Text_IO.Put ("No SH3 data."); 
Text_IO.New_Line;
raise Sh3_NoData;

if it raise an exception, the string "NO SH3 data" is not displayed. it
seems that the text_io don't actually print on screen. i also tryed with
text_io.flush after the New_Line, but nothing happens. 
			

-- 

questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it





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

* Re: writing on terminal before an exception
  2009-08-02 17:47 writing on terminal before an exception Mark Fabbri
@ 2009-08-03  1:13 ` Yannick Duchêne Hibou57
  2009-08-03  6:39 ` Stephen Leake
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Yannick Duchêne Hibou57 @ 2009-08-03  1:13 UTC (permalink / raw)


Hello Mark,

On 2 août, 19:47, mf...@yahoo.com (Mark Fabbri) wrote:
> i have a problem with text_io and exception:
>
> Text_IO.Put ("No SH3 data.");
> Text_IO.New_Line;
> raise Sh3_NoData;
>
> if it raise an exception, the string "NO SH3 data" is not displayed. it
> seems that the text_io don't actually print on screen. i also tryed with
> text_io.flush after the New_Line, but nothing happens.
Its quite common to me to display some informations on the console or
via a message box before a statement which raise en exception, while
debuging.

Perhaps a too much agressive optimizer ?

Or else, any redirection anywhere ?

I would suggest first to try to remove the raise statement, to see if
the string is displayed or not (just to be sure this is really due to
the raise statement).

If it happens to be confirmed, then insert some other statements
between the text I/O operations (some extra statements which would not
be Text_IO operations) and the raise statement, to see if it change
something.

Beside of the latter, another test I would be tempted to do, would be
to try to put the text I/O operations and the raise statement, each on
a dedicated scope. I mean, ... if the exception is raised after a
conditional test like

if Condition then
   Text_IO. ....
   raise ....
end if;

then to try

if Condition then
   Text_IO. ....
end if;

if Condition then
   raise ....
end if;

to see if it changes anything

Standard questions : what's your OS ? Your compiler ?

Always difficult to figure what the trouble is in such strange cases,
so I'm sorry if it does not help you as much as would expect, and I
just try to imagine some ways to guess where this behaviour comes
from.

Have a nice time

Y.



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

* Re: writing on terminal before an exception
  2009-08-02 17:47 writing on terminal before an exception Mark Fabbri
  2009-08-03  1:13 ` Yannick Duchêne Hibou57
@ 2009-08-03  6:39 ` Stephen Leake
  2009-08-03 20:40 ` vlc
  2009-08-04 20:18 ` Mark Fabbri
  3 siblings, 0 replies; 8+ messages in thread
From: Stephen Leake @ 2009-08-03  6:39 UTC (permalink / raw)


mfads@yahoo.com (Mark Fabbri) writes:

> i have a problem with text_io and exception:
>
> Text_IO.Put ("No SH3 data."); 
> Text_IO.New_Line;
> raise Sh3_NoData;
>
> if it raise an exception, the string "NO SH3 data" is not displayed. it
> seems that the text_io don't actually print on screen. i also tryed with
> text_io.flush after the New_Line, but nothing happens. 

What compiler and operating system? It works for me with GNAT on
Windows:

with Ada.Text_IO; use Ada.Text_IO;
procedure Hello
is
   Sh3_NoData : exception;
begin
   Put ("No SH3 data.");
   New_Line;
   Flush;
   raise Sh3_NoData;

end Hello;

gnatmake -p -k -C -Pgnat.gpr  hello 
gnatbind -E -I- -x C:\Stephe\Ada_Work\Gnat\objects\hello.ali
gnatlink C:\Stephe\Ada_Work\Gnat\objects\hello.ali -LC:\Apps\GNAT-6.2.1\lib\asis -lasis -o C:\Stephe\Ada_Work\Gnat\hello.exe
./hello.exe 
No SH3 data.

Execution terminated by unhandled exception
Exception name: HELLO.SH3_NODATA
Message: hello.adb:9
Call stack traceback locations:
0x401776 0x4016c8 0x401235 0x401286 0x7c817075

Perhaps you have Text_IO.Standard_Output redirected somewhere?

-- 
-- Stephe



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

* Re: writing on terminal before an exception
  2009-08-02 17:47 writing on terminal before an exception Mark Fabbri
  2009-08-03  1:13 ` Yannick Duchêne Hibou57
  2009-08-03  6:39 ` Stephen Leake
@ 2009-08-03 20:40 ` vlc
  2009-08-03 22:29   ` Yannick Duchêne Hibou57
  2009-08-04 20:18 ` Mark Fabbri
  3 siblings, 1 reply; 8+ messages in thread
From: vlc @ 2009-08-03 20:40 UTC (permalink / raw)


On Aug 2, 7:47 pm, mf...@yahoo.com (Mark Fabbri) wrote:
> i have a problem with text_io and exception:
>
> Text_IO.Put ("No SH3 data.");
> Text_IO.New_Line;
> raise Sh3_NoData;
>
> if it raise an exception, the string "NO SH3 data" is not displayed. it
> seems that the text_io don't actually print on screen. i also tryed with
> text_io.flush after the New_Line, but nothing happens.
>
Have you already considered something like

raise Sh3_NoData with "No SH3 data.";

I'm not absolutely sure, but I think this will only compile in Ada
2005.

Cheers!



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

* Re: writing on terminal before an exception
  2009-08-03 20:40 ` vlc
@ 2009-08-03 22:29   ` Yannick Duchêne Hibou57
  2009-08-04  0:14     ` Adam Beneschan
  0 siblings, 1 reply; 8+ messages in thread
From: Yannick Duchêne Hibou57 @ 2009-08-03 22:29 UTC (permalink / raw)


On 3 août, 22:40, vlc <just.another.spam.acco...@googlemail.com>
wrote:
> Have you already considered something like
>
> raise Sh3_NoData with "No SH3 data.";
>
> I'm not absolutely sure, but I think this will only compile in Ada
> 2005.

It will, surely, as said the ARM 2005 :

ARM 11.3 (2/2) says

> raise_statement ::= raise;
>       | raise exception_name [with string_expression]; raise [exception_name];

But he will loose the default exception informations which are useful
too (the string provided will replace the exception message which is
defaulted to some exception informations).

And any way, the behaviour he has meet is not a normal behaviour, so
it would be nice to solve it.



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

* Re: writing on terminal before an exception
  2009-08-03 22:29   ` Yannick Duchêne Hibou57
@ 2009-08-04  0:14     ` Adam Beneschan
  2009-08-04  1:07       ` stefan-lucks
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Beneschan @ 2009-08-04  0:14 UTC (permalink / raw)


On Aug 3, 3:29 pm, Yannick Duchêne Hibou57 <yannick_duch...@yahoo.fr>
wrote:
> On 3 août, 22:40, vlc <just.another.spam.acco...@googlemail.com>
> wrote:
>
> > Have you already considered something like
>
> > raise Sh3_NoData with "No SH3 data.";
>
> > I'm not absolutely sure, but I think this will only compile in Ada
> > 2005.
>
> It will, surely, as said the ARM 2005 :
>
> ARM 11.3 (2/2) says
>
> > raise_statement ::= raise;
> >       | raise exception_name [with string_expression]; raise [exception_name];
>
> But he will loose the default exception informations which are useful
> too (the string provided will replace the exception message which is
> defaulted to some exception informations).

It isn't lost.  If the exception is caught,
Ada.Exceptions.Exception_Information will still return information.
The RM says that Exception_Information returns "implementation-defined
information about the exception occurrence", and that
Exception_Message returns "implementation-defined information about
the exception occurrence" if RAISE is used without a
string_expression.  The RM doesn't say what the relationship between
those two strings is, but it's reasonable to assume that the string
returned by Exception_Information is at least as informative as the
default one returned by Exception_Message, if the two strings aren't
identical.

None of this matters if the exception isn't caught.  If the exception
is propagated out of the main program, the behavior is implementation-
dependent, and there's no guarantee that the message or any other
information will be displayed.  If the exception is propagated out of
a task body, the task will terminate and any message in the
RAISE...WITH statement will be lost.

                                           -- Adam




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

* Re: writing on terminal before an exception
  2009-08-04  0:14     ` Adam Beneschan
@ 2009-08-04  1:07       ` stefan-lucks
  0 siblings, 0 replies; 8+ messages in thread
From: stefan-lucks @ 2009-08-04  1:07 UTC (permalink / raw)


On Mon, 3 Aug 2009, Adam Beneschan wrote:

> [...] If the exception is propagated out of a task body, the task will
> terminate and any message in the RAISE...WITH statement will be lost.

Not neccessarily! Ada 2005 allows to set some callback procedures, which
are called in the case of (expected or unexpected) task terminations:
<http://www.adaic.com/standards/05rat/html/Rat-5-2.html>.


-- 
------ Stefan Lucks   --  Bauhaus-University Weimar  --   Germany  ------
               Stefan dot Lucks at uni minus weimar dot de
------  I  love  the  taste  of  Cryptanalysis  in  the  morning!  ------




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

* Re: writing on terminal before an exception
  2009-08-02 17:47 writing on terminal before an exception Mark Fabbri
                   ` (2 preceding siblings ...)
  2009-08-03 20:40 ` vlc
@ 2009-08-04 20:18 ` Mark Fabbri
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Fabbri @ 2009-08-04 20:18 UTC (permalink / raw)


thank you very much for the answers.
i have debian linux and gnat.

i've followed your tips, but nothing works.
i have structured the program in another way and now it works.


thank you.

-- 

questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it





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

end of thread, other threads:[~2009-08-04 20:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-02 17:47 writing on terminal before an exception Mark Fabbri
2009-08-03  1:13 ` Yannick Duchêne Hibou57
2009-08-03  6:39 ` Stephen Leake
2009-08-03 20:40 ` vlc
2009-08-03 22:29   ` Yannick Duchêne Hibou57
2009-08-04  0:14     ` Adam Beneschan
2009-08-04  1:07       ` stefan-lucks
2009-08-04 20:18 ` Mark Fabbri

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