mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
Compare commits
21 Commits
efbd9add96
...
users/vrie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e76289d2b3 | ||
|
|
3240a7e734 | ||
|
|
333d407393 | ||
|
|
4f005db8e0 | ||
|
|
b4303a08c2 | ||
|
|
c2ae16cc58 | ||
|
|
a4f4bbc353 | ||
|
|
2f8fd1da0e | ||
|
|
b0a46c96e4 | ||
|
|
19947698de | ||
|
|
3164537f25 | ||
|
|
fa25a1fa4a | ||
|
|
5a74a1a528 | ||
|
|
060f7c545b | ||
|
|
3f7397885b | ||
|
|
281b014f52 | ||
|
|
80a527c1c9 | ||
|
|
9ce66f579a | ||
|
|
947a158521 | ||
|
|
b4045c876d | ||
|
|
ce6da2065f |
0
gdb/COVER-LETTER
Normal file
0
gdb/COVER-LETTER
Normal file
@@ -2607,7 +2607,7 @@ arm_exidx_new_objfile (struct objfile *objfile)
|
||||
if (n_bytes || n_words)
|
||||
{
|
||||
gdb_byte *p = entry
|
||||
= (gdb_byte *) obstack_alloc (&objfile->objfile_obstack,
|
||||
= (gdb_byte *) obstack_alloc (objfile->objfile_obstack (),
|
||||
n_bytes + n_words * 4 + 1);
|
||||
|
||||
while (n_bytes--)
|
||||
|
||||
11
gdb/bcache.c
11
gdb/bcache.c
@@ -24,6 +24,11 @@
|
||||
#include "bcache.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
|
||||
#if CXX_STD_THREAD
|
||||
static std::mutex bcache_lock;
|
||||
#endif
|
||||
|
||||
namespace gdb {
|
||||
|
||||
@@ -63,6 +68,9 @@ struct bstring
|
||||
void
|
||||
bcache::expand_hash_table ()
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
//std::lock_guard<std::mutex> guard (bcache_lock);
|
||||
#endif
|
||||
/* A table of good hash table sizes. Whenever we grow, we pick the
|
||||
next larger size from this table. sizes[i] is close to 1 << (i+10),
|
||||
so we roughly double the table size each time. After we fall off
|
||||
@@ -142,6 +150,9 @@ bcache::expand_hash_table ()
|
||||
const void *
|
||||
bcache::insert (const void *addr, int length, bool *added)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::mutex> guard (bcache_lock);
|
||||
#endif
|
||||
unsigned long full_hash;
|
||||
unsigned short half_hash;
|
||||
int hash_index;
|
||||
|
||||
@@ -881,7 +881,7 @@ make_blockranges (struct objfile *objfile,
|
||||
size_t n = rangevec.size();
|
||||
|
||||
blr = (struct blockranges *)
|
||||
obstack_alloc (&objfile->objfile_obstack,
|
||||
obstack_alloc (objfile->objfile_obstack (),
|
||||
sizeof (struct blockranges)
|
||||
+ (n - 1) * sizeof (struct blockrange));
|
||||
|
||||
|
||||
@@ -211,13 +211,13 @@ buildsym_compunit::finish_block_internal
|
||||
struct pending_block *opblock;
|
||||
|
||||
block = (is_global
|
||||
? allocate_global_block (&m_objfile->objfile_obstack)
|
||||
: allocate_block (&m_objfile->objfile_obstack));
|
||||
? allocate_global_block (m_objfile->objfile_obstack ())
|
||||
: allocate_block (m_objfile->objfile_obstack ()));
|
||||
|
||||
if (symbol)
|
||||
{
|
||||
block->set_multidict
|
||||
(mdict_create_linear (&m_objfile->objfile_obstack, *listhead));
|
||||
(mdict_create_linear (m_objfile->objfile_obstack (), *listhead));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -230,7 +230,7 @@ buildsym_compunit::finish_block_internal
|
||||
else
|
||||
{
|
||||
block->set_multidict
|
||||
(mdict_create_hashed (&m_objfile->objfile_obstack, *listhead));
|
||||
(mdict_create_hashed (m_objfile->objfile_obstack (), *listhead));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ buildsym_compunit::finish_block_internal
|
||||
(is_global
|
||||
? m_global_using_directives
|
||||
: m_local_using_directives),
|
||||
&m_objfile->objfile_obstack);
|
||||
m_objfile->objfile_obstack ());
|
||||
if (is_global)
|
||||
m_global_using_directives = NULL;
|
||||
else
|
||||
@@ -434,7 +434,7 @@ buildsym_compunit::make_blockvector ()
|
||||
}
|
||||
|
||||
blockvector = (struct blockvector *)
|
||||
obstack_alloc (&m_objfile->objfile_obstack,
|
||||
obstack_alloc (m_objfile->objfile_obstack (),
|
||||
(sizeof (struct blockvector)
|
||||
+ (i - 1) * sizeof (struct block *)));
|
||||
|
||||
@@ -454,8 +454,8 @@ buildsym_compunit::make_blockvector ()
|
||||
blockvector. */
|
||||
if (m_pending_addrmap_interesting)
|
||||
blockvector->set_map
|
||||
(new (&m_objfile->objfile_obstack) addrmap_fixed
|
||||
(&m_objfile->objfile_obstack, &m_pending_addrmap));
|
||||
(new (m_objfile->objfile_obstack ()) addrmap_fixed
|
||||
(m_objfile->objfile_obstack (), &m_pending_addrmap));
|
||||
else
|
||||
blockvector->set_map (nullptr);
|
||||
|
||||
@@ -939,7 +939,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
|
||||
int linetablesize = sizeof (struct linetable) + entry_array_size;
|
||||
|
||||
symtab->set_linetable
|
||||
(XOBNEWVAR (&m_objfile->objfile_obstack, struct linetable,
|
||||
(XOBNEWVAR (m_objfile->objfile_obstack (), struct linetable,
|
||||
linetablesize));
|
||||
|
||||
symtab->linetable ()->nitems = n_entries;
|
||||
@@ -966,7 +966,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
|
||||
if (!m_comp_dir.empty ())
|
||||
{
|
||||
/* Reallocate the dirname on the symbol obstack. */
|
||||
cu->set_dirname (obstack_strdup (&m_objfile->objfile_obstack,
|
||||
cu->set_dirname (obstack_strdup (m_objfile->objfile_obstack (),
|
||||
m_comp_dir.c_str ()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1561,13 +1561,13 @@ process_coff_symbol (struct coff_symbol *cs,
|
||||
union internal_auxent *aux,
|
||||
struct objfile *objfile)
|
||||
{
|
||||
struct symbol *sym = new (&objfile->objfile_obstack) symbol;
|
||||
struct symbol *sym = new (objfile->objfile_obstack ()) symbol;
|
||||
char *name;
|
||||
|
||||
name = cs->c_name;
|
||||
name = EXTERNAL_NAME (name, objfile->obfd);
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
sym->compute_and_set_names (name, true, objfile->per_bfd);
|
||||
|
||||
/* default assumptions */
|
||||
@@ -2014,7 +2014,7 @@ coff_read_struct_type (int index, int length, int lastsym,
|
||||
list = newobj;
|
||||
|
||||
/* Save the data. */
|
||||
list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
|
||||
list->field.set_name (obstack_strdup (objfile->objfile_obstack (),
|
||||
name));
|
||||
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
|
||||
objfile));
|
||||
@@ -2031,7 +2031,7 @@ coff_read_struct_type (int index, int length, int lastsym,
|
||||
list = newobj;
|
||||
|
||||
/* Save the data. */
|
||||
list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
|
||||
list->field.set_name (obstack_strdup (objfile->objfile_obstack (),
|
||||
name));
|
||||
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
|
||||
objfile));
|
||||
@@ -2100,9 +2100,9 @@ coff_read_enum_type (int index, int length, int lastsym,
|
||||
switch (ms->c_sclass)
|
||||
{
|
||||
case C_MOE:
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
|
||||
name = obstack_strdup (&objfile->objfile_obstack, name);
|
||||
name = obstack_strdup (objfile->objfile_obstack (), name);
|
||||
sym->set_linkage_name (name);
|
||||
sym->set_aclass_index (LOC_CONST);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
|
||||
@@ -693,7 +693,7 @@ compile_object_load (const compile_file_names &file_names,
|
||||
/* The memory may be later needed
|
||||
by bfd_generic_get_relocated_section_contents
|
||||
called from default_symfile_relocate. */
|
||||
symbol_table = (asymbol **) obstack_alloc (&objfile->objfile_obstack,
|
||||
symbol_table = (asymbol **) obstack_alloc (objfile->objfile_obstack (),
|
||||
storage_needed);
|
||||
number_of_symbols = bfd_canonicalize_symtab (abfd.get (), symbol_table);
|
||||
if (number_of_symbols < 0)
|
||||
|
||||
@@ -97,7 +97,7 @@ cp_scan_for_anonymous_namespaces (struct buildsym_compunit *compunit,
|
||||
std::vector<const char *> excludes;
|
||||
add_using_directive (compunit->get_local_using_directives (),
|
||||
dest, src, NULL, NULL, excludes,
|
||||
1, &objfile->objfile_obstack);
|
||||
1, objfile->objfile_obstack ());
|
||||
}
|
||||
/* The "+ 2" is for the "::". */
|
||||
previous_component = next_component + 2;
|
||||
|
||||
@@ -257,7 +257,7 @@ set_tid_type (struct objfile *of, ctf_id_t tid, struct type *typ)
|
||||
ids.type = typ;
|
||||
slot = (struct ctf_tid_and_type **) htab_find_slot (htab, &ids, INSERT);
|
||||
if (*slot == nullptr)
|
||||
*slot = XOBNEW (&of->objfile_obstack, struct ctf_tid_and_type);
|
||||
*slot = XOBNEW (of->objfile_obstack (), struct ctf_tid_and_type);
|
||||
**slot = ids;
|
||||
return typ;
|
||||
}
|
||||
@@ -445,10 +445,10 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
|
||||
|
||||
if (name != nullptr)
|
||||
{
|
||||
struct symbol *sym = new (&ccp->of->objfile_obstack) symbol;
|
||||
struct symbol *sym = new (ccp->of->objfile_obstack ()) symbol;
|
||||
OBJSTAT (ccp->of, n_syms++);
|
||||
|
||||
sym->set_language (language_c, &ccp->of->objfile_obstack);
|
||||
sym->set_language (language_c, ccp->of->objfile_obstack ());
|
||||
sym->compute_and_set_names (name, false, ccp->of->per_bfd);
|
||||
sym->set_aclass_index (LOC_CONST);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
@@ -474,10 +474,10 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
|
||||
const char *name = ctf_type_name_raw (fp, tid);
|
||||
if (name != nullptr)
|
||||
{
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
OBJSTAT (objfile, n_syms++);
|
||||
|
||||
sym->set_language (language_c, &objfile->objfile_obstack);
|
||||
sym->set_language (language_c, objfile->objfile_obstack ());
|
||||
sym->compute_and_set_names (name, false, objfile->per_bfd);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
sym->set_aclass_index (LOC_OPTIMIZED_OUT);
|
||||
@@ -928,7 +928,7 @@ read_typedef_type (struct ctf_context *ccp, ctf_id_t tid,
|
||||
struct objfile *objfile = ccp->of;
|
||||
struct type *this_type, *target_type;
|
||||
|
||||
char *aname = obstack_strdup (&objfile->objfile_obstack, name);
|
||||
char *aname = obstack_strdup (objfile->objfile_obstack (), name);
|
||||
this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, aname);
|
||||
set_tid_type (objfile, tid, this_type);
|
||||
target_type = fetch_tid_type (ccp, btid);
|
||||
@@ -1167,7 +1167,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
|
||||
complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id);
|
||||
type = objfile_type (ccp->of)->builtin_error;
|
||||
}
|
||||
sym = new (&ccp->of->objfile_obstack) symbol;
|
||||
sym = new (ccp->of->objfile_obstack ()) symbol;
|
||||
OBJSTAT (ccp->of, n_syms++);
|
||||
sym->set_type (type);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
@@ -1203,7 +1203,7 @@ add_stt_entries (struct ctf_context *ccp, int functions)
|
||||
type = get_tid_type (ccp->of, tid);
|
||||
if (type == nullptr)
|
||||
continue;
|
||||
sym = new (&ccp->of->objfile_obstack) symbol;
|
||||
sym = new (ccp->of->objfile_obstack ()) symbol;
|
||||
OBJSTAT (ccp->of, n_syms++);
|
||||
sym->set_type (type);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
|
||||
@@ -669,7 +669,7 @@ dbx_symfile_init (struct objfile *objfile)
|
||||
DBX_STRINGTAB_SIZE (objfile));
|
||||
|
||||
DBX_STRINGTAB (objfile) =
|
||||
(char *) obstack_alloc (&objfile->objfile_obstack,
|
||||
(char *) obstack_alloc (objfile->objfile_obstack (),
|
||||
DBX_STRINGTAB_SIZE (objfile));
|
||||
OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile));
|
||||
|
||||
@@ -1440,7 +1440,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
|
||||
if (new_name != nullptr)
|
||||
{
|
||||
sym_len = strlen (new_name.get ());
|
||||
sym_name = obstack_strdup (&objfile->objfile_obstack,
|
||||
sym_name = obstack_strdup (objfile->objfile_obstack (),
|
||||
new_name.get ());
|
||||
}
|
||||
}
|
||||
@@ -1945,7 +1945,7 @@ start_psymtab (psymtab_storage *partial_symtabs, struct objfile *objfile,
|
||||
objfile->per_bfd, textlow);
|
||||
|
||||
result->read_symtab_private =
|
||||
XOBNEW (&objfile->objfile_obstack, struct symloc);
|
||||
XOBNEW (objfile->objfile_obstack (), struct symloc);
|
||||
LDSYMOFF (result) = ldsymoff;
|
||||
result->legacy_read_symtab = dbx_read_symtab;
|
||||
result->legacy_expand_psymtab = dbx_expand_psymtab;
|
||||
@@ -2068,7 +2068,7 @@ dbx_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs,
|
||||
new legacy_psymtab (include_list[i], partial_symtabs, objfile->per_bfd);
|
||||
|
||||
subpst->read_symtab_private =
|
||||
XOBNEW (&objfile->objfile_obstack, struct symloc);
|
||||
XOBNEW (objfile->objfile_obstack (), struct symloc);
|
||||
LDSYMOFF (subpst) =
|
||||
LDSYMLEN (subpst) = 0;
|
||||
|
||||
@@ -2452,7 +2452,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
|
||||
|
||||
/* For C++, set the block's scope. */
|
||||
if (cstk.name->language () == language_cplus)
|
||||
cp_set_block_scope (cstk.name, block, &objfile->objfile_obstack);
|
||||
cp_set_block_scope (cstk.name, block, objfile->objfile_obstack ());
|
||||
|
||||
/* May be switching to an assembler file which may not be using
|
||||
block relative stabs, so reset the offset. */
|
||||
@@ -2819,7 +2819,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
|
||||
/* For C++, set the block's scope. */
|
||||
if (cstk.name->language () == language_cplus)
|
||||
cp_set_block_scope (cstk.name, block,
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
}
|
||||
|
||||
newobj = push_context (0, valu);
|
||||
@@ -2949,7 +2949,7 @@ coffstab_build_psymtabs (struct objfile *objfile,
|
||||
if (stabstrsize > bfd_get_size (sym_bfd))
|
||||
error (_("ridiculous string table size: %d bytes"), stabstrsize);
|
||||
DBX_STRINGTAB (objfile) = (char *)
|
||||
obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
|
||||
obstack_alloc (objfile->objfile_obstack (), stabstrsize + 1);
|
||||
OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
|
||||
|
||||
/* Now read in the string table in one big gulp. */
|
||||
@@ -3042,7 +3042,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
|
||||
if (stabstrsize > bfd_get_size (sym_bfd))
|
||||
error (_("ridiculous string table size: %d bytes"), stabstrsize);
|
||||
DBX_STRINGTAB (objfile) = (char *)
|
||||
obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
|
||||
obstack_alloc (objfile->objfile_obstack (), stabstrsize + 1);
|
||||
OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
|
||||
|
||||
/* Now read in the string table in one big gulp. */
|
||||
@@ -3137,7 +3137,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
|
||||
error (_("ridiculous string table size: %d bytes"),
|
||||
DBX_STRINGTAB_SIZE (objfile));
|
||||
DBX_STRINGTAB (objfile) = (char *)
|
||||
obstack_alloc (&objfile->objfile_obstack,
|
||||
obstack_alloc (objfile->objfile_obstack (),
|
||||
DBX_STRINGTAB_SIZE (objfile) + 1);
|
||||
OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile) + 1);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "dwarf2/cu.h"
|
||||
#include "dwarf2/read.h"
|
||||
#include "objfiles.h"
|
||||
#include "gdbsupport/thread-pool.h"
|
||||
|
||||
/* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */
|
||||
|
||||
@@ -161,8 +162,8 @@ dwarf2_cu::get_builder ()
|
||||
if (m_builder != nullptr)
|
||||
return m_builder.get ();
|
||||
|
||||
if (per_objfile->sym_cu != nullptr)
|
||||
return per_objfile->sym_cu->m_builder.get ();
|
||||
if (per_objfile->sym_cu[gdb::thread_pool::id()] != nullptr)
|
||||
return per_objfile->sym_cu[gdb::thread_pool::id()]->m_builder.get ();
|
||||
|
||||
gdb_assert_not_reached ("");
|
||||
}
|
||||
|
||||
@@ -7067,6 +7067,13 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
|
||||
|
||||
using iter_type = decltype (per_bfd->all_comp_units.begin ());
|
||||
|
||||
std::function<unsigned int (iter_type)> task_size
|
||||
= [=] (iter_type iter)
|
||||
{
|
||||
dwarf2_per_cu_data *per_cu = iter->get ();
|
||||
return per_cu->length ();
|
||||
};
|
||||
|
||||
/* Each thread returns a pair holding a cooked index, and a vector
|
||||
of errors that should be printed. The latter is done because
|
||||
GDB's I/O system is not thread-safe. run_on_main_thread could be
|
||||
@@ -7095,7 +7102,7 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
|
||||
}
|
||||
}
|
||||
return result_type (thread_storage.release (), std::move (errors));
|
||||
});
|
||||
}, &task_size);
|
||||
|
||||
/* Only show a given exception a single time. */
|
||||
std::unordered_set<gdb_exception> seen_exceptions;
|
||||
@@ -7479,7 +7486,7 @@ queue_comp_unit (dwarf2_per_cu_data *per_cu,
|
||||
per_cu->queued = 1;
|
||||
|
||||
gdb_assert (per_objfile->queue.has_value ());
|
||||
per_objfile->queue->emplace (per_cu, per_objfile, pretend_language);
|
||||
per_objfile->queue->emplace_back (per_cu, per_objfile, pretend_language);
|
||||
}
|
||||
|
||||
/* If PER_CU is not yet expanded of queued for expansion, add it to the queue.
|
||||
@@ -7552,65 +7559,106 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu,
|
||||
return queued && cu == nullptr;
|
||||
}
|
||||
|
||||
/* Process a queue item ITEM, helper function of process_queue. */
|
||||
|
||||
static void
|
||||
process_queue_item (dwarf2_per_objfile *per_objfile, dwarf2_queue_item &item)
|
||||
{
|
||||
dwarf2_per_cu_data *per_cu = item.per_cu;
|
||||
|
||||
if (per_objfile->symtab_set_p (per_cu))
|
||||
/* Nothing to do. */
|
||||
return;
|
||||
|
||||
dwarf2_cu *cu = per_objfile->get_cu (per_cu);
|
||||
|
||||
if (cu == nullptr)
|
||||
/* Skip dummy CUs. */
|
||||
return;
|
||||
|
||||
unsigned int debug_print_threshold;
|
||||
char buf[100];
|
||||
|
||||
if (per_cu->is_debug_types)
|
||||
{
|
||||
struct signatured_type *sig_type =
|
||||
(struct signatured_type *) per_cu;
|
||||
|
||||
sprintf (buf, "TU %s at offset %s",
|
||||
hex_string (sig_type->signature),
|
||||
sect_offset_str (per_cu->sect_off));
|
||||
/* There can be 100s of TUs.
|
||||
Only print them in verbose mode. */
|
||||
debug_print_threshold = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (buf, "CU at offset %s",
|
||||
sect_offset_str (per_cu->sect_off));
|
||||
debug_print_threshold = 1;
|
||||
}
|
||||
|
||||
if (dwarf_read_debug >= debug_print_threshold)
|
||||
dwarf_read_debug_printf ("Expanding symtab of %s", buf);
|
||||
|
||||
if (per_cu->is_debug_types)
|
||||
process_full_type_unit (cu, item.pretend_language);
|
||||
else
|
||||
process_full_comp_unit (cu, item.pretend_language);
|
||||
|
||||
if (dwarf_read_debug >= debug_print_threshold)
|
||||
dwarf_read_debug_printf ("Done expanding %s", buf);
|
||||
}
|
||||
|
||||
/* Process the queue. */
|
||||
|
||||
static void
|
||||
process_queue (dwarf2_per_objfile *per_objfile)
|
||||
{
|
||||
if (per_objfile->queue->empty ())
|
||||
return;
|
||||
|
||||
dwarf_read_debug_printf ("Expanding one or more symtabs of objfile %s ...",
|
||||
objfile_name (per_objfile->objfile));
|
||||
|
||||
using iter_type = decltype (per_objfile->queue->begin ());
|
||||
using result_type = int;
|
||||
|
||||
std::function<unsigned int (iter_type)> task_size
|
||||
= [=] (iter_type iter)
|
||||
{
|
||||
dwarf2_queue_item &item = *iter;
|
||||
dwarf2_per_cu_data *per_cu = item.per_cu;
|
||||
return per_cu->length ();
|
||||
};
|
||||
|
||||
/* The queue starts out with one item, but following a DIE reference
|
||||
may load a new CU, adding it to the end of the queue. */
|
||||
while (!per_objfile->queue->empty ())
|
||||
{
|
||||
dwarf2_queue_item &item = per_objfile->queue->front ();
|
||||
dwarf2_per_cu_data *per_cu = item.per_cu;
|
||||
size_t nr_to_be_processed = per_objfile->queue->size ();
|
||||
|
||||
if (!per_objfile->symtab_set_p (per_cu))
|
||||
std::vector<result_type> results
|
||||
= gdb::parallel_for_each (1, per_objfile->queue->begin (),
|
||||
per_objfile->queue->end (),
|
||||
[=] (iter_type iter, iter_type end)
|
||||
{
|
||||
dwarf2_cu *cu = per_objfile->get_cu (per_cu);
|
||||
|
||||
/* Skip dummy CUs. */
|
||||
if (cu != nullptr)
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
unsigned int debug_print_threshold;
|
||||
char buf[100];
|
||||
|
||||
if (per_cu->is_debug_types)
|
||||
{
|
||||
struct signatured_type *sig_type =
|
||||
(struct signatured_type *) per_cu;
|
||||
|
||||
sprintf (buf, "TU %s at offset %s",
|
||||
hex_string (sig_type->signature),
|
||||
sect_offset_str (per_cu->sect_off));
|
||||
/* There can be 100s of TUs.
|
||||
Only print them in verbose mode. */
|
||||
debug_print_threshold = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (buf, "CU at offset %s",
|
||||
sect_offset_str (per_cu->sect_off));
|
||||
debug_print_threshold = 1;
|
||||
}
|
||||
|
||||
if (dwarf_read_debug >= debug_print_threshold)
|
||||
dwarf_read_debug_printf ("Expanding symtab of %s", buf);
|
||||
|
||||
if (per_cu->is_debug_types)
|
||||
process_full_type_unit (cu, item.pretend_language);
|
||||
else
|
||||
process_full_comp_unit (cu, item.pretend_language);
|
||||
|
||||
if (dwarf_read_debug >= debug_print_threshold)
|
||||
dwarf_read_debug_printf ("Done expanding %s", buf);
|
||||
dwarf2_queue_item &item = *iter;
|
||||
process_queue_item (per_objfile, item);
|
||||
}
|
||||
}
|
||||
|
||||
per_cu->queued = 0;
|
||||
per_objfile->queue->pop ();
|
||||
return result_type (1);
|
||||
}, &task_size);
|
||||
|
||||
for (int i = 0; i < nr_to_be_processed; ++i)
|
||||
{
|
||||
dwarf2_queue_item &item = per_objfile->queue->front ();
|
||||
dwarf2_per_cu_data *per_cu = item.per_cu;
|
||||
per_cu->queued = 0;
|
||||
per_objfile->queue->pop_front ();
|
||||
}
|
||||
}
|
||||
|
||||
dwarf_read_debug_printf ("Done expanding symtabs of %s.",
|
||||
@@ -7831,8 +7879,8 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
||||
saved_package_name);
|
||||
struct symbol *sym;
|
||||
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym->set_language (language_go, &objfile->objfile_obstack);
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
sym->set_language (language_go, objfile->objfile_obstack ());
|
||||
sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
|
||||
/* 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(). */
|
||||
@@ -8009,11 +8057,11 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
type->field (1).set_name
|
||||
(rust_last_path_segment (type->field (1).type ()->name ()));
|
||||
type->field (1).type ()->set_name
|
||||
(rust_fully_qualify (&objfile->objfile_obstack, type->name (),
|
||||
(rust_fully_qualify (objfile->objfile_obstack (), type->name (),
|
||||
type->field (1).name ()));
|
||||
|
||||
const char *dataless_name
|
||||
= rust_fully_qualify (&objfile->objfile_obstack, type->name (),
|
||||
= rust_fully_qualify (objfile->objfile_obstack (), type->name (),
|
||||
name);
|
||||
struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0,
|
||||
dataless_name);
|
||||
@@ -8025,7 +8073,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
|
||||
/* Indicate that this is a variant type. */
|
||||
static discriminant_range ranges[1] = { { 0, 0 } };
|
||||
alloc_rust_variant (&objfile->objfile_obstack, type, 0, 1, ranges);
|
||||
alloc_rust_variant (objfile->objfile_obstack (), type, 0, 1, ranges);
|
||||
}
|
||||
/* A union with a single anonymous field is probably an old-style
|
||||
univariant enum. */
|
||||
@@ -8040,10 +8088,10 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
= rust_last_path_segment (field_type->name ());
|
||||
type->field (0).set_name (variant_name);
|
||||
field_type->set_name
|
||||
(rust_fully_qualify (&objfile->objfile_obstack,
|
||||
(rust_fully_qualify (objfile->objfile_obstack (),
|
||||
type->name (), variant_name));
|
||||
|
||||
alloc_rust_variant (&objfile->objfile_obstack, type, -1, 0, {});
|
||||
alloc_rust_variant (objfile->objfile_obstack (), type, -1, 0, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -8117,7 +8165,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
/* We don't need a range entry for the discriminant, but we do
|
||||
need one for every other field, as there is no default
|
||||
variant. */
|
||||
discriminant_range *ranges = XOBNEWVEC (&objfile->objfile_obstack,
|
||||
discriminant_range *ranges = XOBNEWVEC (objfile->objfile_obstack (),
|
||||
discriminant_range,
|
||||
n_fields - 1);
|
||||
/* Skip the discriminant here. */
|
||||
@@ -8149,12 +8197,12 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
}
|
||||
type->field (i).set_name (variant_name);
|
||||
sub_type->set_name
|
||||
(rust_fully_qualify (&objfile->objfile_obstack,
|
||||
(rust_fully_qualify (objfile->objfile_obstack (),
|
||||
type->name (), variant_name));
|
||||
}
|
||||
|
||||
/* Indicate that this is a variant type. */
|
||||
alloc_rust_variant (&objfile->objfile_obstack, type, 0, -1,
|
||||
alloc_rust_variant (objfile->objfile_obstack (), type, 0, -1,
|
||||
gdb::array_view<discriminant_range> (ranges,
|
||||
n_fields - 1));
|
||||
}
|
||||
@@ -8295,7 +8343,7 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu,
|
||||
/* Now we have a transitive closure of all the included symtabs. */
|
||||
len = result_symtabs.size ();
|
||||
cust->includes
|
||||
= XOBNEWVEC (&per_objfile->objfile->objfile_obstack,
|
||||
= XOBNEWVEC (per_objfile->objfile->objfile_obstack (),
|
||||
struct compunit_symtab *, len + 1);
|
||||
memcpy (cust->includes, result_symtabs.data (),
|
||||
len * sizeof (compunit_symtab *));
|
||||
@@ -8423,8 +8471,14 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
|
||||
|
||||
per_objfile->set_symtab (cu->per_cu, cust);
|
||||
|
||||
/* Push it for inclusion processing later. */
|
||||
per_objfile->per_bfd->just_read_cus.push_back (cu->per_cu);
|
||||
#if CXX_STD_THREAD
|
||||
{
|
||||
static std::mutex just_read_cus_lock;
|
||||
std::lock_guard<std::mutex> guard (just_read_cus_lock);
|
||||
#endif
|
||||
/* Push it for inclusion processing later. */
|
||||
per_objfile->per_bfd->just_read_cus.push_back (cu->per_cu);
|
||||
}
|
||||
|
||||
/* Not needed any more. */
|
||||
cu->reset_builder ();
|
||||
@@ -9311,7 +9365,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
|
||||
canonical_name = imported_name_prefix;
|
||||
}
|
||||
else if (strlen (imported_name_prefix) > 0)
|
||||
canonical_name = obconcat (&objfile->objfile_obstack,
|
||||
canonical_name = obconcat (objfile->objfile_obstack (),
|
||||
imported_name_prefix,
|
||||
(cu->lang () == language_d
|
||||
? "."
|
||||
@@ -9372,7 +9426,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
|
||||
imported_declaration,
|
||||
excludes,
|
||||
0,
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
}
|
||||
|
||||
/* ICC<14 does not output the required DW_AT_declaration on incomplete
|
||||
@@ -9563,9 +9617,9 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
cu->start_compunit_symtab (fnd.get_name (), fnd.intern_comp_dir (objfile),
|
||||
lowpc);
|
||||
|
||||
gdb_assert (per_objfile->sym_cu == nullptr);
|
||||
gdb_assert (per_objfile->sym_cu[gdb::thread_pool::id()] == nullptr);
|
||||
scoped_restore restore_sym_cu
|
||||
= make_scoped_restore (&per_objfile->sym_cu, cu);
|
||||
= make_scoped_restore (&per_objfile->sym_cu[gdb::thread_pool::id()], cu);
|
||||
|
||||
/* Decode line number information if present. We do this before
|
||||
processing child DIEs, so that the line header table is available
|
||||
@@ -9587,7 +9641,8 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
child_die = child_die->sibling;
|
||||
}
|
||||
}
|
||||
per_objfile->sym_cu = nullptr;
|
||||
|
||||
per_objfile->sym_cu[gdb::thread_pool::id()] = nullptr;
|
||||
|
||||
/* Decode macro information, if present. Dwarf 2 macro information
|
||||
refers to information in the line number info statement program
|
||||
@@ -9683,7 +9738,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
|
||||
time. */
|
||||
|
||||
tug_unshare->symtabs
|
||||
= XOBNEWVEC (&cust->objfile ()->objfile_obstack,
|
||||
= XOBNEWVEC (cust->objfile ()->objfile_obstack (),
|
||||
struct symtab *, line_header->file_names_size ());
|
||||
|
||||
auto &file_names = line_header->file_names ();
|
||||
@@ -11986,7 +12041,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (child_die->tag == DW_TAG_template_type_param
|
||||
|| child_die->tag == DW_TAG_template_value_param)
|
||||
{
|
||||
templ_func = new (&objfile->objfile_obstack) template_symbol;
|
||||
templ_func = new (objfile->objfile_obstack ()) template_symbol;
|
||||
templ_func->subclass = SYMBOL_TEMPLATE;
|
||||
break;
|
||||
}
|
||||
@@ -12013,7 +12068,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (attr != nullptr)
|
||||
{
|
||||
newobj->static_link
|
||||
= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
|
||||
= XOBNEW (objfile->objfile_obstack (), struct dynamic_prop);
|
||||
attr_to_dynamic_prop (attr, die, cu, newobj->static_link,
|
||||
cu->addr_type ());
|
||||
}
|
||||
@@ -12078,7 +12133,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|| cu->lang () == language_rust)
|
||||
&& cu->processing_has_namespace_info)
|
||||
block_set_scope (block, determine_prefix (die, cu),
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
|
||||
/* If we have address ranges, record them. */
|
||||
dwarf2_record_block_ranges (die, block, baseaddr, cu);
|
||||
@@ -12092,7 +12147,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
templ_func->n_template_arguments = template_args.size ();
|
||||
templ_func->template_arguments
|
||||
= XOBNEWVEC (&objfile->objfile_obstack, struct symbol *,
|
||||
= XOBNEWVEC (objfile->objfile_obstack (), struct symbol *,
|
||||
templ_func->n_template_arguments);
|
||||
memcpy (templ_func->template_arguments,
|
||||
template_args.data (),
|
||||
@@ -12242,7 +12297,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (cu->call_site_htab == NULL)
|
||||
cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash,
|
||||
call_site::eq, NULL,
|
||||
&objfile->objfile_obstack,
|
||||
objfile->objfile_obstack (),
|
||||
hashtab_obstack_allocate, NULL);
|
||||
struct call_site call_site_local (pc, nullptr, nullptr);
|
||||
slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);
|
||||
@@ -12275,7 +12330,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
}
|
||||
|
||||
struct call_site *call_site
|
||||
= new (XOBNEWVAR (&objfile->objfile_obstack,
|
||||
= new (XOBNEWVAR (objfile->objfile_obstack (),
|
||||
struct call_site,
|
||||
sizeof (*call_site) + sizeof (call_site->parameter[0]) * nparams))
|
||||
struct call_site (pc, cu->per_cu, per_objfile);
|
||||
@@ -12353,7 +12408,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
struct dwarf2_locexpr_baton *dlbaton;
|
||||
struct dwarf_block *block = attr->as_block ();
|
||||
|
||||
dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
|
||||
dlbaton = XOBNEW (objfile->objfile_obstack (), struct dwarf2_locexpr_baton);
|
||||
dlbaton->data = block->data;
|
||||
dlbaton->size = block->size;
|
||||
dlbaton->per_objfile = per_objfile;
|
||||
@@ -12394,7 +12449,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
std::vector<CORE_ADDR> addresses;
|
||||
dwarf2_ranges_read_low_addrs (ranges_offset, target_cu,
|
||||
target_die->tag, addresses);
|
||||
CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR,
|
||||
CORE_ADDR *saved = XOBNEWVAR (objfile->objfile_obstack (), CORE_ADDR,
|
||||
addresses.size ());
|
||||
std::copy (addresses.begin (), addresses.end (), saved);
|
||||
call_site->target.set_loc_array (addresses.size (), saved);
|
||||
@@ -12583,7 +12638,7 @@ read_variable (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
struct objfile *objfile = cu->per_objfile->objfile;
|
||||
|
||||
storage = new (&objfile->objfile_obstack) rust_vtable_symbol;
|
||||
storage = new (objfile->objfile_obstack ()) rust_vtable_symbol;
|
||||
storage->concrete_type = containing_type;
|
||||
storage->subclass = SYMBOL_RUST_VTABLE;
|
||||
}
|
||||
@@ -13420,7 +13475,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
|
||||
dwarf2_per_objfile *per_objfile = cu->per_objfile;
|
||||
struct objfile *objfile = per_objfile->objfile;
|
||||
struct dwarf2_locexpr_baton *dlbaton
|
||||
= XOBNEW (&objfile->objfile_obstack,
|
||||
= XOBNEW (objfile->objfile_obstack (),
|
||||
struct dwarf2_locexpr_baton);
|
||||
dlbaton->data = attr->as_block ()->data;
|
||||
dlbaton->size = attr->as_block ()->size;
|
||||
@@ -13869,12 +13924,12 @@ add_variant_property (struct field_info *fip, struct type *type,
|
||||
|
||||
struct objfile *objfile = cu->per_objfile->objfile;
|
||||
gdb::array_view<const variant_part> parts
|
||||
= create_variant_parts (&objfile->objfile_obstack, offset_map, fip,
|
||||
= create_variant_parts (objfile->objfile_obstack (), offset_map, fip,
|
||||
fip->variant_parts);
|
||||
|
||||
struct dynamic_prop prop;
|
||||
prop.set_variant_parts ((gdb::array_view<variant_part> *)
|
||||
obstack_copy (&objfile->objfile_obstack, &parts,
|
||||
obstack_copy (objfile->objfile_obstack (), &parts,
|
||||
sizeof (parts)));
|
||||
|
||||
type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop);
|
||||
@@ -14842,7 +14897,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
ALLOCATE_CPLUS_STRUCT_TYPE (type);
|
||||
TYPE_N_TEMPLATE_ARGUMENTS (type) = template_args.size ();
|
||||
TYPE_TEMPLATE_ARGUMENTS (type)
|
||||
= XOBNEWVEC (&objfile->objfile_obstack,
|
||||
= XOBNEWVEC (objfile->objfile_obstack (),
|
||||
struct symbol *,
|
||||
TYPE_N_TEMPLATE_ARGUMENTS (type));
|
||||
memcpy (TYPE_TEMPLATE_ARGUMENTS (type),
|
||||
@@ -15771,7 +15826,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
|
||||
gdb_assert (member_loc->form_is_block ()
|
||||
|| member_loc->form_is_constant ());
|
||||
|
||||
baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
|
||||
baton = XOBNEW (objfile->objfile_obstack (), struct dwarf2_locexpr_baton);
|
||||
baton->per_objfile = per_objfile;
|
||||
baton->per_cu = cu->per_cu;
|
||||
gdb_assert (baton->per_cu);
|
||||
@@ -15786,7 +15841,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
|
||||
else
|
||||
baton->size += member_loc->as_block ()->size;
|
||||
|
||||
ptr = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, baton->size);
|
||||
ptr = (gdb_byte *) obstack_alloc (objfile->objfile_obstack (), baton->size);
|
||||
baton->data = ptr;
|
||||
|
||||
*ptr++ = DW_OP_call4;
|
||||
@@ -15864,7 +15919,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
|
||||
size = (sizeof (struct common_block)
|
||||
+ (n_entries - 1) * sizeof (struct symbol *));
|
||||
common_block
|
||||
= (struct common_block *) obstack_alloc (&objfile->objfile_obstack,
|
||||
= (struct common_block *) obstack_alloc (objfile->objfile_obstack (),
|
||||
size);
|
||||
memset (common_block->contents, 0, n_entries * sizeof (struct symbol *));
|
||||
common_block->n_entries = 0;
|
||||
@@ -15946,7 +16001,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
previous_prefix = determine_prefix (die, cu);
|
||||
if (previous_prefix[0] != '\0')
|
||||
name = typename_concat (&objfile->objfile_obstack,
|
||||
name = typename_concat (objfile->objfile_obstack (),
|
||||
previous_prefix, name, 0, cu);
|
||||
|
||||
/* Create the type. */
|
||||
@@ -15982,7 +16037,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
|
||||
std::vector<const char *> excludes;
|
||||
add_using_directive (using_directives (cu),
|
||||
previous_prefix, type->name (), NULL,
|
||||
NULL, excludes, 0, &objfile->objfile_obstack);
|
||||
NULL, excludes, 0, objfile->objfile_obstack ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17121,7 +17176,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
gdb_assert (startswith (gnat_encoding_suffix,
|
||||
GNAT_FIXED_POINT_SUFFIX));
|
||||
name = obstack_strndup (&cu->per_objfile->objfile->objfile_obstack,
|
||||
name = obstack_strndup (cu->per_objfile->objfile->objfile_obstack (),
|
||||
name, gnat_encoding_suffix - name);
|
||||
/* Use -1 here so that SUFFIX points at the "_" after the
|
||||
"XF". */
|
||||
@@ -17151,7 +17206,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (name == nullptr)
|
||||
{
|
||||
struct obstack *obstack
|
||||
= &cu->per_objfile->objfile->objfile_obstack;
|
||||
= cu->per_objfile->objfile->objfile_obstack ();
|
||||
name = obconcat (obstack, "_Complex ", type->name (),
|
||||
nullptr);
|
||||
}
|
||||
@@ -17282,7 +17337,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
|
||||
struct dwarf2_property_baton *baton;
|
||||
dwarf2_per_objfile *per_objfile = cu->per_objfile;
|
||||
struct objfile *objfile = per_objfile->objfile;
|
||||
struct obstack *obstack = &objfile->objfile_obstack;
|
||||
struct obstack *obstack = objfile->objfile_obstack ();
|
||||
|
||||
gdb_assert (default_type != NULL);
|
||||
|
||||
@@ -20675,11 +20730,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
|
||||
if (space)
|
||||
sym = space;
|
||||
else
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
OBJSTAT (objfile, n_syms++);
|
||||
|
||||
/* Cache this symbol's name and the name's demangled form (if any). */
|
||||
sym->set_language (cu->lang (), &objfile->objfile_obstack);
|
||||
sym->set_language (cu->lang (), objfile->objfile_obstack ());
|
||||
/* Fortran does not have mangling standard and the mangling does differ
|
||||
between gfortran, iFort etc. */
|
||||
const char *physname
|
||||
@@ -20692,7 +20747,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
|
||||
sym->set_linkage_name (physname);
|
||||
else
|
||||
{
|
||||
sym->set_demangled_name (physname, &objfile->objfile_obstack);
|
||||
sym->set_demangled_name (physname, objfile->objfile_obstack ());
|
||||
sym->set_linkage_name (linkagename);
|
||||
}
|
||||
|
||||
@@ -21051,6 +21106,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
|
||||
|
||||
if (suppress_add)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
static std::mutex template_symbols_lock;
|
||||
std::lock_guard<std::mutex> guard (template_symbols_lock);
|
||||
#endif
|
||||
sym->hash_next = objfile->template_symbols;
|
||||
objfile->template_symbols = sym;
|
||||
list_to_add = NULL;
|
||||
@@ -21227,7 +21286,7 @@ dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
|
||||
|
||||
dwarf2_const_value_attr (attr, sym->type (),
|
||||
sym->print_name (),
|
||||
&objfile->objfile_obstack, cu,
|
||||
objfile->objfile_obstack (), cu,
|
||||
&value, &bytes, &baton);
|
||||
|
||||
if (baton != NULL)
|
||||
@@ -21340,11 +21399,15 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
|
||||
objfile_name (objfile),
|
||||
sect_offset_str (cu->header.sect_off),
|
||||
sect_offset_str (die->sect_off));
|
||||
saved = obstack_strdup (&objfile->objfile_obstack, message);
|
||||
saved = obstack_strdup (objfile->objfile_obstack (), message);
|
||||
|
||||
return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
|
||||
}
|
||||
|
||||
#if CXX_STD_THREAD
|
||||
static std::recursive_mutex lookup_die_type_lock;
|
||||
#endif
|
||||
|
||||
/* Look up the type of DIE in CU using its type attribute ATTR.
|
||||
ATTR must be one of: DW_AT_type, DW_AT_GNAT_descriptive_type,
|
||||
DW_AT_containing_type.
|
||||
@@ -21354,6 +21417,9 @@ static struct type *
|
||||
lookup_die_type (struct die_info *die, const struct attribute *attr,
|
||||
struct dwarf2_cu *cu)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::recursive_mutex> guard (lookup_die_type_lock);
|
||||
#endif
|
||||
dwarf2_per_objfile *per_objfile = cu->per_objfile;
|
||||
struct objfile *objfile = per_objfile->objfile;
|
||||
struct type *this_type;
|
||||
@@ -21430,6 +21496,9 @@ lookup_die_type (struct die_info *die, const struct attribute *attr,
|
||||
static struct type *
|
||||
read_type_die (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::recursive_mutex> guard (lookup_die_type_lock);
|
||||
#endif
|
||||
struct type *this_type;
|
||||
|
||||
this_type = get_die_type (die, cu);
|
||||
@@ -23327,7 +23396,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
|
||||
{
|
||||
struct dwarf2_loclist_baton *baton;
|
||||
|
||||
baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_loclist_baton);
|
||||
baton = XOBNEW (objfile->objfile_obstack (), struct dwarf2_loclist_baton);
|
||||
|
||||
fill_in_loclist_baton (cu, baton, attr);
|
||||
|
||||
@@ -23344,7 +23413,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
|
||||
{
|
||||
struct dwarf2_locexpr_baton *baton;
|
||||
|
||||
baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
|
||||
baton = XOBNEW (objfile->objfile_obstack (), struct dwarf2_locexpr_baton);
|
||||
baton->per_objfile = per_objfile;
|
||||
baton->per_cu = cu->per_cu;
|
||||
gdb_assert (baton->per_cu);
|
||||
@@ -23732,6 +23801,10 @@ per_cu_offset_and_type_eq (const void *item_lhs, const void *item_rhs)
|
||||
&& ofs_lhs->sect_off == ofs_rhs->sect_off);
|
||||
}
|
||||
|
||||
#if CXX_STD_THREAD
|
||||
static std::mutex die_type_hash_lock;
|
||||
#endif
|
||||
|
||||
/* Set the type associated with DIE to TYPE. Save it in CU's hash
|
||||
table if necessary. For convenience, return TYPE.
|
||||
|
||||
@@ -23754,6 +23827,9 @@ static struct type *
|
||||
set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
|
||||
bool skip_data_location)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::recursive_mutex> guard (lookup_die_type_lock);
|
||||
#endif
|
||||
dwarf2_per_objfile *per_objfile = cu->per_objfile;
|
||||
struct dwarf2_per_cu_offset_and_type **slot, ofs;
|
||||
struct objfile *objfile = per_objfile->objfile;
|
||||
@@ -23812,25 +23888,30 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
|
||||
type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop);
|
||||
}
|
||||
|
||||
if (per_objfile->die_type_hash == NULL)
|
||||
per_objfile->die_type_hash
|
||||
= htab_up (htab_create_alloc (127,
|
||||
per_cu_offset_and_type_hash,
|
||||
per_cu_offset_and_type_eq,
|
||||
NULL, xcalloc, xfree));
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::mutex> guard2 (die_type_hash_lock);
|
||||
#endif
|
||||
if (per_objfile->die_type_hash == NULL)
|
||||
per_objfile->die_type_hash
|
||||
= htab_up (htab_create_alloc (127,
|
||||
per_cu_offset_and_type_hash,
|
||||
per_cu_offset_and_type_eq,
|
||||
NULL, xcalloc, xfree));
|
||||
|
||||
ofs.per_cu = cu->per_cu;
|
||||
ofs.sect_off = die->sect_off;
|
||||
ofs.type = type;
|
||||
slot = (struct dwarf2_per_cu_offset_and_type **)
|
||||
htab_find_slot (per_objfile->die_type_hash.get (), &ofs, INSERT);
|
||||
if (*slot)
|
||||
complaint (_("A problem internal to GDB: DIE %s has type already set"),
|
||||
sect_offset_str (die->sect_off));
|
||||
*slot = XOBNEW (&objfile->objfile_obstack,
|
||||
struct dwarf2_per_cu_offset_and_type);
|
||||
**slot = ofs;
|
||||
return type;
|
||||
ofs.per_cu = cu->per_cu;
|
||||
ofs.sect_off = die->sect_off;
|
||||
ofs.type = type;
|
||||
slot = (struct dwarf2_per_cu_offset_and_type **)
|
||||
htab_find_slot (per_objfile->die_type_hash.get (), &ofs, INSERT);
|
||||
if (*slot)
|
||||
complaint (_("A problem internal to GDB: DIE %s has type already set"),
|
||||
sect_offset_str (die->sect_off));
|
||||
*slot = XOBNEW (objfile->objfile_obstack (),
|
||||
struct dwarf2_per_cu_offset_and_type);
|
||||
**slot = ofs;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look up the type for the die at SECT_OFF in PER_CU in die_type_hash,
|
||||
@@ -23841,6 +23922,10 @@ get_die_type_at_offset (sect_offset sect_off,
|
||||
dwarf2_per_cu_data *per_cu,
|
||||
dwarf2_per_objfile *per_objfile)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::mutex> guard (die_type_hash_lock);
|
||||
#endif
|
||||
|
||||
struct dwarf2_per_cu_offset_and_type *slot, ofs;
|
||||
|
||||
if (per_objfile->die_type_hash == NULL)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef DWARF2READ_H
|
||||
#define DWARF2READ_H
|
||||
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
#include <unordered_map>
|
||||
#include "dwarf2/comp-unit-head.h"
|
||||
#include "dwarf2/cooked-index.h"
|
||||
@@ -587,7 +587,12 @@ struct dwarf2_per_objfile
|
||||
{
|
||||
dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd)
|
||||
: objfile (objfile), per_bfd (per_bfd)
|
||||
{}
|
||||
{
|
||||
for (int i = 0;
|
||||
i < gdb::thread_pool::g_thread_pool->thread_count () + 1;
|
||||
++i)
|
||||
sym_cu.push_back (nullptr);
|
||||
}
|
||||
|
||||
~dwarf2_per_objfile ();
|
||||
|
||||
@@ -655,10 +660,10 @@ struct dwarf2_per_objfile
|
||||
htab_up line_header_hash;
|
||||
|
||||
/* The CU containing the m_builder in scope. */
|
||||
dwarf2_cu *sym_cu = nullptr;
|
||||
std::vector<dwarf2_cu *> sym_cu;
|
||||
|
||||
/* CUs that are queued to be read. */
|
||||
gdb::optional<std::queue<dwarf2_queue_item>> queue;
|
||||
gdb::optional<std::deque<dwarf2_queue_item>> queue;
|
||||
|
||||
private:
|
||||
/* Hold the corresponding compunit_symtab for each CU or TU. This
|
||||
|
||||
@@ -164,7 +164,7 @@ dwarf2_section_info::read (struct objfile *objfile)
|
||||
return;
|
||||
}
|
||||
|
||||
buf = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, size);
|
||||
buf = (gdb_byte *) obstack_alloc (objfile->objfile_obstack (), size);
|
||||
buffer = buf;
|
||||
|
||||
/* When debugging .o files, we may need to apply relocations; see
|
||||
|
||||
@@ -728,11 +728,11 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
|
||||
}
|
||||
|
||||
entry_local.addr = addr;
|
||||
obstack_grow (&objfile->objfile_obstack, &entry_local,
|
||||
obstack_grow (objfile->objfile_obstack (), &entry_local,
|
||||
offsetof (struct elf_gnu_ifunc_cache, name));
|
||||
obstack_grow_str0 (&objfile->objfile_obstack, name);
|
||||
obstack_grow_str0 (objfile->objfile_obstack (), name);
|
||||
entry_p
|
||||
= (struct elf_gnu_ifunc_cache *) obstack_finish (&objfile->objfile_obstack);
|
||||
= (struct elf_gnu_ifunc_cache *) obstack_finish (objfile->objfile_obstack ());
|
||||
|
||||
slot = htab_find_slot (htab, entry_p, INSERT);
|
||||
if (*slot != NULL)
|
||||
|
||||
@@ -185,8 +185,8 @@ alloc_type (struct objfile *objfile)
|
||||
gdb_assert (objfile != NULL);
|
||||
|
||||
/* Alloc the structure and start off with all fields zeroed. */
|
||||
type = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct type);
|
||||
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||
type = OBSTACK_ZALLOC (objfile->objfile_obstack (), struct type);
|
||||
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (objfile->objfile_obstack (),
|
||||
struct main_type);
|
||||
OBJSTAT (objfile, n_types++);
|
||||
|
||||
@@ -298,7 +298,7 @@ alloc_type_instance (struct type *oldtype)
|
||||
if (!oldtype->is_objfile_owned ())
|
||||
type = GDBARCH_OBSTACK_ZALLOC (oldtype->arch_owner (), struct type);
|
||||
else
|
||||
type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack,
|
||||
type = OBSTACK_ZALLOC (oldtype->objfile_owner ()->objfile_obstack (),
|
||||
struct type);
|
||||
|
||||
TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
|
||||
@@ -2411,7 +2411,7 @@ resolve_dynamic_array_or_string (struct type *type,
|
||||
if (prop_list != nullptr)
|
||||
{
|
||||
struct obstack *obstack
|
||||
= &type->objfile_owner ()->objfile_obstack;
|
||||
= type->objfile_owner ()->objfile_obstack ();
|
||||
TYPE_MAIN_TYPE (type)->dyn_prop_list
|
||||
= copy_dynamic_prop_list (obstack, prop_list);
|
||||
}
|
||||
@@ -2933,7 +2933,7 @@ type::add_dyn_prop (dynamic_prop_node_kind prop_kind, dynamic_prop prop)
|
||||
|
||||
gdb_assert (this->is_objfile_owned ());
|
||||
|
||||
temp = XOBNEW (&this->objfile_owner ()->objfile_obstack,
|
||||
temp = XOBNEW (this->objfile_owner ()->objfile_obstack (),
|
||||
struct dynamic_prop_list);
|
||||
temp->prop_kind = prop_kind;
|
||||
temp->prop = prop;
|
||||
@@ -5596,7 +5596,7 @@ htab_up
|
||||
create_copied_types_hash (struct objfile *objfile)
|
||||
{
|
||||
return htab_up (htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
|
||||
NULL, &objfile->objfile_obstack,
|
||||
NULL, objfile->objfile_obstack (),
|
||||
hashtab_obstack_allocate,
|
||||
dummy_obstack_deallocate));
|
||||
}
|
||||
@@ -5657,7 +5657,7 @@ copy_type_recursive (struct objfile *objfile,
|
||||
/* We must add the new type to the hash table immediately, in case
|
||||
we encounter this type again during a recursive call below. */
|
||||
struct type_pair *stored
|
||||
= new (&objfile->objfile_obstack) struct type_pair (type, new_type);
|
||||
= new (objfile->objfile_obstack ()) struct type_pair (type, new_type);
|
||||
|
||||
*slot = stored;
|
||||
|
||||
@@ -5736,7 +5736,7 @@ copy_type_recursive (struct objfile *objfile,
|
||||
|
||||
if (type->main_type->dyn_prop_list != NULL)
|
||||
new_type->main_type->dyn_prop_list
|
||||
= copy_dynamic_prop_list (&objfile->objfile_obstack,
|
||||
= copy_dynamic_prop_list (objfile->objfile_obstack (),
|
||||
type->main_type->dyn_prop_list);
|
||||
|
||||
|
||||
@@ -5809,7 +5809,7 @@ copy_type (const struct type *type)
|
||||
if (type->main_type->dyn_prop_list != NULL)
|
||||
{
|
||||
struct obstack *storage = (type->is_objfile_owned ()
|
||||
? &type->objfile_owner ()->objfile_obstack
|
||||
? type->objfile_owner ()->objfile_obstack ()
|
||||
: gdbarch_obstack (type->arch_owner ()));
|
||||
new_type->main_type->dyn_prop_list
|
||||
= copy_dynamic_prop_list (storage, type->main_type->dyn_prop_list);
|
||||
@@ -6330,7 +6330,7 @@ objfile_type (struct objfile *objfile)
|
||||
if (objfile_type)
|
||||
return objfile_type;
|
||||
|
||||
objfile_type = OBSTACK_CALLOC (&objfile->objfile_obstack,
|
||||
objfile_type = OBSTACK_CALLOC (objfile->objfile_obstack (),
|
||||
1, struct objfile_type);
|
||||
|
||||
/* Use the objfile architecture to determine basic type properties. */
|
||||
|
||||
@@ -1488,7 +1488,9 @@ struct type
|
||||
value of 1 means the alignment is 1, and a value of 9 means the
|
||||
alignment is 256. */
|
||||
|
||||
unsigned align_log2 : TYPE_ALIGN_BITS;
|
||||
struct {
|
||||
unsigned align_log2 : TYPE_ALIGN_BITS;
|
||||
};
|
||||
|
||||
/* * Flags specific to this instance of the type, indicating where
|
||||
on the ring we are.
|
||||
@@ -1500,7 +1502,9 @@ struct type
|
||||
instance flags are completely inherited from the target type. No
|
||||
qualifiers can be cleared by the typedef. See also
|
||||
check_typedef. */
|
||||
unsigned m_instance_flags : 9;
|
||||
struct {
|
||||
unsigned m_instance_flags : 9;
|
||||
};
|
||||
|
||||
/* * Length of storage for a value of this type. The value is the
|
||||
expression in host bytes of what sizeof(type) would return. This
|
||||
@@ -2473,7 +2477,7 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
|
||||
|
||||
#define TYPE_ALLOC(t,size) \
|
||||
(obstack_alloc (((t)->is_objfile_owned () \
|
||||
? &((t)->objfile_owner ()->objfile_obstack) \
|
||||
? ((t)->objfile_owner ()->objfile_obstack ()) \
|
||||
: gdbarch_obstack ((t)->arch_owner ())), \
|
||||
size))
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ read_unwind_info (struct objfile *objfile)
|
||||
struct hppa_objfile_private *obj_private;
|
||||
|
||||
text_offset = objfile->text_section_offset ();
|
||||
ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
|
||||
ui = (struct hppa_unwind_info *) obstack_alloc (objfile->objfile_obstack (),
|
||||
sizeof (struct hppa_unwind_info));
|
||||
|
||||
ui->table = NULL;
|
||||
@@ -397,7 +397,7 @@ read_unwind_info (struct objfile *objfile)
|
||||
|
||||
/* Allocate memory for the unwind table. */
|
||||
ui->table = (struct unwind_table_entry *)
|
||||
obstack_alloc (&objfile->objfile_obstack, total_size);
|
||||
obstack_alloc (objfile->objfile_obstack (), total_size);
|
||||
ui->last = total_entries - 1;
|
||||
|
||||
/* Now read in each unwind section and internalize the standard unwind
|
||||
|
||||
18
gdb/jit.c
18
gdb/jit.c
@@ -550,13 +550,13 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
|
||||
* sizeof (struct linetable_entry)
|
||||
+ sizeof (struct linetable));
|
||||
filetab->set_linetable ((struct linetable *)
|
||||
obstack_alloc (&objfile->objfile_obstack, size));
|
||||
obstack_alloc (objfile->objfile_obstack (), size));
|
||||
memcpy (filetab->linetable (), stab->linetable.get (), size);
|
||||
}
|
||||
|
||||
blockvector_size = (sizeof (struct blockvector)
|
||||
+ (actual_nblocks - 1) * sizeof (struct block *));
|
||||
bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
|
||||
bv = (struct blockvector *) obstack_alloc (objfile->objfile_obstack (),
|
||||
blockvector_size);
|
||||
cust->set_blockvector (bv);
|
||||
|
||||
@@ -573,15 +573,15 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
|
||||
int block_idx = FIRST_LOCAL_BLOCK;
|
||||
for (gdb_block &gdb_block_iter : stab->blocks)
|
||||
{
|
||||
struct block *new_block = allocate_block (&objfile->objfile_obstack);
|
||||
struct symbol *block_name = new (&objfile->objfile_obstack) symbol;
|
||||
struct block *new_block = allocate_block (objfile->objfile_obstack ());
|
||||
struct symbol *block_name = new (objfile->objfile_obstack ()) symbol;
|
||||
struct type *block_type = arch_type (objfile->arch (),
|
||||
TYPE_CODE_VOID,
|
||||
TARGET_CHAR_BIT,
|
||||
"void");
|
||||
|
||||
new_block->set_multidict
|
||||
(mdict_create_linear (&objfile->objfile_obstack, NULL));
|
||||
(mdict_create_linear (objfile->objfile_obstack (), NULL));
|
||||
/* The address range. */
|
||||
new_block->set_start (gdb_block_iter.begin);
|
||||
new_block->set_end (gdb_block_iter.end);
|
||||
@@ -593,7 +593,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
|
||||
block_name->set_type (lookup_function_type (block_type));
|
||||
block_name->set_value_block (new_block);
|
||||
|
||||
block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
|
||||
block_name->m_name = obstack_strdup (objfile->objfile_obstack (),
|
||||
gdb_block_iter.name.get ());
|
||||
|
||||
new_block->set_function (block_name);
|
||||
@@ -616,10 +616,10 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
|
||||
struct block *new_block;
|
||||
|
||||
new_block = (i == GLOBAL_BLOCK
|
||||
? allocate_global_block (&objfile->objfile_obstack)
|
||||
: allocate_block (&objfile->objfile_obstack));
|
||||
? allocate_global_block (objfile->objfile_obstack ())
|
||||
: allocate_block (objfile->objfile_obstack ()));
|
||||
new_block->set_multidict
|
||||
(mdict_create_linear (&objfile->objfile_obstack, NULL));
|
||||
(mdict_create_linear (objfile->objfile_obstack (), NULL));
|
||||
new_block->set_superblock (block_iter);
|
||||
block_iter = new_block;
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader,
|
||||
char *fdr_end;
|
||||
FDR *fdr_ptr;
|
||||
|
||||
info->fdr = (FDR *) XOBNEWVEC (&objfile->objfile_obstack, FDR,
|
||||
info->fdr = (FDR *) XOBNEWVEC (objfile->objfile_obstack (), FDR,
|
||||
info->symbolic_header.ifdMax);
|
||||
fdr_src = (char *) info->external_fdr;
|
||||
fdr_end = (fdr_src
|
||||
@@ -503,7 +503,7 @@ add_pending (FDR *fh, char *sh, struct type *t)
|
||||
/* Make sure we do not make duplicates. */
|
||||
if (!p)
|
||||
{
|
||||
p = XOBNEW (&mdebugread_objfile->objfile_obstack, mdebug_pending);
|
||||
p = XOBNEW (mdebugread_objfile->objfile_obstack (), mdebug_pending);
|
||||
p->s = sh;
|
||||
p->t = t;
|
||||
p->next = pending_list[f_idx];
|
||||
@@ -1018,7 +1018,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
|
||||
if (sh->iss == 0 || name[0] == '.' || name[0] == '\0')
|
||||
t->set_name (NULL);
|
||||
else
|
||||
t->set_name (obconcat (&mdebugread_objfile->objfile_obstack,
|
||||
t->set_name (obconcat (mdebugread_objfile->objfile_obstack (),
|
||||
name, (char *) NULL));
|
||||
|
||||
t->set_code (type_code);
|
||||
@@ -1061,9 +1061,9 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
|
||||
f->set_name (debug_info->ss + cur_fdr->issBase + tsym.iss);
|
||||
FIELD_BITSIZE (*f) = 0;
|
||||
|
||||
enum_sym = new (&mdebugread_objfile->objfile_obstack) symbol;
|
||||
enum_sym = new (mdebugread_objfile->objfile_obstack ()) symbol;
|
||||
enum_sym->set_linkage_name
|
||||
(obstack_strdup (&mdebugread_objfile->objfile_obstack,
|
||||
(obstack_strdup (mdebugread_objfile->objfile_obstack (),
|
||||
f->name ()));
|
||||
enum_sym->set_aclass_index (LOC_CONST);
|
||||
enum_sym->set_type (t);
|
||||
@@ -1157,7 +1157,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
|
||||
s->set_domain (LABEL_DOMAIN);
|
||||
s->set_aclass_index (LOC_CONST);
|
||||
s->set_type (objfile_type (mdebugread_objfile)->builtin_void);
|
||||
e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
|
||||
e = OBSTACK_ZALLOC (mdebugread_objfile->objfile_obstack (),
|
||||
mdebug_extra_func_info);
|
||||
s->set_value_bytes ((gdb_byte *) e);
|
||||
e->numargs = top_stack->numargs;
|
||||
@@ -1370,7 +1370,7 @@ basic_type (int bt, struct objfile *objfile)
|
||||
|
||||
if (!map_bt)
|
||||
{
|
||||
map_bt = OBSTACK_CALLOC (&objfile->objfile_obstack,
|
||||
map_bt = OBSTACK_CALLOC (objfile->objfile_obstack (),
|
||||
btMax, struct type *);
|
||||
basic_type_data.set (objfile, map_bt);
|
||||
}
|
||||
@@ -1681,7 +1681,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
|
||||
tp->set_name (NULL);
|
||||
else if (tp->name () == NULL
|
||||
|| strcmp (tp->name (), name) != 0)
|
||||
tp->set_name (obstack_strdup (&mdebugread_objfile->objfile_obstack,
|
||||
tp->set_name (obstack_strdup (mdebugread_objfile->objfile_obstack (),
|
||||
name));
|
||||
}
|
||||
}
|
||||
@@ -1717,7 +1717,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
|
||||
}
|
||||
if (tp->name () == NULL
|
||||
|| strcmp (tp->name (), name) != 0)
|
||||
tp->set_name (obstack_strdup (&mdebugread_objfile->objfile_obstack,
|
||||
tp->set_name (obstack_strdup (mdebugread_objfile->objfile_obstack (),
|
||||
name));
|
||||
}
|
||||
}
|
||||
@@ -2331,7 +2331,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
|
||||
&& (bfd_section_flags (text_sect) & SEC_RELOC))
|
||||
relocatable = 1;
|
||||
|
||||
extern_tab = XOBNEWVEC (&objfile->objfile_obstack, EXTR, hdr->iextMax);
|
||||
extern_tab = XOBNEWVEC (objfile->objfile_obstack (), EXTR, hdr->iextMax);
|
||||
|
||||
includes_allocated = 30;
|
||||
includes_used = 0;
|
||||
@@ -2373,7 +2373,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
|
||||
}
|
||||
|
||||
/* Allocate the global pending list. */
|
||||
pending_list = XOBNEWVEC (&objfile->objfile_obstack, mdebug_pending *,
|
||||
pending_list = XOBNEWVEC (objfile->objfile_obstack (), mdebug_pending *,
|
||||
hdr->ifdMax);
|
||||
memset (pending_list, 0,
|
||||
hdr->ifdMax * sizeof (struct mdebug_pending *));
|
||||
@@ -2604,7 +2604,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
|
||||
textlow = 0;
|
||||
pst = new legacy_psymtab (fdr_name (fh), partial_symtabs,
|
||||
objfile->per_bfd, textlow);
|
||||
pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, md_symloc);
|
||||
pst->read_symtab_private = XOBNEW (objfile->objfile_obstack (), md_symloc);
|
||||
memset (pst->read_symtab_private, 0, sizeof (struct md_symloc));
|
||||
|
||||
save_pst = pst;
|
||||
@@ -3980,7 +3980,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
|
||||
/* Make up special symbol to contain
|
||||
procedure specific info. */
|
||||
mdebug_extra_func_info *e
|
||||
= OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
|
||||
= OBSTACK_ZALLOC (mdebugread_objfile->objfile_obstack (),
|
||||
mdebug_extra_func_info);
|
||||
struct symbol *s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
|
||||
|
||||
@@ -4173,7 +4173,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
|
||||
--size;
|
||||
cust->primary_filetab ()->set_linetable
|
||||
((struct linetable *)
|
||||
obstack_copy (&mdebugread_objfile->objfile_obstack,
|
||||
obstack_copy (mdebugread_objfile->objfile_obstack (),
|
||||
lines, (sizeof (struct linetable)
|
||||
+ size * sizeof (lines->item))));
|
||||
xfree (lines);
|
||||
@@ -4649,7 +4649,7 @@ new_psymtab (const char *name, psymtab_storage *partial_symtabs,
|
||||
/* Keep a backpointer to the file's symbols. */
|
||||
|
||||
psymtab->read_symtab_private
|
||||
= OBSTACK_ZALLOC (&objfile->objfile_obstack, md_symloc);
|
||||
= OBSTACK_ZALLOC (objfile->objfile_obstack (), md_symloc);
|
||||
CUR_BFD (psymtab) = cur_bfd;
|
||||
DEBUG_SWAP (psymtab) = debug_swap;
|
||||
DEBUG_INFO (psymtab) = debug_info;
|
||||
@@ -4735,9 +4735,9 @@ new_block (enum block_type type, enum language language)
|
||||
static struct symbol *
|
||||
new_symbol (const char *name)
|
||||
{
|
||||
struct symbol *s = new (&mdebugread_objfile->objfile_obstack) symbol;
|
||||
struct symbol *s = new (mdebugread_objfile->objfile_obstack ()) symbol;
|
||||
|
||||
s->set_language (psymtab_language, &mdebugread_objfile->objfile_obstack);
|
||||
s->set_language (psymtab_language, mdebugread_objfile->objfile_obstack ());
|
||||
s->compute_and_set_names (name, true, mdebugread_objfile->per_bfd);
|
||||
return s;
|
||||
}
|
||||
@@ -4773,7 +4773,7 @@ elfmdebug_build_psymtabs (struct objfile *objfile,
|
||||
|
||||
minimal_symbol_reader reader (objfile);
|
||||
|
||||
info = XOBNEW (&objfile->objfile_obstack, ecoff_debug_info);
|
||||
info = XOBNEW (objfile->objfile_obstack (), ecoff_debug_info);
|
||||
|
||||
if (!(*swap->read_debug_info) (abfd, sec, info))
|
||||
error (_("Error reading ECOFF debugging information: %s"),
|
||||
|
||||
@@ -225,7 +225,7 @@ objfile_register_static_link (struct objfile *objfile,
|
||||
slot = htab_find_slot (objfile->static_links.get (), &lookup_entry, INSERT);
|
||||
gdb_assert (*slot == NULL);
|
||||
|
||||
entry = XOBNEW (&objfile->objfile_obstack, static_link_htab_entry);
|
||||
entry = XOBNEW (objfile->objfile_obstack (), static_link_htab_entry);
|
||||
entry->block = block;
|
||||
entry->static_link = static_link;
|
||||
*slot = (void *) entry;
|
||||
@@ -291,7 +291,7 @@ build_objfile_section_table (struct objfile *objfile)
|
||||
{
|
||||
int count = gdb_bfd_count_sections (objfile->obfd);
|
||||
|
||||
objfile->sections = OBSTACK_CALLOC (&objfile->objfile_obstack,
|
||||
objfile->sections = OBSTACK_CALLOC (objfile->objfile_obstack (),
|
||||
count,
|
||||
struct obj_section);
|
||||
objfile->sections_end = (objfile->sections + count);
|
||||
@@ -327,7 +327,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
|
||||
|
||||
/* We could use obstack_specify_allocation here instead, but
|
||||
gdb_obstack.h specifies the alloc/dealloc functions. */
|
||||
obstack_init (&objfile_obstack);
|
||||
obstack_init (objfile_obstack ());
|
||||
|
||||
objfile_alloc_data (this);
|
||||
|
||||
@@ -346,7 +346,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
|
||||
name_holder = gdb_abspath (name);
|
||||
expanded_name = name_holder.c_str ();
|
||||
}
|
||||
original_name = obstack_strdup (&objfile_obstack, expanded_name);
|
||||
original_name = obstack_strdup (objfile_obstack (), expanded_name);
|
||||
|
||||
/* Update the per-objfile information that comes from the bfd, ensuring
|
||||
that any data that is reference is saved in the per-objfile data
|
||||
@@ -594,7 +594,7 @@ objfile::~objfile ()
|
||||
}
|
||||
|
||||
/* Free the obstacks for non-reusable objfiles. */
|
||||
obstack_free (&objfile_obstack, 0);
|
||||
obstack_free (objfile_obstack (), 0);
|
||||
|
||||
/* Rebuild section map next time we need it. */
|
||||
get_objfile_pspace_data (pspace)->section_map_dirty = 1;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "jit.h"
|
||||
#include "quick-symbol.h"
|
||||
#include <forward_list>
|
||||
#include "gdbsupport/thread-pool.h"
|
||||
|
||||
struct htab;
|
||||
struct objfile_data;
|
||||
@@ -166,13 +167,13 @@ struct entry_info
|
||||
struct objstats
|
||||
{
|
||||
/* Number of full symbols read. */
|
||||
int n_syms = 0;
|
||||
std::atomic<int> n_syms {0};
|
||||
|
||||
/* Number of ".stabs" read (if applicable). */
|
||||
int n_stabs = 0;
|
||||
|
||||
/* Number of types. */
|
||||
int n_types = 0;
|
||||
std::atomic<int> n_types {0};
|
||||
|
||||
/* Size of stringtable, (if applicable). */
|
||||
int sz_strtab = 0;
|
||||
@@ -666,7 +667,24 @@ public:
|
||||
/* Obstack to hold objects that should be freed when we load a new symbol
|
||||
table from this object file. */
|
||||
|
||||
struct obstack objfile_obstack {};
|
||||
std::vector<struct obstack *> m_objfile_obstack;
|
||||
struct obstack *objfile_obstack ()
|
||||
{
|
||||
unsigned id = gdb::thread_pool::id ();
|
||||
size_t count = gdb::thread_pool::g_thread_pool->thread_count () + 1;
|
||||
if (m_objfile_obstack.empty ())
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
struct obstack *p
|
||||
= (struct obstack *)malloc (sizeof (struct obstack));
|
||||
m_objfile_obstack.push_back (p);
|
||||
if (i == 0)
|
||||
/* Main thread initializes it. */
|
||||
continue;
|
||||
obstack_init (m_objfile_obstack[i]);
|
||||
}
|
||||
return m_objfile_obstack[id];
|
||||
}
|
||||
|
||||
/* Structure which keeps track of functions that manipulate objfile's
|
||||
of the same type as this objfile. I.e. the function to read partial
|
||||
|
||||
@@ -423,11 +423,11 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
|
||||
/* On xcoff, if a global is defined and never referenced,
|
||||
ld will remove it from the executable. There is then
|
||||
a N_GSYM stab for it, but no regular (C_EXT) symbol. */
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
sym->set_aclass_index (LOC_OPTIMIZED_OUT);
|
||||
sym->set_linkage_name
|
||||
(obstack_strndup (&objfile->objfile_obstack, name, pp - name));
|
||||
(obstack_strndup (objfile->objfile_obstack (), name, pp - name));
|
||||
pp += 2;
|
||||
if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
|
||||
{
|
||||
@@ -687,7 +687,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
|
||||
nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
|
||||
|
||||
current_symbol = sym = new (&objfile->objfile_obstack) symbol;
|
||||
current_symbol = sym = new (objfile->objfile_obstack ()) symbol;
|
||||
|
||||
if (processing_gcc_compilation)
|
||||
{
|
||||
@@ -701,7 +701,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
}
|
||||
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
|
||||
if (is_cplus_marker (string[0]))
|
||||
{
|
||||
@@ -799,7 +799,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
|
||||
dbl_type = objfile_type (objfile)->builtin_double;
|
||||
dbl_valu
|
||||
= (gdb_byte *) obstack_alloc (&objfile->objfile_obstack,
|
||||
= (gdb_byte *) obstack_alloc (objfile->objfile_obstack (),
|
||||
TYPE_LENGTH (dbl_type));
|
||||
|
||||
target_float_from_string (dbl_valu, dbl_type, std::string (p));
|
||||
@@ -884,7 +884,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
(create_array_type (NULL, objfile_type (objfile)->builtin_char,
|
||||
range_type));
|
||||
string_value
|
||||
= (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, ind + 1);
|
||||
= (gdb_byte *) obstack_alloc (objfile->objfile_obstack (), ind + 1);
|
||||
memcpy (string_value, string_local, ind + 1);
|
||||
p++;
|
||||
|
||||
@@ -1283,7 +1283,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
if (synonym)
|
||||
{
|
||||
/* Create the STRUCT_DOMAIN clone. */
|
||||
struct symbol *struct_sym = new (&objfile->objfile_obstack) symbol;
|
||||
struct symbol *struct_sym = new (objfile->objfile_obstack ()) symbol;
|
||||
|
||||
*struct_sym = *sym;
|
||||
struct_sym->set_aclass_index (LOC_TYPEDEF);
|
||||
@@ -1291,7 +1291,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
struct_sym->set_domain (STRUCT_DOMAIN);
|
||||
if (sym->type ()->name () == 0)
|
||||
sym->type ()->set_name
|
||||
(obconcat (&objfile->objfile_obstack, sym->linkage_name (),
|
||||
(obconcat (objfile->objfile_obstack (), sym->linkage_name (),
|
||||
(char *) NULL));
|
||||
add_symbol_to_list (struct_sym, get_file_symbols ());
|
||||
}
|
||||
@@ -1318,14 +1318,14 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
sym->set_domain (STRUCT_DOMAIN);
|
||||
if (sym->type ()->name () == 0)
|
||||
sym->type ()->set_name
|
||||
(obconcat (&objfile->objfile_obstack, sym->linkage_name (),
|
||||
(obconcat (objfile->objfile_obstack (), sym->linkage_name (),
|
||||
(char *) NULL));
|
||||
add_symbol_to_list (sym, get_file_symbols ());
|
||||
|
||||
if (synonym)
|
||||
{
|
||||
/* Clone the sym and then modify it. */
|
||||
struct symbol *typedef_sym = new (&objfile->objfile_obstack) symbol;
|
||||
struct symbol *typedef_sym = new (objfile->objfile_obstack ()) symbol;
|
||||
|
||||
*typedef_sym = *sym;
|
||||
typedef_sym->set_aclass_index (LOC_TYPEDEF);
|
||||
@@ -1333,7 +1333,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
typedef_sym->set_domain (VAR_DOMAIN);
|
||||
if (sym->type ()->name () == 0)
|
||||
sym->type ()->set_name
|
||||
(obconcat (&objfile->objfile_obstack, sym->linkage_name (),
|
||||
(obconcat (objfile->objfile_obstack (), sym->linkage_name (),
|
||||
(char *) NULL));
|
||||
add_symbol_to_list (typedef_sym, get_file_symbols ());
|
||||
}
|
||||
@@ -1599,13 +1599,13 @@ again:
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> new_name = cp_canonicalize_string (name);
|
||||
if (new_name != nullptr)
|
||||
type_name = obstack_strdup (&objfile->objfile_obstack,
|
||||
type_name = obstack_strdup (objfile->objfile_obstack (),
|
||||
new_name.get ());
|
||||
}
|
||||
if (type_name == NULL)
|
||||
{
|
||||
char *to = type_name = (char *)
|
||||
obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
|
||||
obstack_alloc (objfile->objfile_obstack (), p - *pp + 1);
|
||||
|
||||
/* Copy the name. */
|
||||
from = *pp + 1;
|
||||
@@ -1633,7 +1633,7 @@ again:
|
||||
&& (sym->type ()->code () == code)
|
||||
&& strcmp (sym->linkage_name (), type_name) == 0)
|
||||
{
|
||||
obstack_free (&objfile->objfile_obstack, type_name);
|
||||
obstack_free (objfile->objfile_obstack (), type_name);
|
||||
type = sym->type ();
|
||||
if (typenums[0] != -1)
|
||||
*dbx_lookup_type (typenums, objfile) = type;
|
||||
@@ -2038,7 +2038,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
|
||||
if (!negative_types)
|
||||
{
|
||||
/* This includes an empty slot for type number -0. */
|
||||
negative_types = OBSTACK_CALLOC (&objfile->objfile_obstack,
|
||||
negative_types = OBSTACK_CALLOC (objfile->objfile_obstack (),
|
||||
NUMBER_RECOGNIZED + 1, struct type *);
|
||||
rs6000_builtin_type_data.set (objfile, negative_types);
|
||||
}
|
||||
@@ -2584,11 +2584,11 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
|
||||
struct next_fnfieldlist);
|
||||
|
||||
destr_fnlist->fn_fieldlist.name
|
||||
= obconcat (&objfile->objfile_obstack, "~",
|
||||
= obconcat (objfile->objfile_obstack (), "~",
|
||||
new_fnlist->fn_fieldlist.name, (char *) NULL);
|
||||
|
||||
destr_fnlist->fn_fieldlist.fn_fields =
|
||||
XOBNEWVEC (&objfile->objfile_obstack,
|
||||
XOBNEWVEC (objfile->objfile_obstack (),
|
||||
struct fn_field, has_destructor);
|
||||
memset (destr_fnlist->fn_fieldlist.fn_fields, 0,
|
||||
sizeof (struct fn_field) * has_destructor);
|
||||
@@ -2643,13 +2643,13 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
|
||||
else if (has_destructor && new_fnlist->fn_fieldlist.name[0] != '~')
|
||||
{
|
||||
new_fnlist->fn_fieldlist.name =
|
||||
obconcat (&objfile->objfile_obstack,
|
||||
obconcat (objfile->objfile_obstack (),
|
||||
"~", main_fn_name, (char *)NULL);
|
||||
xfree (main_fn_name);
|
||||
}
|
||||
|
||||
new_fnlist->fn_fieldlist.fn_fields
|
||||
= OBSTACK_CALLOC (&objfile->objfile_obstack, length, fn_field);
|
||||
= OBSTACK_CALLOC (objfile->objfile_obstack (), length, fn_field);
|
||||
for (i = length; (i--, sublist); sublist = sublist->next)
|
||||
{
|
||||
new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
|
||||
@@ -2712,7 +2712,7 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
|
||||
{
|
||||
name = "";
|
||||
}
|
||||
fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
|
||||
fip->list->field.set_name (obconcat (objfile->objfile_obstack (),
|
||||
vptr_name, name, (char *) NULL));
|
||||
break;
|
||||
|
||||
@@ -2725,13 +2725,13 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
|
||||
symnum);
|
||||
name = "FOO";
|
||||
}
|
||||
fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
|
||||
fip->list->field.set_name (obconcat (objfile->objfile_obstack (),
|
||||
vb_name, name, (char *) NULL));
|
||||
break;
|
||||
|
||||
default:
|
||||
invalid_cpp_abbrev_complaint (*pp);
|
||||
fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
|
||||
fip->list->field.set_name (obconcat (objfile->objfile_obstack (),
|
||||
"INVALID_CPLUSPLUS_ABBREV",
|
||||
(char *) NULL));
|
||||
break;
|
||||
@@ -2782,7 +2782,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
|
||||
struct gdbarch *gdbarch = objfile->arch ();
|
||||
|
||||
fip->list->field.set_name
|
||||
(obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp));
|
||||
(obstack_strndup (objfile->objfile_obstack (), *pp, p - *pp));
|
||||
*pp = p + 1;
|
||||
|
||||
/* This means we have a visibility for a field coming. */
|
||||
@@ -3582,16 +3582,16 @@ read_enum_type (const char **pp, struct type *type,
|
||||
p = *pp;
|
||||
while (*p != ':')
|
||||
p++;
|
||||
name = obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp);
|
||||
name = obstack_strndup (objfile->objfile_obstack (), *pp, p - *pp);
|
||||
*pp = p + 1;
|
||||
n = read_huge_number (pp, ',', &nbits, 0);
|
||||
if (nbits != 0)
|
||||
return error_type (pp, objfile);
|
||||
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
sym->set_linkage_name (name);
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
objfile->objfile_obstack ());
|
||||
sym->set_aclass_index (LOC_CONST);
|
||||
sym->set_domain (VAR_DOMAIN);
|
||||
sym->set_value_longest (n);
|
||||
@@ -4232,7 +4232,7 @@ common_block_start (const char *name, struct objfile *objfile)
|
||||
}
|
||||
common_block = *get_local_symbols ();
|
||||
common_block_i = common_block ? common_block->nsyms : 0;
|
||||
common_block_name = obstack_strdup (&objfile->objfile_obstack, name);
|
||||
common_block_name = obstack_strdup (objfile->objfile_obstack (), name);
|
||||
}
|
||||
|
||||
/* Process a N_ECOMM symbol. */
|
||||
@@ -4257,7 +4257,7 @@ common_block_end (struct objfile *objfile)
|
||||
return;
|
||||
}
|
||||
|
||||
sym = new (&objfile->objfile_obstack) symbol;
|
||||
sym = new (objfile->objfile_obstack ()) symbol;
|
||||
/* Note: common_block_name already saved on objfile_obstack. */
|
||||
sym->set_linkage_name (common_block_name);
|
||||
sym->set_aclass_index (LOC_BLOCK);
|
||||
@@ -4497,6 +4497,11 @@ cleanup_undefined_types_1 (void)
|
||||
void
|
||||
cleanup_undefined_stabs_types (struct objfile *objfile)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
static std::mutex cleanup_undefined_stabs_types_lock;
|
||||
std::lock_guard<std::mutex> guard (cleanup_undefined_stabs_types_lock);
|
||||
#endif
|
||||
|
||||
cleanup_undefined_types_1 ();
|
||||
cleanup_undefined_types_noname (objfile);
|
||||
}
|
||||
|
||||
@@ -2525,7 +2525,7 @@ reread_symbols (int from_tty)
|
||||
|
||||
/* NB: after this call to obstack_free, objfiles_changed
|
||||
will need to be called (see discussion below). */
|
||||
obstack_free (&objfile->objfile_obstack, 0);
|
||||
obstack_free (objfile->objfile_obstack (), 0);
|
||||
objfile->sections = NULL;
|
||||
objfile->section_offsets.clear ();
|
||||
objfile->sect_index_bss = -1;
|
||||
@@ -2539,7 +2539,7 @@ reread_symbols (int from_tty)
|
||||
/* obstack_init also initializes the obstack so it is
|
||||
empty. We could use obstack_specify_allocation but
|
||||
gdb_obstack.h specifies the alloc/dealloc functions. */
|
||||
obstack_init (&objfile->objfile_obstack);
|
||||
obstack_init (objfile->objfile_obstack ());
|
||||
|
||||
/* set_objfile_per_bfd potentially allocates the per-bfd
|
||||
data on the objfile's obstack (if sharing data across
|
||||
@@ -2548,7 +2548,7 @@ reread_symbols (int from_tty)
|
||||
set_objfile_per_bfd (objfile);
|
||||
|
||||
objfile->original_name
|
||||
= obstack_strdup (&objfile->objfile_obstack, original_name);
|
||||
= obstack_strdup (objfile->objfile_obstack (), original_name);
|
||||
|
||||
/* Reset the sym_fns pointer. The ELF reader can change it
|
||||
based on whether .gdb_index is present, and we need it to
|
||||
@@ -2776,7 +2776,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
|
||||
{
|
||||
struct objfile *objfile = cust->objfile ();
|
||||
struct symtab *symtab
|
||||
= OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
|
||||
= OBSTACK_ZALLOC (objfile->objfile_obstack (), struct symtab);
|
||||
|
||||
symtab->filename = objfile->intern (filename);
|
||||
symtab->fullname = NULL;
|
||||
@@ -2819,7 +2819,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
|
||||
struct compunit_symtab *
|
||||
allocate_compunit_symtab (struct objfile *objfile, const char *name)
|
||||
{
|
||||
struct compunit_symtab *cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||
struct compunit_symtab *cu = OBSTACK_ZALLOC (objfile->objfile_obstack (),
|
||||
struct compunit_symtab);
|
||||
const char *saved_name;
|
||||
|
||||
@@ -2829,7 +2829,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
|
||||
Just save the basename to avoid path issues (too long for display,
|
||||
relative vs absolute, etc.). */
|
||||
saved_name = lbasename (name);
|
||||
cu->name = obstack_strdup (&objfile->objfile_obstack, saved_name);
|
||||
cu->name = obstack_strdup (objfile->objfile_obstack (), saved_name);
|
||||
|
||||
cu->set_debugformat ("unknown");
|
||||
|
||||
@@ -2849,6 +2849,10 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
|
||||
void
|
||||
add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
static std::mutex add_compunit_symtab_to_objfile_lock;
|
||||
std::lock_guard<std::mutex> guard (add_compunit_symtab_to_objfile_lock);
|
||||
#endif
|
||||
cu->next = cu->objfile ()->compunit_symtabs;
|
||||
cu->objfile ()->compunit_symtabs = cu;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ print_objfile_statistics (void)
|
||||
objfile->per_bfd->n_minsyms);
|
||||
if (OBJSTAT (objfile, n_syms) > 0)
|
||||
gdb_printf (_(" Number of \"full\" symbols read: %d\n"),
|
||||
OBJSTAT (objfile, n_syms));
|
||||
OBJSTAT (objfile, n_syms).load ());
|
||||
if (OBJSTAT (objfile, n_types) > 0)
|
||||
gdb_printf (_(" Number of \"types\" defined: %d\n"),
|
||||
OBJSTAT (objfile, n_types));
|
||||
OBJSTAT (objfile, n_types).load ());
|
||||
|
||||
i = linetables = 0;
|
||||
for (compunit_symtab *cu : objfile->compunits ())
|
||||
@@ -95,8 +95,8 @@ print_objfile_statistics (void)
|
||||
gdb_printf (_(" Space used by string tables: %d\n"),
|
||||
OBJSTAT (objfile, sz_strtab));
|
||||
gdb_printf (_(" Total memory used for objfile obstack: %s\n"),
|
||||
pulongest (obstack_memory_used (&objfile
|
||||
->objfile_obstack)));
|
||||
pulongest (obstack_memory_used (objfile
|
||||
->objfile_obstack ())));
|
||||
gdb_printf (_(" Total memory used for BFD obstack: %s\n"),
|
||||
pulongest (obstack_memory_used (&objfile->per_bfd
|
||||
->storage_obstack)));
|
||||
|
||||
@@ -1005,7 +1005,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = (char *) obstack_alloc (&objfile->objfile_obstack,
|
||||
p = (char *) obstack_alloc (objfile->objfile_obstack (),
|
||||
E_SYMNMLEN + 1);
|
||||
strncpy (p, cs->c_name, E_SYMNMLEN);
|
||||
p[E_SYMNMLEN] = '\0';
|
||||
@@ -1450,7 +1450,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
|
||||
}
|
||||
|
||||
#define SYMNAME_ALLOC(NAME, ALLOCED) \
|
||||
((ALLOCED) ? (NAME) : obstack_strdup (&objfile->objfile_obstack, \
|
||||
((ALLOCED) ? (NAME) : obstack_strdup (objfile->objfile_obstack (), \
|
||||
(NAME)))
|
||||
|
||||
|
||||
@@ -1499,7 +1499,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile)
|
||||
sym->set_type (objfile_type (objfile)->nodebug_text_symbol);
|
||||
|
||||
sym->set_aclass_index (LOC_BLOCK);
|
||||
sym2 = new (&objfile->objfile_obstack) symbol (*sym);
|
||||
sym2 = new (objfile->objfile_obstack ()) symbol (*sym);
|
||||
|
||||
if (cs->c_sclass == C_EXT || C_WEAKEXT)
|
||||
add_symbol_to_list (sym2, get_global_symbols ());
|
||||
@@ -1850,7 +1850,7 @@ init_stringtab (bfd *abfd, file_ptr offset, struct objfile *objfile)
|
||||
/* Allocate string table from objfile_obstack. We will need this table
|
||||
as long as we have its symbol table around. */
|
||||
|
||||
strtbl = (char *) obstack_alloc (&objfile->objfile_obstack, length);
|
||||
strtbl = (char *) obstack_alloc (objfile->objfile_obstack (), length);
|
||||
xcoff->strtbl = strtbl;
|
||||
|
||||
/* Copy length buffer, the first byte is usually zero and is
|
||||
@@ -1893,7 +1893,7 @@ xcoff_start_psymtab (psymtab_storage *partial_symtabs,
|
||||
objfile->per_bfd, 0);
|
||||
|
||||
result->read_symtab_private =
|
||||
XOBNEW (&objfile->objfile_obstack, struct xcoff_symloc);
|
||||
XOBNEW (objfile->objfile_obstack (), struct xcoff_symloc);
|
||||
((struct xcoff_symloc *) result->read_symtab_private)->first_symnum = first_symnum;
|
||||
result->legacy_read_symtab = xcoff_read_symtab;
|
||||
result->legacy_expand_psymtab = xcoff_expand_psymtab;
|
||||
@@ -1948,7 +1948,7 @@ xcoff_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs,
|
||||
legacy_psymtab *subpst =
|
||||
new legacy_psymtab (include_list[i], partial_symtabs, objfile->per_bfd);
|
||||
|
||||
subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, xcoff_symloc);
|
||||
subpst->read_symtab_private = XOBNEW (objfile->objfile_obstack (), xcoff_symloc);
|
||||
((struct xcoff_symloc *) subpst->read_symtab_private)->first_symnum = 0;
|
||||
((struct xcoff_symloc *) subpst->read_symtab_private)->numsyms = 0;
|
||||
|
||||
@@ -1999,7 +1999,7 @@ swap_sym (struct internal_syment *symbol, union internal_auxent *aux,
|
||||
into the minimal symbols. */
|
||||
char *p;
|
||||
|
||||
p = (char *) obstack_alloc (&objfile->objfile_obstack,
|
||||
p = (char *) obstack_alloc (objfile->objfile_obstack (),
|
||||
E_SYMNMLEN + 1);
|
||||
strncpy (p, symbol->n_name, E_SYMNMLEN);
|
||||
p[E_SYMNMLEN] = '\0';
|
||||
@@ -2826,7 +2826,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||
if (length)
|
||||
{
|
||||
debugsec
|
||||
= (bfd_byte *) obstack_alloc (&objfile->objfile_obstack,
|
||||
= (bfd_byte *) obstack_alloc (objfile->objfile_obstack (),
|
||||
length);
|
||||
|
||||
if (!bfd_get_full_section_contents (abfd, secp, &debugsec))
|
||||
@@ -2847,7 +2847,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||
error (_("Error reading symbols from %s: %s"),
|
||||
name, bfd_errmsg (bfd_get_error ()));
|
||||
size = coff_data (abfd)->local_symesz * num_symbols;
|
||||
info->symtbl = (char *) obstack_alloc (&objfile->objfile_obstack, size);
|
||||
info->symtbl = (char *) obstack_alloc (objfile->objfile_obstack (), size);
|
||||
info->symtbl_num_syms = num_symbols;
|
||||
|
||||
val = bfd_bread (info->symtbl, size, abfd);
|
||||
|
||||
@@ -134,7 +134,9 @@ typename gdb::detail::par_for_accumulator<
|
||||
typename std::result_of<RangeFunction (RandomIt, RandomIt)>::type
|
||||
>::result_type
|
||||
parallel_for_each (unsigned n, RandomIt first, RandomIt last,
|
||||
RangeFunction callback)
|
||||
RangeFunction callback,
|
||||
std::function<unsigned int(RandomIt)> *task_size_ptr
|
||||
= (std::function<unsigned int(RandomIt)> *)nullptr)
|
||||
{
|
||||
using result_type
|
||||
= typename std::result_of<RangeFunction (RandomIt, RandomIt)>::type;
|
||||
@@ -148,17 +150,33 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
|
||||
size_t n_elements = last - first;
|
||||
size_t elts_per_thread = 0;
|
||||
size_t elts_left_over = 0;
|
||||
size_t total_size = 0;
|
||||
size_t size_per_thread = 0;
|
||||
|
||||
if (n_threads > 1)
|
||||
{
|
||||
/* Require that there should be at least N elements in a
|
||||
thread. */
|
||||
gdb_assert (n > 0);
|
||||
if (n_elements / n_threads < n)
|
||||
n_threads = std::max (n_elements / n, (size_t) 1);
|
||||
elts_per_thread = n_elements / n_threads;
|
||||
elts_left_over = n_elements % n_threads;
|
||||
/* n_elements == n_threads * elts_per_thread + elts_left_over. */
|
||||
if (task_size_ptr != nullptr)
|
||||
{
|
||||
gdb_assert (n == 1);
|
||||
for (RandomIt i = first; i != last; ++i)
|
||||
{
|
||||
std::function<unsigned int(RandomIt)> f = *task_size_ptr;
|
||||
size_t s = (size_t)f (i);
|
||||
total_size += s;
|
||||
}
|
||||
size_per_thread = total_size / n_threads;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Require that there should be at least N elements in a
|
||||
thread. */
|
||||
gdb_assert (n > 0);
|
||||
if (n_elements / n_threads < n)
|
||||
n_threads = std::max (n_elements / n, (size_t) 1);
|
||||
elts_per_thread = n_elements / n_threads;
|
||||
elts_left_over = n_elements % n_threads;
|
||||
/* n_elements == n_threads * elts_per_thread + elts_left_over. */
|
||||
}
|
||||
}
|
||||
|
||||
size_t count = n_threads == 0 ? 0 : n_threads - 1;
|
||||
@@ -167,20 +185,47 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
|
||||
if (parallel_for_each_debug)
|
||||
{
|
||||
debug_printf (_("Parallel for: n_elements: %zu\n"), n_elements);
|
||||
debug_printf (_("Parallel for: minimum elements per thread: %u\n"), n);
|
||||
debug_printf (_("Parallel for: elts_per_thread: %zu\n"), elts_per_thread);
|
||||
if (task_size_ptr != nullptr)
|
||||
{
|
||||
debug_printf (_("Parallel for: total_size: %zu\n"), total_size);
|
||||
debug_printf (_("Parallel for: size_per_thread: %zu\n"), size_per_thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_printf (_("Parallel for: minimum elements per thread: %u\n"), n);
|
||||
debug_printf (_("Parallel for: elts_per_thread: %zu\n"), elts_per_thread);
|
||||
}
|
||||
}
|
||||
|
||||
size_t remaining_size = total_size;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
RandomIt end = first + elts_per_thread;
|
||||
if (i < elts_left_over)
|
||||
/* Distribute the leftovers over the worker threads, to avoid having
|
||||
to handle all of them in a single thread. */
|
||||
end++;
|
||||
RandomIt end;
|
||||
size_t s = 0;
|
||||
if (task_size_ptr == nullptr)
|
||||
{
|
||||
end = first + elts_per_thread;
|
||||
if (i < elts_left_over)
|
||||
/* Distribute the leftovers over the worker threads, to avoid having
|
||||
to handle all of them in a single thread. */
|
||||
end++;
|
||||
}
|
||||
else
|
||||
{
|
||||
RandomIt j;
|
||||
for (j = first; j < last && s < size_per_thread; ++j)
|
||||
s += (size_t)(*task_size_ptr) (j);
|
||||
end = j;
|
||||
remaining_size -= s;
|
||||
}
|
||||
if (parallel_for_each_debug)
|
||||
debug_printf (_("Parallel for: elements on worker thread %i\t: %zu\n"),
|
||||
i, (size_t)(end - first));
|
||||
{
|
||||
debug_printf (_("Parallel for: elements on worker thread %i\t: %zu"),
|
||||
i, (size_t)(end - first));
|
||||
if (task_size_ptr != nullptr)
|
||||
debug_printf (_("\t(size: %zu)"), s);
|
||||
debug_printf (_("\n"));
|
||||
}
|
||||
results.post (i, [=] ()
|
||||
{
|
||||
return callback (first, end);
|
||||
@@ -190,12 +235,22 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
|
||||
|
||||
for (int i = count; i < n_worker_threads; ++i)
|
||||
if (parallel_for_each_debug)
|
||||
debug_printf (_("Parallel for: elements on worker thread %i\t: 0\n"), i);
|
||||
{
|
||||
debug_printf (_("Parallel for: elements on worker thread %i\t: 0"), i);
|
||||
if (task_size_ptr != nullptr)
|
||||
debug_printf (_("\t(size: 0)"));
|
||||
debug_printf (_("\n"));
|
||||
}
|
||||
|
||||
/* Process all the remaining elements in the main thread. */
|
||||
if (parallel_for_each_debug)
|
||||
debug_printf (_("Parallel for: elements on main thread\t\t: %zu\n"),
|
||||
(size_t)(last - first));
|
||||
{
|
||||
debug_printf (_("Parallel for: elements on main thread\t\t: %zu"),
|
||||
(size_t)(last - first));
|
||||
if (task_size_ptr != nullptr)
|
||||
debug_printf (_("\t(size: %zu)"), remaining_size);
|
||||
debug_printf (_("\n"));
|
||||
}
|
||||
return results.finish ([=] ()
|
||||
{
|
||||
return callback (first, last);
|
||||
|
||||
@@ -29,12 +29,7 @@
|
||||
char *
|
||||
get_print_cell (void)
|
||||
{
|
||||
static char buf[NUMCELLS][PRINT_CELL_SIZE];
|
||||
static int cell = 0;
|
||||
|
||||
if (++cell >= NUMCELLS)
|
||||
cell = 0;
|
||||
return buf[cell];
|
||||
return (char *)malloc (PRINT_CELL_SIZE);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
||||
@@ -149,12 +149,25 @@ thread_pool::~thread_pool ()
|
||||
case -- see the comment by the definition of g_thread_pool. */
|
||||
}
|
||||
|
||||
unsigned thread_pool::id ()
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::thread::id id = std::this_thread::get_id();
|
||||
return g_thread_pool->m_thread_ids[id];
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
thread_pool::set_thread_count (size_t num_threads)
|
||||
{
|
||||
#if CXX_STD_THREAD
|
||||
std::lock_guard<std::mutex> guard (m_tasks_mutex);
|
||||
|
||||
m_thread_ids[std::this_thread::get_id ()] = 0;
|
||||
m_thread_ids_reverse[0] = std::this_thread::get_id ();
|
||||
|
||||
/* If the new size is larger, start some new threads. */
|
||||
if (m_thread_count < num_threads)
|
||||
{
|
||||
@@ -166,6 +179,8 @@ thread_pool::set_thread_count (size_t num_threads)
|
||||
try
|
||||
{
|
||||
std::thread thread (&thread_pool::thread_function, this);
|
||||
m_thread_ids[thread.get_id ()] = i + 1;
|
||||
m_thread_ids_reverse[i + 1] = thread.get_id ();
|
||||
thread.detach ();
|
||||
}
|
||||
catch (const std::system_error &)
|
||||
@@ -182,7 +197,12 @@ thread_pool::set_thread_count (size_t num_threads)
|
||||
if (num_threads < m_thread_count)
|
||||
{
|
||||
for (size_t i = num_threads; i < m_thread_count; ++i)
|
||||
m_tasks.emplace ();
|
||||
{
|
||||
std::thread::id id = m_thread_ids_reverse[i];
|
||||
m_thread_ids.erase (id);
|
||||
m_thread_ids_reverse.erase (i);
|
||||
m_tasks.emplace ();
|
||||
}
|
||||
m_tasks_cv.notify_all ();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#if CXX_STD_THREAD
|
||||
#include <thread>
|
||||
@@ -119,6 +120,8 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned id ();
|
||||
|
||||
/* Post a task to the thread pool. A future is returned, which can
|
||||
be used to wait for the result. */
|
||||
future<void> post_task (std::function<void ()> &&func)
|
||||
@@ -177,6 +180,8 @@ private:
|
||||
between the main thread and the worker threads. */
|
||||
std::condition_variable m_tasks_cv;
|
||||
std::mutex m_tasks_mutex;
|
||||
std::unordered_map<std::thread::id, unsigned> m_thread_ids;
|
||||
std::unordered_map<unsigned, std::thread::id> m_thread_ids_reverse;
|
||||
#endif /* CXX_STD_THREAD */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user