From: Tom Tromey Date: Thu, 10 May 2018 22:23:46 +0000 (-0600) Subject: Change add_psymbol_to_list to use an enum X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75aedd27e6a2c58734ab44cc7cad8491f19d059a;p=binutils-gdb.git Change add_psymbol_to_list to use an enum This changes add_psymbol_to_list to use an enum, rather than a pointer to a vector, to decide where to put the new symbol. This reduces the number of direct references to the static_psymbols and global_psymbols members of the objfile, which is handy in a later patch. gdb/ChangeLog 2019-01-10 Tom Tromey * xcoffread.c (scan_xcoff_symtab): Update. * psymtab.c (add_psymbol_to_list): Replace "list" parameter with "where". * mdebugread.c (parse_partial_symbols) (handle_psymbol_enumerators): Update. * dwarf2read.c (add_partial_symbol, load_partial_dies): Update. * dbxread.c (read_dbx_symtab): Update. * psympriv.h (psymbol_placement): New enum. (add_psymbol_to_list): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da78ec52eb2..e00047c27d5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2019-01-10 Tom Tromey + + * xcoffread.c (scan_xcoff_symtab): Update. + * psymtab.c (add_psymbol_to_list): Replace "list" parameter with + "where". + * mdebugread.c (parse_partial_symbols) + (handle_psymbol_enumerators): Update. + * dwarf2read.c (add_partial_symbol, load_partial_dies): Update. + * dbxread.c (read_dbx_symtab): Update. + * psympriv.h (psymbol_placement): New enum. + (add_psymbol_to_list): Update. + 2019-01-10 Tom Tromey * xcoffread.c (xcoff_start_psymtab): Remove global_psymbols and diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 21a29273f26..73e436f4f62 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1476,7 +1476,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_STATIC, data_sect_index, - &objfile->static_psymbols, + psymbol_placement::STATIC, nlist.n_value, psymtab_language, objfile); continue; @@ -1486,7 +1486,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_STATIC, data_sect_index, - &objfile->global_psymbols, + psymbol_placement::GLOBAL, nlist.n_value, psymtab_language, objfile); continue; @@ -1503,14 +1503,14 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) { add_psymbol_to_list (sym_name, sym_len, 1, STRUCT_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); p += 1; } @@ -1522,7 +1522,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) { add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); } check_enum: @@ -1583,7 +1583,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) enum constants in psymtabs, just in symtabs. */ add_psymbol_to_list (p, q - p, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, 0, + psymbol_placement::STATIC, 0, psymtab_language, objfile); /* Point past the name. */ p = q; @@ -1601,7 +1601,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) /* Constant, e.g. from "const" in Pascal. */ add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, 0, + psymbol_placement::STATIC, 0, psymtab_language, objfile); continue; @@ -1657,7 +1657,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, nlist.n_value, psymtab_language, objfile); continue; @@ -1716,7 +1716,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, nlist.n_value, psymtab_language, objfile); continue; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 338b4832daa..070a0c21954 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8888,7 +8888,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, addr, cu->language, objfile); } @@ -8898,7 +8898,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, addr, cu->language, objfile); } @@ -8906,17 +8906,12 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) set_objfile_main_name (objfile, actual_name, cu->language); break; case DW_TAG_constant: - { - std::vector *list; - - if (pdi->is_external) - list = &objfile->global_psymbols; - else - list = &objfile->static_psymbols; - add_psymbol_to_list (actual_name, strlen (actual_name), - built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, - -1, list, 0, cu->language, objfile); - } + add_psymbol_to_list (actual_name, strlen (actual_name), + built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, + -1, (pdi->is_external + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC), + 0, cu->language, objfile); break; case DW_TAG_variable: if (pdi->d.locdesc) @@ -8951,7 +8946,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, SECT_OFF_TEXT (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, addr, cu->language, objfile); } else @@ -8970,7 +8965,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, SECT_OFF_TEXT (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, has_loc ? addr : 0, cu->language, objfile); } @@ -8981,7 +8976,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name != NULL, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, cu->language, objfile); break; case DW_TAG_imported_declaration: @@ -8989,14 +8984,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name != NULL, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->global_psymbols, + psymbol_placement::GLOBAL, 0, cu->language, objfile); break; case DW_TAG_module: add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name != NULL, MODULE_DOMAIN, LOC_TYPEDEF, -1, - &objfile->global_psymbols, + psymbol_placement::GLOBAL, 0, cu->language, objfile); break; case DW_TAG_class_type: @@ -9021,8 +9016,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, STRUCT_DOMAIN, LOC_TYPEDEF, -1, cu->language == language_cplus - ? &objfile->global_psymbols - : &objfile->static_psymbols, + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC, 0, cu->language, objfile); break; @@ -9031,8 +9026,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) built_actual_name != NULL, VAR_DOMAIN, LOC_CONST, -1, cu->language == language_cplus - ? &objfile->global_psymbols - : &objfile->static_psymbols, + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC, 0, cu->language, objfile); break; default: @@ -18440,7 +18435,7 @@ load_partial_dies (const struct die_reader_specs *reader, if (building_psymtab && pdi.name != NULL) add_psymbol_to_list (pdi.name, strlen (pdi.name), 0, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, cu->language, objfile); info_ptr = locate_pdi_sibling (reader, &pdi, info_ptr); continue; @@ -18475,8 +18470,8 @@ load_partial_dies (const struct die_reader_specs *reader, add_psymbol_to_list (pdi.name, strlen (pdi.name), 0, VAR_DOMAIN, LOC_CONST, -1, cu->language == language_cplus - ? &objfile->global_psymbols - : &objfile->static_psymbols, + ? psymbol_placement::GLOBAL + : psymbol_placement::STATIC, 0, cu->language, objfile); info_ptr = locate_pdi_sibling (reader, &pdi, info_ptr); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 766a6d15318..6cf2cad182b 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -3048,7 +3048,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, sh.value, psymtab_language, objfile); continue; @@ -3059,7 +3059,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, sh.value, psymtab_language, objfile); continue; @@ -3078,7 +3078,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, STRUCT_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); if (p[2] == 't') { @@ -3087,7 +3087,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, p - namestring, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); p += 1; @@ -3101,7 +3101,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); } check_enum: @@ -3166,7 +3166,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (p, q - p, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); /* Point past the name. */ @@ -3184,7 +3184,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Constant, e.g. from "const" in Pascal. */ add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); continue; @@ -3198,7 +3198,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, sh.value, psymtab_language, objfile); continue; @@ -3217,7 +3217,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, sh.value, psymtab_language, objfile); continue; @@ -3455,13 +3455,13 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (sym_name, strlen (sym_name), 1, VAR_DOMAIN, LOC_BLOCK, section, - &objfile->global_psymbols, + psymbol_placement::GLOBAL, sh.value, psymtab_language, objfile); else add_psymbol_to_list (sym_name, strlen (sym_name), 1, VAR_DOMAIN, LOC_BLOCK, section, - &objfile->static_psymbols, + psymbol_placement::STATIC, sh.value, psymtab_language, objfile); procaddr = sh.value; @@ -3527,7 +3527,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, { add_psymbol_to_list (sym_name, strlen (sym_name), 1, STRUCT_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); } handle_psymbol_enumerators (objfile, fh, sh.st, sh.value); @@ -3567,7 +3567,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Use this gdb symbol. */ add_psymbol_to_list (sym_name, strlen (sym_name), 1, VAR_DOMAIN, theclass, section, - &objfile->static_psymbols, + psymbol_placement::STATIC, sh.value, psymtab_language, objfile); skip: cur_sdx++; /* Go to next file symbol. */ @@ -3647,7 +3647,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, add_psymbol_to_list (sym_name, strlen (sym_name), 1, VAR_DOMAIN, theclass, section, - &objfile->global_psymbols, + psymbol_placement::GLOBAL, svalue, psymtab_language, objfile); } } @@ -3808,7 +3808,7 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype, in psymtabs, just in symtabs. */ add_psymbol_to_list (name, strlen (name), 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, 0, + psymbol_placement::STATIC, 0, psymtab_language, objfile); ext_sym += external_sym_size; } diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 878be2bdc6f..9f1af742842 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -271,13 +271,22 @@ struct partial_symtab void *read_symtab_private; }; +/* Specify whether a partial psymbol should be allocated on the global + list or the static list. */ + +enum class psymbol_placement +{ + STATIC, + GLOBAL +}; + /* Add any kind of symbol to a partial_symbol vector. */ extern void add_psymbol_to_list (const char *, int, int, domain_enum, enum address_class, short /* section */, - std::vector *, + enum psymbol_placement, CORE_ADDR, enum language, struct objfile *); diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 8e467860952..ddb8e767bb4 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1638,7 +1638,7 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name, domain_enum domain, enum address_class theclass, short section, - std::vector *list, + psymbol_placement where, CORE_ADDR coreaddr, enum language language, struct objfile *objfile) { @@ -1651,11 +1651,14 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name, section, coreaddr, language, objfile, &added); /* Do not duplicate global partial symbols. */ - if (list == &objfile->global_psymbols - && !added) + if (where == psymbol_placement::GLOBAL && !added) return; /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ + std::vector *list + = (where == psymbol_placement::STATIC + ? &objfile->static_psymbols + : &objfile->global_psymbols); append_psymbol_to_list (list, psym, objfile); } diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 59de19cf17a..76c683db0c7 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2654,7 +2654,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, symbol.n_value, psymtab_language, objfile); continue; @@ -2665,7 +2665,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_STATIC, SECT_OFF_DATA (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, symbol.n_value, psymtab_language, objfile); continue; @@ -2683,14 +2683,14 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, { add_psymbol_to_list (namestring, p - namestring, 1, STRUCT_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); p += 1; } @@ -2702,7 +2702,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, { add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_TYPEDEF, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); } check_enum: @@ -2764,7 +2764,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, enum constants in psymtabs, just in symtabs. */ add_psymbol_to_list (p, q - p, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); /* Point past the name. */ p = q; @@ -2782,7 +2782,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, /* Constant, e.g. from "const" in Pascal. */ add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_CONST, -1, - &objfile->static_psymbols, + psymbol_placement::STATIC, 0, psymtab_language, objfile); continue; @@ -2800,7 +2800,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->static_psymbols, + psymbol_placement::STATIC, symbol.n_value, psymtab_language, objfile); continue; @@ -2830,7 +2830,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), - &objfile->global_psymbols, + psymbol_placement::GLOBAL, symbol.n_value, psymtab_language, objfile); continue;