Rename common to gdbsupport
[deliverable/binutils-gdb.git] / gdb / cp-support.c
index 07265ef88db9f2a8291ca0055dd71bb4649e8635..562c6f155c7f48fc6dbf445ca0447213b13eb845 100644 (file)
@@ -34,9 +34,9 @@
 #include "cp-abi.h"
 #include "namespace.h"
 #include <signal.h>
-#include "common/gdb_setjmp.h"
+#include "gdbsupport/gdb_setjmp.h"
 #include "safe-ctype.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
@@ -155,7 +155,7 @@ inspect_type (struct demangle_parse_info *info,
     {
       sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol;
     }
-  catch (const gdb_exception_RETURN_MASK_ALL &except)
+  catch (const gdb_exception &except)
     {
       return 0;
     }
@@ -190,10 +190,20 @@ inspect_type (struct demangle_parse_info *info,
          /* Get the real type of the typedef.  */
          type = check_typedef (otype);
 
-         /* If the symbol is a namespace and its type name is no different
+         /* If the symbol name is the same as the original type name,
+            don't substitute.  That would cause infinite recursion in
+            symbol lookups, as the typedef symbol is often the first
+            found symbol in the symbol table.
+
+            However, this can happen in a number of situations, such as:
+
+            If the symbol is a namespace and its type name is no different
             than the name we looked up, this symbol is not a namespace
-            alias and does not need to be substituted.  */
-         if (TYPE_CODE (otype) == TYPE_CODE_NAMESPACE
+            alias and does not need to be substituted.
+
+            If the symbol is typedef and its type name is the same
+            as the symbol's name, e.g., "typedef struct foo foo;".  */
+         if (TYPE_NAME (type) != nullptr
              && strcmp (TYPE_NAME (type), name) == 0)
            return 0;
 
@@ -228,7 +238,7 @@ inspect_type (struct demangle_parse_info *info,
            }
          /* If type_print threw an exception, there is little point
             in continuing, so just bow out gracefully.  */
-         catch (const gdb_exception_RETURN_MASK_ERROR &except)
+         catch (const gdb_exception_error &except)
            {
              return 0;
            }
@@ -427,7 +437,7 @@ replace_typedefs (struct demangle_parse_info *info,
                  sym = lookup_symbol (local_name.get (), 0,
                                       VAR_DOMAIN, 0).symbol;
                }
-             catch (const gdb_exception_RETURN_MASK_ALL &except)
+             catch (const gdb_exception &except)
                {
                }
 
@@ -898,7 +908,7 @@ cp_remove_params_if_any (const char *demangled_name, bool completion_mode)
      we're completing / matching everything, avoid returning NULL
      which would make callers interpret the result as an error.  */
   if (demangled_name[0] == '\0' && completion_mode)
-    return gdb::unique_xmalloc_ptr<char> (xstrdup (""));
+    return make_unique_xstrdup ("");
 
   gdb::unique_xmalloc_ptr<char> without_params
     = cp_remove_params_1 (demangled_name, false);
This page took 0.028701 seconds and 4 git commands to generate.