From: Tom Tromey Date: Fri, 24 Apr 2020 21:35:01 +0000 (-0600) Subject: Use the new add_psymbol_to_list overload X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76e288d1d2f1a6b1a19fb9856dc3256a3a5443fa;p=binutils-gdb.git Use the new add_psymbol_to_list overload This changes the DWARF reader to use the new add_psymbol_to_list overload. There should be no visible changes due to this patch. gdb/ChangeLog 2020-04-24 Tom Tromey * dwarf2/read.c (add_partial_symbol): Use new add_psymbol_to_list overload. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 083d4d29eca..bf96cfec4e3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-04-24 Tom Tromey + + * dwarf2/read.c (add_partial_symbol): Use new add_psymbol_to_list + overload. + 2020-04-24 Tom Tromey * psymtab.c (add_psymbol_to_bcache): Simplify calling convention. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5663d7dfb96..ddf4b5b1e28 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -8219,6 +8219,15 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) if (actual_name == NULL) actual_name = pdi->name; + partial_symbol psymbol; + memset (&psymbol, 0, sizeof (psymbol)); + psymbol.ginfo.set_language (cu->language, &objfile->objfile_obstack); + psymbol.ginfo.section = -1; + + /* The code below indicates that the psymbol should be installed by + setting this. */ + gdb::optional where; + switch (pdi->tag) { case DW_TAG_inlined_subroutine: @@ -8235,34 +8244,25 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) But in Ada and Fortran, we want to be able to access nested procedures globally. So all Ada and Fortran subprograms are stored in the global scope. */ - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_BLOCK, - SECT_OFF_TEXT (objfile), - psymbol_placement::GLOBAL, - addr, - cu->language, objfile); + where = psymbol_placement::GLOBAL; } else - { - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_BLOCK, - SECT_OFF_TEXT (objfile), - psymbol_placement::STATIC, - addr, cu->language, objfile); - } + where = psymbol_placement::STATIC; + + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_BLOCK; + psymbol.ginfo.section = SECT_OFF_TEXT (objfile); + psymbol.ginfo.value.address = addr; if (pdi->main_subprogram && actual_name != NULL) set_objfile_main_name (objfile, actual_name, cu->language); break; case DW_TAG_constant: - add_psymbol_to_list (actual_name, - built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, - -1, (pdi->is_external - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC), - 0, cu->language, objfile); + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_STATIC; + where = (pdi->is_external + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC); break; case DW_TAG_variable: if (pdi->d.locdesc) @@ -8293,12 +8293,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) table building. */ if (pdi->d.locdesc || pdi->has_type) - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_STATIC, - SECT_OFF_TEXT (objfile), - psymbol_placement::GLOBAL, - addr, cu->language, objfile); + { + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_STATIC; + psymbol.ginfo.section = SECT_OFF_TEXT (objfile); + psymbol.ginfo.value.address = addr; + where = psymbol_placement::GLOBAL; + } } else { @@ -8309,42 +8310,37 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) if (!has_loc && !pdi->has_const_value) return; - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_STATIC, - SECT_OFF_TEXT (objfile), - psymbol_placement::STATIC, - has_loc ? addr : 0, - cu->language, objfile); + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_STATIC; + psymbol.ginfo.section = SECT_OFF_TEXT (objfile); + if (has_loc) + psymbol.ginfo.value.address = addr; + where = psymbol_placement::STATIC; } break; case DW_TAG_typedef: case DW_TAG_base_type: case DW_TAG_subrange_type: - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_TYPEDEF, -1, - psymbol_placement::STATIC, - 0, cu->language, objfile); + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_TYPEDEF; + where = psymbol_placement::STATIC; break; case DW_TAG_imported_declaration: case DW_TAG_namespace: - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_TYPEDEF, -1, - psymbol_placement::GLOBAL, - 0, cu->language, objfile); + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_TYPEDEF; + where = psymbol_placement::GLOBAL; break; case DW_TAG_module: /* With Fortran 77 there might be a "BLOCK DATA" module available without any name. If so, we skip the module as it doesn't bring any value. */ if (actual_name != nullptr) - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - MODULE_DOMAIN, LOC_TYPEDEF, -1, - psymbol_placement::GLOBAL, - 0, cu->language, objfile); + { + psymbol.domain = MODULE_DOMAIN; + psymbol.aclass = LOC_TYPEDEF; + where = psymbol_placement::GLOBAL; + } break; case DW_TAG_class_type: case DW_TAG_interface_type: @@ -8361,27 +8357,30 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) /* NOTE: carlton/2003-10-07: See comment in new_symbol about static vs. global. */ - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - STRUCT_DOMAIN, LOC_TYPEDEF, -1, - cu->language == language_cplus - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC, - 0, cu->language, objfile); - + psymbol.domain = STRUCT_DOMAIN; + psymbol.aclass = LOC_TYPEDEF; + where = (cu->language == language_cplus + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC); break; case DW_TAG_enumerator: - add_psymbol_to_list (actual_name, - built_actual_name != NULL, - VAR_DOMAIN, LOC_CONST, -1, - cu->language == language_cplus - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC, - 0, cu->language, objfile); + psymbol.domain = VAR_DOMAIN; + psymbol.aclass = LOC_CONST; + where = (cu->language == language_cplus + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC); break; default: break; } + + if (where.has_value ()) + { + psymbol.ginfo.compute_and_set_names (actual_name, + built_actual_name != nullptr, + objfile->per_bfd); + add_psymbol_to_list (psymbol, *where, objfile); + } } /* Read a partial die corresponding to a namespace; also, add a symbol