*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / jv-valprint.c
index 8c29f3725ad173eb4d0f1afaed40a4cfc958a4bb..6cdceb0eb70ae25e7c435ca7c1186b451938c010 100644 (file)
@@ -1,7 +1,6 @@
 /* Support for printing Java values for GDB, the GNU debugger.
 
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
-   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -34,7 +33,7 @@
 
 /* Local functions */
 
-int
+void
 java_value_print (struct value *val, struct ui_file *stream, 
                  const struct value_print_options *options)
 {
@@ -43,7 +42,7 @@ java_value_print (struct value *val, struct ui_file *stream,
   struct type *type;
   CORE_ADDR address;
   int i;
-  char *name;
+  const char *name;
   struct value_print_options opts;
 
   type = value_type (val);
@@ -52,10 +51,13 @@ java_value_print (struct value *val, struct ui_file *stream,
   if (is_object_type (type))
     {
       CORE_ADDR obj_addr;
+      struct value *tem = val;
 
       /* Get the run-time type, and cast the object into that.  */
+      while (TYPE_CODE (value_type (tem)) == TYPE_CODE_PTR)
+       tem = value_ind (tem);
 
-      obj_addr = unpack_pointer (type, value_contents (val));
+      obj_addr = value_address (tem);
 
       if (obj_addr != 0)
        {
@@ -179,8 +181,11 @@ java_value_print (struct value *val, struct ui_file *stream,
                  set_value_lazy (next_v, 1);
                  set_value_offset (next_v, value_offset (next_v)
                                    + TYPE_LENGTH (el_type));
-                 if (memcmp (value_contents (v), value_contents (next_v),
-                             TYPE_LENGTH (el_type)) != 0)
+                 value_fetch_lazy (next_v);
+                 if (!(value_available_contents_eq
+                       (v, value_embedded_offset (v),
+                        next_v, value_embedded_offset (next_v),
+                        TYPE_LENGTH (el_type))))
                    break;
                }
 
@@ -203,7 +208,7 @@ java_value_print (struct value *val, struct ui_file *stream,
 
       fprintf_filtered (stream, "}");
 
-      return 0;
+      return;
     }
 
   /* If it's type String, print it.  */
@@ -226,6 +231,8 @@ java_value_print (struct value *val, struct ui_file *stream,
       unsigned long count;
       struct value *mark;
 
+      fputs_filtered (" ", stream);
+
       mark = value_mark ();    /* Remember start of new values.  */
 
       data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);
@@ -243,12 +250,12 @@ java_value_print (struct value *val, struct ui_file *stream,
       val_print_string (char_type, NULL, data + boffset, count, stream,
                        options);
 
-      return 0;
+      return;
     }
 
   opts = *options;
   opts.deref_ref = 1;
-  return common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, &opts, current_language);
 }
 
 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
@@ -281,7 +288,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
        {
          int boffset;
          struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-         char *basename = TYPE_NAME (baseclass);
+         const char *basename = TYPE_NAME (baseclass);
          const gdb_byte *base_valaddr;
 
          if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -323,7 +330,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
          /* If requested, skip printing of static fields.  */
          if (field_is_static (&TYPE_FIELD (type, i)))
            {
-             char *name = TYPE_FIELD_NAME (type, i);
+             const char *name = TYPE_FIELD_NAME (type, i);
 
              if (!options->static_field_print)
                continue;
@@ -354,36 +361,17 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
            {
              wrap_here (n_spaces (2 + 2 * recurse));
            }
-         if (options->inspect_it)
-           {
-             if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
-               fputs_filtered ("\"( ptr \"", stream);
-             else
-               fputs_filtered ("\"( nodef \"", stream);
-             if (field_is_static (&TYPE_FIELD (type, i)))
-               fputs_filtered ("static ", stream);
-             fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
-                                      language_cplus,
-                                      DMGL_PARAMS | DMGL_ANSI);
-             fputs_filtered ("\" \"", stream);
-             fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
-                                      language_cplus,
-                                      DMGL_PARAMS | DMGL_ANSI);
-             fputs_filtered ("\") \"", stream);
-           }
-         else
-           {
-             annotate_field_begin (TYPE_FIELD_TYPE (type, i));
-
-             if (field_is_static (&TYPE_FIELD (type, i)))
-               fputs_filtered ("static ", stream);
-             fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
-                                      language_cplus,
-                                      DMGL_PARAMS | DMGL_ANSI);
-             annotate_field_name_end ();
-             fputs_filtered (": ", stream);
-             annotate_field_value ();
-           }
+
+         annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+
+         if (field_is_static (&TYPE_FIELD (type, i)))
+           fputs_filtered ("static ", stream);
+         fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
+                                  language_cplus,
+                                  DMGL_PARAMS | DMGL_ANSI);
+         annotate_field_name_end ();
+         fputs_filtered (": ", stream);
+         annotate_field_value ();
 
          if (!field_is_static (&TYPE_FIELD (type, i))
              && TYPE_FIELD_PACKED (type, i))
@@ -413,9 +401,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
                {
                  struct value_print_options opts;
 
-                 v = value_from_longest
-                   (TYPE_FIELD_TYPE (type, i),
-                    unpack_field_as_long (type, valaddr + offset, i));
+                 v = value_field_bitfield (type, i, valaddr, offset, val);
 
                  opts = *options;
                  opts.deref_ref = 0;
@@ -474,14 +460,10 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "}");
 }
 
