]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2004-07-06 Jeff Johnston <jjohnstn@redhat.com>
authorJeff Johnston <jjohnstn@redhat.com>
Tue, 6 Jul 2004 19:29:31 +0000 (19:29 +0000)
committerJeff Johnston <jjohnstn@redhat.com>
Tue, 6 Jul 2004 19:29:31 +0000 (19:29 +0000)
        * language.h (struct_language_defn): Add new function pointer:
        la_class_name_from_physname.  Also add new prototype for
        language_class_name_from_physname.
        * language.c (language_class_name_from_physname): New function.
        (unk_lang_class_name): Ditto.
        (unknown_language_defn, auto_language_defn): Change
        to add unk_lang_class_name function pointer for
        la_class_name_from_physname.
        (local_language_defn): Ditto.
        * dwarf2read.c (guess_structure_name): Change to call
        language_class_name_from_physname.
        (determine_class_name): Ditto.
        * cp-support.c (class_name_from_physname): Renamed.
        (cp_class_name_from_physname): New name of function.
        * cp-support.h: Ditto.
        * c-lang.c (c_language_defn): Change to add NULL
        for class_name_from_physname function pointer.
        (cplus_language_defn): Change to add cp_class_name_from_physname.
        * jv-lang.c (java_class_name_physname): New function.
        (java_find_last_component): New static routine.
        (java_language_defn): Add java_class_name_from_physname pointer.
        * ada-lang.c (ada_language_defn): Change to add NULL
        for class_name_from_physname function pointer.
        * f-lang.c (f_language_defn): Ditto.
        * m2-lang.c (m2_language_defn): Ditto.
        * objc-lang.c (objc_language_defn): Ditto.
        * p-lang.c (pascal_language_defn): Ditto.
        * scm-lang.c (scm_language_defn): Ditto.

14 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/cp-support.c
gdb/cp-support.h
gdb/dwarf2read.c
gdb/f-lang.c
gdb/jv-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/p-lang.c
gdb/scm-lang.c

index d16379d4994daf3e1d937fcd829e4635f986c323..8f694501ce4cce26e2bdab68b81239d24e2a95db 100644 (file)
@@ -1,3 +1,34 @@
+2004-07-06  Jeff Johnston <jjohnstn@redhat.com>
+
+       * language.h (struct_language_defn): Add new function pointer:
+       la_class_name_from_physname.  Also add new prototype for
+       language_class_name_from_physname.
+       * language.c (language_class_name_from_physname): New function.
+       (unk_lang_class_name): Ditto.
+       (unknown_language_defn, auto_language_defn): Change
+       to add unk_lang_class_name function pointer for
+       la_class_name_from_physname.
+       (local_language_defn): Ditto.
+       * dwarf2read.c (guess_structure_name): Change to call
+       language_class_name_from_physname.
+       (determine_class_name): Ditto.
+       * cp-support.c (class_name_from_physname): Renamed.
+       (cp_class_name_from_physname): New name of function.
+       * cp-support.h: Ditto.
+       * c-lang.c (c_language_defn): Change to add NULL
+       for class_name_from_physname function pointer.
+       (cplus_language_defn): Change to add cp_class_name_from_physname.
+       * jv-lang.c (java_class_name_physname): New function.
+       (java_find_last_component): New static routine.
+       (java_language_defn): Add java_class_name_from_physname pointer.
+       * ada-lang.c (ada_language_defn): Change to add NULL
+       for class_name_from_physname function pointer.
+       * f-lang.c (f_language_defn): Ditto.
+       * m2-lang.c (m2_language_defn): Ditto.
+       * objc-lang.c (objc_language_defn): Ditto.
+       * p-lang.c (pascal_language_defn): Ditto.
+       * scm-lang.c (scm_language_defn): Ditto. 
+
 2004-07-06  Andrew Cagney  <cagney@gnu.org>
 
        Patch from Bart Robinson.
