diff options
author | Tom Tromey <tom@tromey.com> | 2017-10-20 09:30:48 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-11-04 10:27:15 -0600 |
commit | 33c7c59df060e9952fc2f608c3a6ff0a23ecd40d (patch) | |
tree | eb6725ca4c4c70e816584cd479bc76a34e97031a /gdb/buildsym.c | |
parent | ebe6dbc2645081e3a166865f057e7cc9643e7e12 (diff) | |
download | gdb-33c7c59df060e9952fc2f608c3a6ff0a23ecd40d.zip gdb-33c7c59df060e9952fc2f608c3a6ff0a23ecd40d.tar.gz gdb-33c7c59df060e9952fc2f608c3a6ff0a23ecd40d.tar.bz2 |
Replace really_free_pendings with a scoped_ class
This introduces scoped_free_pendings, and changes users of
really_free_pendings to use it instead, removing some clenaups.
I tried to examine the affected code to ensure there aren't dangling
cleanups in the vicinity.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
Use scoped_free_pendings.
* dbxread.c (dbx_symfile_read, dbx_psymtab_to_symtab_1): Use
scoped_free_pendings.
* xcoffread.c (xcoff_psymtab_to_symtab_1): Use scoped_free_pendings.
(xcoff_initial_scan): Likewise.
* buildsym.c (reset_symtab_globals): Update comment.
(scoped_free_pendings): Rename from really_free_pendings.
(prepare_for_building): Update comment.
(buildsym_init): Likewise.
* buildsym.h (class scoped_free_pendings): New class.
(really_free_pendings): Don't declare.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r-- | gdb/buildsym.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 07bfbd5..d07bfb3 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -26,11 +26,10 @@ The basic way this module is used is as follows: buildsym_init (); - cleanups = make_cleanup (really_free_pendings, NULL); + scoped_free_pendings free_pending; cust = start_symtab (...); ... read debug info ... cust = end_symtab (...); - do_cleanups (cleanups); The compunit symtab pointer ("cust") is returned from both start_symtab and end_symtab to simplify the debug info readers. @@ -42,31 +41,28 @@ Reading DWARF Type Units is another variation: buildsym_init (); - cleanups = make_cleanup (really_free_pendings, NULL); + scoped_free_pendings free_pending; cust = start_symtab (...); ... read debug info ... cust = end_expandable_symtab (...); - do_cleanups (cleanups); And then reading subsequent Type Units within the containing "Comp Unit" will use a second flow: buildsym_init (); - cleanups = make_cleanup (really_free_pendings, NULL); + scoped_free_pendings free_pending; cust = restart_symtab (...); ... read debug info ... cust = augment_type_symtab (...); - do_cleanups (cleanups); dbxread.c and xcoffread.c use another variation: buildsym_init (); - cleanups = make_cleanup (really_free_pendings, NULL); + scoped_free_pendings free_pending; cust = start_symtab (...); ... read debug info ... cust = end_symtab (...); ... start_symtab + read + end_symtab repeated ... - do_cleanups (cleanups); */ #include "defs.h" @@ -269,15 +265,13 @@ find_symbol_in_list (struct pending *list, char *name, int length) return (NULL); } -/* At end of reading syms, or in case of quit, ensure everything associated - with building symtabs is freed. This is intended to be registered as a - cleanup before doing psymtab->symtab expansion. +/* At end of reading syms, or in case of quit, ensure everything + associated with building symtabs is freed. N.B. This is *not* intended to be used when building psymtabs. Some debug info readers call this anyway, which is harmless if confusing. */ -void -really_free_pendings (void *dummy) +scoped_free_pendings::~scoped_free_pendings () { struct pending *next, *next1; @@ -1028,7 +1022,7 @@ prepare_for_building (const char *name, CORE_ADDR start_addr) context_stack_depth = 0; /* These should have been reset either by successful completion of building - a symtab, or by the really_free_pendings cleanup. */ + a symtab, or by the scoped_free_pendings destructor. */ gdb_assert (file_symbols == NULL); gdb_assert (global_symbols == NULL); gdb_assert (global_using_directives == NULL); @@ -1169,7 +1163,7 @@ watch_main_source_file_lossage (void) /* Reset state after a successful building of a symtab. This exists because dbxread.c and xcoffread.c can call start_symtab+end_symtab multiple times after one call to buildsym_init, - and before the really_free_pendings cleanup is called. + and before the scoped_free_pendings destructor is called. We keep the free_pendings list around for dbx/xcoff sake. */ static void @@ -1753,7 +1747,7 @@ buildsym_init (void) context_stack = XNEWVEC (struct context_stack, context_stack_size); } - /* Ensure the really_free_pendings cleanup was called after + /* Ensure the scoped_free_pendings destructor was called after the last time. */ gdb_assert (free_pendings == NULL); gdb_assert (pending_blocks == NULL); |