-/* Print data of type TYPE located at VALADDR (within GDB), which came from
-   the inferior at address ADDRESS, onto stdio stream STREAM according to
-   OPTIONS.  The data at VALADDR is in target byte order.
+/* See val_print for a description of the various parameters of this
+   function; they are identical.  */
 
-   If the data are a string pointer, returns the number of string characters
-   printed.  */
-
-int
+void
 java_val_print (struct type *type, const gdb_byte *valaddr,
                int embedded_offset, CORE_ADDR address,
                struct ui_file *stream, int recurse,
@@ -489,7 +471,6 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
                const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
-  unsigned int i = 0;  /* Number of characters printed.  */
   struct type *target_type;
   CORE_ADDR addr;
 
@@ -499,39 +480,23 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
     case TYPE_CODE_PTR:
       if (options->format && options->format != 's')
        {
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, options, 0, stream);
-         break;
-       }
-#if 0
-      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
-       {
-         /* Print the unmangled name if desired.  */
-         /* Print vtable entry - we only get here if we ARE using
-            -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.)  */
-         /* Extract an address, assume that it is unsigned.  */
-         print_address_demangle
-           (gdbarch,
-            extract_unsigned_integer (valaddr + embedded_offset,
-                                      TYPE_LENGTH (type)),
-            stream, demangle);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     val, options, 0, stream);
          break;
        }
-#endif
       addr = unpack_pointer (type, valaddr + embedded_offset);
       if (addr == 0)
        {
          fputs_filtered ("null", stream);
-         return i;
+         return;
        }
       target_type = check_typedef (TYPE_TARGET_TYPE (type));
 
       if (TYPE_CODE (target_type) == TYPE_CODE_FUNC)
        {
          /* Try to print what function it points to.  */
-         print_address_demangle (gdbarch, addr, stream, demangle);
-         /* Return value is irrelevant except for string pointers.  */
-         return (0);
+         print_address_demangle (options, gdbarch, addr, stream, demangle);
+         return;
        }
 
       if (options->addressprint && options->format != 's')
@@ -540,7 +505,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
          print_longest (stream, 'x', 0, (ULONGEST) addr);
        }
 
-      return i;
+      return;
 
     case TYPE_CODE_CHAR:
     case TYPE_CODE_INT:
@@ -552,8 +517,8 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
 
          opts.format = (options->format ? options->format
                         : options->output_format);
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, &opts, 0, stream);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     val, &opts, 0, stream);
        }
       else if (TYPE_CODE (type) == TYPE_CODE_CHAR
               || (TYPE_CODE (type) == TYPE_CODE_INT
@@ -571,9 +536,8 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     default:
-      return c_val_print (type, valaddr, embedded_offset, address, stream,
-                         recurse, val, options);
+      c_val_print (type, valaddr, embedded_offset, address, stream,
+                  recurse, val, options);
+      break;
     }
-
-  return 0;
 }
This page took 0.026828 seconds and 4 git commands to generate.