+2019-10-29 Christian Biesinger <cbiesinger@google.com>
+
+ * 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) <record_full>: 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.
+
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* symtab.h (symbol_set_names): Document that copy_name must be
return NULL;
}
- return reader.record_full (cs->c_name, strlen (cs->c_name), true, address,
- type, section);
+ return reader.record_full (cs->c_name, true, address, type, section);
}
\f
/* coff_symfile_init ()
name = EXTERNAL_NAME (name, objfile->obfd);
SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
&objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile);
+ SYMBOL_SET_NAMES (sym, name, true, objfile);
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
OBJSTAT (ccp->of, n_syms++);
SYMBOL_SET_LANGUAGE (sym, language_c, &ccp->of->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
+ SYMBOL_SET_NAMES (sym, name, false, ccp->of);
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_TYPE (sym) = fip->ptype;
OBJSTAT (objfile, n_syms++);
SYMBOL_SET_LANGUAGE (sym, language_c, &objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name.get (), strlen (name.get ()), 1, objfile);
+ SYMBOL_SET_NAMES (sym, name.get (), true, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
if (type)
{
sym = new_symbol (ccp, type, id);
- SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
+ SYMBOL_SET_NAMES (sym, name, false, ccp->of);
}
break;
case CTF_K_STRUCT:
SYMBOL_TYPE (sym) = type;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
- SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
+ SYMBOL_SET_NAMES (sym, name, false, ccp->of);
add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
break;
default:
return 0;
}
- add_psymbol_to_list (name.get (), strlen (name.get ()), true,
+ add_psymbol_to_list (name.get (), true,
domain, aclass, section,
psymbol_placement::GLOBAL,
0, language_c, ccp->of);
{
ctf_context_t *ccp = (ctf_context_t *) arg;
- add_psymbol_to_list (name, strlen (name), true,
+ add_psymbol_to_list (name, true,
VAR_DOMAIN, LOC_STATIC, -1,
psymbol_placement::GLOBAL,
0, language_c, ccp->of);
else
aclass = LOC_TYPEDEF;
- add_psymbol_to_list (tname.get (), strlen (tname.get ()), true,
+ add_psymbol_to_list (tname.get (), true,
tdomain, aclass, -1,
psymbol_placement::STATIC,
0, language_c, of);
if (gdbarch_static_transform_name_p (gdbarch))
gdbarch_static_transform_name (gdbarch, namestring);
- add_psymbol_to_list (sym_name, sym_len, true,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len), true,
VAR_DOMAIN, LOC_STATIC,
data_sect_index,
psymbol_placement::STATIC,
case 'G':
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
- add_psymbol_to_list (sym_name, sym_len, true,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len), true,
VAR_DOMAIN, LOC_STATIC,
data_sect_index,
psymbol_placement::GLOBAL,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (sym_name, sym_len, true,
- STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len),
+ true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
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, true,
- VAR_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
p += 1;
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- add_psymbol_to_list (sym_name, sym_len, true,
- VAR_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
}
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- add_psymbol_to_list (p, q - p, true,
+ add_psymbol_to_list (gdb::string_view (p, q - p), true,
VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC, 0,
psymtab_language, objfile);
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (sym_name, sym_len, true,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len), true,
VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC, 0,
psymtab_language, objfile);
pst->set_text_low (nlist.n_value);
textlow_not_set = 0;
}
- add_psymbol_to_list (sym_name, sym_len, true,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len), true,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::STATIC,
pst->set_text_low (nlist.n_value);
textlow_not_set = 0;
}
- add_psymbol_to_list (sym_name, sym_len, true,
+ add_psymbol_to_list (gdb::string_view (sym_name, sym_len), true,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::GLOBAL,
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, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
}
else
{
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
set_objfile_main_name (objfile, actual_name, cu->language);
break;
case DW_TAG_constant:
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC,
-1, (pdi->is_external
? psymbol_placement::GLOBAL
table building. */
if (pdi->d.locdesc || pdi->has_type)
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_TEXT (objfile),
return;
}
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_TEXT (objfile),
case DW_TAG_typedef:
case DW_TAG_base_type:
case DW_TAG_subrange_type:
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
break;
case DW_TAG_imported_declaration:
case DW_TAG_namespace:
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::GLOBAL,
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, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
MODULE_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::GLOBAL,
/* NOTE: carlton/2003-10-07: See comment in new_symbol about
static vs. global. */
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
STRUCT_DOMAIN, LOC_TYPEDEF, -1,
cu->language == language_cplus
break;
case DW_TAG_enumerator:
- add_psymbol_to_list (actual_name, strlen (actual_name),
+ add_psymbol_to_list (actual_name,
built_actual_name != NULL,
VAR_DOMAIN, LOC_CONST, -1,
cu->language == language_cplus
sym = allocate_symbol (objfile);
SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, saved_package_name,
- strlen (saved_package_name), 0, objfile);
+ SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile);
/* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
e.g., "main" finds the "main" module and not C's main(). */
SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
|| pdi.tag == DW_TAG_subrange_type))
{
if (building_psymtab && pdi.name != NULL)
- add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
+ add_psymbol_to_list (pdi.name, false,
VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, cu->language, objfile);
if (pdi.name == NULL)
complaint (_("malformed enumerator DIE ignored"));
else if (building_psymtab)
- add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
+ add_psymbol_to_list (pdi.name, false,
VAR_DOMAIN, LOC_CONST, -1,
cu->language == language_cplus
? psymbol_placement::GLOBAL
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
linkagename = dwarf2_physname (name, die, cu);
- SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
+ SYMBOL_SET_NAMES (sym, linkagename, false, objfile);
/* Fortran does not have mangling standard and the mangling does differ
between gfortran, iFort etc. */
#include "auxv.h"
#include "mdebugread.h"
#include "ctfread.h"
+#include "gdbsupport/gdb_string_view.h"
/* Forward declarations. */
extern const struct sym_fns elf_sym_fns_gdb_index;
static struct minimal_symbol *
record_minimal_symbol (minimal_symbol_reader &reader,
- const char *name, int name_len, bool copy_name,
+ gdb::string_view name, bool copy_name,
CORE_ADDR address,
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
address = gdbarch_addr_bits_remove (gdbarch, address);
struct minimal_symbol *result
- = reader.record_full (name, name_len, copy_name, address,
+ = reader.record_full (name, copy_name, address,
ms_type,
gdb_bfd_section_index (objfile->obfd,
bfd_section));
continue;
msym = record_minimal_symbol
- (reader, sym->name, strlen (sym->name), copy_names,
+ (reader, sym->name, copy_names,
symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
{
continue; /* Skip this symbol. */
}
msym = record_minimal_symbol
- (reader, sym->name, strlen (sym->name), copy_names, symaddr,
+ (reader, sym->name, copy_names, symaddr,
ms_type, sym->section, objfile);
if (msym)
{
int len = atsign - sym->name;
- record_minimal_symbol (reader, sym->name, len, true, symaddr,
- ms_type, sym->section, objfile);
+ record_minimal_symbol (reader,
+ gdb::string_view (sym->name, len),
+ true, symaddr, ms_type, sym->section,
+ objfile);
}
}
{
struct minimal_symbol *mtramp;
- mtramp = record_minimal_symbol (reader, sym->name, len - 4,
- true, symaddr,
- mst_solib_trampoline,
- sym->section, objfile);
+ mtramp = record_minimal_symbol
+ (reader, gdb::string_view (sym->name, len - 4), true,
+ symaddr, mst_solib_trampoline, sym->section, objfile);
if (mtramp)
{
SET_MSYMBOL_SIZE (mtramp, MSYMBOL_SIZE (msym));
string_buffer.assign (name);
string_buffer.append (got_suffix, got_suffix + got_suffix_len);
- msym = record_minimal_symbol (reader, string_buffer.c_str (),
- string_buffer.size (),
+ msym = record_minimal_symbol (reader, string_buffer,
true, address, mst_slot_got_plt,
msym_section, objfile);
if (msym)
namestring = gdbarch_static_transform_name
(gdbarch, namestring);
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_STATIC,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
psymbol_placement::STATIC,
sh.value,
/* The addresses in these entries are reported
to be wrong. See the code that reads 'G's
for symtabs. */
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_STATIC,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
psymbol_placement::GLOBAL,
sh.value,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (namestring, p - namestring, true,
- STRUCT_DOMAIN, LOC_TYPEDEF,
- -1,
- psymbol_placement::STATIC,
- 0, psymtab_language, objfile);
+ add_psymbol_to_list
+ (gdb::string_view (namestring, p - namestring),
+ true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+ 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, true,
- VAR_DOMAIN, LOC_TYPEDEF,
- -1,
- psymbol_placement::STATIC,
- 0, psymtab_language,
- objfile);
+ add_psymbol_to_list
+ (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC, 0,
+ psymtab_language, objfile);
p += 1;
}
}
if (p != namestring) /* a name is there, not
just :T... */
{
- add_psymbol_to_list (namestring, p - namestring,
- true, VAR_DOMAIN, LOC_TYPEDEF,
- -1,
- psymbol_placement::STATIC,
- 0, psymtab_language, objfile);
+ add_psymbol_to_list
+ (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC, 0, psymtab_language,
+ objfile);
}
check_enum:
/* If this is an enumerated type, we need to add
/* Note that the value doesn't matter for
enum constants in psymtabs, just in
symtabs. */
- add_psymbol_to_list (p, q - p, true,
- VAR_DOMAIN, LOC_CONST,
- -1,
+ add_psymbol_to_list (gdb::string_view (p,
+ q - p),
+ true, VAR_DOMAIN,
+ LOC_CONST, -1,
psymbol_placement::STATIC,
0, psymtab_language,
objfile);
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_CONST, -1,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
continue;
function_outside_compilation_unit_complaint
(copy.c_str ());
}
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_BLOCK,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::STATIC,
sh.value,
function_outside_compilation_unit_complaint
(copy.c_str ());
}
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_BLOCK,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::GLOBAL,
sh.value,
symbol table, and the MAIN__ symbol via the minimal
symbol table. */
if (sh.st == stProc)
- add_psymbol_to_list (sym_name, strlen (sym_name), true,
+ add_psymbol_to_list (sym_name, true,
VAR_DOMAIN, LOC_BLOCK,
section,
psymbol_placement::GLOBAL,
sh.value, psymtab_language, objfile);
else
- add_psymbol_to_list (sym_name, strlen (sym_name), true,
+ add_psymbol_to_list (sym_name, true,
VAR_DOMAIN, LOC_BLOCK,
section,
psymbol_placement::STATIC,
&& sh.iss != 0
&& sh.index != cur_sdx + 2)
{
- add_psymbol_to_list (sym_name, strlen (sym_name), true,
+ add_psymbol_to_list (sym_name, true,
STRUCT_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
continue;
}
/* Use this gdb symbol. */
- add_psymbol_to_list (sym_name, strlen (sym_name), true,
+ add_psymbol_to_list (sym_name, true,
VAR_DOMAIN, theclass, section,
psymbol_placement::STATIC,
sh.value, psymtab_language, objfile);
break;
}
char *sym_name = debug_info->ssext + psh->iss;
- add_psymbol_to_list (sym_name, strlen (sym_name), true,
+ add_psymbol_to_list (sym_name, true,
VAR_DOMAIN, theclass,
section,
psymbol_placement::GLOBAL,
/* Note that the value doesn't matter for enum constants
in psymtabs, just in symtabs. */
- add_psymbol_to_list (name, strlen (name), true,
+ add_psymbol_to_list (name, true,
VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC, 0,
psymtab_language, objfile);
SYMBOL_SET_LANGUAGE (s, psymtab_language,
&mdebugread_objfile->objfile_obstack);
- SYMBOL_SET_NAMES (s, name, strlen (name), 1, mdebugread_objfile);
+ SYMBOL_SET_NAMES (s, name, true, mdebugread_objfile);
return s;
}
/* 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)
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)
{
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;
Arguments are:
NAME - the symbol's name
- NAME_LEN - the length of the name
COPY_NAME - if true, the minsym code must make a copy of NAME. If
false, then NAME must be NUL-terminated, and must have a lifetime
that is at least as long as OBJFILE's lifetime.
SECTION - the symbol's section
*/
- struct minimal_symbol *record_full (const char *name,
- int name_len,
+ struct minimal_symbol *record_full (gdb::string_view name,
bool copy_name,
CORE_ADDR address,
enum minimal_symbol_type ms_type,
int section);
/* Like record_full, but:
- - uses strlen to compute NAME_LEN,
+ - computes the length of NAME
- passes COPY_NAME = true,
- and passes a default SECTION, depending on the type
enum minimal_symbol_type ms_type);
/* Like record_full, but:
- - uses strlen to compute NAME_LEN,
+ - computes the length of NAME
- passes COPY_NAME = true.
This variant does not return the new symbol. */
enum minimal_symbol_type ms_type,
int section)
{
- record_full (name, strlen (name), true, address, ms_type, section);
+ record_full (name, true, address, ms_type, section);
}
private:
#include "psymtab.h"
#include "objfiles.h"
+#include "gdbsupport/gdb_string_view.h"
/* A partial_symbol records the name, domain, and address class of
symbols whose types we have not parsed yet. For functions, it also
LANGUAGE is the language from which the symbol originates. This will
influence, amongst other things, how the symbol name is demangled. */
-extern void add_psymbol_to_list (const char *name, int namelength,
+extern void add_psymbol_to_list (gdb::string_view name,
bool copy_name, domain_enum domain,
enum address_class theclass,
short section,
different domain (or address) is possible and correct. */
static struct partial_symbol *
-add_psymbol_to_bcache (const char *name, int namelength, bool copy_name,
+add_psymbol_to_bcache (gdb::string_view name, bool copy_name,
domain_enum domain,
enum address_class theclass,
short section,
psymbol.aclass = theclass;
symbol_set_language (&psymbol.ginfo, language,
objfile->partial_symtabs->obstack ());
- symbol_set_names (&psymbol.ginfo, name, namelength, copy_name,
+ symbol_set_names (&psymbol.ginfo, name, copy_name,
objfile->per_bfd);
/* Stash the partial symbol away in the cache. */
/* See psympriv.h. */
void
-add_psymbol_to_list (const char *name, int namelength, bool copy_name,
+add_psymbol_to_list (gdb::string_view name, bool copy_name,
domain_enum domain,
enum address_class theclass,
short section,
int added;
/* Stash the partial symbol away in the cache. */
- psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, theclass,
+ psym = add_psymbol_to_bcache (name, copy_name, domain, theclass,
section, coreaddr, language, objfile, &added);
/* Do not duplicate global partial symbols. */
if (!new_name.empty ())
{
SYMBOL_SET_NAMES (sym,
- new_name.c_str (), new_name.length (),
+ new_name,
1, objfile);
}
else
- SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
+ SYMBOL_SET_NAMES (sym, gdb::string_view (string, p - string), true,
+ objfile);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
void
symbol_set_names (struct general_symbol_info *gsymbol,
- const char *linkage_name, int len, bool copy_name,
+ gdb::string_view linkage_name, bool copy_name,
struct objfile_per_bfd_storage *per_bfd)
{
struct demangled_name_entry **slot;
/* In Ada, we do the symbol lookups using the mangled name, so
we can save some space by not storing the demangled name. */
if (!copy_name)
- gsymbol->name = linkage_name;
+ gsymbol->name = linkage_name.data ();
else
{
char *name = (char *) obstack_alloc (&per_bfd->storage_obstack,
- len + 1);
+ linkage_name.length () + 1);
- memcpy (name, linkage_name, len);
- name[len] = '\0';
+ memcpy (name, linkage_name.data (), linkage_name.length ());
+ name[linkage_name.length ()] = '\0';
gsymbol->name = name;
}
symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack);
if (per_bfd->demangled_names_hash == NULL)
create_demangled_names_hash (per_bfd);
- struct demangled_name_entry entry (gdb::string_view (linkage_name, len));
+ struct demangled_name_entry entry (linkage_name);
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash.get (),
&entry, INSERT));
/* A 0-terminated copy of the linkage name. Callers must set COPY_NAME
to true if the string might not be nullterminated. We have to make
this copy because demangling needs a nullterminated string. */
- const char *linkage_name_copy;
+ gdb::string_view linkage_name_copy;
if (copy_name)
{
- char *alloc_name = (char *) alloca (len + 1);
- memcpy (alloc_name, linkage_name, len);
- alloc_name[len] = '\0';
+ char *alloc_name = (char *) alloca (linkage_name.length () + 1);
+ memcpy (alloc_name, linkage_name.data (), linkage_name.length ());
+ alloc_name[linkage_name.length ()] = '\0';
- linkage_name_copy = alloc_name;
+ linkage_name_copy = gdb::string_view (alloc_name,
+ linkage_name.length ());
}
else
linkage_name_copy = linkage_name;
gdb::unique_xmalloc_ptr<char> demangled_name_ptr
- (symbol_find_demangled_name (gsymbol, linkage_name_copy));
+ (symbol_find_demangled_name (gsymbol, linkage_name_copy.data ()));
/* Suppose we have demangled_name==NULL, copy_name==0, and
linkage_name_copy==linkage_name. In this case, we already have the
= ((struct demangled_name_entry *)
obstack_alloc (&per_bfd->storage_obstack,
sizeof (demangled_name_entry)));
- new (*slot) demangled_name_entry
- (gdb::string_view (linkage_name, len));
+ new (*slot) demangled_name_entry (linkage_name);
}
else
{
*slot
= ((struct demangled_name_entry *)
obstack_alloc (&per_bfd->storage_obstack,
- sizeof (demangled_name_entry) + len + 1));
+ sizeof (demangled_name_entry)
+ + linkage_name.length () + 1));
char *mangled_ptr = reinterpret_cast<char *> (*slot + 1);
- memcpy (mangled_ptr, linkage_name, len);
- mangled_ptr [len] = '\0';
+ memcpy (mangled_ptr, linkage_name.data (), linkage_name.length ());
+ mangled_ptr [linkage_name.length ()] = '\0';
new (*slot) demangled_name_entry
- (gdb::string_view (mangled_ptr, len));
+ (gdb::string_view (mangled_ptr, linkage_name.length ()));
}
(*slot)->demangled = std::move (demangled_name_ptr);
(*slot)->language = gsymbol->language;
#include "gdbsupport/enum-flags.h"
#include "gdbsupport/function-view.h"
#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/next-iterator.h"
#include "completer.h"
/* 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. */
-#define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \
- symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \
+#define SYMBOL_SET_NAMES(symbol,linkage_name,copy_name,objfile) \
+ symbol_set_names (&(symbol)->ginfo, linkage_name, copy_name, \
(objfile)->per_bfd)
extern void symbol_set_names (struct general_symbol_info *symbol,
- const char *linkage_name, int len, bool copy_name,
+ gdb::string_view linkage_name, bool copy_name,
struct objfile_per_bfd_storage *per_bfd);
/* Now come lots of name accessor macros. Short version as to when to
namestring = gdbarch_static_transform_name
(gdbarch, namestring);
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_STATIC,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
psymbol_placement::STATIC,
symbol.n_value,
case 'G':
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_STATIC,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
psymbol_placement::GLOBAL,
symbol.n_value,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (namestring, p - namestring, true,
- STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
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, true,
- VAR_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
p += 1;
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_TYPEDEF, -1,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
}
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- add_psymbol_to_list (p, q - p, true,
+ add_psymbol_to_list (gdb::string_view (p, q - p), true,
VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_CONST, -1,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_CONST, -1,
psymbol_placement::STATIC,
0, psymtab_language, objfile);
continue;
function_outside_compilation_unit_complaint (name);
xfree (name);
}
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_BLOCK,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::STATIC,
symbol.n_value,
if (startswith (namestring, "@FIX"))
continue;
- add_psymbol_to_list (namestring, p - namestring, true,
- VAR_DOMAIN, LOC_BLOCK,
+ add_psymbol_to_list (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
psymbol_placement::GLOBAL,
symbol.n_value,