asan: som: heap-buffer-overflow
[deliverable/binutils-gdb.git] / gdb / compile / compile-cplus-symbols.c
index 234b97783bc055ed6271f7a95a5db34a83b123df..65b27f89e7bc870f4631a7f4bfaaa3380df52b01 100644 (file)
@@ -1,6 +1,6 @@
 /* Convert symbols from GDB to GCC
 
-   Copyright (C) 2014-2018 Free Software Foundation, Inc.
+   Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,7 +21,7 @@
 #include "defs.h"
 #include "compile-internal.h"
 #include "compile-cplus.h"
-#include "gdb_assert.h"
+#include "gdbsupport/gdb_assert.h"
 #include "symtab.h"
 #include "parser-defs.h"
 #include "block.h"
@@ -100,27 +100,27 @@ convert_one_symbol (compile_cplus_instance *instance,
              return;
            }
          instance->plugin ().build_constant
-           (sym_type, SYMBOL_NATURAL_NAME (sym.symbol),
+           (sym_type, sym.symbol->natural_name (),
             SYMBOL_VALUE (sym.symbol), filename, line);
          return;
 
        case LOC_CONST_BYTES:
          error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."),
-                SYMBOL_PRINT_NAME (sym.symbol));
+                sym.symbol->print_name ());
 
        case LOC_UNDEF:
          internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."),
-                         SYMBOL_PRINT_NAME (sym.symbol));
+                         sym.symbol->print_name ());
 
        case LOC_COMMON_BLOCK:
          error (_("Fortran common block is unsupported for compilation "
                   "evaluaton of symbol \"%s\"."),
-                SYMBOL_PRINT_NAME (sym.symbol));
+                sym.symbol->print_name ());
 
        case LOC_OPTIMIZED_OUT:
          error (_("Symbol \"%s\" cannot be used for compilation evaluation "
                   "as it is optimized out."),
-                SYMBOL_PRINT_NAME (sym.symbol));
+                sym.symbol->print_name ());
 
        case LOC_COMPUTED:
          if (is_local)
@@ -129,7 +129,7 @@ convert_one_symbol (compile_cplus_instance *instance,
          warning (_("Symbol \"%s\" is thread-local and currently can only "
                     "be referenced from the current thread in "
                     "compiled code."),
-                  SYMBOL_PRINT_NAME (sym.symbol));
+                  sym.symbol->print_name ());
          /* FALLTHROUGH */
        case LOC_UNRESOLVED:
          /* 'symbol_name' cannot be used here as that one is used only for
@@ -146,14 +146,14 @@ convert_one_symbol (compile_cplus_instance *instance,
                if (frame == nullptr)
                  error (_("Symbol \"%s\" cannot be used because "
                           "there is no selected frame"),
-                        SYMBOL_PRINT_NAME (sym.symbol));
+                        sym.symbol->print_name ());
              }
 
            val = read_var_value (sym.symbol, sym.block, frame);
            if (VALUE_LVAL (val) != lval_memory)
              error (_("Symbol \"%s\" cannot be used for compilation "
                       "evaluation as its address has not been found."),
-                    SYMBOL_PRINT_NAME (sym.symbol));
+                    sym.symbol->print_name ());
 
            kind = GCC_CP_SYMBOL_VARIABLE;
            addr = value_address (val);
@@ -184,29 +184,27 @@ convert_one_symbol (compile_cplus_instance *instance,
       /* Don't emit local variable decls for a raw expression.  */
       if (instance->scope () != COMPILE_I_RAW_SCOPE || symbol_name == nullptr)
        {
-         compile_scope scope;
-
          /* For non-local symbols, create/push a new scope so that the
             symbol is properly scoped to the plug-in.  */
          if (!is_local)
            {
-             scope
-               = instance->new_scope (SYMBOL_NATURAL_NAME (sym.symbol),
+             compile_scope scope
+               = instance->new_scope (sym.symbol->natural_name (),
                                       SYMBOL_TYPE (sym.symbol));
              if (scope.nested_type () != GCC_TYPE_NONE)
                {
                  /* We found a symbol for this type that was defined inside
-                    some other symbol, e.g., a class tyepdef defined.  */
+                    some other symbol, e.g., a class typedef defined.  */
                  return;
                }
 
-             instance->enter_scope (scope);
+             instance->enter_scope (std::move (scope));
            }
 
          /* Get the `raw' name of the symbol.  */
-         if (name.empty () && SYMBOL_NATURAL_NAME (sym.symbol) != nullptr)
+         if (name.empty () && sym.symbol->natural_name () != nullptr)
            name = compile_cplus_instance::decl_name
-             (SYMBOL_NATURAL_NAME (sym.symbol)).get ();
+             (sym.symbol->natural_name ()).get ();
 
          /* Define the decl.  */
          instance->plugin ().build_decl
@@ -325,7 +323,7 @@ convert_symbol_bmsym (compile_cplus_instance *instance,
   sym_type = instance->convert_type (type);
   instance->plugin ().push_namespace ("");
   instance->plugin ().build_decl
-    ("minsym", MSYMBOL_NATURAL_NAME (msym), kind, sym_type, nullptr, addr,
+    ("minsym", msym->natural_name (), kind, sym_type, nullptr, addr,
      nullptr, 0);
   instance->plugin ().pop_binding_level ("");
 }
@@ -345,7 +343,7 @@ gcc_cplus_convert_symbol (void *datum,
   bool found = false;
   compile_cplus_instance *instance = (compile_cplus_instance *) datum;
 
-  TRY
+  try
     {
       /* Symbol searching is a three part process unfortunately.  */
 
@@ -390,13 +388,12 @@ gcc_cplus_convert_symbol (void *datum,
            }
        }
     }
-  CATCH (e, RETURN_MASK_ALL)
+  catch (const gdb_exception &e)
     {
       /* We can't allow exceptions to escape out of this callback.  Safest
         is to simply emit a gcc error.  */
-      instance->plugin ().error (e.message);
+      instance->plugin ().error (e.what ());
     }
-  END_CATCH
 
   if (compile_debug && !found)
     fprintf_unfiltered (gdb_stdlog,
@@ -433,7 +430,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
 
   /* We can't allow exceptions to escape out of this callback.  Safest
      is to simply emit a gcc error.  */
-  TRY
+  try
     {
       struct symbol *sym
        = lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol;
@@ -469,11 +466,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
        }
     }
 
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
-      instance->plugin ().error (e.message);
+      instance->plugin ().error (e.what ());
     }
-  END_CATCH
 
   if (compile_debug && !found)
     fprintf_unfiltered (gdb_stdlog,
This page took 0.02627 seconds and 4 git commands to generate.