From 31edb802957b0073c571f48b9262e66b817fd360 Mon Sep 17 00:00:00 2001 From: Christian Biesinger Date: Sun, 13 Oct 2019 06:57:14 -0500 Subject: Change some arguments to gdb::string_view instead of name+len Just some code cleanup. This change has a few benefits: - Shorter argument list in the functions - If the caller needs to calculate the string, they no longer need to explicitly call strlen - It is easy to pass std::string to this (done in one place currently) This also updates a couple of places that were passing 0/1 to a bool parameter. gdb/ChangeLog: 2019-10-29 Christian Biesinger * coffread.c (record_minimal_symbol): Update. (process_coff_symbol): Update. * dbxread.c (read_dbx_symtab): Update. * dwarf2read.c (add_partial_symbol): Update. (fixup_go_packaging): Update. (load_partial_dies): Update. (new_symbol): Update. * elfread.c (record_minimal_symbol): Change signature to use gdb::string_view instead of name+len. (elf_symtab_read): Update. (elf_rel_plt_read): Update. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Update. (new_symbol): Update. * minsyms.c (minimal_symbol_reader::record_full): Change signature to use gdb::string_view instead of name+len. * minsyms.h (class minimal_symbol_reader) : Likewise. * psympriv.h (add_psymbol_to_list): Likewise. * psymtab.c (add_psymbol_to_bcache): Likewise. (add_psymbol_to_list): Likewise. * stabsread.c (define_symbol): Update. * symtab.c (symbol_set_names): Change signature to use gdb::string_view. * symtab.h (SYMBOL_SET_NAMES): Likewise. (symbol_set_names): Likewise. * xcoffread.c (scan_xcoff_symtab): Update. Change-Id: I2675c6865e0368f9c755a1081088a53aa54dda4c --- gdb/minsyms.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'gdb/minsyms.c') diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 0267472..db3e546 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1086,7 +1086,7 @@ mst_str (minimal_symbol_type t) /* See minsyms.h. */ struct minimal_symbol * -minimal_symbol_reader::record_full (const char *name, int name_len, +minimal_symbol_reader::record_full (gdb::string_view name, bool copy_name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section) @@ -1100,24 +1100,22 @@ minimal_symbol_reader::record_full (const char *name, int name_len, lookup_minimal_symbol_by_pc would have no way of getting the right one. */ if (ms_type == mst_file_text && name[0] == 'g' - && (strcmp (name, GCC_COMPILED_FLAG_SYMBOL) == 0 - || strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)) + && (name == GCC_COMPILED_FLAG_SYMBOL + || name == GCC2_COMPILED_FLAG_SYMBOL)) return (NULL); /* It's safe to strip the leading char here once, since the name is also stored stripped in the minimal symbol table. */ if (name[0] == get_symbol_leading_char (m_objfile->obfd)) - { - ++name; - --name_len; - } + name = name.substr (1); if (ms_type == mst_file_text && startswith (name, "__gnu_compiled")) return (NULL); if (symtab_create_debug >= 2) - printf_unfiltered ("Recording minsym: %-21s %18s %4d %s\n", - mst_str (ms_type), hex_string (address), section, name); + printf_unfiltered ("Recording minsym: %-21s %18s %4d %.*s\n", + mst_str (ms_type), hex_string (address), section, + (int) name.size (), name.data ()); if (m_msym_bunch_index == BUNCH_SIZE) { @@ -1129,7 +1127,7 @@ minimal_symbol_reader::record_full (const char *name, int name_len, msymbol = &m_msym_bunch->contents[m_msym_bunch_index]; symbol_set_language (msymbol, language_auto, &m_objfile->per_bfd->storage_obstack); - symbol_set_names (msymbol, name, name_len, copy_name, m_objfile->per_bfd); + symbol_set_names (msymbol, name, copy_name, m_objfile->per_bfd); SET_MSYMBOL_VALUE_ADDRESS (msymbol, address); MSYMBOL_SECTION (msymbol) = section; -- cgit v1.1