Replace SYMBOL_SET_LINKAGE_NAME with a member function
authorChristian Biesinger <cbiesinger@google.com>
Tue, 26 Nov 2019 20:41:30 +0000 (14:41 -0600)
committerChristian Biesinger <cbiesinger@google.com>
Wed, 27 Nov 2019 17:09:18 +0000 (11:09 -0600)
Easier to read, shorter, and will later make it possible to make the
name field private.

gdb/ChangeLog:

2019-11-27  Christian Biesinger  <cbiesinger@google.com>

* ada-exp.y (write_ambiguous_var): Replace SYMBOL_SET_LINKAGE_NAME
with sym->set_linkage_name.
* coffread.c (coff_read_enum_type): Likewise.
* mdebugread.c (parse_symbol): Likewise.
* stabsread.c (patch_block_stabs): Likewise.
(define_symbol): Likewise.
(read_enum_type): Likewise.
(common_block_end): Likewise.
* symtab.h (struct general_symbol_info) <set_linkage_name>: New
function.
(SYMBOL_SET_LINKAGE_NAME): Remove.
* xcoffread.c (process_xcoff_symbol): Replace SYMBOL_SET_LINKAGE_NAME
with sym->set_linkage_name.

Change-Id: I174a0542c014f1b035070068076308bb8ae79abb

gdb/ChangeLog
gdb/ada-exp.y
gdb/coffread.c
gdb/mdebugread.c
gdb/stabsread.c
gdb/symtab.h
gdb/xcoffread.c

index 6544661677d06f5bbb3e2b129d3fe668ce5a79a0..028a58cd34e34e252c94ede879bc90bcf0d16ccc 100644 (file)
@@ -1,3 +1,19 @@
+2019-11-27  Christian Biesinger  <cbiesinger@google.com>
+
+       * ada-exp.y (write_ambiguous_var): Replace SYMBOL_SET_LINKAGE_NAME
+       with sym->set_linkage_name.
+       * coffread.c (coff_read_enum_type): Likewise.
+       * mdebugread.c (parse_symbol): Likewise.
+       * stabsread.c (patch_block_stabs): Likewise.
+       (define_symbol): Likewise.
+       (read_enum_type): Likewise.
+       (common_block_end): Likewise.
+       * symtab.h (struct general_symbol_info) <set_linkage_name>: New
+       function.
+       (SYMBOL_SET_LINKAGE_NAME): Remove.
+       * xcoffread.c (process_xcoff_symbol): Replace SYMBOL_SET_LINKAGE_NAME
+       with sym->set_linkage_name.
+
 2019-11-27  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * mi/mi-cmds.c (mi_cmds): Add 'symbol-info-modules' entry.
