Use an accessor function for general_symbol_info::language
authorChristian Biesinger <cbiesinger@google.com>
Tue, 3 Dec 2019 23:10:32 +0000 (17:10 -0600)
committerChristian Biesinger <cbiesinger@google.com>
Mon, 16 Dec 2019 06:44:36 +0000 (00:44 -0600)
Also renames the member variable to m_language to make code easier to read
when more functions become member functions.

I was originally hoping to eventually make m_language private (after a few
more patches), but unfortunately then it no longer counts as a POD type,
which means gdbsupport/poison.h won't let us use memset to initialize
this type, which psymtabs rely on to clear padding bytes so that bcache
can work properly.

gdb/ChangeLog:

2019-12-15  Christian Biesinger  <cbiesinger@google.com>

* ada-lang.c (ada_add_block_symbols): Update.
(ada_collect_symbol_completion_matches): Update.
* ax-gdb.c (gen_expr): Update.
* block.c (block_lookup_symbol): Update.
(block_lookup_symbol_primary): Update.
(block_find_symbol): Update.
* cp-namespace.c (cp_lookup_symbol_imports_or_template): Update.
* dbxread.c (process_one_symbol): Update.
* dictionary.c (insert_symbol_hashed): Update.
(collate_pending_symbols_by_language): Update.
(mdict_add_symbol): Update.
* dwarf-index-write.c (write_psymbols): Update.
* dwarf2read.c (fixup_go_packaging): Update.
* findvar.c (read_var_value): Update.
* ft32-tdep.c (ft32_skip_prologue): Update.
* go-lang.c (go_symbol_package_name): Update.
* language.h (scoped_switch_to_sym_language_if_auto::
scoped_switch_to_sym_language_if_auto): Update.
* linespec.c (find_method): Update.
(find_label_symbols_in_block): Update.
* mdebugread.c (parse_symbol): Update.
* mi/mi-cmd-stack.c (list_arg_or_local): Update.
* minsyms.c (add_minsym_to_demangled_hash_table): Update.
(minimal_symbol_reader::install): Update.
* moxie-tdep.c (moxie_skip_prologue): Update.
* parse.c (parse_exp_in_context): Update.
* psymtab.c (psymbol_name_matches): Update.
(match_partial_symbol): Update.
(lookup_partial_symbol): Update.
(psymbol_hash): Update.
(psymbol_compare): Update.
* python/py-framefilter.c (extract_sym): Update.
(py_print_single_arg): Update.
* stabsread.c (define_symbol): Update.
* stack.c (print_frame_arg): Update.
(find_frame_funname): Update.
(info_frame_command_core): Update.
* symfile.c (set_initial_language): Update.
* symtab.c (symbol_set_demangled_name): Update.
(symbol_get_demangled_name): Update.
(symbol_set_language): Update.
(symbol_find_demangled_name): Update.
(symbol_set_names): Update.
(general_symbol_info::natural_name): Update.
(general_symbol_info::demangled_name): Update.
(general_symbol_info::search_name): Update.
(symbol_matches_search_name): Update.
(eq_symbol_entry): Update.
(iterate_over_symbols): Update.
(completion_list_add_symbol): Update.
(completion_list_add_msymbol): Update.
(completion_list_add_fields): Update.
* symtab.h (struct general_symbol_info) <language>: New function.
<language>: Rename to...
<m_language>: ...this.
(SYMBOL_LANGUAGE): Remove.
(MSYMBOL_LANGUAGE): Remove.
(struct symbol) <ctor>: Update.
* xstormy16-tdep.c (xstormy16_skip_prologue): Update.

Change-Id: I6464d477457e61639c63ddf8b145e407a35c235a

27 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ax-gdb.c
gdb/block.c
gdb/cp-namespace.c
gdb/dbxread.c
gdb/dictionary.c
gdb/dwarf-index-write.c
gdb/dwarf2read.c
gdb/findvar.c
gdb/ft32-tdep.c
gdb/go-lang.c
gdb/language.h
gdb/linespec.c
gdb/mdebugread.c
gdb/mi/mi-cmd-stack.c
gdb/minsyms.c
gdb/moxie-tdep.c
gdb/parse.c
gdb/psymtab.c
gdb/python/py-framefilter.c
gdb/stabsread.c
gdb/stack.c
gdb/symfile.c
gdb/symtab.c
gdb/symtab.h
gdb/xstormy16-tdep.c

