comp.lang.ada
 help / color / mirror / Atom feed
* Bug in GNAT.Traceback.Symbolic?
@ 2002-08-27 12:29 Joachim Schröer
  2002-08-27 20:36 ` Rod Chapman
  0 siblings, 1 reply; 2+ messages in thread
From: Joachim Schröer @ 2002-08-27 12:29 UTC (permalink / raw)


Hello all,

I have a problem using Gnat.Traceback.Symbolic (Win2000).
A stream based read procedure shall do a 2 step error handling.

First when an error is encountered the reason is appended to
an Exception_Occurrence by Ada.Exceptions.Raise_Exception.
On a higher level were the file object is known a local handler
shall append the filename and the file index to the message by first
retrieving the information including the symbolic stack by

Ada.Exceptions.Exception_Information(E) & 
Gnat.Traceback.Symbolic.Symbolic_Traceback(E)

and then appending the file info and calling Raise_Exception again.

The problem is:
The first call to Symbolic_Traceback does not contain the symbolic 
information.

Appended info:
- Code excerpts
- Stacktrace output using Symbolic_Traceback(E) in the main
- gcc and gnatmake options (gnat.ago)

Is there something else then "-bargs -E" necessary???

----------------------------------------------------------------
   exception
     when Error : others => Add_Info_Close_Reraise(Error, File);
   end Read;

----------------------------------------------------------------

procedure Add_Info_Close_Reraise
            (Error : in     Ada.Exceptions.Exception_Occurrence;
             File  : in out Ada.Streams.Stream_Io.File_Type) is 

begin
   if Ada.Streams.Stream_Io.Is_Open(File) then
     declare
       Name  : constant String  := Ada.Streams.Stream_Io.Name(File);
       Index : constant Natural := 
Natural(Ada.Streams.Stream_Io.Index(File));
       Info  : constant String  := 
Portable.Utils.Exception_Information(Error);
       begin
         Ada.Streams.Stream_Io.Close(File);

         Ada.Exceptions.Raise_Exception
           (E       => Ada.Exceptions.Exception_Identity(Error),
            Message => Info & Os.New_Line &
                       "File: " & Name & ", Index: " & 
Natural'Image(Index));
       end;
     else
       Ada.Exceptions.Reraise_Occurrence(Error);
     end if;
   end Add_Info_Close_Reraise;

----------------------------------------------------------------------------

with Gnat.Traceback.Symbolic;

package body Portable.Utils is
 
---------------------------------------------------------------------------- 

   function Exception_Information(E : in 
Ada.Exceptions.Exception_Occurrence)
            return String is
   begin
     return Ada.Exceptions.Exception_Information(E) &
            Gnat.Traceback.Symbolic.Symbolic_Traceback(E);
   end Exception_Information;
 
---------------------------------------------------------------------------- 

end Portable.Utils;

----------------------------------------------------------------------------
******** First traceback without symbolic info!!!

C:\Ada95\source\Projects\MST_SA\Geo>test_dted_io
E:\dted\DTED\E000\N46.dt1
Exception name: GEO.DTED.IO.DTED_FILE_ERROR

Message: Exception name: GEO.DTED.IO.DTED_FILE_ERROR

Message: unexpected string, '  D' read, expected 'DSI'

File: E:\dted\DTED\E000\N46.dt1, Index:  82

Call stack traceback locations:
0x4488c3 0x44e140 0x4

Call stack traceback locations:
0x449be6 0x450a21 0x410ae0 0x410bc6 0x401401 0x401103 0x77e8ca8e
00449BE6 in geo.dted.io.add_info_close_reraise at geo-dted-io.adb:570
00450A21 in geo.dted.io.read at geo-dted-io.adb:1088
00410AE0 in test_dted_io.test_dted at test_dted_io.adb:86
00410BC6 in test_dted_io at test_dted_io.adb:103
00401401 in ?? at crt1.c:0
00401103 in ?? at crt1.c:0
77E8CA8E in ?? at fake:0
----------------------------------------------------------------------------
******** Only one exception occurrence!!!

C:\Ada95\source\Projects\MST_SA\Geo>test_dted_io
E:\dted\DTED\E000\N46.dt1
Exception name: GEO.DTED.IO.DTED_FILE_ERROR
Message: unexpected string, '  D' read, expected 'DSI'
File: E:\dted\DTED\E000\N46.dt1, Index:  82
Call stack traceback locations:
0x4488c3 0x44e140 0x450a9e 0x410ae0 0x410bc6 0x401401 0x401103 0x77e8ca8e
004488C3 in geo.dted.io.check at geo-dted-io.adb:400
0044E140 in geo.dted.io.read.read at geo-dted-io.adb:937
00450A9E in geo.dted.io.read at geo-dted-io.adb:1082
00410AE0 in test_dted_io.test_dted at test_dted_io.adb:86
00410BC6 in test_dted_io at test_dted_io.adb:103
00401401 in ?? at crt1.c:0
00401103 in ?? at crt1.c:0
77E8CA8E in ?? at fake:0
----------------------------------------------------------------------------
***** gnat options

-O3 -I\ada95\source\lib\math -I\ada95\source\lib\math\arrays 
-I\ada95\source\lib\utilities -I\ada95\source\lib\portable 
-I\ada95\source\lib\portable\posix-win\src 
-I\ada95\compiler\gnat\bindings\win32ada -I\ada95\compiler\gnat\asis 
-I\ada95\source\projects\asis -I\ada95\bin\gnat -I..\mst

-cargs -O3 -bargs -f -E -largs \ada95\compiler\gnat\asis\libasis.a 
\ada95\compiler\gnat\lib\libopengl32.a 
\ada95\compiler\gnat\lib\libglu32.a \ada95\compiler\gnat\lib\libglut32.a 
\ada95\compiler\gnat\lib\libgdi32.a 
\ada95\compiler\gnat\lib\libwsock32.a -I\ada95\source\lib\math 
-I\ada95\source\lib\math\arrays -I\ada95\source\lib\utilities 
-I\ada95\source\lib\portable -I\ada95\source\lib\portable\posix-win\src 
-I\ada95\compiler\gnat\bindings\win32ada -I\ada95\compiler\gnat\asis 
-I\ada95\source\projects\asis -I\ada95\bin\gnat -I..\mst


WINDOWS_TARGET
-----------------------------------------------------------------------------

Thanks for any help
   J. Schr�er




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

* Re: Bug in GNAT.Traceback.Symbolic?
  2002-08-27 12:29 Bug in GNAT.Traceback.Symbolic? Joachim Schröer
@ 2002-08-27 20:36 ` Rod Chapman
  0 siblings, 0 replies; 2+ messages in thread
From: Rod Chapman @ 2002-08-27 20:36 UTC (permalink / raw)


Joachim Schr�er <joachim.schroeer@dornier.eads.net> wrote in message news:<c 
> Is there something else then "-bargs -E" necessary???

We use
  gnatmake -g spark -cargs -funwind-tables -bargs -E
which works fine for us using GNAT Pro 3.15
 - Rod Chapman, SPARK Team



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

end of thread, other threads:[~2002-08-27 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-27 12:29 Bug in GNAT.Traceback.Symbolic? Joachim Schröer
2002-08-27 20:36 ` Rod Chapman

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