]> Git Repo - binutils.git/blobdiff - gdb/compile/compile-cplus-types.c
Automatic date update in version.in
[binutils.git] / gdb / compile / compile-cplus-types.c
index 1bd083df8703260d5639f8163ec41f6703356813..bd90753eae17dfb09c8c00beb9f2cc68608af527 100644 (file)
@@ -1,6 +1,6 @@
 /* Convert types from GDB to GCC
 
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
+   Copyright (C) 2014-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -161,7 +161,7 @@ type_name_to_scope (const char *type_name, const struct block *block)
 
          scope.push_back (comp);
 
-         if (SYMBOL_TYPE (bsymbol.symbol)->code () != TYPE_CODE_NAMESPACE)
+         if (bsymbol.symbol->type ()->code () != TYPE_CODE_NAMESPACE)
            {
              /* We're done.  */
              break;
@@ -178,8 +178,7 @@ type_name_to_scope (const char *type_name, const struct block *block)
              /* This shouldn't happen since we are not attempting to
                 loop over user input.  This name is generated by GDB
                 from debug info.  */
-             internal_error (__FILE__, __LINE__,
-                             _("malformed TYPE_NAME during parsing"));
+             internal_error (_("malformed TYPE_NAME during parsing"));
            }
        }
     }
@@ -258,8 +257,8 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
     {
       if (debug_compile_cplus_scopes)
        {
-         fprintf_unfiltered (gdb_stdlog, "entering new scope %s\n",
-                             host_address_to_string (&m_scopes.back ()));
+         gdb_printf (gdb_stdlog, "entering new scope %s\n",
+                     host_address_to_string (&m_scopes.back ()));
        }
 
       /* Push the global namespace. */
@@ -271,7 +270,7 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
        (m_scopes.back ().begin (), m_scopes.back ().end () - 1,
         [this] (const scope_component &comp)
         {
-         gdb_assert (SYMBOL_TYPE (comp.bsymbol.symbol)->code ()
+         gdb_assert (comp.bsymbol.symbol->type ()->code ()
                      == TYPE_CODE_NAMESPACE);
 
          const char *ns = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr
@@ -284,8 +283,8 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
     {
       if (debug_compile_cplus_scopes)
        {
-         fprintf_unfiltered (gdb_stdlog, "staying in current scope -- "
-                             "scopes are identical\n");
+         gdb_printf (gdb_stdlog, "staying in current scope -- "
+                     "scopes are identical\n");
        }
     }
 }
@@ -305,15 +304,15 @@ compile_cplus_instance::leave_scope ()
     {
       if (debug_compile_cplus_scopes)
        {
-         fprintf_unfiltered (gdb_stdlog, "leaving scope %s\n",
-                             host_address_to_string (&current));
+         gdb_printf (gdb_stdlog, "leaving scope %s\n",
+                     host_address_to_string (&current));
        }
 
       /* Pop namespaces.  */
       std::for_each
        (current.begin (),current.end () - 1,
         [this] (const scope_component &comp) {
-         gdb_assert (SYMBOL_TYPE (comp.bsymbol.symbol)->code ()
+         gdb_assert (comp.bsymbol.symbol->type ()->code ()
                      == TYPE_CODE_NAMESPACE);
          this->plugin ().pop_binding_level (comp.name.c_str ());
        });
@@ -324,8 +323,8 @@ compile_cplus_instance::leave_scope ()
   else
     {
       if (debug_compile_cplus_scopes)
-       fprintf_unfiltered (gdb_stdlog,
-                           "identical scopes -- not leaving scope\n");
+       gdb_printf (gdb_stdlog,
+                   "identical scopes -- not leaving scope\n");
     }
 }
 
@@ -345,14 +344,14 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type)
         unqualified name of the type to process.  */
       scope_component &comp = scope.back ();
 
-      if (!types_equal (type, SYMBOL_TYPE (comp.bsymbol.symbol))
+      if (!types_equal (type, comp.bsymbol.symbol->type ())
          && (m_scopes.empty ()
              || (m_scopes.back ().back ().bsymbol.symbol
                  != comp.bsymbol.symbol)))
        {
          /* The type is defined inside another class(es).  Convert that
             type instead of defining this type.  */
-         convert_type (SYMBOL_TYPE (comp.bsymbol.symbol));
+         convert_type (comp.bsymbol.symbol->type ());
 
          /* If the original type (passed in to us) is defined in a nested
             class, the previous call will give us that type's gcc_type.
@@ -410,7 +409,7 @@ static gcc_type
 compile_cplus_convert_reference (compile_cplus_instance *instance,
                                 struct type *type)
 {
-  gcc_type target = instance->convert_type (TYPE_TARGET_TYPE (type));
+  gcc_type target = instance->convert_type (type->target_type ());
 
   enum gcc_cp_ref_qualifiers quals = GCC_CP_REF_QUAL_NONE;
   switch (type->code ())
@@ -442,7 +441,7 @@ static gcc_type
 compile_cplus_convert_pointer (compile_cplus_instance *instance,
                               struct type *type)
 {
-  gcc_type target = instance->convert_type (TYPE_TARGET_TYPE (type));
+  gcc_type target = instance->convert_type (type->target_type ());
 
   return instance->convert_pointer_base (target);
 }
@@ -454,7 +453,7 @@ compile_cplus_convert_array (compile_cplus_instance *instance,
                             struct type *type)
 {
   struct type *range = type->index_type ();
-  gcc_type element_type = instance->convert_type (TYPE_TARGET_TYPE (type));
+  gcc_type element_type = instance->convert_type (type->target_type ());
 
   if (range->bounds ()->low.kind () != PROP_CONST)
     {
@@ -603,7 +602,7 @@ compile_cplus_convert_struct_or_union_members
            {
            case FIELD_LOC_KIND_PHYSADDR:
              {
-               physaddr = TYPE_FIELD_STATIC_PHYSADDR (type, i);
+               physaddr = type->field (i).loc_physaddr ();
 
                instance->plugin ().build_decl
                  ("field physaddr", field_name,
@@ -614,7 +613,7 @@ compile_cplus_convert_struct_or_union_members
 
            case FIELD_LOC_KIND_PHYSNAME:
              {
-               const char *physname = TYPE_FIELD_STATIC_PHYSNAME (type, i);
+               const char *physname = type->field (i).loc_physname ();
                struct block_symbol sym
                  = lookup_symbol (physname, instance->block (),
                                   VAR_DOMAIN, nullptr);
@@ -625,10 +624,10 @@ compile_cplus_convert_struct_or_union_members
                       we can do but ignore this member.  */
                    continue;
                  }
-               const char *filename = symbol_symtab (sym.symbol)->filename;
-               unsigned int line = SYMBOL_LINE (sym.symbol);
+               const char *filename = sym.symbol->symtab ()->filename;
+               unsigned int line = sym.symbol->line ();
 
-               physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol);
+               physaddr = sym.symbol->value_address ();
                instance->plugin ().build_decl
                  ("field physname", field_name,
                   (GCC_CP_SYMBOL_VARIABLE| get_field_access_flag (type, i)),
@@ -648,7 +647,7 @@ compile_cplus_convert_struct_or_union_members
            | get_field_access_flag (type, i);
 
          if (bitsize == 0)
-           bitsize = 8 * TYPE_LENGTH (type->field (i).type ());
+           bitsize = 8 * type->field (i).type ()->length ();
 
          instance->plugin ().build_field
            (field_name, field_type, field_flags, bitsize,
@@ -697,7 +696,7 @@ compile_cplus_convert_memberptr (compile_cplus_instance *instance,
 
   gcc_type class_type = instance->convert_type (containing_class);
   gcc_type member_type
-    = instance->convert_type (TYPE_TARGET_TYPE (type));
+    = instance->convert_type (type->target_type ());
 
   return instance->plugin ().build_pointer_to_member_type
     (class_type, member_type);
@@ -764,9 +763,9 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
              continue;
            }
 
-         const char *filename = symbol_symtab (sym.symbol)->filename;
-         unsigned int line = SYMBOL_LINE (sym.symbol);
-         CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
+         const char *filename = sym.symbol->symtab ()->filename;
+         unsigned int line = sym.symbol->line ();
+         CORE_ADDR address = sym.symbol->value_block()->start ();
          const char *kind;
 
          if (TYPE_FN_FIELD_STATIC_P (methods, j))
@@ -891,7 +890,7 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance,
   compile_cplus_convert_struct_or_union_members (instance, type, result);
 
   /* All finished.  */
-  instance->plugin ().finish_class_type (name.get (), TYPE_LENGTH (type));
+  instance->plugin ().finish_class_type (name.get (), type->length ());
 
   /* Pop all scopes.  */
   instance->leave_scope ();
@@ -926,7 +925,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
 
   gcc_type int_type
     = instance->plugin ().get_int_type (type->is_unsigned (),
-                                       TYPE_LENGTH (type), nullptr);
+                                       type->length (), nullptr);
   gcc_type result
     = instance->plugin ().start_enum_type (name.get (), int_type,
                                           GCC_CP_SYMBOL_ENUM | nested_access
@@ -961,7 +960,7 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
                            struct type *type, bool strip_artificial)
 {
   int is_varargs = type->has_varargs ();
-  struct type *target_type = TYPE_TARGET_TYPE (type);
+  struct type *target_type = type->target_type ();
 
   /* Functions with no debug info have no return type.  Ideally we'd
      want to fallback to the type of the cast just before the
@@ -1012,12 +1011,12 @@ compile_cplus_convert_int (compile_cplus_instance *instance, struct type *type)
 {
   if (type->has_no_signedness ())
     {
-      gdb_assert (TYPE_LENGTH (type) == 1);
+      gdb_assert (type->length () == 1);
       return instance->plugin ().get_char_type ();
     }
 
   return instance->plugin ().get_int_type
-    (type->is_unsigned (), TYPE_LENGTH (type), type->name ());
+    (type->is_unsigned (), type->length (), type->name ());
 }
 
 /* Convert a floating-point type to its gcc representation.  */
@@ -1027,7 +1026,7 @@ compile_cplus_convert_float (compile_cplus_instance *instance,
                             struct type *type)
 {
   return instance->plugin ().get_float_type
-    (TYPE_LENGTH (type), type->name ());
+    (type->length (), type->name ());
 }
 
 /* Convert the 'void' type to its gcc representation.  */
@@ -1086,7 +1085,7 @@ static gcc_type
 compile_cplus_convert_complex (compile_cplus_instance *instance,
                               struct type *type)
 {
-  gcc_type base = instance->convert_type (TYPE_TARGET_TYPE (type));
+  gcc_type base = instance->convert_type (type->target_type ());
 
   return instance->plugin ().build_complex_type (base);
 }
@@ -1239,16 +1238,16 @@ compile_cplus_instance::gcc_cplus_leave_scope
 static void
 compile_cplus_debug_output_1 (ULONGEST arg)
 {
-  fprintf_unfiltered (gdb_stdlog, "%s", pulongest (arg));
+  gdb_printf (gdb_stdlog, "%s", pulongest (arg));
 }
 
 static void
 compile_cplus_debug_output_1 (const char *arg)
 {
   if (arg == nullptr)
-    fputs_unfiltered ("NULL", gdb_stdlog);
+    gdb_puts ("NULL", gdb_stdlog);
   else
-    fputs_unfiltered (arg, gdb_stdlog);
+    gdb_puts (arg, gdb_stdlog);
 }
 
 static void
@@ -1267,7 +1266,7 @@ static void
 compile_cplus_debug_output (T arg, Targs... Args)
 {
   compile_cplus_debug_output_1 (arg);
-  fputc_unfiltered (' ', gdb_stdlog);
+  gdb_putc (' ', gdb_stdlog);
   compile_cplus_debug_output (Args...);
 }
 
@@ -1275,9 +1274,9 @@ compile_cplus_debug_output (T arg, Targs... Args)
 #define OUTPUT_DEBUG_RESULT(R)                   \
   if (debug_compile_cplus_types)                 \
     {                                            \
-      fputs_unfiltered (": ", gdb_stdlog);       \
+      gdb_puts (": ", gdb_stdlog);               \
       compile_cplus_debug_output (R);            \
-      fputc_unfiltered ('\n', gdb_stdlog);       \
+      gdb_putc ('\n', gdb_stdlog);               \
     }                                            \
 
 #define GCC_METHOD0(R, N)                        \
@@ -1363,7 +1362,7 @@ gcc_cp_plugin::build_decl (const char *debug_decltype, const char *name,
                           const char *filename, unsigned int line_number)
 {
   if (debug_compile_cplus_types)
-    fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_decltype);
+    gdb_printf (gdb_stdlog, "<%s> ", debug_decltype);
 
   return build_decl (name, sym_kind, sym_type, substitution_name,
                     address, filename, line_number);
@@ -1375,7 +1374,7 @@ gcc_cp_plugin::start_class_type (const char *debug_name, gcc_decl typedecl,
                                 const char *filename, unsigned int line_number)
 {
   if (debug_compile_cplus_types)
-    fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
+    gdb_printf (gdb_stdlog, "<%s> ", debug_name);
 
   return start_class_type (typedecl, base_classes, filename, line_number);
 }
@@ -1385,7 +1384,7 @@ gcc_cp_plugin::finish_class_type (const char *debug_name,
                                  unsigned long size_in_bytes)
 {
   if (debug_compile_cplus_types)
-    fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
+    gdb_printf (gdb_stdlog, "<%s> ", debug_name);
 
   return finish_class_type (size_in_bytes);
 }
@@ -1394,7 +1393,7 @@ int
 gcc_cp_plugin::pop_binding_level (const char *debug_name)
 {
   if (debug_compile_cplus_types)
-    fprintf_unfiltered (gdb_stdlog, "<%s> ", debug_name);
+    gdb_printf (gdb_stdlog, "<%s> ", debug_name);
 
   return pop_binding_level ();
 }
This page took 0.042193 seconds and 4 git commands to generate.