diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2021-11-19 21:14:36 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-02-06 15:48:18 -0500 |
commit | 36664835fa3f81503633024e0e834be4d84276e1 (patch) | |
tree | a00cbe27884e94579e4ddb559faf62356be3d4b1 | |
parent | 43b49762a17718fe13718238a8c0af9b62b682d4 (diff) | |
download | gdb-36664835fa3f81503633024e0e834be4d84276e1.zip gdb-36664835fa3f81503633024e0e834be4d84276e1.tar.gz gdb-36664835fa3f81503633024e0e834be4d84276e1.tar.bz2 |
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
-rw-r--r-- | gdb/buildsym.c | 24 | ||||
-rw-r--r-- | gdb/symtab.c | 28 | ||||
-rw-r--r-- | gdb/symtab.h | 6 |
3 files changed, 36 insertions, 22 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 1754f5f..914834f 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 2028e83..f4f5f09 100644 --- a/gdb/symtab.c +++ b/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 { diff --git a/gdb/symtab.h b/gdb/symtab.h index 3fa4d5f..23a348a 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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; |