index 5e9d3e70b9292db2834e21fa9a2cb060820deea6..00020cd0677b1aa241b9dd2feb474508cb1f8ad1 100644 (file)
@@ -1105,8 +1105,7 @@ write_ambiguous_var (struct parser_state *par_state,
   struct symbol *sym = new (&temp_parse_space) symbol ();
 
   SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
-  SYMBOL_SET_LINKAGE_NAME (sym,
-                          obstack_strndup (&temp_parse_space, name, len));
+  sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
   SYMBOL_LANGUAGE (sym) = language_ada;
 
   write_exp_elt_opcode (par_state, OP_VAR_VALUE);
index ac00e1c1e3b1f3c11214dbb5b86edaf9d005be2e..d0a9233de731682d61ebe40542ccc09ad9fc771b 100644 (file)
@@ -2106,7 +2106,7 @@ coff_read_enum_type (int index, int length, int lastsym,
          sym = allocate_symbol (objfile);
 
          name = obstack_strdup (&objfile->objfile_obstack, name);
-         SYMBOL_SET_LINKAGE_NAME (sym, name);
+         sym->set_linkage_name (name);
          SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
          SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
          SYMBOL_VALUE (sym) = ms->c_value;
index c58e40c94a007c08e809eff315273f07900f68ec..f279f131711bd3a7e9f26c5da7e3f82012a064ff 100644 (file)
@@ -1066,9 +1066,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
                FIELD_BITSIZE (*f) = 0;
 
                enum_sym = allocate_symbol (mdebugread_objfile);
-               SYMBOL_SET_LINKAGE_NAME
-                 (enum_sym,
-                  obstack_strdup (&mdebugread_objfile->objfile_obstack,
+               enum_sym->set_linkage_name
+                 (obstack_strdup (&mdebugread_objfile->objfile_obstack,
                                   f->name));
                SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST;
                SYMBOL_TYPE (enum_sym) = t;
index 6ec9f971e16076ef8bb6b052199ca2b9b47d4cb1..979df0266cf08c61bd1a2984707562dcfc331667 100644 (file)
@@ -426,9 +426,8 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
              sym = allocate_symbol (objfile);
              SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
              SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
-             SYMBOL_SET_LINKAGE_NAME
-               (sym, obstack_strndup (&objfile->objfile_obstack,
-                                      name, pp - name));
+             sym->set_linkage_name
+               (obstack_strndup (&objfile->objfile_obstack, name, pp - name));
              pp += 2;
              if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
                {
@@ -710,14 +709,14 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       switch (string[1])
        {
        case 't':
-         SYMBOL_SET_LINKAGE_NAME (sym, "this");
+         sym->set_linkage_name ("this");
          break;
 
        case 'v':               /* $vtbl_ptr_type */
          goto normal;
 
        case 'e':
-         SYMBOL_SET_LINKAGE_NAME (sym, "eh_throw");
+         sym->set_linkage_name ("eh_throw");
          break;
 
        case '_':
@@ -1202,7 +1201,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
              const char *new_name = gdbarch_static_transform_name
                (gdbarch, sym->linkage_name ());
 
-             SYMBOL_SET_LINKAGE_NAME (sym, new_name);
+             sym->set_linkage_name (new_name);
              SET_SYMBOL_VALUE_ADDRESS (sym,
                                        BMSYMBOL_VALUE_ADDRESS (msym));
            }
@@ -1385,7 +1384,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
              const char *new_name = gdbarch_static_transform_name
                (gdbarch, sym->linkage_name ());
 
-             SYMBOL_SET_LINKAGE_NAME (sym, new_name);
+             sym->set_linkage_name (new_name);
              SET_SYMBOL_VALUE_ADDRESS (sym, BMSYMBOL_VALUE_ADDRESS (msym));
            }
        }
@@ -3638,7 +3637,7 @@ read_enum_type (const char **pp, struct type *type,
        return error_type (pp, objfile);
 
       sym = allocate_symbol (objfile);
-      SYMBOL_SET_LINKAGE_NAME (sym, name);
+      sym->set_linkage_name (name);
       SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
                           &objfile->objfile_obstack);
       SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
@@ -4306,7 +4305,7 @@ common_block_end (struct objfile *objfile)
 
   sym = allocate_symbol (objfile);
   /* Note: common_block_name already saved on objfile_obstack.  */
-  SYMBOL_SET_LINKAGE_NAME (sym, common_block_name);
+  sym->set_linkage_name (common_block_name);
   SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
 
   /* Now we copy all the symbols which have been defined since the BCOMM.  */
index a52f2a5db2e11147c8536c8fd62c80c983a672b7..7a5145663a17d1df38f95faa52a10e6bc3f0aa7b 100644 (file)
@@ -416,6 +416,14 @@ struct general_symbol_info
      returns the same value (same pointer) as linkage_name ().  */
   const char *search_name () const;
 
+  /* Set just the linkage name of a symbol; do not try to demangle
+     it.  Used for constructs which do not have a mangled name,
+     e.g. struct tags.  Unlike SYMBOL_SET_NAMES, linkage_name must
+     be terminated and either already on the objfile's obstack or
+     permanently allocated.  */
+  void set_linkage_name (const char *linkage_name)
+  { name = linkage_name; }
+
   /* 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
@@ -528,7 +536,6 @@ extern void symbol_set_language (struct general_symbol_info *symbol,
                                  enum language language,
                                 struct obstack *obstack);
 
-
 /* Try to determine the demangled name for a symbol, based on the
    language of that symbol.  If the language is set to language_auto,
    it will attempt to find any demangling algorithm that works and
@@ -538,14 +545,6 @@ extern void symbol_set_language (struct general_symbol_info *symbol,
 extern char *symbol_find_demangled_name (struct general_symbol_info *gsymbol,
                                         const char *mangled);
 
-/* Set just the linkage name of a symbol; do not try to demangle
-   it.  Used for constructs which do not have a mangled name,
-   e.g. struct tags.  Unlike SYMBOL_SET_NAMES, linkage_name must
-   be terminated and either already on the objfile's obstack or
-   permanently allocated.  */
-#define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \
-  (symbol)->name = (linkage_name)
-
 /* Set the linkage and natural names of a symbol, by demangling
    the linkage name.  If linkage_name may not be nullterminated,
    copy_name must be set to true.  */
index 4ea9b0b5bddc24b27a9f14fb78d5f88084f0b34a..eaa77fd4915482d4766e8d167f90ef42ba7ef374 100644 (file)
@@ -1574,7 +1574,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
          will be patched with the type from its stab entry later on in
          patch_block_stabs (), unless the file was compiled without -g.  */
 
-      SYMBOL_SET_LINKAGE_NAME (sym, SYMNAME_ALLOC (name, symname_alloced));
+      sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced));
       SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol;
 
       SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;