This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Workaround ada (gnat-4.3.0) on x86_64


Hi,

FYI: not sure if it should be applied upstream as it is just a workaround of
a GCC bug.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35998

The source:

procedure AdaFF is
  type rec is
    record
      null;
    end record;
  X : rec;
begin
  null;
end AdaFF;

produces output by:
$ rm -f adaff{,.o,.ali};gnatmake -g adaff.adb ;readelf -a --debug-dump adaff |
grep 'DW_AT_byte_size.*0xffff'
    <30b>   DW_AT_byte_size   : 0xffffffff

 <1><306>: Abbrev Number: 20 (DW_TAG_structure_type)
    <307>   DW_AT_name        : (indirect string, offset: 0x3c8):
ada_main__main__TsehB___XUT
    <30b>   DW_AT_byte_size   : 0xffffffff
    <30f>   DW_AT_decl_file   : 1
    <310>   DW_AT_decl_line   : 105
    <311>   DW_AT_sibling     : <0x33b>

A more complicated testcase
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/packed_tagged/comp_bug.adb?rev=1.1&cvsroot=src
crashes GDB eating all the memory on `print x' there.

gcc-gnat-4.3.0-7.x86_64

The attached patch workarounds GDB to no longer trash the memory while running
its testsuite with gcc-gnat installed.


Regards,
Jan
2008-04-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Workaround GCC PR ada/35998.
	* ada-lang.c (to_fixed_record_type): Error out on invalid length of the
	type TYPE0.

--- ./gdb/ada-lang.c	6 Apr 2008 08:56:36 -0000	1.137
+++ ./gdb/ada-lang.c	20 Apr 2008 21:47:05 -0000
@@ -7313,6 +7313,11 @@ to_fixed_record_type (struct type *type0
 {
   struct type *templ_type;
 
+  /* GCC PR ada/35998 workaround.  */
+  if (TYPE_LENGTH (type0) == 0xffffffff)
+    error (_("Type %s has invalid length -1, check your GCC"),
+	   TYPE_NAME (type0));
+
   if (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE)
     return type0;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]