index 8cc1c6b594847f547ead22895d4e7a1757858c22..60cf8c152f777abf4de5ef136f45d1acd539dc5d 100644 (file)
@@ -1,3 +1,65 @@
+2019-12-15  Christian Biesinger  <cbiesinger@google.com>
+
+       * ada-lang.c (ada_add_block_symbols): Update.
+       (ada_collect_symbol_completion_matches): Update.
+       * ax-gdb.c (gen_expr): Update.
+       * block.c (block_lookup_symbol): Update.
+       (block_lookup_symbol_primary): Update.
+       (block_find_symbol): Update.
+       * cp-namespace.c (cp_lookup_symbol_imports_or_template): Update.
+       * dbxread.c (process_one_symbol): Update.
+       * dictionary.c (insert_symbol_hashed): Update.
+       (collate_pending_symbols_by_language): Update.
+       (mdict_add_symbol): Update.
+       * dwarf-index-write.c (write_psymbols): Update.
+       * dwarf2read.c (fixup_go_packaging): Update.
+       * findvar.c (read_var_value): Update.
+       * ft32-tdep.c (ft32_skip_prologue): Update.
+       * go-lang.c (go_symbol_package_name): Update.
+       * language.h (scoped_switch_to_sym_language_if_auto::
+       scoped_switch_to_sym_language_if_auto): Update.
+       * linespec.c (find_method): Update.
+       (find_label_symbols_in_block): Update.
+       * mdebugread.c (parse_symbol): Update.
+       * mi/mi-cmd-stack.c (list_arg_or_local): Update.
+       * minsyms.c (add_minsym_to_demangled_hash_table): Update.
+       (minimal_symbol_reader::install): Update.
+       * moxie-tdep.c (moxie_skip_prologue): Update.
+       * parse.c (parse_exp_in_context): Update.
+       * psymtab.c (psymbol_name_matches): Update.
+       (match_partial_symbol): Update.
+       (lookup_partial_symbol): Update.
+       (psymbol_hash): Update.
+       (psymbol_compare): Update.
+       * python/py-framefilter.c (extract_sym): Update.
+       (py_print_single_arg): Update.
+       * stabsread.c (define_symbol): Update.
+       * stack.c (print_frame_arg): Update.
+       (find_frame_funname): Update.
+       (info_frame_command_core): Update.
+       * symfile.c (set_initial_language): Update.
+       * symtab.c (symbol_set_demangled_name): Update.
+       (symbol_get_demangled_name): Update.
+       (symbol_set_language): Update.
+       (symbol_find_demangled_name): Update.
+       (symbol_set_names): Update.
+       (general_symbol_info::natural_name): Update.
+       (general_symbol_info::demangled_name): Update.
+       (general_symbol_info::search_name): Update.
+       (symbol_matches_search_name): Update.
+       (eq_symbol_entry): Update.
+       (iterate_over_symbols): Update.
+       (completion_list_add_symbol): Update.
+       (completion_list_add_msymbol): Update.
+       (completion_list_add_fields): Update.
+       * symtab.h (struct general_symbol_info) <language>: New function.
+       <language>: Rename to...
+       <m_language>: ...this.
+       (SYMBOL_LANGUAGE): Remove.
+       (MSYMBOL_LANGUAGE): Remove.
+       (struct symbol) <ctor>: Update.
+       * xstormy16-tdep.c (xstormy16_skip_prologue): Update.
+
 2019-12-15  Christian Biesinger  <cbiesinger@google.com>
 
        * ada-exp.y (write_ambiguous_var): Call symbol_set_language to
