我必须将一些用ADA编写的遗留软件从Windows移植到Linux.程序编译正常,但在执行时以分段错误终止.
当程序试图打开文件(文件存在;)时发生段错误.奇怪的是,该程序成功地在执行早期打开另一个文件而没有错误.两个文件都是二进制文件.
使用gdb逐步执行程序,我可以追踪执行的最后一行
dio.Open (FP (File),To_FCB (Mode),Name,Form);
它在a-direio.adb第167行中定义.
如何进一步调查故障原因? dio.Open的参数值看起来没问题(它们与上一次成功调用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;
其中ADA_File_IO声明为
package Ada_File_IO is
new Ada.Direct_IO(Element_Type => GNL_Universal_Representation.An_Item);
GNL_Universal_Representation.An_Item解析为
subtype An_Item is GNL_Basic_Types.A_Byte;
type A_Byte is mod 2**Byte_Size;
和DB_Mode_To_File_Mode(The_Mode)解析为Ada_File_IO.In_File.
编辑(2)
Program received signal SIGSEGV,Segmentation fault.
[Switching to Thread 0xb563db40 (LWP 9887)]
0x081053af in system.file_io.open ()
(gdb) bt
#0 0x081053af in system.file_io.open ()
#1 0x080fd447 in system.direct_io.open ()
#2 0x08066182 in dbs_file.ada_file_io.open (file=0x0,mode=in_file,name=...,form=...)
at /media/chmiwah/ADA/lib/gcc/i686-pc-linux-gnu/4.7.4/adainclude/a-direio.adb:167
#3 0x080665cc in dbs_file.open (the_file=0x0,the_mode=in_db,the_name=...,the_form=...)
at /media/chmiwah/GISMO/bbp-benchmark/code/rebsys/src/dbs/ntv/bdy/dbs_file.adb:108
#4 0x080631b0 in dbs_database.open (the_database=0xb5500468,the_form=...,using_the_definition=0xb5646008)
at /media/chmiwah/GISMO/bbp-benchmark/code/rebsys/src/dbs/gnc/bdy/dbs_database.adb:363
最佳答案
原文链接:https://www.f2er.com/linux/440948.html