index b99e19786ff11661e41f648dd085b687900bf7ee..ad5ec1c1365e5070305e30a6dcc0547166fcd0de 100644 (file)
@@ -10144,6 +10144,7 @@ const struct language_defn ada_language_defn = {
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
   basic_lookup_transparent_type,        /* lookup_transparent_type */
   ada_la_decode,                /* Language specific symbol demangler */
+  NULL,                         /* Language specific class_name_from_physname */
   {"", "", "", ""},             /* Binary format info */
 #if 0
   {"8#%lo#", "8#", "o", "#"},   /* Octal format info */
index 3b52890309aeed5449c7508396ddd9a1cef44a0b..19c08dc44155a6311356cd676bb454d026c5bfad 100644 (file)
@@ -559,6 +559,7 @@ const struct language_defn c_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -618,6 +619,7 @@ const struct language_defn cplus_language_defn =
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
   cp_lookup_transparent_type,   /* lookup_transparent_type */
   cplus_demangle,              /* Language specific symbol demangler */
+  cp_class_name_from_physname,  /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -654,6 +656,7 @@ const struct language_defn asm_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -695,6 +698,7 @@ const struct language_defn minimal_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
index 4344545c3e9bcd841ce5f3f497dd1b199474f92b..a182dd9a2323bc103a8e310f9e495105a3b8c7d7 100644 (file)
@@ -148,7 +148,7 @@ find_last_component (const char *name)
 /* Return the name of the class containing method PHYSNAME.  */
 
 char *
-class_name_from_physname (const char *physname)
+cp_class_name_from_physname (const char *physname)
 {
   char *ret = NULL;
   const char *end;
index bbf911a387fb0187f1791f88757030aa19f732fb..569aeacb7d214c87f64ab64385d4ddef918d010c 100644 (file)
@@ -52,7 +52,7 @@ struct using_direct
 
 /* Functions from cp-support.c.  */
 
-extern char *class_name_from_physname (const char *physname);
+extern char *cp_class_name_from_physname (const char *physname);
 
 extern char *method_name_from_physname (const char *physname);
 
index c1f6c654f332e35d075588530e582c03a4bc0c7b..845672d0afade8625a3cf11ccd9530960dc54050 100644 (file)
@@ -1840,7 +1840,8 @@ guess_structure_name (struct partial_die_info *struct_pdi,
          if (child_pdi->tag == DW_TAG_subprogram)
            {
              char *actual_class_name
-               = class_name_from_physname (child_pdi->name);
+               = language_class_name_from_physname (cu->language_defn,
+                                                    child_pdi->name);
              if (actual_class_name != NULL)
                {
                  struct_pdi->name
@@ -3557,7 +3558,9 @@ determine_class_name (struct die_info *die, struct dwarf2_cu *cu)
        {
          if (child->tag == DW_TAG_subprogram)
            {
-             new_prefix = class_name_from_physname (dwarf2_linkage_name
+             new_prefix 
+               = language_class_name_from_physname (cu->language_defn,
+                                                    dwarf2_linkage_name
                                                     (child, cu));
 
              if (new_prefix != NULL)
index 0e30c70dd0dee214314caa4c097019aa1c6d8ea0..4219d4539e4da195d8e0f606882192a89ce14d50 100644 (file)
@@ -478,6 +478,7 @@ const struct language_defn f_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%o", "0", "o", ""},       /* Octal format info */
   {"%d", "", "d", ""},         /* Decimal format info */
index e84019168321ecfd065ebe814737b6d44599c255..1fb8cd2d2ba1db04da66dfb8d9fcd3f3dbd664f1 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. */
@@ -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.  */
@@ -1049,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 */
index b4d38ea364a1c41770d3efee6e7b9bd838903720..dae3e809a4b36a3d60239e6929c9cc33a8af6d08 100644 (file)
@@ -1176,6 +1176,16 @@ language_demangle (const struct language_defn *current_language,
   return NULL;
 }
 
+/* Return class name from physname or NULL.  */
+char *
+language_class_name_from_physname (const struct language_defn *current_language,
+                                  const char *physname)
+{
+  if (current_language != NULL && current_language->la_class_name_from_physname)
+    return current_language->la_class_name_from_physname (physname);
+  return NULL;
+}
+
 /* Return the default string containing the list of characters
    delimiting words.  This is a reasonable default value that
    most languages should be able to use.  */
@@ -1258,6 +1268,10 @@ static char *unk_lang_demangle (const char *mangled, int options)
   return cplus_demangle (mangled, options);
 }
 
+static char *unk_lang_class_name (const char *mangled)
+{
+  return NULL;
+}
 
 static struct type **const (unknown_builtin_types[]) =
 {
@@ -1292,6 +1306,7 @@ const struct language_defn unknown_language_defn =
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
+  unk_lang_class_name,         /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -1329,6 +1344,7 @@ const struct language_defn auto_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
+  unk_lang_class_name,         /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -1365,6 +1381,7 @@ const struct language_defn local_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
+  unk_lang_class_name,         /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
index 27c1491d76d6bc949641dcc5cfbb85cf7ee84edf..bbb45f6c7b892f9f86f877118368b4fcf02ee652 100644 (file)
@@ -247,6 +247,9 @@ struct language_defn
     /* Return demangled language symbol, or NULL.  */
     char *(*la_demangle) (const char *mangled, int options);
 
+    /* Return class name of a mangled method name or NULL.  */
+    char *(*la_class_name_from_physname) (const char *physname);
+
     /* Base 2 (binary) formats. */
 
     struct language_format_info la_binary_format;
@@ -516,6 +519,10 @@ extern CORE_ADDR skip_language_trampoline (CORE_ADDR pc);
 extern char *language_demangle (const struct language_defn *current_language, 
                                const char *mangled, int options);
 
+/* Return class name from physname, or NULL.  */
+extern char *language_class_name_from_physname (const struct language_defn *,
+                                               const char *physname);
+
 /* Splitting strings into words.  */
 extern char *default_word_break_characters (void);
 
index c66b70341e2ba0f304dbcd0f55e880cf99ef4508..1ab5d3b7a4e29c243606bc4eb0ab5ab6ecda2ee2 100644 (file)
@@ -431,6 +431,7 @@ const struct language_defn m2_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"%loB", "", "o", "B"},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
index ecbce77b1906bbdf7c26cafd4cb91fd7c9b74d01..bcd487378bc248b9ecc49947ebfdebadffe8bb77 100644 (file)
@@ -675,6 +675,7 @@ const struct language_defn objc_language_defn = {
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   objc_demangle,               /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"",     "",    "",  ""},    /* Binary format info */
   {"0%lo",  "0",   "o", ""},   /* Octal format info */
   {"%ld",   "",    "d", ""},   /* Decimal format info */
index 9ab55734a1d0c8a6ca55dd0db926d7a33c8b7bb0..3866e2cd6600ea2b588167baa391be873b38cc7f 100644 (file)
@@ -467,6 +467,7 @@ const struct language_defn pascal_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "%", "b", ""},          /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
index 1c410766963ec84ba0cb404bbd38f381ced7f945..665ac1b96bf56f9a7fbcf76bbea4913002dd3f87 100644 (file)
@@ -266,6 +266,7 @@ const struct language_defn scm_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
+  NULL,                                /* Language specific class_name_from_physname */
   {"", "", "", ""},            /* Binary format info */
   {"#o%lo", "#o", "o", ""},    /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */