From 484b1090630d273dfb70ee96b152ec6b527a1b65 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 20 Mar 2021 17:23:40 -0600 Subject: [PATCH] Do not pass objfile to psymtab_discarder This changes the psymtab_discarder to not assume that partial symtabs are attached to the objfile. Instead, a psymtab_storage object is passed directly to it. gdb/ChangeLog 2021-03-20 Tom Tromey * psympriv.h (psymtab_discarder): Take psymtab_storage parameter. (~psymtab_discarder, keep): Update. : Remove. : New member. * dwarf2/read.c (dwarf2_build_psymtabs): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/read.c | 2 +- gdb/psympriv.h | 17 ++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 491ddd5e2b2..7bb862e43f0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2021-03-20 Tom Tromey + + * psympriv.h (psymtab_discarder): Take psymtab_storage parameter. + (~psymtab_discarder, keep): Update. + : Remove. + : New member. + * dwarf2/read.c (dwarf2_build_psymtabs): Update. + 2021-03-20 Tom Tromey * xcoffread.c (xcoff_end_psymtab): Add partial_symtabs parameter. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 19e5cdb6d5a..aad25f7c086 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6142,7 +6142,7 @@ dwarf2_build_psymtabs (struct objfile *objfile) /* This isn't really ideal: all the data we allocate on the objfile's obstack is still uselessly kept around. However, freeing it seems unsafe. */ - psymtab_discarder psymtabs (objfile); + psymtab_discarder psymtabs (objfile->partial_symtabs.get ()); dwarf2_build_psymtabs_hard (per_objfile); psymtabs.keep (); diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 73f00a50992..0f24c104aca 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -446,29 +446,28 @@ class psymtab_discarder { public: - psymtab_discarder (struct objfile *objfile) - : m_objfile (objfile), - m_psymtab (objfile->partial_symtabs->psymtabs) + psymtab_discarder (psymtab_storage *partial_symtabs) + : m_partial_symtabs (partial_symtabs), + m_psymtab (partial_symtabs->psymtabs) { } ~psymtab_discarder () { - if (m_objfile != NULL) - m_objfile->partial_symtabs->discard_psymtabs_to (m_psymtab); + if (m_partial_symtabs != nullptr) + m_partial_symtabs->discard_psymtabs_to (m_psymtab); } /* Keep any partial symbol tables that were built. */ void keep () { - m_objfile = NULL; + m_partial_symtabs = nullptr; } private: - /* The objfile. If NULL this serves as a sentinel to indicate that - the psymtabs should be kept. */ - struct objfile *m_objfile; + /* The partial symbol storage object. */ + psymtab_storage *m_partial_symtabs; /* How far back to free. */ struct partial_symtab *m_psymtab; }; -- 2.30.2