diff options
author | Tom Tromey <tom@tromey.com> | 2020-04-24 15:35:01 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-24 15:35:03 -0600 |
commit | 76e288d1d2f1a6b1a19fb9856dc3256a3a5443fa (patch) | |
tree | 8f5638aae95f881bea0a282ad12146bf593e9f03 | |
parent | 2467f4f6a533a28047e0b45ce716b9b1f9f72a09 (diff) | |
download | gdb-76e288d1d2f1a6b1a19fb9856dc3256a3a5443fa.zip gdb-76e288d1d2f1a6b1a19fb9856dc3256a3a5443fa.tar.gz gdb-76e288d1d2f1a6b1a19fb9856dc3256a3a5443fa.tar.bz2 |
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 <tom@tromey.com>
* dwarf2/read.c (add_partial_symbol): Use new add_psymbol_to_list
overload.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 127 |
2 files changed, 68 insertions, 64 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 083d4d2..bf96cfe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2020-04-24 Tom Tromey <tom@tromey.com> + * dwarf2/read.c (add_partial_symbol): Use new add_psymbol_to_list + overload. + +2020-04-24 Tom Tromey <tom@tromey.com> + * psymtab.c (add_psymbol_to_bcache): Simplify calling convention. (add_psymbol_to_list): New overload. Make old overload call new one. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5663d7d..ddf4b5b 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<psymbol_placement> 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 |