2002-12-06 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / f-valprint.c
index f3b3114b3ac43d6ff0f3382563c21d032eae54e9..1be07e791a5b2a1c127311a7dbdbd1d2035cadda 100644 (file)
@@ -1,5 +1,6 @@
 /* Support for printing Fortran values for GDB, the GNU debugger.
-   Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000
+   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.
 
@@ -26,7 +27,6 @@
 #include "gdbtypes.h"
 #include "expression.h"
 #include "value.h"
-#include "demangle.h"
 #include "valprint.h"
 #include "language.h"
 #include "f-lang.h"
 #include "command.h"
 
 #if 0
-static int there_is_a_visible_common_named PARAMS ((char *));
+static int there_is_a_visible_common_named (char *);
 #endif
 
-extern void _initialize_f_valprint PARAMS ((void));
-static void info_common_command PARAMS ((char *, int));
-static void list_all_visible_commons PARAMS ((char *));
-static void f77_print_array PARAMS ((struct type *, char *, CORE_ADDR,
-                                    GDB_FILE *, int, int, int,
-                                    enum val_prettyprint));
-static void f77_print_array_1 PARAMS ((int, int, struct type *, char *,
-                                      CORE_ADDR, GDB_FILE *, int, int, int,
-                                      enum val_prettyprint));
-static void f77_create_arrayprint_offset_tbl PARAMS ((struct type *,
-                                                     GDB_FILE *));
-static void f77_get_dynamic_length_of_aggregate PARAMS ((struct type *));
+extern void _initialize_f_valprint (void);
+static void info_common_command (char *, int);
+static void list_all_visible_commons (char *);
+static void f77_print_array (struct type *, char *, CORE_ADDR,
+                            struct ui_file *, int, int, int,
+                            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);
+static void f77_create_arrayprint_offset_tbl (struct type *,
+                                             struct ui_file *);
+static void f77_get_dynamic_length_of_aggregate (struct type *);
 
 int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
 
@@ -66,9 +66,7 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
 #define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
 
 int
-f77_get_dynamic_lowerbound (type, lower_bound)
-     struct type *type;
-     int *lower_bound;
+f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
 {
   CORE_ADDR current_frame_addr;
   CORE_ADDR ptr_to_lower_bound;
@@ -76,7 +74,7 @@ f77_get_dynamic_lowerbound (type, 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 =
@@ -100,13 +98,13 @@ f77_get_dynamic_lowerbound (type, 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
@@ -126,9 +124,7 @@ f77_get_dynamic_lowerbound (type, lower_bound)
 }
 
 int
-f77_get_dynamic_upperbound (type, upper_bound)
-     struct type *type;
-     int *upper_bound;
+f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
 {
   CORE_ADDR current_frame_addr = 0;
   CORE_ADDR ptr_to_upper_bound;
@@ -136,7 +132,7 @@ f77_get_dynamic_upperbound (type, 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 =
@@ -165,13 +161,13 @@ f77_get_dynamic_upperbound (type, 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
@@ -193,8 +189,7 @@ f77_get_dynamic_upperbound (type, upper_bound)
 /* Obtain F77 adjustable array dimensions */
 
 static void
