daily update
[deliverable/binutils-gdb.git] / gdb / jv-lang.c
index 3d153130f25c33abd83cebea2ccd64606b9fee30..30a75c077ade50b4b3a8bd1e7b439e6c7ea8c7c3 100644 (file)
@@ -62,6 +62,8 @@ 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. */
@@ -104,19 +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 = allocate_block (&objfile->symbol_obstack);
-      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);
       BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
 
       /* Allocate GLOBAL_BLOCK.  */
-      bl = allocate_block (&objfile->symbol_obstack);
+      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;
@@ -139,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);
@@ -488,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));
@@ -559,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;
@@ -975,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.  */
@@ -1029,13 +1084,14 @@ 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,
   &exp_descriptor_java,
   java_parse,
   java_error,
+  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 */
@@ -1048,6 +1104,7 @@ const struct language_defn java_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   java_demangle,               /* Language specific symbol demangler */
+  java_class_name_from_physname,/* Language specific class name */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -1055,8 +1112,9 @@ const struct language_defn java_language_defn =
   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.025452 seconds and 4 git commands to generate.