PR symtab/14931:
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index 5181ec3885fe34f1c1c20c911c44cdd339a488ab..24aef99b1b7ebeadbfab1f86a678cba0e81c6ae2 100644 (file)
@@ -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);
+}
+
 \f
 
 static void
This page took 0.023307 seconds and 4 git commands to generate.