diff options
author | Tom Tromey <tom@tromey.com> | 2018-03-28 15:04:30 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-03-30 13:15:57 -0600 |
commit | 11ed8cada64e717900117364c2fee0132c1eb099 (patch) | |
tree | b3edabc80fab73f447eb4a041fe177e8279430d9 /gdb | |
parent | 9ae79dac31c2bcbd2f5418da2e12af94060e139a (diff) | |
download | fsf-binutils-gdb-11ed8cada64e717900117364c2fee0132c1eb099.zip fsf-binutils-gdb-11ed8cada64e717900117364c2fee0132c1eb099.tar.gz fsf-binutils-gdb-11ed8cada64e717900117364c2fee0132c1eb099.tar.bz2 |
Remove free_cached_comp_units cleanups
This changes free_cached_comp_units from a cleanup function to an RAII
class.
gdb/ChangeLog
2018-03-30 Tom Tromey <tom@tromey.com>
* dwarf2read.c (class free_cached_comp_units): New class.
(dw2_instantiate_symtab, dwarf2_build_psymtabs_hard): Use it.
(free_cached_comp_units): Remove function.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 46 |
2 files changed, 32 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 815d03d..9b4675f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2018-03-30 Tom Tromey <tom@tromey.com> + * dwarf2read.c (class free_cached_comp_units): New class. + (dw2_instantiate_symtab, dwarf2_build_psymtabs_hard): Use it. + (free_cached_comp_units): Remove function. + +2018-03-30 Tom Tromey <tom@tromey.com> + * utils.h (make_cleanup_unpush_target): Remove. * inf-ptrace.c (struct target_unpusher): New. (target_unpush_up) New typedef. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index dfa69d1..7840496 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1821,8 +1821,6 @@ static void prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, enum language pretend_language); -static void free_cached_comp_units (void *); - static void age_cached_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile); static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *); @@ -2172,6 +2170,30 @@ dwarf2_per_objfile::free_cached_comp_units () } } +/* A helper class that calls free_cached_comp_units on + destruction. */ + +class free_cached_comp_units +{ +public: + + explicit free_cached_comp_units (dwarf2_per_objfile *per_objfile) + : m_per_objfile (per_objfile) + { + } + + ~free_cached_comp_units () + { + m_per_objfile->free_cached_comp_units (); + } + + DISABLE_COPY_AND_ASSIGN (free_cached_comp_units); + +private: + + dwarf2_per_objfile *m_per_objfile; +}; + /* Try to locate the sections we need for DWARF 2 debugging information and return true if we have enough to do something. NAMES points to the dwarf2 section names, or is NULL if the standard @@ -2876,12 +2898,10 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu) gdb_assert (dwarf2_per_objfile->using_index); if (!per_cu->v.quick->compunit_symtab) { - struct cleanup *back_to = make_cleanup (free_cached_comp_units, - dwarf2_per_objfile); + free_cached_comp_units freer (dwarf2_per_objfile); scoped_restore decrementer = increment_reading_symtab (); dw2_do_instantiate_symtab (per_cu); process_cu_includes (dwarf2_per_objfile); - do_cleanups (back_to); } return per_cu->v.quick->compunit_symtab; @@ -8434,7 +8454,6 @@ set_partial_user (struct dwarf2_per_objfile *dwarf2_per_objfile) static void dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile) { - struct cleanup *back_to; int i; struct objfile *objfile = dwarf2_per_objfile->objfile; @@ -8450,7 +8469,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile) /* Any cached compilation units will be linked by the per-objfile read_in_chain. Make sure to free them when we're done. */ - back_to = make_cleanup (free_cached_comp_units, dwarf2_per_objfile); + free_cached_comp_units freer (dwarf2_per_objfile); build_type_psymtabs (dwarf2_per_objfile); @@ -8491,8 +8510,6 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile) /* At this point we want to keep the address map. */ save_psymtabs_addrmap.release (); - do_cleanups (back_to); - if (dwarf_read_debug) fprintf_unfiltered (gdb_stdlog, "Done building psymtabs of %s\n", objfile_name (objfile)); @@ -25072,17 +25089,6 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, cu->producer = dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu); } -/* Free all cached compilation units. */ - -static void -free_cached_comp_units (void *data) -{ - struct dwarf2_per_objfile *dwarf2_per_objfile - = (struct dwarf2_per_objfile *) data; - - dwarf2_per_objfile->free_cached_comp_units (); -} - /* Increase the age counter on each cached compilation unit, and free any that are too old. */ |