{
/* The dwarf2_per_objfile owning the CUs we are iterating on. */
struct dwarf2_per_objfile *dwarf2_per_objfile;
- /* If non-zero, only look for symbols that match BLOCK_INDEX. */
- int want_specific_block;
- /* One of GLOBAL_BLOCK or STATIC_BLOCK.
- Unused if !WANT_SPECIFIC_BLOCK. */
- int block_index;
+ /* If set, only look for symbols that match that block. Valid values are
+ GLOBAL_BLOCK and STATIC_BLOCK. */
+ gdb::optional<int> block_index;
/* The kind of symbol we're looking for. */
domain_enum domain;
/* The list of CUs from the index entry of the symbol,
int global_seen;
};
-/* Initialize the index symtab iterator ITER.
- If WANT_SPECIFIC_BLOCK is non-zero, only look for symbols
- in block BLOCK_INDEX. Otherwise BLOCK_INDEX is ignored. */
+/* Initialize the index symtab iterator ITER. */
static void
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
struct dwarf2_per_objfile *dwarf2_per_objfile,
- int want_specific_block,
- int block_index,
+ gdb::optional<int> block_index,
domain_enum domain,
const char *name)
{
iter->dwarf2_per_objfile = dwarf2_per_objfile;
- iter->want_specific_block = want_specific_block;
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
offset_type cu_index_and_attrs =
MAYBE_SWAP (iter->vec[iter->next + 1]);
offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
- int want_static = iter->block_index != GLOBAL_BLOCK;
- /* This value is only valid for index versions >= 7. */
- int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
gdb_index_symbol_kind symbol_kind =
GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
/* Only check the symbol attributes if they're present.
/* Check static vs global. */
if (attrs_valid)
{
- if (iter->want_specific_block
- && want_static != is_static)
- continue;
+ bool is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
+
+ if (iter->block_index.has_value ())
+ {
+ bool want_static = *iter->block_index == STATIC_BLOCK;
+
+ if (is_static != want_static)
+ continue;
+ }
+
/* Work around gold/15646. */
if (!is_static && iter->global_seen)
continue;
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
- dw2_symtab_iter_init (&iter, dwarf2_per_objfile, 1, block_index, domain, name);
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, block_index, domain, name);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
{
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
- /* Note: It doesn't matter what we pass for block_index here. */
- dw2_symtab_iter_init (&iter, dwarf2_per_objfile, 0, GLOBAL_BLOCK, VAR_DOMAIN,
- func_name);
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, {}, VAR_DOMAIN, func_name);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
dw2_instantiate_symtab (per_cu, false);
class dw2_debug_names_iterator
{
public:
- /* If WANT_SPECIFIC_BLOCK is true, only look for symbols in block
- BLOCK_INDEX. Otherwise BLOCK_INDEX is ignored. */
dw2_debug_names_iterator (const mapped_debug_names &map,
- bool want_specific_block,
- block_enum block_index, domain_enum domain,
+ gdb::optional<block_enum> block_index,
+ domain_enum domain,
const char *name)
- : m_map (map), m_want_specific_block (want_specific_block),
- m_block_index (block_index), m_domain (domain),
+ : m_map (map), m_block_index (block_index), m_domain (domain),
m_addr (find_vec_in_debug_names (map, name))
{}
/* The internalized form of .debug_names. */
const mapped_debug_names &m_map;
- /* If true, only look for symbols that match BLOCK_INDEX. */
- const bool m_want_specific_block = false;
-
- /* One of GLOBAL_BLOCK or STATIC_BLOCK.
- Unused if !WANT_SPECIFIC_BLOCK - FIRST_LOCAL_BLOCK is an invalid
- value. */
- const block_enum m_block_index = FIRST_LOCAL_BLOCK;
+ /* If set, only look for symbols that match that block. Valid values are
+ GLOBAL_BLOCK and STATIC_BLOCK. */
+ const gdb::optional<block_enum> m_block_index;
/* The kind of symbol we're looking for. */
const domain_enum m_domain = UNDEF_DOMAIN;
return NULL;
}
const mapped_debug_names::index_val &indexval = indexval_it->second;
- bool have_is_static = false;
- bool is_static;
+ gdb::optional<bool> is_static;
dwarf2_per_cu_data *per_cu = NULL;
for (const mapped_debug_names::index_val::attr &attr : indexval.attr_vec)
{
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
break;
- have_is_static = true;
is_static = true;
break;
case DW_IDX_GNU_external:
if (!m_map.augmentation_is_gdb)
break;
- have_is_static = true;
is_static = false;
break;
}
goto again;
/* Check static vs global. */
- if (have_is_static)
+ if (is_static.has_value () && m_block_index.has_value ())
{
- const bool want_static = m_block_index != GLOBAL_BLOCK;
- if (m_want_specific_block && want_static != is_static)
- goto again;
+ const bool want_static = *m_block_index == STATIC_BLOCK;
+ if (want_static != *is_static)
+ goto again;
}
/* Match dw2_symtab_iter_next, symbol_kind
}
const auto &map = *mapp;
- dw2_debug_names_iterator iter (map, true /* want_specific_block */,
- block_index, domain, name);
+ dw2_debug_names_iterator iter (map, block_index, domain, name);
struct compunit_symtab *stab_best = NULL;
struct dwarf2_per_cu_data *per_cu;
{
const mapped_debug_names &map = *dwarf2_per_objfile->debug_names_table;
- /* Note: It doesn't matter what we pass for block_index here. */
- dw2_debug_names_iterator iter (map, false /* want_specific_block */,
- GLOBAL_BLOCK, VAR_DOMAIN, func_name);
+ dw2_debug_names_iterator iter (map, {}, VAR_DOMAIN, func_name);
struct dwarf2_per_cu_data *per_cu;
while ((per_cu = iter.next ()) != NULL)
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
const char *saved_package_name
- = (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
- package_name,
- strlen (package_name));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name);
struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
saved_package_name);
struct symbol *sym;
INTERMEDIATE_NAME is already canonical, then we need to
copy it to the appropriate obstack. */
if (canonical_name == NULL || canonical_name == intermediate_name.c_str ())
- name = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- intermediate_name.c_str (),
- intermediate_name.length ()));
+ name = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ intermediate_name);
else
name = canonical_name;
}
retval = canon;
if (need_copy)
- retval = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- retval, strlen (retval)));
+ retval = obstack_strdup (&objfile->per_bfd->storage_obstack, retval);
return retval;
}
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- virtual_dwo_name.c_str (),
- virtual_dwo_name.size ());
+ dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
+ virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev = sections.abbrev;
dwo_file->sections.line = sections.line;
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- virtual_dwo_name.c_str (),
- virtual_dwo_name.size ());
+ dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
+ virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev =
create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.abbrev,
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
struct_pdi->name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- actual_class_name,
- strlen (actual_class_name)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ actual_class_name);
xfree (actual_class_name);
}
break;
base = demangled;
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- base, strlen (base)));
+ name = obstack_strdup (&objfile->per_bfd->storage_obstack, base);
xfree (demangled);
}
}
objfile_name (objfile),
sect_offset_str (cu->header.sect_off),
sect_offset_str (die->sect_off));
- saved = (char *) obstack_copy0 (&objfile->objfile_obstack,
- message.c_str (), message.length ());
+ saved = obstack_strdup (&objfile->objfile_obstack, message);
return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
}
if (actual_name_len > die_name_len + 2
&& actual_name[actual_name_len
- die_name_len - 1] == ':')
- name = (char *) obstack_copy0 (
+ name = obstack_strndup (
&objfile->per_bfd->storage_obstack,
actual_name, actual_name_len - die_name_len - 2);
}
return "";
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- return (char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
- DW_STRING (attr),
- &base[-1] - DW_STRING (attr));
+ return obstack_strndup (&objfile->per_bfd->storage_obstack,
+ DW_STRING (attr),
+ &base[-1] - DW_STRING (attr));
}
/* Return the name of the namespace/class that DIE is defined within,
if (!canon_name.empty ())
{
if (canon_name != name)
- name = (const char *) obstack_copy0 (obstack,
- canon_name.c_str (),
- canon_name.length ());
+ name = obstack_strdup (obstack, canon_name);
}
}
/* FIXME: we already did this for the partial symbol... */
DW_STRING (attr)
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- demangled, strlen (demangled)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ demangled);
DW_STRING_IS_CANONICAL (attr) = 1;
xfree (demangled);
{
add_prefix_cmd ("dwarf", class_maintenance, set_dwarf_cmd, _("\
Set DWARF specific variables.\n\
-Configure DWARF variables such as the cache size"),
+Configure DWARF variables such as the cache size."),
&set_dwarf_cmdlist, "maintenance set dwarf ",
0/*allow-unknown*/, &maintenance_set_cmdlist);
add_prefix_cmd ("dwarf", class_maintenance, show_dwarf_cmd, _("\
-Show DWARF specific variables\n\
-Show DWARF variables such as the cache size"),
+Show DWARF specific variables.\n\
+Show DWARF variables such as the cache size."),
&show_dwarf_cmdlist, "maintenance show dwarf ",
0/*allow-unknown*/, &maintenance_show_cmdlist);