summaryrefslogtreecommitdiff
path: root/gdb/psymtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-01-14 20:51:43 +0000
committerTom Tromey <tromey@redhat.com>2013-01-14 20:51:43 +0000
commit0a07598a6944a2848e1b7d33d0baad774fb9156a (patch)
tree576ff55bf00c19d8c54c508e4956d9b86f45e438 /gdb/psymtab.c
parent5e745c33d04f696ad075cf12c7fd827cea94ddbe (diff)
downloadgdb-0a07598a6944a2848e1b7d33d0baad774fb9156a.tar.gz
PR symtab/14931:
* psymtab.c (struct psymtab_state): New. (discard_psymtabs_upto, make_cleanup_discard_psymtabs): New functions. * psympriv.h (make_cleanup_discard_psymtabs): Declare. * dwarf2read.c (dwarf2_build_psymtabs): Catch exceptions. gdb/testsuite * gdb.dwarf2/dw2-error.exp: New file. * gdb.dwarf2/dw2-error.c: New file. * gdb.dwarf2/dw2-error.S: New file.
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r--gdb/psymtab.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 5181ec3885f..24aef99b1b7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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