From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22136 invoked by alias); 13 Jan 2002 05:56:46 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 22100 invoked from network); 13 Jan 2002 05:56:42 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 13 Jan 2002 05:56:42 -0000 Received: from telocity.telocity.com (taarna.sfbay.redhat.com [205.180.230.102]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with SMTP id VAA29863; Sat, 12 Jan 2002 21:56:38 -0800 (PST) Message-ID: <3C412094.7205@redhat.com> Date: Sat, 12 Jan 2002 21:56:00 -0000 From: Michael Snyder X-Mailer: Mozilla 3.04 (Win95; I) MIME-Version: 1.0 To: Elena Zannoni CC: Michael Snyder , gdb-patches@sources.redhat.com, jimb@redhat.com Subject: Re: [RFA] symfile.c -- use bfd access methods References: <200201112353.g0BNrAl09266@reddwarf.cygnus.com> <15423.49431.767568.557157@localhost.cygnus.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-01/txt/msg00336.txt.bz2 Elena Zannoni wrote: > > Michael Snyder writes: > > > > Some more cleanups of symfile.c, using bfd access methods instead of > > accessing private bfd data fields. In several cases (those that > > would require touching more than one source file) I've just added > > a FIXME comment and deferred doing the actual work. > > > > Michael, there are some typos in your patch. I get the following errors: > e -Wcomment -Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized -Werror /home/ezannoni/sources/src/gdb/symfile.c > /home/ezannoni/sources/src/gdb/symfile.c: In function `simple_overlay_update_1':/home/ezannoni/sources/src/gdb/symfile.c:3129: `osection' undeclared (first use in this function) > /home/ezannoni/sources/src/gdb/symfile.c:3129: (Each undeclared identifier is reported only once > /home/ezannoni/sources/src/gdb/symfile.c:3129: for each function it appears in.)/home/ezannoni/sources/src/gdb/symfile.c:3129: `bsect' undeclared (first use in this function) > /home/ezannoni/sources/src/gdb/symfile.c:3129: invalid lvalue in assignment > /home/ezannoni/sources/src/gdb/symfile.c: In function `simple_overlay_update': > /home/ezannoni/sources/src/gdb/symfile.c:3190: `osection' undeclared (first use in this function) > /home/ezannoni/sources/src/gdb/symfile.c:3190: `bsect' undeclared (first use in this function) > /home/ezannoni/sources/src/gdb/symfile.c:3190: invalid lvalue in assignment > > Maybe you wanted asection instead of osection? > > Modulus that, the patch is ok. > > Elena Corrected and committed. > > > 2002-01-11 Michael Snyder > > > > * symfile.c (build_section_addr_info_from_section_tab): > > Use bfd access method instead of manipulating bfd directly. > > (syms_from_objfile): Ditto. > > (simple_overlay_update_1): Ditto. > > (simple_overlay_update): Ditto. > > (generic_load): Ditto. > > (overlay_unmapped_address): FIXME comment, bfd access methods. > > (sections_overlap): FIXME comment, bfd access methods. > > (pc_in_mapped_range): FIXME comment, bfd access methods. > > (pc_in_unmapped_range): FIXME comment, bfd access methods. > > (section_is_mapped): FIXME comment, bfd access methods. > > (section_is_overlay): FIXME comment, bfd access methods. > > > > Index: symfile.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/symfile.c,v > > retrieving revision 1.46 > > diff -c -3 -p -r1.46 symfile.c > > *** symfile.c 2002/01/08 02:09:31 1.46 > > --- symfile.c 2002/01/11 23:54:31 > > *************** build_section_addr_info_from_section_tab > > *** 452,462 **** > > > > for (stp = start, oidx = 0; stp != end; stp++) > > { > > ! if (stp->the_bfd_section->flags & (SEC_ALLOC | SEC_LOAD) > > && oidx < MAX_SECTIONS) > > { > > sap->other[oidx].addr = stp->addr; > > ! sap->other[oidx].name = xstrdup (stp->the_bfd_section->name); > > sap->other[oidx].sectindex = stp->the_bfd_section->index; > > oidx++; > > } > > --- 452,464 ---- > > > > for (stp = start, oidx = 0; stp != end; stp++) > > { > > ! if (bfd_get_section_flags (stp->bfd, > > ! stp->the_bfd_section) & (SEC_ALLOC | SEC_LOAD) > > && oidx < MAX_SECTIONS) > > { > > sap->other[oidx].addr = stp->addr; > > ! sap->other[oidx].name > > ! = xstrdup (bfd_section_name (stp->bfd, stp->the_bfd_section)); > > sap->other[oidx].sectindex = stp->the_bfd_section->index; > > oidx++; > > } > > *************** syms_from_objfile (struct objfile *objfi > > *** 708,714 **** > > for (i = 0; > > !s_addr && i < MAX_SECTIONS && addrs->other[i].name; > > i++) > > ! if (strcmp (s->the_bfd_section->name, addrs->other[i].name) == 0) > > s_addr = addrs->other[i].addr; /* end added for gdb/13815 */ > > > > s->addr -= s->offset; > > --- 710,718 ---- > > for (i = 0; > > !s_addr && i < MAX_SECTIONS && addrs->other[i].name; > > i++) > > ! if (strcmp (bfd_section_name (s->objfile->obfd, > > ! s->the_bfd_section), > > ! addrs->other[i].name) == 0) > > s_addr = addrs->other[i].addr; /* end added for gdb/13815 */ > > > > s->addr -= s->offset; > > *************** generic_load (char *args, int from_tty) > > *** 1222,1228 **** > > } > > > > for (s = loadfile_bfd->sections; s; s = s->next) > > ! if (s->flags & SEC_LOAD) > > total_size += bfd_get_section_size_before_reloc (s); > > > > start_time = time (NULL); > > --- 1226,1232 ---- > > } > > > > for (s = loadfile_bfd->sections; s; s = s->next) > > ! if (bfd_get_section_flags (loadfile_bfd, s) & SEC_LOAD) > > total_size += bfd_get_section_size_before_reloc (s); > > > > start_time = time (NULL); > > *************** void (*target_overlay_update) (struct ob > > *** 2512,2517 **** > > --- 2516,2523 ---- > > int > > section_is_overlay (asection *section) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_lma methods. */ > > + > > if (overlay_debugging) > > if (section && section->lma != 0 && > > section->vma != section->lma) > > *************** section_is_mapped (asection *section) > > *** 2598,2603 **** > > --- 2604,2611 ---- > > CORE_ADDR > > pc_in_unmapped_range (CORE_ADDR pc, asection *section) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_lma methods. */ > > + > > int size; > > > > if (overlay_debugging) > > *************** pc_in_unmapped_range (CORE_ADDR pc, asec > > *** 2616,2621 **** > > --- 2624,2631 ---- > > CORE_ADDR > > pc_in_mapped_range (CORE_ADDR pc, asection *section) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_vma methods. */ > > + > > int size; > > > > if (overlay_debugging) > > *************** pc_in_mapped_range (CORE_ADDR pc, asecti > > *** 2634,2639 **** > > --- 2644,2651 ---- > > int > > sections_overlap (asection *a, asection *b) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_vma methods. */ > > + > > CORE_ADDR a_start = a->vma; > > CORE_ADDR a_end = a->vma + bfd_get_section_size_before_reloc (a); > > CORE_ADDR b_start = b->vma; > > *************** sections_overlap (asection *a, asection > > *** 2649,2654 **** > > --- 2661,2668 ---- > > CORE_ADDR > > overlay_unmapped_address (CORE_ADDR pc, asection *section) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_lma methods. */ > > + > > if (overlay_debugging) > > if (section && section_is_overlay (section) && > > pc_in_mapped_range (pc, section)) > > *************** overlay_unmapped_address (CORE_ADDR pc, > > *** 2664,2669 **** > > --- 2678,2685 ---- > > CORE_ADDR > > overlay_mapped_address (CORE_ADDR pc, asection *section) > > { > > + /* FIXME: need bfd *, so we can use bfd_section_vma methods. */ > > + > > if (overlay_debugging) > > if (section && section_is_overlay (section) && > > pc_in_unmapped_range (pc, section)) > > *************** static int > > *** 3102,3124 **** > > simple_overlay_update_1 (struct obj_section *osect) > > { > > int i, size; > > > > size = bfd_get_section_size_before_reloc (osect->the_bfd_section); > > for (i = 0; i < cache_novlys; i++) > > ! if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma && > > ! cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* && > > ! cache_ovly_table[i][SIZE] == size */ ) > > { > > read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES, > > (int *) cache_ovly_table[i], 4); > > ! if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma && > > ! cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* && > > ! cache_ovly_table[i][SIZE] == size */ ) > > { > > osect->ovly_mapped = cache_ovly_table[i][MAPPED]; > > return 1; > > } > > ! else /* Warning! Warning! Target's ovly table has changed! */ > > return 0; > > } > > return 0; > > --- 3118,3142 ---- > > simple_overlay_update_1 (struct obj_section *osect) > > { > > int i, size; > > + bfd *obfd = osect->objfile->obfd; > > + osection *bsect = osect->the_bfd_section; > > > > size = bfd_get_section_size_before_reloc (osect->the_bfd_section); > > for (i = 0; i < cache_novlys; i++) > > ! if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) > > ! && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) > > ! /* && cache_ovly_table[i][SIZE] == size */ ) > > { > > read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES, > > (int *) cache_ovly_table[i], 4); > > ! if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) > > ! && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) > > ! /* && cache_ovly_table[i][SIZE] == size */ ) > > { > > osect->ovly_mapped = cache_ovly_table[i][MAPPED]; > > return 1; > > } > > ! else /* Warning! Warning! Target's ovly table has changed! */ > > return 0; > > } > > return 0; > > *************** simple_overlay_update (struct obj_sectio > > *** 3161,3173 **** > > if (section_is_overlay (osect->the_bfd_section)) > > { > > int i, size; > > > > size = bfd_get_section_size_before_reloc (osect->the_bfd_section); > > for (i = 0; i < cache_novlys; i++) > > ! if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma && > > ! cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* && > > ! cache_ovly_table[i][SIZE] == size */ ) > > ! { /* obj_section matches i'th entry in ovly_table */ > > osect->ovly_mapped = cache_ovly_table[i][MAPPED]; > > break; /* finished with inner for loop: break out */ > > } > > --- 3179,3193 ---- > > if (section_is_overlay (osect->the_bfd_section)) > > { > > int i, size; > > + bfd *obfd = osect->objfile->obfd; > > + osection *bsect = osect->the_bfd_section; > > > > size = bfd_get_section_size_before_reloc (osect->the_bfd_section); > > for (i = 0; i < cache_novlys; i++) > > ! if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) > > ! && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) > > ! /* && cache_ovly_table[i][SIZE] == size */ ) > > ! { /* obj_section matches i'th entry in ovly_table */ > > osect->ovly_mapped = cache_ovly_table[i][MAPPED]; > > break; /* finished with inner for loop: break out */ > > }