* hpux-core.c (thread_section_p): New function.
[deliverable/binutils-gdb.git] / gdb / jv-lang.c
index b76796301ec930b10b3cc14498cd06dbbe3e09b6..4b7cf28ede9fe4ef0a99ee5b752cc1eb5f76b2b2 100644 (file)
@@ -1,5 +1,5 @@
 /* Java language support routines for GDB, the GNU debugger.
-   Copyright 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -58,11 +58,12 @@ static void java_demangled_signature_copy (char *, char *);
 static struct symtab *get_java_class_symtab (void);
 static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
 static int java_class_is_primitive (struct value *clas);
-static struct type *java_lookup_type (char *signature);
 static struct value *java_value_string (char *ptr, int len);
 
 static void java_emit_char (int c, struct ui_file * stream, int quoter);
 
+static char *java_class_name_from_physname (const char *physname);
+
 /* This objfile contains symtabs that have been dynamically created
    to record dynamically loaded Java classes and dynamically
    compiled java methods. */
@@ -105,28 +106,19 @@ get_java_class_symtab (void)
       class_symtab = allocate_symtab ("<java-classes>", objfile);
       class_symtab->language = language_java;
       bv = (struct blockvector *)
-       obstack_alloc (&objfile->symbol_obstack,
+       obstack_alloc (&objfile->objfile_obstack,
                       sizeof (struct blockvector) + sizeof (struct block *));
       BLOCKVECTOR_NBLOCKS (bv) = 1;
       BLOCKVECTOR (class_symtab) = bv;
 
       /* Allocate dummy STATIC_BLOCK. */
-      bl = (struct block *)
-       obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
-      BLOCK_DICT (bl) = dict_create_linear (&objfile->symbol_obstack,
+      bl = allocate_block (&objfile->objfile_obstack);
+      BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack,
                                            NULL);
-      BLOCK_START (bl) = 0;
-      BLOCK_END (bl) = 0;
-      BLOCK_FUNCTION (bl) = NULL;
-      BLOCK_SUPERBLOCK (bl) = NULL;
-      BLOCK_NAMESPACE (bl) = NULL;
-      BLOCK_GCC_COMPILED (bl) = 0;
       BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
 
-      /* Allocate GLOBAL_BLOCK.  This has to be relocatable. */
-      bl = (struct block *)
-       obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
-      *bl = *BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+      /* Allocate GLOBAL_BLOCK.  */
+      bl = allocate_block (&objfile->objfile_obstack);
       BLOCK_DICT (bl) = dict_create_hashed_expandable ();
       BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
       class_symtab->free_func = free_class_block;
@@ -149,7 +141,7 @@ add_class_symbol (struct type *type, CORE_ADDR addr)
 {
   struct symbol *sym;
   sym = (struct symbol *)
-    obstack_alloc (&dynamics_objfile->symbol_obstack, sizeof (struct symbol));
+    obstack_alloc (&dynamics_objfile->objfile_obstack, sizeof (struct symbol));
   memset (sym, 0, sizeof (struct symbol));
   SYMBOL_LANGUAGE (sym) = language_java;
   DEPRECATED_SYMBOL_NAME (sym) = TYPE_TAG_NAME (type);
@@ -196,7 +188,7 @@ java_lookup_class (char *name)
   type = alloc_type (objfile);
   TYPE_CODE (type) = TYPE_CODE_STRUCT;
   INIT_CPLUS_SPECIFIC (type);
-  TYPE_TAG_NAME (type) = obsavestring (name, strlen (name), &objfile->type_obstack);
+  TYPE_TAG_NAME (type) = obsavestring (name, strlen (name), &objfile->objfile_obstack);
   TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
   TYPE ? = addr;
   return type;
@@ -299,7 +291,7 @@ type_from_class (struct value *clas)
   /* if clasloader non-null, prepend loader address. FIXME */
   temp = clas;
   utf8_name = value_struct_elt (&temp, NULL, "name", NULL, "structure");
-  name = get_java_utf8_name (&objfile->type_obstack, utf8_name);
+  name = get_java_utf8_name (&objfile->objfile_obstack, utf8_name);
   for (nptr = name; *nptr != 0; nptr++)
     {
       if (*nptr == '/')
@@ -319,7 +311,7 @@ type_from_class (struct value *clas)
       char *signature = name;
       int namelen = java_demangled_signature_length (signature);
       if (namelen > strlen (name))
-       name = obstack_alloc (&objfile->type_obstack, namelen + 1);
+       name = obstack_alloc (&objfile->objfile_obstack, namelen + 1);
       java_demangled_signature_copy (name, signature);
       name[namelen] = '\0';
       is_array = 1;
@@ -452,7 +444,7 @@ java_link_class_type (struct type *type, struct value *clas)
       temp = field;
       temp = value_struct_elt (&temp, NULL, "name", NULL, "structure");
       TYPE_FIELD_NAME (type, i) =
-       get_java_utf8_name (&objfile->type_obstack, temp);
+       get_java_utf8_name (&objfile->objfile_obstack, temp);
       temp = field;
       accflags = value_as_long (value_struct_elt (&temp, NULL, "accflags",
                                                  NULL, "structure"));
@@ -498,7 +490,7 @@ java_link_class_type (struct type *type, struct value *clas)
   TYPE_NFN_FIELDS_TOTAL (type) = nmethods;
   j = nmethods * sizeof (struct fn_field);
   fn_fields = (struct fn_field *)
-    obstack_alloc (&dynamics_objfile->symbol_obstack, j);
+    obstack_alloc (&dynamics_objfile->objfile_obstack, j);
   memset (fn_fields, 0, j);
   fn_fieldlists = (struct fn_fieldlist *)
     alloca (nmethods * sizeof (struct fn_fieldlist));
@@ -523,7 +515,7 @@ java_link_class_type (struct type *type, struct value *clas)
       /* Get method name. */
       temp = method;
       temp = value_struct_elt (&temp, NULL, "name", NULL, "structure");
-      mname = get_java_utf8_name (&objfile->type_obstack, temp);
+      mname = get_java_utf8_name (&objfile->objfile_obstack, temp);
       if (strcmp (mname, "<init>") == 0)
        mname = unqualified_name;
 
@@ -548,7 +540,7 @@ java_link_class_type (struct type *type, struct value *clas)
            {                   /* Found an existing method with the same name. */
              int l;
              if (mname != unqualified_name)
-               obstack_free (&objfile->type_obstack, mname);
+               obstack_free (&objfile->objfile_obstack, mname);
              mname = fn_fieldlists[j].name;
              fn_fieldlists[j].length++;
              k = i - k;        /* Index of new slot. */
@@ -569,7 +561,7 @@ java_link_class_type (struct type *type, struct value *clas)
 
   j = TYPE_NFN_FIELDS (type) * sizeof (struct fn_fieldlist);
   TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
-    obstack_alloc (&dynamics_objfile->symbol_obstack, j);
+    obstack_alloc (&dynamics_objfile->objfile_obstack, j);
   memcpy (TYPE_FN_FIELDLISTS (type), fn_fieldlists, j);
 
   return type;
@@ -773,19 +765,6 @@ java_demangle_type_signature (char *signature)
   return result;
 }
 
-struct type *
-java_lookup_type (char *signature)
-{
-  switch (signature[0])
-    {
-    case 'L':
-    case '[':
-      error ("java_lookup_type not fully implemented");
-    default:
-      return java_primitive_type (signature[0]);
-    }
-}
-
 /* Return the type of TYPE followed by DIMS pairs of [ ].
    If DIMS == 0, TYPE is returned. */
 
@@ -998,6 +977,59 @@ static char *java_demangle (const char *mangled, int options)
   return cplus_demangle (mangled, options | DMGL_JAVA);
 }
 
+/* Find the member function name of the demangled name NAME.  NAME
+   must be a method name including arguments, in order to correctly
+   locate the last component.
+
+   This function return a pointer to the first dot before the
+   member function name, or NULL if the name was not of the
+   expected form.  */
+
+static const char *
+java_find_last_component (const char *name)
+{
+  const char *p;
+
+  /* Find argument list.  */
+  p = strchr (name, '(');
+
+  if (p == NULL)
+    return NULL;
+
+  /* Back up and find first dot prior to argument list.  */
+  while (p > name && *p != '.')
+    p--;
+
+  if (p == name)
+    return NULL;
+
+  return p;
+}
+
+/* Return the name of the class containing method PHYSNAME.  */
+
+static char *
+java_class_name_from_physname (const char *physname) 
+{
+  char *ret = NULL;
+  const char *end;
+  int depth = 0;
+  char *demangled_name = java_demangle (physname, DMGL_PARAMS | DMGL_ANSI);
+
+  if (demangled_name == NULL)
+    return NULL;
+
+  end = java_find_last_component (demangled_name);
+  if (end != NULL)
+    {
+      ret = xmalloc (end - demangled_name + 1);
+      memcpy (ret, demangled_name, end - demangled_name);
+      ret[end - demangled_name] = '\0';
+    }
+
+  xfree (demangled_name);
+  return ret;
+}
 
 /* Table mapping opcodes into strings for printing operators
    and precedences of the operators.  */
@@ -1039,17 +1071,28 @@ const struct op_print java_op_print_tab[] =
   {NULL, 0, 0, 0}
 };
 
+const struct exp_descriptor exp_descriptor_java = 
+{
+  print_subexp_standard,
+  operator_length_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_java
+};
+
 const struct language_defn java_language_defn =
 {
   "java",                      /* Language name */
   language_java,
-  c_builtin_types,
+  NULL,
   range_check_off,
   type_check_off,
   case_sensitive_on,
+  array_row_major,
+  &exp_descriptor_java,
   java_parse,
   java_error,
-  evaluate_subexp_java,
+  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   java_emit_char,              /* Function to print a single character */
@@ -1060,15 +1103,15 @@ const struct language_defn java_language_defn =
   NULL,                                /* Language specific skip_trampoline */
   value_of_this,               /* value_of_this */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
   java_demangle,               /* Language specific symbol demangler */
-  {"", "", "", ""},            /* Binary format info */
-  {"0%lo", "0", "o", ""},      /* Octal format info */
-  {"%ld", "", "d", ""},                /* Decimal format info */
-  {"0x%lx", "0x", "x", ""},    /* Hex format info */
+  java_class_name_from_physname,/* Language specific class name */
   java_op_print_tab,           /* expression operators for printing */
   0,                           /* not c-style arrays */
   0,                           /* String lower bound */
-  &builtin_type_char,          /* Type of string elements */
+  NULL,
+  default_word_break_characters,
+  c_language_arch_info,
   LANG_MAGIC
 };
 
This page took 0.033885 seconds and 4 git commands to generate.