From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12346 invoked by alias); 11 Jan 2002 23:58:35 -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 12307 invoked from network); 11 Jan 2002 23:58:32 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 11 Jan 2002 23:58:32 -0000 Received: from reddwarf.cygnus.com (reddwarf.sfbay.redhat.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id PAA22377; Fri, 11 Jan 2002 15:58:25 -0800 (PST) Received: (from msnyder@localhost) by reddwarf.cygnus.com (8.11.2/8.11.2) id g0BNrAl09266; Fri, 11 Jan 2002 15:53:10 -0800 Date: Fri, 11 Jan 2002 15:58:00 -0000 From: Michael Snyder Message-Id: <200201112353.g0BNrAl09266@reddwarf.cygnus.com> To: gdb-patches@sources.redhat.com Subject: [RFA] symfile.c -- use bfd access methods Cc: ezannoni@redhat.com, jimb@redhat.com X-SW-Source: 2002-01/txt/msg00313.txt.bz2 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. 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 */ }