* strerror.c: Revert last change. Declare static sys_nerr
[deliverable/binutils-gdb.git] / gdb / f-valprint.c
index 56b48dd21e821599548e6c9b3c79758e14b0a8c3..cc337e9481e67e8d8e7304178224724162ff5c9b 100644 (file)
@@ -1,5 +1,6 @@
 /* Support for printing Fortran values for GDB, the GNU debugger.
-   Copyright 1993-1995, 2000 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003
+   Free Software Foundation, Inc.
    Contributed by Motorola.  Adapted from the C definitions by Farooq Butt
    (fmbutt@engage.sps.mot.com), additionally worked over by Stan Shebs.
 
 #include "gdbtypes.h"
 #include "expression.h"
 #include "value.h"
-#include "demangle.h"
 #include "valprint.h"
 #include "language.h"
 #include "f-lang.h"
 #include "frame.h"
 #include "gdbcore.h"
 #include "command.h"
+#include "block.h"
 
 #if 0
 static int there_is_a_visible_common_named (char *);
@@ -46,7 +47,8 @@ static void f77_print_array (struct type *, char *, CORE_ADDR,
                             enum val_prettyprint);
 static void f77_print_array_1 (int, int, struct type *, char *,
                               CORE_ADDR, struct ui_file *, int, int, int,
-                              enum val_prettyprint);
+                              enum val_prettyprint,
+                              int *elts);
 static void f77_create_arrayprint_offset_tbl (struct type *,
                                              struct ui_file *);
 static void f77_get_dynamic_length_of_aggregate (struct type *);
@@ -74,7 +76,7 @@ f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
   switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
     {
     case BOUND_BY_VALUE_ON_STACK:
-      current_frame_addr = selected_frame->frame;
+      current_frame_addr = get_frame_base (deprecated_selected_frame);
       if (current_frame_addr > 0)
        {
          *lower_bound =
@@ -98,13 +100,13 @@ f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
       break;
 
     case BOUND_BY_REF_ON_STACK:
-      current_frame_addr = selected_frame->frame;
+      current_frame_addr = get_frame_base (deprecated_selected_frame);
       if (current_frame_addr > 0)
        {
          ptr_to_lower_bound =
-           read_memory_integer (current_frame_addr +
-                                TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-                                4);
+           read_memory_typed_address (current_frame_addr +
+                                      TYPE_ARRAY_LOWER_BOUND_VALUE (type),
+                                      builtin_type_void_data_ptr);
          *lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
        }
       else
@@ -132,7 +134,7 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
   switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
     {
     case BOUND_BY_VALUE_ON_STACK:
-      current_frame_addr = selected_frame->frame;
+      current_frame_addr = get_frame_base (deprecated_selected_frame);
       if (current_frame_addr > 0)
        {
          *upper_bound =
@@ -161,13 +163,13 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
       break;
 
     case BOUND_BY_REF_ON_STACK:
-      current_frame_addr = selected_frame->frame;
+      current_frame_addr = get_frame_base (deprecated_selected_frame);
       if (current_frame_addr > 0)
        {
          ptr_to_upper_bound =
-           read_memory_integer (current_frame_addr +
-                                TYPE_ARRAY_UPPER_BOUND_VALUE (type),
-                                4);
+           read_memory_typed_address (current_frame_addr +
+                                      TYPE_ARRAY_UPPER_BOUND_VALUE (type),
+                                      builtin_type_void_data_ptr);
          *upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
        }
       else
@@ -270,31 +272,36 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
     }
 }
 
+
+
 /* Actual function which prints out F77 arrays, Valaddr == address in 
    the superior.  Address == the address in the inferior.  */
-
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type, char *valaddr,
                   CORE_ADDR address, struct ui_file *stream, int format,
