X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fpsymtab.c;h=24aef99b1b7ebeadbfab1f86a678cba0e81c6ae2;hb=c9bf062262da5a158d7a74907f8db2cd6df6bdfd;hp=c6adb971e827dd77d05dded965de1b0093360d08;hpb=da5132d379d3e1bbda3411de63b1a40c16614809;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/psymtab.c b/gdb/psymtab.c index c6adb971e8..24aef99b1b 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1702,7 +1702,7 @@ init_psymbol_list (struct objfile *objfile, int total_symbols) /* Current best guess is that approximately a twentieth of the total symbols (in a debugging file) are global or static - oriented symbols. */ + oriented symbols, then multiply that by slop factor of two. */ objfile->global_psymbols.size = total_symbols / 10; objfile->static_psymbols.size = total_symbols / 10; @@ -1798,6 +1798,44 @@ discard_psymtab (struct objfile *objfile, struct partial_symtab *pst) objfile->free_psymtabs = pst; } +/* An object of this type is passed to discard_psymtabs_upto. */ + +struct psymtab_state +{ + /* The objfile where psymtabs are discarded. */ + + struct objfile *objfile; + + /* The first psymtab to save. */ + + struct partial_symtab *save; +}; + +/* A cleanup function used by make_cleanup_discard_psymtabs. */ + +static void +discard_psymtabs_upto (void *arg) +{ + struct psymtab_state *state = arg; + + while (state->objfile->psymtabs != state->save) + discard_psymtab (state->objfile, state->objfile->psymtabs); +} + +/* Return a new cleanup that discards all psymtabs created in OBJFILE + after this function is called. */ + +struct cleanup * +make_cleanup_discard_psymtabs (struct objfile *objfile) +{ + struct psymtab_state *state = XNEW (struct psymtab_state); + + state->objfile = objfile; + state->save = objfile->psymtabs; + + return make_cleanup_dtor (discard_psymtabs_upto, state, xfree); +} + static void