Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fortran: Intel vs G77
@ 2003-01-15 21:51 David Lecomber
  2003-01-15 22:09 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: David Lecomber @ 2003-01-15 21:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

The current situation with g77 and Intel meets gdb is as follows for
multi-dim arrays

Intel compiled code:
  whatis -- wrong way round real(4 * 5 ) is reported as real (5 * 4)
  indexing -- correct 
  print elements -- boundaries not aligned properly ( it prints a 5 * 4 
as a 4 * 5 )


g77 fortran compilers compiled code:
  whatis -- correct
  print elements -- correct
  indexing -- 'print A(1,2)' will get the wrong answer.

So, unless there is a method to check what the compiler was used, we are
left with

  1. status quo
or
  2. compile up two different versions -- one for gdb + intel, the
other for gdb + g77

Does anyone know of the existence of such a check?

Patches to fix the three issues are attached, but of course they
cannot all be applied at once; the fix to make g77 work will bust
intel, and vice-versa..

David




[-- Attachment #2: gdb.g77-array-printing-patch --]
[-- Type: text/plain, Size: 621 bytes --]

*** eval.c	Fri Jan  4 17:51:38 2002
--- eval.c	Wed Oct 16 14:08:04 2002
*************** evaluate_subexp_standard (struct type *e
*** 1358,1364 ****
  	    if (retcode == BOUND_FETCH_ERROR)
  	      error ("Cannot obtain dynamic lower bound");
  
! 	    array_size_array[i] = upper - lower + 1;
  
  	    /* Zero-normalize subscripts so that offsetting will work. */
  
--- 1358,1364 ----
  	    if (retcode == BOUND_FETCH_ERROR)
  	      error ("Cannot obtain dynamic lower bound");
  
! 	    array_size_array[nargs - i + 1] = upper - lower + 1;
  
  	    /* Zero-normalize subscripts so that offsetting will work. */
  

[-- Attachment #3: gdb.intel-print-elements-patch --]
[-- Type: text/plain, Size: 1665 bytes --]

*** f-valprint.c	Mon Oct 21 17:47:36 2002
--- /tmp/gdb-5.2/gdb/f-valprint.c	Mon Oct 21 16:14:33 2002
*************** f77_create_arrayprint_offset_tbl (struct
*** 234,239 ****
--- 234,241 ----
    int eltlen;
    int ndimen = 1;
    int upper, lower, retcode;
+   int i, j;
+   int t;
  
    tmp_type = type;
  
*************** f77_create_arrayprint_offset_tbl (struct
*** 256,270 ****
        ndimen++;
      }
  
    /* Now we multiply eltlen by all the offsets, so that later we 
       can print out array elements correctly.  Up till now we 
       know an offset to apply to get the item but we also 
       have to know how much to add to get to the next item */
  
    ndimen--;
    eltlen = TYPE_LENGTH (tmp_type);
    F77_DIM_OFFSET (ndimen) = eltlen;
!   while (--ndimen > 0)
      {
        eltlen *= F77_DIM_SIZE (ndimen + 1);
        F77_DIM_OFFSET (ndimen) = eltlen;
--- 258,285 ----
        ndimen++;
      }
  
+ 
    /* Now we multiply eltlen by all the offsets, so that later we 
       can print out array elements correctly.  Up till now we 
       know an offset to apply to get the item but we also 
       have to know how much to add to get to the next item */
  
    ndimen--;
+ 
+   /**
+      intel compiler, reckon this to be wrong way round.. so here's a quick in-place swap.
+    */
+ 
+   for (i = 1, j = ndimen; i < j; i++,j--) {
+     t = F77_DIM_SIZE(i);
+     F77_DIM_SIZE(i) = F77_DIM_SIZE(j);
+     F77_DIM_SIZE(j) = t;
+   }
+ 
    eltlen = TYPE_LENGTH (tmp_type);
    F77_DIM_OFFSET (ndimen) = eltlen;
! 
!   while (--ndimen > 0) 
      {
        eltlen *= F77_DIM_SIZE (ndimen + 1);
        F77_DIM_OFFSET (ndimen) = eltlen;

[-- Attachment #4: gdb.intel-print-whatis-patch --]
[-- Type: text/plain, Size: 1526 bytes --]

*** f-typeprint.c	Sun Jan 20 19:42:04 2002
--- f-typeprint.c	Mon Oct 21 16:18:12 2002
*************** f_type_print_varspec_suffix (struct type
*** 175,183 ****
  
        if (arrayprint_recurse_level == 1)
  	fprintf_filtered (stream, "(");
  
-       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
- 	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
  
        retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
  
--- 175,183 ----
  
        if (arrayprint_recurse_level == 1)
  	fprintf_filtered (stream, "(");
+       else
+ 	fprintf_filtered (stream, ",");
  
  
        retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
  
*************** f_type_print_varspec_suffix (struct type
*** 212,221 ****
  
        if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
  	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
        if (arrayprint_recurse_level == 1)
  	fprintf_filtered (stream, ")");
-       else
- 	fprintf_filtered (stream, ",");
        arrayprint_recurse_level--;
        break;
  
--- 212,223 ----
  
        if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
  	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+ 
+       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
+ 	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+ 
        if (arrayprint_recurse_level == 1)
  	fprintf_filtered (stream, ")");
        arrayprint_recurse_level--;
        break;
  

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

end of thread, other threads:[~2003-01-16 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-15 21:51 Fortran: Intel vs G77 David Lecomber
2003-01-15 22:09 ` Daniel Jacobowitz
2003-01-15 23:22   ` David Lecomber
2003-01-16  4:41     ` Daniel Jacobowitz
2003-01-16 10:40       ` David Lecomber

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