Add a TRY_CATCH to get_prev_frame_always to better manage errors during unwind.
[deliverable/binutils-gdb.git] / gdb / cp-support.c
index b91bcdcdf3ff26f89b737270353e7d94b37f1425..91533e8e4ece62353232e610686e27c8dcf26f26 100644 (file)
@@ -1,5 +1,5 @@
 /* Helper routines for C++ support in GDB.
-   Copyright (C) 2002-2013 Free Software Foundation, Inc.
+   Copyright (C) 2002-2014 Free Software Foundation, Inc.
 
    Contributed by MontaVista Software.
 
@@ -20,7 +20,7 @@
 
 #include "defs.h"
 #include "cp-support.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "demangle.h"
 #include "gdb_assert.h"
 #include "gdbcmd.h"
@@ -35,6 +35,7 @@
 #include "expression.h"
 #include "value.h"
 #include "cp-abi.h"
+#include "language.h"
 
 #include "safe-ctype.h"
 
@@ -177,7 +178,29 @@ inspect_type (struct demangle_parse_info *info,
   sym = NULL;
   TRY_CATCH (except, RETURN_MASK_ALL)
   {
-    sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
+    /* It is not legal to have a typedef and tag name of the same
+       name in C++.  However, anonymous composite types that are defined
+       with a typedef ["typedef struct {...} anonymous_struct;"] WILL
+       have symbols for a TYPE_CODE_TYPEDEF (in VAR_DOMAIN) and a
+       TYPE_CODE_STRUCT (in STRUCT_DOMAIN).
+
+       If VAR_DOMAIN is searched first, it will return the TYPEDEF symbol,
+       and this function will never output the definition of the typedef,
+       since type_print is called below with SHOW = -1. [The typedef hash
+       is never initialized/used when SHOW <= 0 -- and the finder
+       (find_typedef_for_canonicalize) will always return NULL as a result.]
+
+       Consequently, type_print will eventually keep calling this function
+       to replace the typedef (via
+       print_name_maybe_canonical/cp_canonicalize_full).  This leads to
+       infinite recursion.
+
+       This can all be safely avoid by explicitly searching STRUCT_DOMAIN
+       first to find the structure definition.  */
+    if (current_language->la_language == language_cplus)
+      sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0);
+    if (sym == NULL)
+      sym = lookup_symbol (name, 0, VAR_DOMAIN, NULL);
   }
 
   if (except.reason >= 0 && sym != NULL)
This page took 0.029312 seconds and 4 git commands to generate.