-                  int deref_ref, int recurse, enum val_prettyprint pretty)
+                  int deref_ref, int recurse, enum val_prettyprint pretty,
+                  int *elts)
 {
   int i;
 
   if (nss != ndimensions)
     {
-      for (i = 0; i < F77_DIM_SIZE (nss); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
        {
          fprintf_filtered (stream, "( ");
          f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
                             valaddr + i * F77_DIM_OFFSET (nss),
                             address + i * F77_DIM_OFFSET (nss),
-                            stream, format, deref_ref, recurse, pretty);
+                            stream, format, deref_ref, recurse, pretty, elts);
          fprintf_filtered (stream, ") ");
        }
+      if (*elts >= print_max && i < F77_DIM_SIZE (nss)) {
+       fprintf_filtered (stream, "...");
+      }
     }
   else
     {
-      for (i = 0; (i < F77_DIM_SIZE (nss) && i < print_max); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++, (*elts)++)
        {
          val_print (TYPE_TARGET_TYPE (type),
                     valaddr + i * F77_DIM_OFFSET (ndimensions),
@@ -305,7 +312,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, char *valaddr,
          if (i != (F77_DIM_SIZE (nss) - 1))
            fprintf_filtered (stream, ", ");
 
-         if (i == print_max - 1)
+         if ((( *elts) == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
            fprintf_filtered (stream, "...");
        }
     }
@@ -320,6 +327,7 @@ f77_print_array (struct type *type, char *valaddr, CORE_ADDR address,
                 enum val_prettyprint pretty)
 {
   int ndimensions;
+  int elts = 0;
 
   ndimensions = calc_f77_array_dims (type);
 
@@ -334,7 +342,7 @@ f77_print_array (struct type *type, char *valaddr, CORE_ADDR address,
   f77_create_arrayprint_offset_tbl (type, stream);
 
   f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
-                    deref_ref, recurse, pretty);
+                    deref_ref, recurse, pretty, &elts);
 }
 \f
 
@@ -356,7 +364,7 @@ f_val_print (struct type *type, char *valaddr, int embedded_offset,
             CORE_ADDR address, struct ui_file *stream, int format,
             int deref_ref, int recurse, enum val_prettyprint pretty)
 {
-  register unsigned int i = 0; /* Number of characters printed */
+  unsigned int i = 0;  /* Number of characters printed */
   struct type *elttype;
   LONGEST val;
   CORE_ADDR addr;
@@ -562,7 +570,7 @@ list_all_visible_commons (char *funname)
 
   while (tmp != NULL)
     {
-      if (STREQ (tmp->owning_function, funname))
+      if (strcmp (tmp->owning_function, funname) == 0)
        printf_filtered ("%s\n", tmp->name);
 
       tmp = tmp->next;
@@ -579,7 +587,7 @@ info_common_command (char *comname, int from_tty)
   SAVED_F77_COMMON_PTR the_common;
   COMMON_ENTRY_PTR entry;
   struct frame_info *fi;
-  register char *funname = 0;
+  char *funname = 0;
   struct symbol *func;
 
   /* We have been told to display the contents of F77 COMMON 
@@ -587,7 +595,7 @@ info_common_command (char *comname, int from_tty)
      first make sure that it is visible and if so, let 
      us display its contents */
 
-  fi = selected_frame;
+  fi = deprecated_selected_frame;
 
   if (fi == NULL)
     error ("No frame selected");
@@ -595,7 +603,7 @@ info_common_command (char *comname, int from_tty)
   /* The following is generally ripped off from stack.c's routine 
      print_frame_info() */
 
-  func = find_pc_function (fi->pc);
+  func = find_pc_function (get_frame_pc (fi));
   if (func)
     {
       /* In certain pathological cases, the symtabs give the wrong
@@ -612,22 +620,22 @@ info_common_command (char *comname, int from_tty)
          be any minimal symbols in the middle of a function.
          FIXME:  (Not necessarily true.  What about text labels) */
 
-      struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
+      struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
 
       if (msymbol != NULL
          && (SYMBOL_VALUE_ADDRESS (msymbol)
              > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
-       funname = SYMBOL_NAME (msymbol);
+       funname = DEPRECATED_SYMBOL_NAME (msymbol);
       else
-       funname = SYMBOL_NAME (func);
+       funname = DEPRECATED_SYMBOL_NAME (func);
     }
   else
     {
-      register struct minimal_symbol *msymbol =
-      lookup_minimal_symbol_by_pc (fi->pc);
+      struct minimal_symbol *msymbol =
+      lookup_minimal_symbol_by_pc (get_frame_pc (fi));
 
       if (msymbol != NULL)
-       funname = SYMBOL_NAME (msymbol);
+       funname = DEPRECATED_SYMBOL_NAME (msymbol);
     }
 
   /* If comname is NULL, we assume the user wishes to see the 
@@ -643,7 +651,7 @@ info_common_command (char *comname, int from_tty)
 
   if (the_common)
     {
-      if (STREQ (comname, BLANK_COMMON_NAME_LOCAL))
+      if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0)
        printf_filtered ("Contents of blank COMMON block:\n");
       else
        printf_filtered ("Contents of F77 COMMON block '%s':\n", comname);
@@ -653,7 +661,7 @@ info_common_command (char *comname, int from_tty)
 
       while (entry != NULL)
        {
-         printf_filtered ("%s = ", SYMBOL_NAME (entry->symbol));
+         printf_filtered ("%s = ", DEPRECATED_SYMBOL_NAME (entry->symbol));
          print_variable_value (entry->symbol, fi, gdb_stdout);
          printf_filtered ("\n");
          entry = entry->next;
@@ -673,13 +681,13 @@ there_is_a_visible_common_named (char *comname)
 {
   SAVED_F77_COMMON_PTR the_common;
   struct frame_info *fi;
-  register char *funname = 0;
+  char *funname = 0;
   struct symbol *func;
 
   if (comname == NULL)
     error ("Cannot deal with NULL common name!");
 
-  fi = selected_frame;
+  fi = deprecated_selected_frame;
 
   if (fi == NULL)
     error ("No frame selected");
@@ -709,17 +717,17 @@ there_is_a_visible_common_named (char *comname)
       if (msymbol != NULL
          && (SYMBOL_VALUE_ADDRESS (msymbol)
              > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
-       funname = SYMBOL_NAME (msymbol);
+       funname = DEPRECATED_SYMBOL_NAME (msymbol);
       else
-       funname = SYMBOL_NAME (func);
+       funname = DEPRECATED_SYMBOL_NAME (func);
     }
   else
     {
-      register struct minimal_symbol *msymbol =
+      struct minimal_symbol *msymbol =
       lookup_minimal_symbol_by_pc (fi->pc);
 
       if (msymbol != NULL)
-       funname = SYMBOL_NAME (msymbol);
+       funname = DEPRECATED_SYMBOL_NAME (msymbol);
     }
 
   the_common = find_common_for_function (comname, funname);
This page took 0.03173 seconds and 4 git commands to generate.