Index: dwarf2cfi.h =================================================================== RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v retrieving revision 1.16 diff -u -p -r1.16 dwarf2cfi.h --- dwarf2cfi.h 19 Jul 2002 09:40:51 -0000 1.16 +++ dwarf2cfi.h 20 Dec 2002 15:14:21 -0000 @@ -64,6 +64,12 @@ struct cie_unit /* Next in chain. */ struct cie_unit *next; + + /* Keep or destroy this CIE on a new run? */ + int keep; + + /* How many FDEs refer to this CIE? */ + int refs; }; /* Frame Description Entry. */ Index: dwarf2cfi.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v retrieving revision 1.16 diff -u -p -r1.16 dwarf2cfi.c --- dwarf2cfi.c 19 Jul 2002 09:40:51 -0000 1.16 +++ dwarf2cfi.c 20 Dec 2002 15:14:21 -0000 @@ -317,6 +326,86 @@ frame_state_alloc (void) (struct frame_state_reg *) obstack_alloc (&unwind_tmp_obstack, regs_size); memset (fs->regs.reg, 0, regs_size); return fs; +} + +void +cleanup_cfi (void *name) +{ + struct objfile *ofp; + struct cie_unit *cie, *cie_prev; + int fde_index=0, fde_free=0; + + cie = cie_chunks; + while (cie) + { + cie->refs = 0; + cie->keep = 0; + cie = cie->next; + } + + /* Mark all unwanted CIEs. */ + ALL_OBJFILES (ofp) + { + if (!(ofp->flags & OBJF_USERLOADED) && (ofp->flags & OBJF_SHARED)) + printf ("\tRemoving %s...\n", ofp->name); + else + { + printf ("\tKeeping %s...\n", ofp->name); + cie = cie_chunks; + while(cie) + { + if (cie->objfile == ofp) + cie->keep = 1; + cie = cie->next; + } + } + } + + /* Remove all FDEs pointing to unwanted CIEs. */ + for (fde_index = 0, fde_free=0; + fde_index < fde_chunks.elems; + fde_index++, fde_free++) + { + if (!fde_chunks.array[fde_index]->cie_ptr->keep) + { + fde_free--; + continue; + } + else if (fde_free < fde_index) + fde_chunks.array[fde_free] = fde_chunks.array[fde_index]; + fde_chunks.array[fde_free]->cie_ptr->refs++; + } + fde_chunks.elems = fde_free; + + /* Remove all unwanted CIEs. */ + cie = cie_chunks; + cie_prev = NULL; + while (cie) + { + struct cie_unit *cie_tmp; + + if (! cie->keep || !cie->refs) + { + cie_tmp = cie; + if (cie_prev == NULL) + { + cie_chunks = cie->next; + cie = cie_chunks; + } + else + { + cie_prev->next = cie->next; + cie = cie->next; + } + /* cie_prev must remain unchanged. */ + xfree (cie_tmp); + } + else + { + cie_prev = cie; + cie = cie->next; + } + } } static void