index 3289a8e5c8eef918370afe44298808210f9b864e..030c4aa131b5981f9931c3506eaa4b63b0ebd7f9 100644 (file)
@@ -6220,8 +6220,7 @@ ada_add_block_symbols (struct obstack *obstackp,
        sym != NULL;
        sym = block_iter_match_next (lookup_name, &iter))
     {
-      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
-                                SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
        {
          if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED)
            {
@@ -6260,7 +6259,7 @@ ada_add_block_symbols (struct obstack *obstackp,
 
       ALL_BLOCK_SYMBOLS (block, iter, sym)
       {
-        if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+        if (symbol_matches_domain (sym->language (),
                                    SYMBOL_DOMAIN (sym), domain))
           {
             int cmp;
@@ -6428,7 +6427,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
          if (completion_skip_symbol (mode, msymbol))
            continue;
 
-         language symbol_language = MSYMBOL_LANGUAGE (msymbol);
+         language symbol_language = msymbol->language ();
 
          /* Ada minimal symbols won't have their language set to Ada.  If
             we let completion_list_add_name compare using the
@@ -6466,7 +6465,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
          continue;
 
        completion_list_add_name (tracker,
-                                 SYMBOL_LANGUAGE (sym),
+                                 sym->language (),
                                  sym->linkage_name (),
                                  lookup_name, text, word);
       }
@@ -6487,7 +6486,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
                continue;
 
              completion_list_add_name (tracker,
-                                       SYMBOL_LANGUAGE (sym),
+                                       sym->language (),
                                        sym->linkage_name (),
                                        lookup_name, text, word);
            }
@@ -6509,7 +6508,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
                continue;
 
              completion_list_add_name (tracker,
-                                       SYMBOL_LANGUAGE (sym),
+                                       sym->language (),
                                        sym->linkage_name (),
                                        lookup_name, text, word);
            }
index 848958706437511606f265688a745462b108ba3e..d25413ea1f2f15ac1d05353865a9425e4c088b7b 100644 (file)
@@ -2230,7 +2230,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
 
        b = block_for_pc (ax->scope);
        func = block_linkage_function (b);
-       lang = language_def (SYMBOL_LANGUAGE (func));
+       lang = language_def (func->language ());
 
        sym = lookup_language_this (lang, b).symbol;
        if (!sym)
index b49c548adc87e0a41aac6c1d1158d807dfeba700..58441bfe8993c37a94cf26148bc9420eaafb0db6 100644 (file)
@@ -729,7 +729,7 @@ block_lookup_symbol (const struct block *block, const char *name,
             STRUCT vs VAR domain symbols.  So if a matching symbol is found,
             make sure there is no "better" matching symbol, i.e., one with
             exactly the same domain.  PR 16253.  */
-         if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+         if (symbol_matches_domain (sym->language (),
                                     SYMBOL_DOMAIN (sym), domain))
            other = better_symbol (other, sym, domain);
        }
@@ -750,7 +750,7 @@ block_lookup_symbol (const struct block *block, const char *name,
 
       ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
        {
-         if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+         if (symbol_matches_domain (sym->language (),
                                     SYMBOL_DOMAIN (sym), domain))
            {
              sym_found = sym;
@@ -819,8 +819,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
         STRUCT vs VAR domain symbols.  So if a matching symbol is found,
         make sure there is no "better" matching symbol, i.e., one with
         exactly the same domain.  PR 16253.  */
-      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
-                                SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
        other = better_symbol (other, sym, domain);
     }
 
@@ -847,8 +846,7 @@ block_find_symbol (const struct block *block, const char *name,
     {
       /* MATCHER is deliberately called second here so that it never sees
         a non-domain-matching symbol.  */
-      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
-                                SYMBOL_DOMAIN (sym), domain)
+      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain)
          && matcher (sym, data))
        return sym;
     }
index d813d050733ce5537ed34da4549d62a62cf488ba..20067cdd0360ae535099a54f44e9251adf782eb8 100644 (file)
@@ -516,7 +516,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
                          domain_name (domain));
     }
 
-  if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
+  if (function != NULL && function->language () == language_cplus)
     {
       /* Search the function's template parameters.  */
       if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
index 73f1ba8759a1f790c961cc9940336a987f8ffde3..ecfa89ae0cd0269679c5bd9b8434a9c35a1099fa 100644 (file)
@@ -2456,7 +2456,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
                                cstk.start_addr, cstk.start_addr + valu);
 
          /* For C++, set the block's scope.  */
-         if (SYMBOL_LANGUAGE (cstk.name) == language_cplus)
+         if (cstk.name->language () == language_cplus)
            cp_set_block_scope (cstk.name, block, &objfile->objfile_obstack);
 
          /* May be switching to an assembler file which may not be using
@@ -2823,7 +2823,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
                                        cstk.start_addr, valu);
 
                  /* For C++, set the block's scope.  */
-                 if (SYMBOL_LANGUAGE (cstk.name) == language_cplus)
+                 if (cstk.name->language () == language_cplus)
                    cp_set_block_scope (cstk.name, block,
                                        &objfile->objfile_obstack);
                }
index 0d13370b7269924a89d4bdc45b3a858a73872634..125a062d80d88c3ec4d82da83314f09b51eb8eff 100644 (file)
@@ -640,9 +640,9 @@ insert_symbol_hashed (struct dictionary *dict,
 
   /* We don't want to insert a symbol into a dictionary of a different
      language.  The two may not use the same hashing algorithm.  */
-  gdb_assert (SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language);
+  gdb_assert (sym->language () == DICT_LANGUAGE (dict)->la_language);
 
-  hash = search_name_hash (SYMBOL_LANGUAGE (sym), sym->search_name ());
+  hash = search_name_hash (sym->language (), sym->search_name ());
   hash_index = hash % DICT_HASHED_NBUCKETS (dict);
   sym->hash_next = buckets[hash_index];
   buckets[hash_index] = sym;
@@ -928,7 +928,7 @@ collate_pending_symbols_by_language (const struct pending *symbol_list)
     {
       for (int i = list_counter->nsyms - 1; i >= 0; --i)
        {
-         enum language language = SYMBOL_LANGUAGE (list_counter->symbol[i]);
+         enum language language = list_counter->symbol[i]->language ();
          nsyms[language].push_back (list_counter->symbol[i]);
        }
     }
@@ -1116,13 +1116,13 @@ void
 mdict_add_symbol (struct multidictionary *mdict, struct symbol *sym)
 {
   struct dictionary *dict
-    = find_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+    = find_language_dictionary (mdict, sym->language ());
 
   if (dict == nullptr)
     {
       /* SYM is of a new language that we haven't previously seen.
         Create a new dictionary for it.  */
-      dict = create_new_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+      dict = create_new_language_dictionary (mdict, sym->language ());
     }
 
   dict_add_symbol (dict, sym);
index cbad3084307afda194edeadbf579a95a4d7b84f9..66c2368b9c14d244b600b18b578e3e40da0a247c 100644 (file)
@@ -543,7 +543,7 @@ write_psymbols (struct mapped_symtab *symtab,
     {
       struct partial_symbol *psym = *psymp;
 
-      if (psym->ginfo.language == language_ada)
+      if (psym->ginfo.language () == language_ada)
        error (_("Ada is not currently supported by the index; "
                 "use the DWARF 5 index instead"));
 
@@ -690,7 +690,7 @@ public:
       return;
     const char *name = psym->ginfo.search_name ();
 
-    if (psym->ginfo.language == language_ada)
+    if (psym->ginfo.language () == language_ada)
       {
        /* We want to ensure that the Ada main function's name appears
           verbatim in the index.  However, this name will be of the
index e009b523ccc831ca315f13a5ec4a44f8b8946242..6a09d5568b3bf6963b0afa7de63819d672c63660 100644 (file)
@@ -9916,7 +9916,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
        {
          struct symbol *sym = list->symbol[i];
 
-         if (SYMBOL_LANGUAGE (sym) == language_go
+         if (sym->language () == language_go
              && SYMBOL_CLASS (sym) == LOC_BLOCK)
            {
              char *this_package_name = go_symbol_package_name (sym);
index 50e99f48d1f0bdeab800dde111e074d074223f40..18dd3cd04f5254247d22f9e8e1ba0fd715565b53 100644 (file)
@@ -807,7 +807,7 @@ struct value *
 read_var_value (struct symbol *var, const struct block *var_block,
                struct frame_info *frame)
 {
-  const struct language_defn *lang = language_def (SYMBOL_LANGUAGE (var));
+  const struct language_defn *lang = language_def (var->language ());
 
   gdb_assert (lang != NULL);
   gdb_assert (lang->la_read_var_value != NULL);
index bded02fae4bc4e880b49fb61159f08ddb6a65214..56c2165037b654c8e641d06d2afc0f68d85185e2 100644 (file)
@@ -299,7 +299,7 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
          /* Found a function.  */
          sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
          /* Don't use line number debug info for assembly source files.  */
-         if ((sym != NULL) && SYMBOL_LANGUAGE (sym) != language_asm)
+         if ((sym != NULL) && sym->language () != language_asm)
            {
              sal = find_pc_line (func_addr, 0);
              if (sal.end && sal.end < func_end)
index bf2eb1b6f71696940cc380f111701caff70ece42..b527d9f72eec31dbe002773f0a5af0f92a2163df 100644 (file)
@@ -420,7 +420,7 @@ go_symbol_package_name (const struct symbol *sym)
   char *name_buf;
   char *result;
 
-  gdb_assert (SYMBOL_LANGUAGE (sym) == language_go);
+  gdb_assert (sym->language () == language_go);
   name_buf = unpack_mangled_go_symbol (mangled_name,
                                       &package_name, &object_name,
                                       &method_type_package_name,
index 5fc25a235ff08f84db5c4e345d66bf6c396306f6..14d6fac30371313efc70c5c7316c751ff838b52a 100644 (file)
@@ -715,7 +715,7 @@ public:
       {
        m_lang = current_language->la_language;
        m_switched = true;
-       set_language (SYMBOL_LANGUAGE (sym));
+       set_language (sym->language ());
       }
     else
       {
index 61dcb4830e29821a5fdf5fc347fad30e0ff80a35..9c17331a9343514edc02a621ed0cb43393fc4d97 100644 (file)
@@ -3683,7 +3683,7 @@ find_method (struct linespec_state *self, std::vector<symtab *> *file_symtabs,
       gdb_assert (!pspace->executing_startup);
       set_current_program_space (pspace);
       t = check_typedef (SYMBOL_TYPE (sym));
-      find_methods (t, SYMBOL_LANGUAGE (sym),
+      find_methods (t, sym->language (),
                    method_name, &result_names, &superclass_vec);
 
       /* Handle all items from a single program space at once; and be
@@ -3696,7 +3696,7 @@ find_method (struct linespec_state *self, std::vector<symtab *> *file_symtabs,
             this program space, consider superclasses.  */
          if (result_names.size () == last_result_len)
            find_superclass_methods (std::move (superclass_vec), method_name,
-                                    SYMBOL_LANGUAGE (sym), &result_names);
+                                    sym->language (), &result_names);
 
          /* We have a list of candidate symbol names, so now we
             iterate over the symbol tables looking for all
@@ -3998,7 +3998,7 @@ find_label_symbols_in_block (const struct block *block,
 
       ALL_BLOCK_SYMBOLS (block, iter, sym)
        {
-         if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+         if (symbol_matches_domain (sym->language (),
                                     SYMBOL_DOMAIN (sym), LABEL_DOMAIN)
              && cmp (sym->search_name (), name, name_len) == 0)
            {
index f279f131711bd3a7e9f26c5da7e3f82012a064ff..ceffc012c11f7fca6aa19567e7436277d2da2d65 100644 (file)
@@ -794,11 +794,11 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
       /* All functions in C++ have prototypes.  For C we don't have enough
          information in the debug info.  */
-      if (SYMBOL_LANGUAGE (s) == language_cplus)
+      if (s->language () == language_cplus)
        TYPE_PROTOTYPED (SYMBOL_TYPE (s)) = 1;
 
       /* Create and enter a new lexical context.  */
-      b = new_block (FUNCTION_BLOCK, SYMBOL_LANGUAGE (s));
+      b = new_block (FUNCTION_BLOCK, s->language ());
       SYMBOL_BLOCK_VALUE (s) = b;
       BLOCK_FUNCTION (b) = s;
       BLOCK_START (b) = BLOCK_END (b) = sh->value;
index 50843313f856846e04a99a29077e167fff9add2f..6cd255d072003e811bfc74848c65283bcabbada8 100644 (file)
@@ -543,7 +543,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
              get_no_prettyformat_print_options (&opts);
              opts.deref_ref = 1;
              common_val_print (arg->val, &stb, 0, &opts,
-                               language_def (SYMBOL_LANGUAGE (arg->sym)));
+                               language_def (arg->sym->language ()));
            }
          catch (const gdb_exception_error &except)
            {
index 40bedbd3e7fcec5de04637a7b4eda3c4ea82ce83..6afa3936337a767e9c83e748e337906a42dd7a5e 100644 (file)
@@ -162,7 +162,7 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
 {
   if (sym->demangled_hash_next == NULL)
     {
-      objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym));
+      objfile->per_bfd->demangled_hash_languages.set (sym->language ());
 
       struct minimal_symbol **table
        = objfile->per_bfd->msymbol_demangled_hash;
@@ -1420,8 +1420,7 @@ minimal_symbol_reader::install ()
                  build_minimal_symbol_hash_tables.  */
               if (msym->search_name () != msym->linkage_name ())
                 hash_values[idx].minsym_demangled_hash
-                  = search_name_hash (MSYMBOL_LANGUAGE (msym),
-                                      msym->search_name ());
+                  = search_name_hash (msym->language (), msym->search_name ());
             }
           {
             /* To limit how long we hold the lock, we only acquire it here
index 81fdb7111c2af8c3605e80404089815cd4ba1e6d..0c38438697131208c11690d409a23a599d48fb63 100644 (file)
@@ -232,7 +232,7 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
          sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
          /* Don't use line number debug info for assembly source
             files.  */
-         if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
+         if (sym && sym->language () != language_asm)
            {
              sal = find_pc_line (func_addr, 0);
              if (sal.end && sal.end < func_end)
index d7360aa6bbefcba606fd6b448257e0cb86a55094..399f776a71cb1b1be5bd0dd520bd365f30d81053 100644 (file)
@@ -1098,7 +1098,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
       struct symbol *func = block_linkage_function (block);
 
       if (func != NULL)
-        lang = language_def (SYMBOL_LANGUAGE (func));
+        lang = language_def (func->language ());
       if (lang == NULL || lang->la_language == language_unknown)
         lang = current_language;
     }
index 2cbc6d4f65f7207e7b244b8cae4ccb1da0b64d03..28b452b07ff016b9268bd45e8c4e65094af88baf 100644 (file)
@@ -531,7 +531,7 @@ static bool
 psymbol_name_matches (partial_symbol *psym,
                      const lookup_name_info &lookup_name)
 {
-  const language_defn *lang = language_def (psym->ginfo.language);
+  const language_defn *lang = language_def (psym->ginfo.language ());
   symbol_name_matcher_ftype *name_match
     = get_symbol_name_matcher (lang, lookup_name);
   return name_match (psym->ginfo.search_name (), lookup_name, NULL);
@@ -581,7 +581,7 @@ match_partial_symbol (struct objfile *objfile,
          center = bottom + (top - bottom) / 2;
          gdb_assert (center < top);
 
-         enum language lang = (*center)->ginfo.language;
+         enum language lang = (*center)->ginfo.language ();
          const char *lang_ln
            = name.language_lookup_name (lang).c_str ();
 
@@ -596,7 +596,7 @@ match_partial_symbol (struct objfile *objfile,
       while (top <= real_top
             && psymbol_name_matches (*top, name))
        {
-         if (symbol_matches_domain ((*top)->ginfo.language,
+         if (symbol_matches_domain ((*top)->ginfo.language (),
                                     (*top)->domain, domain))
            return *top;
          top++;
@@ -610,7 +610,7 @@ match_partial_symbol (struct objfile *objfile,
     {
       for (psym = start; psym < start + length; psym++)
        {
-         if (symbol_matches_domain ((*psym)->ginfo.language,
+         if (symbol_matches_domain ((*psym)->ginfo.language (),
                                     (*psym)->domain, domain)
              && psymbol_name_matches (*psym, name))
            return *psym;
@@ -719,7 +719,7 @@ lookup_partial_symbol (struct objfile *objfile,
       while (top <= real_top && symbol_matches_search_name (&(*top)->ginfo,
                                                            lookup_name))
        {
-         if (symbol_matches_domain ((*top)->ginfo.language,
+         if (symbol_matches_domain ((*top)->ginfo.language (),
                                     (*top)->domain, domain))
            return *top;
          top++;
@@ -733,7 +733,7 @@ lookup_partial_symbol (struct objfile *objfile,
     {
       for (psym = start; psym < start + length; psym++)
        {
-         if (symbol_matches_domain ((*psym)->ginfo.language,
+         if (symbol_matches_domain ((*psym)->ginfo.language (),
                                     (*psym)->domain, domain)
              && symbol_matches_search_name (&(*psym)->ginfo, lookup_name))
            return *psym;
@@ -1526,7 +1526,7 @@ psymbol_hash (const void *addr, int length)
 {
   unsigned long h = 0;
   struct partial_symbol *psymbol = (struct partial_symbol *) addr;
-  unsigned int lang = psymbol->ginfo.language;
+  unsigned int lang = psymbol->ginfo.language ();
   unsigned int domain = psymbol->domain;
   unsigned int theclass = psymbol->aclass;
 
@@ -1553,7 +1553,7 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
 
   return (memcmp (&sym1->ginfo.value, &sym2->ginfo.value,
                   sizeof (sym1->ginfo.value)) == 0
-         && sym1->ginfo.language == sym2->ginfo.language
+         && sym1->ginfo.language () == sym2->ginfo.language ()
           && sym1->domain == sym2->domain
           && sym1->aclass == sym2->aclass
          /* Note that psymbol names are interned via
index 8e38d8d7a454927c4b0840c0726f0c5c24989e69..fd03d313e9ea6260e474e1b52f292adee3f0544f 100644 (file)
@@ -109,7 +109,7 @@ extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr<char> *name,
         from the symbol.  If mode is not "auto", then the language
         has been explicitly set, use that.  */
       if (language_mode == language_mode_auto)
-       *language = language_def (SYMBOL_LANGUAGE (*sym));
+       *language = language_def ((*sym)->language ());
       else
        *language = current_language;
     }
@@ -320,7 +320,7 @@ py_print_single_arg (struct ui_out *out,
     {
       if (fa->val == NULL && fa->error == NULL)
        return;
-      language = language_def (SYMBOL_LANGUAGE (fa->sym));
+      language = language_def (fa->sym->language ());
       val = fa->val;
     }
   else
@@ -349,14 +349,14 @@ py_print_single_arg (struct ui_out *out,
       string_file stb;
 
       fprintf_symbol_filtered (&stb, fa->sym->print_name (),
-                              SYMBOL_LANGUAGE (fa->sym),
+                              fa->sym->language (),
                               DMGL_PARAMS | DMGL_ANSI);
       if (fa->entry_kind == print_entry_values_compact)
        {
          stb.puts ("=");
 
          fprintf_symbol_filtered (&stb, fa->sym->print_name (),
-                                  SYMBOL_LANGUAGE (fa->sym),
+                                  fa->sym->language (),
                                   DMGL_PARAMS | DMGL_ANSI);
        }
       if (fa->entry_kind == print_entry_values_only
index 91a73dd10db94bcbc46d36f544619ed235d0a432..1b5426e28426bb6074fd849c45adf48d291b5e91 100644 (file)
@@ -740,7 +740,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     normal:
       std::string new_name;
 
-      if (SYMBOL_LANGUAGE (sym) == language_cplus)
+      if (sym->language () == language_cplus)
        {
          char *name = (char *) alloca (p - string + 1);
 
@@ -758,7 +758,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
        SYMBOL_SET_NAMES (sym, gdb::string_view (string, p - string), true,
                          objfile);
 
-      if (SYMBOL_LANGUAGE (sym) == language_cplus)
+      if (sym->language () == language_cplus)
        cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
                                          objfile);
 
@@ -1225,7 +1225,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
          This is important to do, because of forward references:
          The cleanup of undefined types stored in undef_types only uses
          STRUCT_DOMAIN symbols to perform the replacement.  */
-      synonym = (SYMBOL_LANGUAGE (sym) == language_ada && p[-2] != 'T');
+      synonym = (sym->language () == language_ada && p[-2] != 'T');
 
       /* Typedef */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
index cc7b7e5bbe0a855faf84dbc3471ba516a51694a2..228205248710d32cac4454f40c2cd5e11f0b5685 100644 (file)
@@ -428,7 +428,7 @@ print_frame_arg (const frame_print_options &fp_opts,
   annotate_arg_emitter arg_emitter;
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
   fprintf_symbol_filtered (&stb, arg->sym->print_name (),
-                          SYMBOL_LANGUAGE (arg->sym), DMGL_PARAMS | DMGL_ANSI);
+                          arg->sym->language (), DMGL_PARAMS | DMGL_ANSI);
   if (arg->entry_kind == print_entry_values_compact)
     {
       /* It is OK to provide invalid MI-like stream as with
@@ -436,7 +436,7 @@ print_frame_arg (const frame_print_options &fp_opts,
       stb.puts ("=");
 
       fprintf_symbol_filtered (&stb, arg->sym->print_name (),
-                              SYMBOL_LANGUAGE (arg->sym),
+                              arg->sym->language (),
                               DMGL_PARAMS | DMGL_ANSI);
     }
   if (arg->entry_kind == print_entry_values_only
@@ -474,7 +474,7 @@ print_frame_arg (const frame_print_options &fp_opts,
              /* Use the appropriate language to display our symbol, unless the
                 user forced the language to a specific language.  */
              if (language_mode == language_mode_auto)
-               language = language_def (SYMBOL_LANGUAGE (arg->sym));
+               language = language_def (arg->sym->language ());
              else
                language = current_language;
 
@@ -1261,7 +1261,7 @@ find_frame_funname (struct frame_info *frame, enum language *funlang,
     {
       const char *print_name = func->print_name ();
 
-      *funlang = SYMBOL_LANGUAGE (func);
+      *funlang = func->language ();
       if (funcp)
        *funcp = func;
       if (*funlang == language_cplus)
@@ -1291,7 +1291,7 @@ find_frame_funname (struct frame_info *frame, enum language *funlang,
       if (msymbol.minsym != NULL)
        {
          funname.reset (xstrdup (msymbol.minsym->print_name ()));
-         *funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
+         *funlang = msymbol.minsym->language ();
        }
     }
 
@@ -1495,7 +1495,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
   if (func)
     {
       funname = func->print_name ();
-      funlang = SYMBOL_LANGUAGE (func);
+      funlang = func->language ();
       if (funlang == language_cplus)
        {
          /* It seems appropriate to use print_name() here,
@@ -1517,7 +1517,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
       if (msymbol.minsym != NULL)
        {
          funname = msymbol.minsym->print_name ();
-         funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
+         funlang = msymbol.minsym->language ();
        }
     }
   calling_frame_info = get_prev_frame (fi);
index 8852e2893a4f5657cdb5ea034020da2fbb564c7c..5ca89b45b350f1cb4ff71a7a6616aa7f21ec9105 100644 (file)
@@ -1697,7 +1697,7 @@ set_initial_language (void)
       struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL).symbol;
 
       if (sym != NULL)
-       lang = SYMBOL_LANGUAGE (sym);
+       lang = sym->language ();
     }
 
   if (lang == language_unknown)
index 6fd1c8c4bc0a30b780158367bb1fb13af9141aab..a082ee21a90898cc3f1b3310940175ccf12fceac 100644 (file)
@@ -675,7 +675,7 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol,
                            const char *name,
                            struct obstack *obstack)
 {
-  if (gsymbol->language == language_ada)
+  if (gsymbol->language () == language_ada)
     {
       if (name == NULL)
        {
@@ -697,7 +697,7 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol,
 const char *
 symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
 {
-  if (gsymbol->language == language_ada)
+  if (gsymbol->language () == language_ada)
     {
       if (!gsymbol->ada_mangled)
        return NULL;
@@ -716,16 +716,16 @@ symbol_set_language (struct general_symbol_info *gsymbol,
                      enum language language,
                     struct obstack *obstack)
 {
-  gsymbol->language = language;
-  if (gsymbol->language == language_cplus
-      || gsymbol->language == language_d
-      || gsymbol->language == language_go
-      || gsymbol->language == language_objc
-      || gsymbol->language == language_fortran)
+  gsymbol->m_language = language;
+  if (language == language_cplus
+      || language == language_d
+      || language == language_go
+      || language == language_objc
+      || language == language_fortran)
     {
       symbol_set_demangled_name (gsymbol, NULL, obstack);
     }
-  else if (gsymbol->language == language_ada)
+  else if (language == language_ada)
     {
       gdb_assert (gsymbol->ada_mangled == 0);
       gsymbol->language_specific.obstack = obstack;
@@ -819,12 +819,12 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
   char *demangled = NULL;
   int i;
 
-  if (gsymbol->language == language_unknown)
-    gsymbol->language = language_auto;
+  if (gsymbol->language () == language_unknown)
+    gsymbol->m_language = language_auto;
 
-  if (gsymbol->language != language_auto)
+  if (gsymbol->language () != language_auto)
     {
-      const struct language_defn *lang = language_def (gsymbol->language);
+      const struct language_defn *lang = language_def (gsymbol->language ());
 
       language_sniff_from_mangled_name (lang, mangled, &demangled);
       return demangled;
@@ -837,7 +837,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
 
       if (language_sniff_from_mangled_name (lang, mangled, &demangled))
        {
-         gsymbol->language = l;
+         gsymbol->m_language = l;
          return demangled;
        }
     }
@@ -864,7 +864,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 {
   struct demangled_name_entry **slot;
 
-  if (gsymbol->language == language_ada)
+  if (gsymbol->language () == language_ada)
     {
       /* In Ada, we do the symbol lookups using the mangled name, so
          we can save some space by not storing the demangled name.  */
@@ -898,7 +898,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   if (*slot == NULL
       /* A C version of the symbol may have already snuck into the table.
         This happens to, e.g., main.init (__go_init_main).  Cope.  */
-      || (gsymbol->language == language_go && (*slot)->demangled == nullptr))
+      || (gsymbol->language () == language_go && (*slot)->demangled == nullptr))
     {
       /* A 0-terminated copy of the linkage name.  Callers must set COPY_NAME
          to true if the string might not be nullterminated.  We have to make
@@ -959,11 +959,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
            (gdb::string_view (mangled_ptr, linkage_name.length ()));
        }
       (*slot)->demangled = std::move (demangled_name);
-      (*slot)->language = gsymbol->language;
+      (*slot)->language = gsymbol->language ();
     }
-  else if (gsymbol->language == language_unknown
-          || gsymbol->language == language_auto)
-    gsymbol->language = (*slot)->language;
+  else if (gsymbol->language () == language_unknown
+          || gsymbol->language () == language_auto)
+    gsymbol->m_language = (*slot)->language;
 
   gsymbol->name = (*slot)->mangled.data ();
   if ((*slot)->demangled != nullptr)
@@ -978,7 +978,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 const char *
 general_symbol_info::natural_name () const
 {
-  switch (language)
+  switch (language ())
     {
     case language_cplus:
     case language_d:
@@ -1003,7 +1003,7 @@ general_symbol_info::demangled_name () const
 {
   const char *dem_name = NULL;
 
-  switch (language)
+  switch (language ())
     {
     case language_cplus:
     case language_d:
@@ -1026,7 +1026,7 @@ general_symbol_info::demangled_name () const
 const char *
 general_symbol_info::search_name () const
 {
-  if (language == language_ada)
+  if (language () == language_ada)
     return name;
   else
     return natural_name ();
@@ -1039,7 +1039,7 @@ symbol_matches_search_name (const struct general_symbol_info *gsymbol,
                            const lookup_name_info &name)
 {
   symbol_name_matcher_ftype *name_match
-    = get_symbol_name_matcher (language_def (gsymbol->language), name);
+    = get_symbol_name_matcher (language_def (gsymbol->language ()), name);
   return name_match (gsymbol->search_name (), name, NULL);
 }
 
@@ -1219,8 +1219,7 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
          if (!SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name))
            return 0;
 
-         if (!symbol_matches_domain (SYMBOL_LANGUAGE (sym),
-                                     slot_domain, domain))
+         if (!symbol_matches_domain (sym->language (), slot_domain, domain))
            return 0;
        }
     }
@@ -2846,8 +2845,7 @@ iterate_over_symbols (const struct block *block,
 
   ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     {
-      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
-                                SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
        {
          struct block_symbol block_sym = {sym, block};
 
@@ -5262,7 +5260,7 @@ completion_list_add_symbol (completion_tracker &tracker,
                            const lookup_name_info &lookup_name,
                            const char *text, const char *word)
 {
-  completion_list_add_name (tracker, SYMBOL_LANGUAGE (sym),
+  completion_list_add_name (tracker, sym->language (),
                            sym->natural_name (),
                            lookup_name, text, word);
 }
@@ -5275,7 +5273,7 @@ completion_list_add_msymbol (completion_tracker &tracker,
                             const lookup_name_info &lookup_name,
                             const char *text, const char *word)
 {
-  completion_list_add_name (tracker, MSYMBOL_LANGUAGE (sym),
+  completion_list_add_name (tracker, sym->language (),
                            sym->natural_name (),
                            lookup_name, text, word);
 }
@@ -5409,7 +5407,7 @@ completion_list_add_fields (completion_tracker &tracker,
       if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
        for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
          if (TYPE_FIELD_NAME (t, j))
-           completion_list_add_name (tracker, SYMBOL_LANGUAGE (sym),
+           completion_list_add_name (tracker, sym->language (),
                                      TYPE_FIELD_NAME (t, j),
                                      lookup_name, text, word);
     }
index e8321d4bb8cbe5392626fe4504fff5d103fe8c5a..09e2a20a3657155cd2cd41ae62ada492efc1dff0 100644 (file)
@@ -425,6 +425,9 @@ struct general_symbol_info
   void set_linkage_name (const char *linkage_name)
   { name = linkage_name; }
 
+  enum language language () const
+  { return m_language; }
+
   /* Name of the symbol.  This is a required field.  Storage for the
      name is allocated on the objfile_obstack for the associated
      objfile.  For languages like C++ that make a distinction between
@@ -479,7 +482,7 @@ struct general_symbol_info
      This is used to select one of the fields from the language specific
      union above.  */
 
-  ENUM_BITFIELD(language) language : LANGUAGE_BITS;
+  ENUM_BITFIELD(language) m_language : LANGUAGE_BITS;
 
   /* This is only used by Ada.  If set, then the 'demangled_name' field
      of language_specific is valid.  Otherwise, the 'obstack' field is
@@ -522,7 +525,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
 #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
 #define SYMBOL_BLOCK_VALUE(symbol)     (symbol)->value.block
 #define SYMBOL_VALUE_CHAIN(symbol)     (symbol)->value.chain
-#define SYMBOL_LANGUAGE(symbol)                (symbol)->language
 #define SYMBOL_SECTION(symbol)         (symbol)->section
 #define SYMBOL_OBJ_SECTION(objfile, symbol)                    \
   (((symbol)->section >= 0)                            \
@@ -741,7 +743,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_BYTES(symbol)    (symbol)->value.bytes
 #define MSYMBOL_BLOCK_VALUE(symbol)    (symbol)->value.block
 #define MSYMBOL_VALUE_CHAIN(symbol)    (symbol)->value.chain
-#define MSYMBOL_LANGUAGE(symbol)       (symbol)->language
 #define MSYMBOL_SECTION(symbol)                (symbol)->section
 #define MSYMBOL_OBJ_SECTION(objfile, symbol)                   \
   (((symbol)->section >= 0)                            \
@@ -1098,7 +1099,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       name = nullptr;
       value.ivalue = 0;
       language_specific.obstack = nullptr;
-      language = language_unknown;
+      m_language = language_unknown;
       ada_mangled = 0;
       section = 0;
       /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
index 9b8b7e2864fa1fa527fe3316ef8375389b6caf7a..52a6f3e2aa786a2032d18f1d5c688fcce551c044 100644 (file)
@@ -430,7 +430,7 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
       /* Found a function.  */
       sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
       /* Don't use line number debug info for assembly source files.  */
-      if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
+      if (sym && sym->language () != language_asm)
        {
          sal = find_pc_line (func_addr, 0);
          if (sal.end && sal.end < func_end)