diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-21 16:50:20 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-01-10 19:14:12 -0700 |
commit | 906768f970826102252e8cfd30ee72da71de29f7 (patch) | |
tree | 638e59e15edbea5651e05a0d8739ede2b2276188 /gdb/psympriv.h | |
parent | bef155c3e8a995fcdb1c2ba5aba012eb653d9f30 (diff) | |
download | gdb-906768f970826102252e8cfd30ee72da71de29f7.zip gdb-906768f970826102252e8cfd30ee72da71de29f7.tar.gz gdb-906768f970826102252e8cfd30ee72da71de29f7.tar.bz2 |
Remove make_cleanup_discard_psymtabs
This removes make_cleanup_discard_psymtabs in favor of a new class.
2017-01-10 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_build_psymtabs): Use psymtab_discarder.
* psympriv.h (make_cleanup_discard_psymtabs): Don't declare.
* psymtab.c (discard_psymtabs_upto): Remove.
(make_cleanup_discard_psymtabs): Remove.
(struct psymtab_state): Remove.
Diffstat (limited to 'gdb/psympriv.h')
-rw-r--r-- | gdb/psympriv.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 36ce1d2..c4d2bb9 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -21,6 +21,7 @@ #define PSYMPRIV_H #include "psymtab.h" +#include "objfiles.h" struct psymbol_allocation_list; @@ -225,7 +226,40 @@ extern struct partial_symtab *allocate_psymtab (const char *, extern void discard_psymtab (struct objfile *, struct partial_symtab *); -extern struct cleanup *make_cleanup_discard_psymtabs (struct objfile *); +/* Used when recording partial symbol tables. On destruction, + discards any partial symbol tables that have been built. However, + the tables can be kept by calling the "keep" method. */ +class psymtab_discarder +{ + public: + + psymtab_discarder (struct objfile *objfile) + : m_objfile (objfile), + m_psymtab (objfile->psymtabs) + { + } + + ~psymtab_discarder () + { + if (m_objfile != NULL) + while (m_objfile->psymtabs != m_psymtab) + discard_psymtab (m_objfile, m_objfile->psymtabs); + } + + /* Keep any partial symbol tables that were built. */ + void keep () + { + m_objfile = NULL; + } + + private: + + /* The objfile. If NULL this serves as a sentinel to indicate that + the psymtabs should be kept. */ + struct objfile *m_objfile; + /* How far back to free. */ + struct partial_symtab *m_psymtab; +}; /* Traverse all psymtabs in one objfile. */ |