From mboxrd@z Thu Jan 1 00:00:00 1970 From: Elena Zannoni To: Daniel Berlin Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA]: Add misc_obstack to object files. Date: Mon, 25 Jun 2001 13:59:00 -0000 Message-id: <15159.42589.632817.275157@kwikemart.cygnus.com> References: <87lmngjc5w.fsf@dynamic-addr-83-177.resnet.rochester.edu> X-SW-Source: 2001-06/msg00401.html Daniel Berlin writes: > > This way, we stop putting things in the psymbol_obstack that don't > belong. > Dan, can you elaborate a bit on why we need this? Why are you removing the partial symbol table from the psymbol_objstack? Was this intended? There are several other things that get allocated on the psymbol_objstack, for instance look in xcoffread.c, somread.c, etc. Why just remove the section offset stuff? If your intent was to change the allocation of the section offset information, from psymbol_obstack to misc_obstack, why not modify also the same allocations done in xcoffread.c, elfread.c, somread.c? Thanks Elena > 2001-05-27 Daniel Berlin > > * symfile.c (default_symfile_offsets): Allocate in misc_obstack. > (reread_symbols): Handle misc_obstack too, and use it where > psymbol_obstack didn't belong. > (allocate_psymtab): Ditto. > > * objfiles.c (add_to_objfile_sections): Use misc_obstack, not psymbol_obstack. > (build_objfile_section_table): Ditto. > (free_objfile): Free the misc_obstack. > (allocate_objfile): Setup misc_obstack too. > > * objfiles.h: Add misc_obstack to object file. > > Index: symfile.c > =================================================================== > RCS file: /cvs/src/src/gdb/symfile.c,v > retrieving revision 1.32 > diff -c -3 -p -w -B -b -r1.32 symfile.c > *** symfile.c 2001/05/10 15:33:21 1.32 > --- symfile.c 2001/05/29 17:27:51 > *************** default_symfile_offsets (struct objfile > *** 500,506 **** > > objfile->num_sections = SECT_OFF_MAX; > objfile->section_offsets = (struct section_offsets *) > ! obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); > memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS); > > /* Now calculate offsets for section that were specified by the > --- 500,506 ---- > > objfile->num_sections = SECT_OFF_MAX; > objfile->section_offsets = (struct section_offsets *) > ! obstack_alloc (&objfile->misc_obstack, SIZEOF_SECTION_OFFSETS); > memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS); > > /* Now calculate offsets for section that were specified by the > *************** reread_symbols (void) > *** 1679,1684 **** > --- 1679,1685 ---- > > /* Free the obstacks for non-reusable objfiles */ > free_bcache (&objfile->psymbol_cache); > + obstack_free (&objfile->misc_obstack, 0); > obstack_free (&objfile->psymbol_obstack, 0); > obstack_free (&objfile->symbol_obstack, 0); > obstack_free (&objfile->type_obstack, 0); > *************** reread_symbols (void) > *** 1704,1709 **** > --- 1705,1712 ---- > it is empty. */ > obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0, > xmalloc, xfree); > + obstack_specify_allocation (&objfile->misc_obstack, 0, 0, > + xmalloc, xfree); > obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, > xmalloc, xfree); > obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, > *************** reread_symbols (void) > *** 1719,1725 **** > /* We use the same section offsets as from last time. I'm not > sure whether that is always correct for shared libraries. */ > objfile->section_offsets = (struct section_offsets *) > ! obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); > memcpy (objfile->section_offsets, offsets, SIZEOF_SECTION_OFFSETS); > objfile->num_sections = num_offsets; > > --- 1722,1728 ---- > /* We use the same section offsets as from last time. I'm not > sure whether that is always correct for shared libraries. */ > objfile->section_offsets = (struct section_offsets *) > ! obstack_alloc (&objfile->misc_obstack, SIZEOF_SECTION_OFFSETS); > memcpy (objfile->section_offsets, offsets, SIZEOF_SECTION_OFFSETS); > objfile->num_sections = num_offsets; > > *************** allocate_psymtab (char *filename, struct > *** 1981,1993 **** > objfile->free_psymtabs = psymtab->next; > } > else > ! psymtab = (struct partial_symtab *) > ! obstack_alloc (&objfile->psymbol_obstack, > ! sizeof (struct partial_symtab)); > > memset (psymtab, 0, sizeof (struct partial_symtab)); > ! psymtab->filename = obsavestring (filename, strlen (filename), > ! &objfile->psymbol_obstack); > psymtab->symtab = NULL; > > /* Prepend it to the psymtab list for the objfile it belongs to. > --- 1984,1993 ---- > objfile->free_psymtabs = psymtab->next; > } > else > ! psymtab = (struct partial_symtab *) obstack_alloc (&objfile->misc_obstack, sizeof (struct partial_symtab)); > > memset (psymtab, 0, sizeof (struct partial_symtab)); > ! psymtab->filename = obsavestring (filename, strlen(filename), &objfile->misc_obstack); > psymtab->symtab = NULL; > > /* Prepend it to the psymtab list for the objfile it belongs to. > Index: objfiles.c > =================================================================== > RCS file: /cvs/src/src/gdb/objfiles.c,v > retrieving revision 1.15 > diff -c -3 -p -w -B -b -r1.15 objfiles.c > *** objfiles.c 2001/03/06 08:21:11 1.15 > --- objfiles.c 2001/05/29 17:27:57 > *************** add_to_objfile_sections (bfd *abfd, sec_ > *** 96,102 **** > section.ovly_mapped = 0; > section.addr = bfd_section_vma (abfd, asect); > section.endaddr = section.addr + bfd_section_size (abfd, asect); > ! obstack_grow (&objfile->psymbol_obstack, (char *) §ion, sizeof (section)); > objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1); > } > > --- 96,102 ---- > section.ovly_mapped = 0; > section.addr = bfd_section_vma (abfd, asect); > section.endaddr = section.addr + bfd_section_size (abfd, asect); > ! obstack_grow (&objfile->misc_obstack, (char *) §ion, sizeof (section)); > objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1); > } > > *************** build_objfile_section_table (struct objf > *** 121,134 **** > { > /* objfile->sections can be already set when reading a mapped symbol > file. I believe that we do need to rebuild the section table in > ! this case (we rebuild other things derived from the bfd), but we > ! can't free the old one (it's in the psymbol_obstack). So we just > ! waste some memory. */ > > objfile->sections_end = 0; > bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *) objfile); > objfile->sections = (struct obj_section *) > ! obstack_finish (&objfile->psymbol_obstack); > objfile->sections_end = objfile->sections + (unsigned long) objfile->sections_end; > return (0); > } > --- 121,137 ---- > { > /* objfile->sections can be already set when reading a mapped symbol > file. I believe that we do need to rebuild the section table in > ! this case (we rebuild other things derived from the bfd). > ! DJB - 05-27-2001 > ! It's in the misc_obstack now, feel free to do what you need to. > ! All the stuff in objfile that was on the psymbol obstack, but didnt' belong, is in the misc obstack, which > ! I think is all the stuff you want to blow away anyway. > ! */ > > objfile->sections_end = 0; > bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *) objfile); > objfile->sections = (struct obj_section *) > ! obstack_finish (&objfile->misc_obstack); > objfile->sections_end = objfile->sections + (unsigned long) objfile->sections_end; > return (0); > } > *************** allocate_objfile (bfd *abfd, int flags) > *** 188,193 **** > --- 191,198 ---- > /* Update pointers to functions to *our* copies */ > obstack_chunkfun (&objfile->psymbol_cache.cache, xmmalloc); > obstack_freefun (&objfile->psymbol_cache.cache, mfree); > + obstack_chunkfun (&objfile->misc_obstack, xmmalloc); > + obstack_freefun (&objfile->misc_obstack, mfree); > obstack_chunkfun (&objfile->psymbol_obstack, xmmalloc); > obstack_freefun (&objfile->psymbol_obstack, mfree); > obstack_chunkfun (&objfile->symbol_obstack, xmmalloc); > *************** allocate_objfile (bfd *abfd, int flags) > *** 218,223 **** > --- 223,231 ---- > obstack_specify_allocation_with_arg (&objfile->psymbol_cache.cache, > 0, 0, xmmalloc, mfree, > objfile->md); > + obstack_specify_allocation_with_arg (&objfile->misc_obstack, > + 0, 0, xmmalloc, mfree, > + objfile->md); > obstack_specify_allocation_with_arg (&objfile->psymbol_obstack, > 0, 0, xmmalloc, mfree, > objfile->md); > *************** allocate_objfile (bfd *abfd, int flags) > *** 264,269 **** > --- 272,279 ---- > objfile->md = NULL; > obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0, > xmalloc, xfree); > + obstack_specify_allocation (&objfile->misc_obstack, 0, 0, xmalloc, > + xfree); > obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc, > xfree); > obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc, > *************** free_objfile (struct objfile *objfile) > *** 475,480 **** > --- 485,491 ---- > mfree (objfile->md, objfile->static_psymbols.list); > /* Free the obstacks for non-reusable objfiles */ > free_bcache (&objfile->psymbol_cache); > + obstack_free (&objfile->misc_obstack, 0); > obstack_free (&objfile->psymbol_obstack, 0); > obstack_free (&objfile->symbol_obstack, 0); > obstack_free (&objfile->type_obstack, 0); > Index: objfiles.h > =================================================================== > RCS file: /cvs/src/src/gdb/objfiles.h,v > retrieving revision 1.8 > diff -c -3 -p -w -B -b -r1.8 objfiles.h > *** objfiles.h 2001/03/06 08:21:11 1.8 > --- objfiles.h 2001/05/29 17:28:00 > *************** struct objfile > *** 269,274 **** > --- 269,275 ---- > /* Obstacks to hold objects that should be freed when we load a new symbol > table from this object file. */ > > + struct obstack misc_obstack; /* Misc stuff */ > struct obstack psymbol_obstack; /* Partial symbols */ > struct obstack symbol_obstack; /* Full symbols */ > struct obstack type_obstack; /* Types */ > > -- > "I used to be a narrator for bad mimes. > "-Steven Wright >