-f77_get_dynamic_length_of_aggregate (type)
-     struct type *type;
+f77_get_dynamic_length_of_aggregate (struct type *type)
 {
   int upper_bound = -1;
   int lower_bound = 1;
@@ -232,9 +227,7 @@ f77_get_dynamic_length_of_aggregate (type)
    type "type".  */
 
 static void
-f77_create_arrayprint_offset_tbl (type, stream)
-     struct type *type;
-     GDB_FILE *stream;
+f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 {
   struct type *tmp_type;
   int eltlen;
@@ -281,18 +274,9 @@ f77_create_arrayprint_offset_tbl (type, stream)
    the superior.  Address == the address in the inferior.  */
 
 static void
-f77_print_array_1 (nss, ndimensions, type, valaddr, address,
-                  stream, format, deref_ref, recurse, pretty)
-     int nss;
-     int ndimensions;
-     struct type *type;
-     char *valaddr;
-     CORE_ADDR address;
-     GDB_FILE *stream;
-     int format;
-     int deref_ref;
-     int recurse;
-     enum val_prettyprint pretty;
+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 i;
 
@@ -331,16 +315,9 @@ f77_print_array_1 (nss, ndimensions, type, valaddr, address,
    stuff and then immediately call f77_print_array_1() */
 
 static void
-f77_print_array (type, valaddr, address, stream, format, deref_ref, recurse,
-                pretty)
-     struct type *type;
-     char *valaddr;
-     CORE_ADDR address;
-     GDB_FILE *stream;
-     int format;
-     int deref_ref;
-     int recurse;
-     enum val_prettyprint pretty;
+f77_print_array (struct type *type, char *valaddr, CORE_ADDR address,
+                struct ui_file *stream, int format, int deref_ref, int recurse,
+                enum val_prettyprint pretty)
 {
   int ndimensions;
 
@@ -375,17 +352,9 @@ f77_print_array (type, valaddr, address, stream, format, deref_ref, recurse,
    The PRETTY parameter controls prettyprinting.  */
 
 int
-f_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref, recurse,
-            pretty)
-     struct type *type;
-     char *valaddr;
-     int embedded_offset;
-     CORE_ADDR address;
-     GDB_FILE *stream;
-     int format;
-     int deref_ref;
-     int recurse;
-     enum val_prettyprint pretty;
+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 */
   struct type *elttype;
@@ -431,7 +400,7 @@ f_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref,
            }
 
          if (addressprint && format != 's')
-           fprintf_filtered (stream, "0x%x", addr);
+           fprintf_filtered (stream, "0x%s", paddr_nz (addr));
 
          /* For a pointer to char or unsigned char, also print the string
             pointed to, unless pointer is null.  */
@@ -564,7 +533,7 @@ f_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref,
       fputs_filtered ("(", stream);
       print_floating (valaddr, type, stream);
       fputs_filtered (",", stream);
-      print_floating (valaddr, type, stream);
+      print_floating (valaddr + TYPE_LENGTH (type), type, stream);
       fputs_filtered (")", stream);
       break;
 
@@ -583,8 +552,7 @@ f_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref,
 }
 
 static void
-list_all_visible_commons (funname)
-     char *funname;
+list_all_visible_commons (char *funname)
 {
   SAVED_F77_COMMON_PTR tmp;
 
@@ -606,9 +574,7 @@ list_all_visible_commons (funname)
    given name */
 
 static void
-info_common_command (comname, from_tty)
-     char *comname;
-     int from_tty;
+info_common_command (char *comname, int from_tty)
 {
   SAVED_F77_COMMON_PTR the_common;
   COMMON_ENTRY_PTR entry;
@@ -621,7 +587,7 @@ info_common_command (comname, 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");
@@ -629,7 +595,7 @@ info_common_command (comname, 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
@@ -646,7 +612,7 @@ info_common_command (comname, 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)
@@ -658,7 +624,7 @@ info_common_command (comname, from_tty)
   else
     {
       register struct minimal_symbol *msymbol =
-      lookup_minimal_symbol_by_pc (fi->pc);
+      lookup_minimal_symbol_by_pc (get_frame_pc (fi));
 
       if (msymbol != NULL)
        funname = SYMBOL_NAME (msymbol);
@@ -703,8 +669,7 @@ info_common_command (comname, from_tty)
 
 #if 0
 static int
-there_is_a_visible_common_named (comname)
-     char *comname;
+there_is_a_visible_common_named (char *comname)
 {
   SAVED_F77_COMMON_PTR the_common;
   struct frame_info *fi;
@@ -714,7 +679,7 @@ there_is_a_visible_common_named (comname)
   if (comname == NULL)
     error ("Cannot deal with NULL common name!");
 
-  fi = selected_frame;
+  fi = deprecated_selected_frame;
 
   if (fi == NULL)
     error ("No frame selected");
@@ -764,7 +729,7 @@ there_is_a_visible_common_named (comname)
 #endif
 
 void
-_initialize_f_valprint ()
+_initialize_f_valprint (void)
 {
   add_info ("common", info_common_command,
            "Print out the values contained in a Fortran COMMON block.");
This page took 0.030903 seconds and 4 git commands to generate.