]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Cleanups from precursor patch submissions.
authorKeith Seitz <keiths@redhat.com>
Wed, 8 Feb 2017 19:54:55 +0000 (11:54 -0800)
committerKeith Seitz <keiths@redhat.com>
Wed, 8 Feb 2017 19:54:55 +0000 (11:54 -0800)
gdb/compile/compile-cplus-symbols.c
gdb/cp-support.c
gdb/dwarf2read.c
gdb/linespec.c
gdb/linespec.h
gdb/utils.c
gdb/utils.h

index 61d672515d760455ef0c3efa6cb88f04f7e6ec3e..cbd4cdaa14e754e1ae43d33d9f3d9122a5b650d9 100644 (file)
@@ -111,7 +111,6 @@ convert_one_symbol (compile_cplus_instance *instance,
              addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
 
            special_name = NULL;
-           //cp_find_method_field (sym.symbol, 1);
            func_name = maybe_canonicalize_special_function
              (SYMBOL_LINKAGE_NAME (sym.symbol), NULL,
               SYMBOL_TYPE (sym.symbol), &special_name, &ignore);
index 926308ecde2cbb1876c72279e463df26a6e89788..cbd3c550688e19b38d70c2cd56660cf7504d2ebc 100644 (file)
@@ -36,7 +36,6 @@
 #include <signal.h>
 #include "gdb_setjmp.h"
 #include "safe-ctype.h"
-#include "linespec.h"          /* for find_toplevel_char_r  */
 
 /* Functions related to demangled name parsing.  */
 
@@ -831,99 +830,9 @@ cp_func_name (const char *full_name)
 char *
 cp_strip_template_parameters (const char *linkage_or_phys_name)
 {
-  /* This is by far the best way to do this, but there is one really big
-     problem... The code below resets the the top-level node to below the
-     (first) DEMANGLE_COMPONENT_TEMPLATE node in the tree.
-
-     Normally that works, however, there is a special case (of course!)
-     where this fails: conversion operators.  Those *require* the template
-     parameter to deduce the name of the operator.  As a result, the code
-     below will not work on conversion operators at all (and maybe others).  */
-#if 0
-  struct demangle_component *ret_comp;
-  struct demangle_parse_info *info;
-  void *storage = NULL;
-  char *ret, *str = NULL, *demangled_name = NULL;
-
-  info = cp_mangled_name_to_comp (linkage_or_phys_name, DMGL_ANSI,
-                                 &storage, &demangled_name);
-
-  if (info == NULL)
-    {
-      info = cp_demangled_name_to_comp (linkage_or_phys_name, NULL);
-      if (info == NULL)
-       {
-         char *p;
-
-         /* Special case: cp_demangled_name_to_comp doesn't like
-            template specializations, templatename<>.  Adjust for that
-            here until libiberty is fixed.  */
-         str = xstrdup (linkage_or_phys_name);
-         p = strstr (str, "<>");
-         if (p == NULL)
-           return NULL;
-
-         *p = '\0';
-         info = cp_demangled_name_to_comp (str, NULL);
-         if (info == NULL)
-           {
-             xfree (str);
-             return NULL;
-           }
-       }
-    }
-
-  ret_comp = info->tree;
-  ret = NULL;
-  if (ret_comp != NULL)
-    {
-      int done = 0;
-
-      while (!done)
-       {
-         switch (ret_comp->type)
-           {
-           case DEMANGLE_COMPONENT_QUAL_NAME:
-           case DEMANGLE_COMPONENT_LOCAL_NAME:
-             ret_comp = d_right (ret_comp);
-             break;
-           case DEMANGLE_COMPONENT_TYPED_NAME:
-           case DEMANGLE_COMPONENT_CONST:
-           case DEMANGLE_COMPONENT_RESTRICT:
-           case DEMANGLE_COMPONENT_VOLATILE:
-           case DEMANGLE_COMPONENT_CONST_THIS:
-           case DEMANGLE_COMPONENT_RESTRICT_THIS:
-           case DEMANGLE_COMPONENT_VOLATILE_THIS:
-           case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
-             ret_comp = d_left (ret_comp);
-             break;
-           case DEMANGLE_COMPONENT_TEMPLATE:
-             ret_comp = d_left (ret_comp);
-             if (ret_comp->type == DEMANGLE_COMPONENT_QUAL_NAME
-                 && d_right (ret_comp)->type == DEMANGLE_COMPONENT_CONVERSION)
-               {
-                 /* Remove the template parameter, replacing this
-                    node with a NAME node.  */
-                 /* !!keiths: Can't be done without modifications to
-                    libiberty *or* reimplementing the entire libiberty
-                    printer (d_print_comp_inner).  */
-                 /* !!keiths: Is there any other option???  */
-               }
-             /* fall through */
-           default:
-             done = 1;
-             break;
-           }
-       }
-    }
-
-  ret = cp_comp_to_string (ret_comp, 10);
-  cp_demangled_name_parse_free (info);
-  xfree (storage);
-  xfree (demangled_name);
-  xfree (str);
-  return ret;
-#else
+  /* We do not turn the linkage name into demangle components since we cannot
+     walk the tree in any usable way when dealing with conversion operators.
+     Instead we use a heuristic approach that works for all cases.  */
   char *stripped = NULL;
   const char *name;
 
@@ -934,8 +843,7 @@ cp_strip_template_parameters (const char *linkage_or_phys_name)
     name = linkage_or_phys_name;
 
   /* Only attempt to strip this if it looks like a template.  */
-  if (strchr (name, '<') != NULL
-      && strchr (name, '>') != NULL)
+  if (strchr (name, '<') != NULL && strchr (name, '>') != NULL)
     {
       const char *p;
       size_t len = strlen (name) - 1;
@@ -957,9 +865,7 @@ cp_strip_template_parameters (const char *linkage_or_phys_name)
     }
 
   xfree (demangled_name);
-  //printf ("stripped = \"%s\"\n", stripped);
   return stripped;
-#endif
 }
 
 /* DEMANGLED_NAME is the name of a function, including parameters and
index a3b75c3a345f7c98aef66cfd35145334ee3c5d13..9f8ef405ec0add7b634cfe48dbeb4fc986993326 100644 (file)
@@ -11704,8 +11704,6 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
   /* Attach template arguments to function.  */
   if (! VEC_empty (symbolp, template_args))
     {
-      const char *linkage_name;
-
       gdb_assert (templ_func != NULL);
 
       templ_func->template_arguments
@@ -11737,7 +11735,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
       /* Determine whether the template's return and argument types were
         specified using template parameters.  */
-      linkage_name = dw2_linkage_name (die, cu);
+      const char *linkage_name = dw2_linkage_name (die, cu);
       templ_func->linkage_name = linkage_name;
       if (linkage_name != NULL)
        {
@@ -12938,9 +12936,11 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die,
     accessibility = dwarf2_default_access_attribute (die, cu);
   switch (accessibility)
     {
+#if 1
     case DW_ACCESS_public:
       fp->is_public = 1;
       break;
+#endif
     case DW_ACCESS_private:
       fp->is_private = 1;
       break;
index ef6dc5a6c3866e2eee6cfcd4a81f62ba4743d937..5031c6a63f0f2cc977120ba6bc0003025a8baa2e 100644 (file)
@@ -1132,101 +1132,6 @@ find_methods (struct type *t, const char *name,
     VEC_safe_push (typep, *superclasses, TYPE_BASECLASS (t, ibase));
 }
 
-/* Find an instance of the character C in the string S that is outside
-   of all parenthesis pairs, single-quoted strings, and double-quoted
-   strings.  Also, ignore the char within a template name, like a ','
-   within foo<int, int>.  */
-
-const char *
-find_toplevel_char (const char *s, char c)
-{
-  int quoted = 0;              /* zero if we're not in quotes;
-                                  '"' if we're in a double-quoted string;
-                                  '\'' if we're in a single-quoted string.  */
-  int depth = 0;               /* Number of unclosed parens we've seen.  */
-  const char *scan;
-
-  for (scan = s; *scan; scan++)
-    {
-      if (quoted)
-       {
-         if (*scan == quoted)
-           quoted = 0;
-         else if (*scan == '\\' && *(scan + 1))
-           scan++;
-       }
-      else if (*scan == c && ! quoted && depth == 0)
-       return scan;
-      else if (*scan == '"' || *scan == '\'')
-       quoted = *scan;
-      else if (*scan == '(' || *scan == '<')
-       depth++;
-      else if ((*scan == ')' || *scan == '>') && depth > 0)
-       depth--;
-    }
-
-  return 0;
-}
-
-/* See description in linespec.h.  */
-
-const char *
-find_toplevel_char_r (const char *s, size_t len, char c)
-{
-  int quoted = 0;
-  int depth = 0;
-  const char *scan;
-
-  for (scan = s + len; scan >= s; --scan)
-    {
-      if (quoted)
-       {
-         if (*scan == quoted)
-           quoted = 0;
-       }
-      else if (*scan == ')' || *scan == '>')
-       ++depth;
-      else if ((*scan == '(' || *scan == '<') && depth > 0)
-       --depth;
-
-      if (*scan == c && !quoted && depth == 0)
-       return scan;
-      else if ((*scan == '"' || *scan == '\'')
-              && scan > s && *(scan - 1) != '\\')
-       quoted = *scan;
-    }
-
-  return NULL;
-}
-
-/* See linespec.h.  */
-
-const char *
-find_toplevel_string (const char *haystack, const char *needle)
-{
-  const char *s = haystack;
-
-  do
-    {
-      s = find_toplevel_char (s, *needle);
-
-      if (s != NULL)
-       {
-         /* Found first char in HAYSTACK;  check rest of string.  */
-         if (startswith (s, needle))
-           return s;
-
-         /* Didn't find it; loop over HAYSTACK, looking for the next
-            instance of the first character of NEEDLE.  */
-         ++s;
-       }
-    }
-  while (s != NULL && *s != '\0');
-
-  /* NEEDLE was not found in HAYSTACK.  */
-  return NULL;
-}
-
 /* Convert CANONICAL to its string representation using
    symtab_to_fullname for SYMTAB.  The caller must xfree the result.  */
 
index 4c58356c4fa72a282d81a4f7f7d813a8649b25c2..f4923a752e39707604ea7d447d1a7c571e1a060e 100644 (file)
@@ -175,25 +175,6 @@ extern const char *get_gdb_linespec_parser_quote_characters (void);
 
 extern int is_ada_operator (const char *string);
 
-/* Find an instance of the character C in the string S that is outside
-   of all parenthesis pairs, single-quoted strings, and double-quoted
-   strings.  Also, ignore the char within a template name, like a ','
-   within foo<int, int>.  */
-
-extern const char *find_toplevel_char (const char *s, char c);
-
-/* Like find_toplevel_char but searches S backwards, starting LEN characters
-   into S.  */
-
-extern const char *find_toplevel_char_r (const char *s, size_t len, char c);
-
-/* The string equivalent of find_toplevel_char.  Returns a pointer
-   to the location of NEEDLE in HAYSTACK, ignoring any occurrences
-   inside "()" and "<>".  Returns NULL if NEEDLE was not found.  */
-
-const char *find_toplevel_string (const char *haystack,
-                                 const char *needle);
-
 /* Find the end of the (first) linespec pointed to by *STRINGP.
    STRINGP will be advanced to this point.  */
 
index ab87143c755e767cfd23c69d177d0385aae4f9eb..8f4ca63a9f2b4501de3080c2c53113748417f81b 100644 (file)
@@ -3422,6 +3422,98 @@ strip_leading_path_elements (const char *path, int n)
   return p;
 }
 
+/* See description in utils.h.  */
+
+const char *
+find_toplevel_char (const char *s, char c)
+{
+  int quoted = 0;              /* zero if we're not in quotes;
+                                  '"' if we're in a double-quoted string;
+                                  '\'' if we're in a single-quoted string.  */
+  int depth = 0;               /* Number of unclosed parens we've seen.  */
+  const char *scan;
+
+  for (scan = s; *scan; scan++)
+    {
+      if (quoted)
+       {
+         if (*scan == quoted)
+           quoted = 0;
+         else if (*scan == '\\' && *(scan + 1))
+           scan++;
+       }
+      else if (*scan == c && ! quoted && depth == 0)
+       return scan;
+      else if (*scan == '"' || *scan == '\'')
+       quoted = *scan;
+      else if (*scan == '(' || *scan == '<')
+       depth++;
+      else if ((*scan == ')' || *scan == '>') && depth > 0)
+       depth--;
+    }
+
+  return 0;
+}
+
+/* See description in utils.h.  */
+
+const char *
+find_toplevel_char_r (const char *s, size_t len, char c)
+{
+  int quoted = 0;
+  int depth = 0;
+  const char *scan;
+
+  for (scan = s + len; scan >= s; --scan)
+    {
+      if (quoted)
+       {
+         if (*scan == quoted)
+           quoted = 0;
+       }
+      else if (*scan == ')' || *scan == '>')
+       ++depth;
+      else if ((*scan == '(' || *scan == '<') && depth > 0)
+       --depth;
+
+      if (*scan == c && !quoted && depth == 0)
+       return scan;
+      else if ((*scan == '"' || *scan == '\'')
+              && scan > s && *(scan - 1) != '\\')
+       quoted = *scan;
+    }
+
+  return NULL;
+}
+
+/* See description in utils.h.  */
+
+const char *
+find_toplevel_string (const char *haystack, const char *needle)
+{
+  const char *s = haystack;
+
+  do
+    {
+      s = find_toplevel_char (s, *needle);
+
+      if (s != NULL)
+       {
+         /* Found first char in HAYSTACK;  check rest of string.  */
+         if (startswith (s, needle))
+           return s;
+
+         /* Didn't find it; loop over HAYSTACK, looking for the next
+            instance of the first character of NEEDLE.  */
+         ++s;
+       }
+    }
+  while (s != NULL && *s != '\0');
+
+  /* NEEDLE was not found in HAYSTACK.  */
+  return NULL;
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_utils;
 
index 9e71cc2792ce4b1a663aca6f752748f1ff808d98..d587505611120d9f413901ad608c7af45aa6744a 100644 (file)
@@ -393,4 +393,22 @@ extern void dump_core (void);
 
 extern char *make_hex_string (const gdb_byte *data, size_t length);
 
+/* Find an instance of the character C in the string S that is outside
+   of all parenthesis pairs, single-quoted strings, and double-quoted
+   strings.  Also, ignore the char within a template name, like a ','
+   within foo<int, int>.  */
+
+extern const char *find_toplevel_char (const char *s, char c);
+
+/* Like find_toplevel_char but searches S backwards, starting LEN characters
+   into S.  */
+
+extern const char *find_toplevel_char_r (const char *s, size_t len, char c);
+
+/* The string equivalent of find_toplevel_char.  Returns a pointer
+   to the location of NEEDLE in HAYSTACK, ignoring any occurrences
+   inside "()" and "<>".  Returns NULL if NEEDLE was not found.  */
+
+const char *find_toplevel_string (const char *haystack, const char *needle);
+
 #endif /* UTILS_H */