2010-02-16 Sami Wagiaalla <swagiaal@redhat.com>
[deliverable/binutils-gdb.git] / gdb / jv-valprint.c
index 2157418f16729b3dca9a21a9e240a209809688d8..d53a8e39778f8e8f2ada47366b51eb5dfe41f535 100644 (file)
@@ -1,7 +1,7 @@
 /* Support for printing Java values for GDB, the GNU debugger.
 
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
-   2008, 2009 Free Software Foundation, Inc.
+   2008, 2009, 2010 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,7 +38,8 @@ int
 java_value_print (struct value *val, struct ui_file *stream, 
                  const struct value_print_options *options)
 {
-  struct gdbarch *gdbarch = current_gdbarch;
+  struct gdbarch *gdbarch = get_type_arch (value_type (val));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct type *type;
   CORE_ADDR address;
   int i;
@@ -81,7 +82,7 @@ java_value_print (struct value *val, struct ui_file *stream,
       i = 0;
       read_memory (address + get_java_object_header_size (gdbarch), buf4, 4);
 
-      length = (long) extract_signed_integer (buf4, 4);
+      length = (long) extract_signed_integer (buf4, 4, byte_order);
       fprintf_filtered (stream, "{length: %ld", length);
 
       if (el_type == NULL)
@@ -110,7 +111,8 @@ java_value_print (struct value *val, struct ui_file *stream,
                      pulls a host sized pointer out of the target and
                      then extracts that as an address (while assuming
                      that the address is unsigned)!  */
-                 element = extract_unsigned_integer (buf, sizeof (buf));
+                 element = extract_unsigned_integer (buf, sizeof (buf),
+                                                     byte_order);
                }
 
              for (reps = 1; i + reps < length; reps++)
@@ -121,7 +123,8 @@ java_value_print (struct value *val, struct ui_file *stream,
                      pulls a host sized pointer out of the target and
                      then extracts that as an address (while assuming
                      that the address is unsigned)!  */
-                 next_element = extract_unsigned_integer (buf, sizeof (buf));
+                 next_element = extract_unsigned_integer (buf, sizeof (buf),
+                                                          byte_order);
                  if (next_element != element)
                    break;
                }
@@ -134,7 +137,7 @@ java_value_print (struct value *val, struct ui_file *stream,
              if (element == 0)
                fprintf_filtered (stream, "null");
              else
-               fprintf_filtered (stream, "@%s", paddr_nz (element));
+               fprintf_filtered (stream, "@%s", paddress (gdbarch, element));
 
              things_printed++;
              i += reps;
@@ -461,6 +464,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
                struct ui_file *stream, int recurse,
                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;
@@ -481,7 +485,8 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
          /* 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 (extract_unsigned_integer (valaddr, TYPE_LENGTH (type)),
+         print_address_demangle (gdbarch,
+                                 extract_unsigned_integer (valaddr, TYPE_LENGTH (type)),
                                  stream, demangle);
          break;
        }
@@ -497,7 +502,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       if (TYPE_CODE (target_type) == TYPE_CODE_FUNC)
        {
          /* Try to print what function it points to.  */
-         print_address_demangle (addr, stream, demangle);
+         print_address_demangle (gdbarch, addr, stream, demangle);
          /* Return value is irrelevant except for string pointers.  */
          return (0);
        }
This page took 0.044263 seconds and 4 git commands to generate.