forked from Imagelibrary/binutils-gdb
gdb: add compunit_symtab::set_primary_filetab method
Add a method to set the primary filetab of the CU. This is currently done in buildsym_compunit::end_symtab_with_blockvector. Change-Id: I16c51a6b90a4cb4c0c5f183b0f2e12bc64b6fd74
This commit is contained in:
committed by
Simon Marchi
parent
43b49762a1
commit
36664835fa
@@ -996,28 +996,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
|
||||
symtab->language = subfile->language;
|
||||
}
|
||||
|
||||
/* Make sure the symtab of main_subfile is the first in its list. */
|
||||
{
|
||||
struct symtab *main_symtab, *prev_symtab;
|
||||
|
||||
main_symtab = m_main_subfile->symtab;
|
||||
prev_symtab = NULL;
|
||||
for (symtab *symtab : compunit_filetabs (cu))
|
||||
{
|
||||
if (symtab == main_symtab)
|
||||
{
|
||||
if (prev_symtab != NULL)
|
||||
{
|
||||
prev_symtab->next = main_symtab->next;
|
||||
main_symtab->next = COMPUNIT_FILETABS (cu);
|
||||
COMPUNIT_FILETABS (cu) = main_symtab;
|
||||
}
|
||||
break;
|
||||
}
|
||||
prev_symtab = symtab;
|
||||
}
|
||||
gdb_assert (main_symtab == COMPUNIT_FILETABS (cu));
|
||||
}
|
||||
/* Make sure the filetab of main_subfile is the primary filetab of the CU. */
|
||||
cu->set_primary_filetab (m_main_subfile->symtab);
|
||||
|
||||
/* Fill out the compunit symtab. */
|
||||
|
||||
|
||||
28
gdb/symtab.c
28
gdb/symtab.c
@@ -361,6 +361,34 @@ compunit_symtab::set_call_site_htab (htab_t call_site_htab)
|
||||
|
||||
/* See symtab.h. */
|
||||
|
||||
void
|
||||
compunit_symtab::set_primary_filetab (symtab *primary_filetab)
|
||||
{
|
||||
symtab *prev_filetab = nullptr;
|
||||
|
||||
/* Move PRIMARY_FILETAB to the head of the filetab list. */
|
||||
for (symtab *filetab : compunit_filetabs (this))
|
||||
{
|
||||
if (filetab == primary_filetab)
|
||||
{
|
||||
if (prev_filetab != nullptr)
|
||||
{
|
||||
prev_filetab->next = primary_filetab->next;
|
||||
primary_filetab->next = this->filetabs;
|
||||
this->filetabs = primary_filetab;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
prev_filetab = filetab;
|
||||
}
|
||||
|
||||
gdb_assert (primary_filetab == this->filetabs);
|
||||
}
|
||||
|
||||
/* See symtab.h. */
|
||||
|
||||
struct symtab *
|
||||
compunit_symtab::primary_filetab () const
|
||||
{
|
||||
|
||||
@@ -1473,6 +1473,12 @@ struct compunit_symtab
|
||||
}
|
||||
}
|
||||
|
||||
/* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
|
||||
|
||||
PRIMARY_FILETAB must already be a filetab of this compunit symtab. */
|
||||
|
||||
void set_primary_filetab (symtab *primary_filetab);
|
||||
|
||||
/* Return the primary filetab of the compunit. */
|
||||
symtab *primary_filetab () const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user