This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: Dwarf2-related Internal error


Michal Ludvig told me that:
OK, I have found the problem. The type of the parameter 'xx' is an array with unspecified size. Lower bound is set to '1' for Fortran and since there is no upper bound specified, it's set to '-1' by default.

3097     else if (attr->form == DW_FORM_block1)
3098     {
3099       /* GCC encodes arrays with unspecified or dynamic length
3100          with a DW_FORM_block1 attribute.
3101          FIXME: GDB does not yet know how to handle dynamic
3102          arrays properly, treat them as arrays with unspecified
3103          length for now.  */
3104       high = -1;
3105     }

Later, when the actual size of the array type is computed, it takes the size of the main type (real, size=4) and multiplies it by (high-low+1=-1) leading to -4 which is quite a big number when converted to unsigned.

Now how to solve it. For now I did

                     length for now.  */
                  high = -1;
+                 if (cu_language == language_fortran)
+                   high = 0;
                }

which at least prevents GDB from crashing. IMHO it achieves the same behaviour as for other languages, where low=0, high=-1 and so the size of the array results to 0. In fortran low=1, so with high=0 the size will become 0 as well.

Would this be an acceptable solution? Any comments?

PING! http://sources.redhat.com/ml/gdb/2003-08/msg00150.html

Any comments? Tha patch is attached. It proved to work pretty well - can I apply it?

Thanks!

Michal Ludvig
--
SuSE CR, s.r.o             mludvig@suse.cz | I would like to change
(+420) 296.545.373      http://www.suse.cz | the world, but they wont
Personal homepage http://www.logix.cz/~mic | tell me the source code.
2003-09-17  Michal Ludvig  <mludvig@suse.cz>

	* dwarf2read.c (read_array_type): Set upper bound for
	Fortran arrays of unspecified size.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.105
diff -u -p -r1.105 dwarf2read.c
--- dwarf2read.c	15 Sep 2003 17:19:23 -0000	1.105
+++ dwarf2read.c	17 Sep 2003 10:53:35 -0000
@@ -3239,6 +3239,8 @@ read_array_type (struct die_info *die, s
 		     arrays properly, treat them as arrays with unspecified
 		     length for now.  */
 		  high = -1;
+		  if (cu_language == language_fortran)
+		    high = 0;
 		}
 	      else
 		{

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