I need to port some legacy software written in ADA from Windows to Linux. The program compiles fine, but ends with a segmentation error on execution.
Segfault occurs when a program tries to open a file (file exists;). Oddly enough, the program manages to open another file earlier when executed without errors. Both files are binary files.
By executing the program with gdb, I could track the last line executed with
DIO.Open (FP (File), To_FCB (Mode), Name, Form);
which is defined in line a-direio.adb, line 167.
How can I continue to investigate the cause of the malfunction? The parameter values ββfor DIO.Open look OK (they are similar to the previous successful call to DIO.Open, except for the file name). Any hints are welcome.
Edit
Here is the code that ultimately calls DIO.Open:
procedure Open (The_File : in out File_Type; The_Mode : in A_DB_Mode := DBS_Database_Types.InOut_DB; The_Name : in String; The_Form : in String := "") is begin Ada_File_IO.Open (File => The_File, Mode => DB_Mode_To_File_Mode(The_Mode), Name => The_Name, Form => The_Form); exception when Ada_File_IO.Status_Error => raise Status_Error; when Ada_File_IO.Name_Error => raise Name_Error; when Ada_File_IO.Use_Error => raise Use_Error; end Open;
where ADA_File_IO is declared as
package Ada_File_IO is new Ada.Direct_IO(Element_Type => GNL_Universal_Representation.An_Item);
GNL_Universal_Representation.An_Item allows
subtype An_Item is GNL_Basic_Types.A_Byte; type A_Byte is mod 2**Byte_Size;
and DB_Mode_To_File_Mode (The_Mode) allows Ada_File_IO.In_File.
Edit (2)
This is gdb output with some file names (as suggested by Brian)
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb563db40 (LWP 9887)] 0x081053af in system.file_io.open () (gdb) bt