]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/jv-lang.c
Switch the license of all .c files to GPLv3.
[thirdparty/binutils-gdb.git] / gdb / jv-lang.c
index bc2264f10c4f584edc2bad07b30233654f54031a..3460184a3682442d27b422bc44b3780c57c003f2 100644 (file)
@@ -1,13 +1,13 @@
 /* Java language support routines for GDB, the GNU debugger.
 
-   Copyright 1997, 1998, 1999, 2000, 2003, 2004, 2005 Free Software
-   Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2007
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "symtab.h"
@@ -39,6 +37,7 @@
 #include "demangle.h"
 #include "dictionary.h"
 #include <ctype.h>
+#include "gdb_assert.h"
 
 struct type *java_int_type;
 struct type *java_byte_type;
@@ -216,7 +215,7 @@ get_java_utf8_name (struct obstack *obstack, struct value *name)
     + TYPE_LENGTH (value_type (temp));
   chrs = obstack_alloc (obstack, name_length + 1);
   chrs[name_length] = '\0';
-  read_memory (data_addr, chrs, name_length);
+  read_memory (data_addr, (gdb_byte *) chrs, name_length);
   return chrs;
 }
 
@@ -320,7 +319,7 @@ type_from_class (struct value *clas)
       temp = clas;
       /* Set array element type. */
       temp = value_struct_elt (&temp, NULL, "methods", NULL, "structure");
-      temp->type = lookup_pointer_type (value_type (clas));
+      deprecated_set_value_type (temp, lookup_pointer_type (value_type (clas)));
       TYPE_TARGET_TYPE (type) = type_from_class (temp);
     }
 
@@ -351,13 +350,14 @@ java_link_class_type (struct type *type, struct value *clas)
   struct objfile *objfile = get_dynamics_objfile ();
   struct type *tsuper;
 
+  gdb_assert (name != NULL);
   unqualified_name = strrchr (name, '.');
   if (unqualified_name == NULL)
     unqualified_name = name;
 
   temp = clas;
   temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure");
-  if (name != NULL && strcmp (name, "java.lang.Object") == 0)
+  if (strcmp (name, "java.lang.Object") == 0)
     {
       tsuper = get_java_object_type ();
       if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
@@ -580,7 +580,7 @@ get_java_object_type (void)
       sym = lookup_symbol ("java.lang.Object", NULL, STRUCT_DOMAIN,
                           (int *) 0, (struct symtab **) NULL);
       if (sym == NULL)
-       error ("cannot find java.lang.Object");
+       error (_("cannot find java.lang.Object"));
       java_object_type = SYMBOL_TYPE (sym);
     }
   return java_object_type;
@@ -591,7 +591,7 @@ get_java_object_header_size (void)
 {
   struct type *objtype = get_java_object_type ();
   if (objtype == NULL)
-    return (2 * TARGET_PTR_BIT / TARGET_CHAR_BIT);
+    return (2 * gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT);
   else
     return TYPE_LENGTH (objtype);
 }
@@ -646,7 +646,7 @@ java_primitive_type (int signature)
     case 'V':
       return java_void_type;
     }
-  error ("unknown signature '%c' for primitive type", (char) signature);
+  error (_("unknown signature '%c' for primitive type"), (char) signature);
 }
 
 /* If name[0 .. namelen-1] is the name of a primitive Java type,
@@ -790,7 +790,7 @@ java_array_type (struct type *type, int dims)
 static struct value *
 java_value_string (char *ptr, int len)
 {
-  error ("not implemented - java_value_string");       /* FIXME */
+  error (_("not implemented - java_value_string"));    /* FIXME */
 }
 
 /* Print the character C on STREAM as part of the contents of a literal
@@ -883,14 +883,14 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
          CORE_ADDR address;
          long length, index;
          struct type *el_type;
-         char buf4[4];
+         gdb_byte buf4[4];
 
          struct value *clas = java_class_from_object (arg1);
          struct value *temp = clas;
          /* Get CLASS_ELEMENT_TYPE of the array type. */
          temp = value_struct_elt (&temp, NULL, "methods",
                                   NULL, "structure");
-         temp->type = value_type (clas);
+         deprecated_set_value_type (temp, value_type (clas));
          el_type = type_from_class (temp);
          if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)
            el_type = lookup_pointer_type (el_type);
@@ -903,7 +903,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
          length = (long) extract_signed_integer (buf4, 4);
          index = (long) value_as_long (arg2);
          if (index >= length || index < 0)
-           error ("array index (%ld) out of bounds (length: %ld)",
+           error (_("array index (%ld) out of bounds (length: %ld)"),
                   index, length);
          address = (address + 4) + index * TYPE_LENGTH (el_type);
          return value_at (el_type, address);
@@ -916,9 +916,9 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
            return value_subscript (arg1, arg2);
        }
       if (name)
-       error ("cannot subscript something of type `%s'", name);
+       error (_("cannot subscript something of type `%s'"), name);
       else
-       error ("cannot subscript requested type");
+       error (_("cannot subscript requested type"));
 
     case OP_STRING:
       (*pos)++;
@@ -928,7 +928,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
        goto nosideret;
       return java_value_string (&exp->elts[pc + 2].string, i);
 
-    case STRUCTOP_STRUCT:
+    case STRUCTOP_PTR:
       arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
       /* Convert object field (such as TYPE.class) to reference. */
       if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_STRUCT)
@@ -1114,6 +1114,7 @@ const struct language_defn java_language_defn =
   NULL,
   default_word_break_characters,
   c_language_arch_info,
+  default_print_array_index,
   LANG_MAGIC
 };