From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Modra To: gdb-patches@sources.redhat.com Cc: Andrew Cagney Subject: Re: bfd_read and bfd_write Date: Tue, 18 Sep 2001 03:27:00 -0000 Message-id: <20010918195612.X27386@bubble.sa.bigpond.net.au> References: <20010905145037.K13524@bubble.sa.bigpond.net.au> <3B965696.70401@cygnus.com> <20010905122109.A17937@redhat.com> <3B96C2B2.8050409@cygnus.com> <20010906112244.C24712@bubble.sa.bigpond.net.au> <3B96E752.8030205@cygnus.com> X-SW-Source: 2001-09/msg00221.html On Thu, Sep 06, 2001 at 06:32:13PM +0100, Nick Clifton wrote: > I like the idea of adding the new interface, with new function names, > and a warning message being generated if the old interface is used, as > part of the current CVS sources/forthcoming release. Then in the > release after that, we can remove the old interface. Here is the patch to gdb/ to move over to the new bfd_bread and bfd_bwrite functions, which have just been committed. * coffread.c: Replace all occurrences of bfd_read with bfd_bread. * dbxread.c: Likewise. * dwarf2read.c: Likewise. * dwarfread.c: Likewise. * somread.c: Likewise. * ultra3-nat.c: Likewise. * xcoffread.c: Likewise. OK to apply? -- Alan Modra Index: coffread.c =================================================================== RCS file: /cvs/src/src/gdb/coffread.c,v retrieving revision 1.19 diff -u -p -r1.19 coffread.c --- coffread.c 2001/07/01 10:04:58 1.19 +++ coffread.c 2001/09/18 10:22:49 @@ -1154,18 +1154,18 @@ read_one_sym (register struct coff_symbo int i; cs->c_symnum = symnum; - bfd_read (temp_sym, local_symesz, 1, nlist_bfd_global); + bfd_bread (temp_sym, local_symesz, nlist_bfd_global); bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym); cs->c_naux = sym->n_numaux & 0xff; if (cs->c_naux >= 1) { - bfd_read (temp_aux, local_auxesz, 1, nlist_bfd_global); + bfd_bread (temp_aux, local_auxesz, nlist_bfd_global); bfd_coff_swap_aux_in (symfile_bfd, temp_aux, sym->n_type, sym->n_sclass, 0, cs->c_naux, (char *) aux); /* If more than one aux entry, read past it (only the first aux is important). */ for (i = 1; i < cs->c_naux; i++) - bfd_read (temp_aux, local_auxesz, 1, nlist_bfd_global); + bfd_bread (temp_aux, local_auxesz, nlist_bfd_global); } cs->c_name = getsymname (sym); cs->c_value = sym->n_value; @@ -1232,7 +1232,7 @@ init_stringtab (bfd *abfd, long offset) if (bfd_seek (abfd, offset, 0) < 0) return -1; - val = bfd_read ((char *) lengthbuf, sizeof lengthbuf, 1, abfd); + val = bfd_bread ((char *) lengthbuf, sizeof lengthbuf, abfd); length = bfd_h_get_32 (symfile_bfd, lengthbuf); /* If no string table is needed, then the file may end immediately @@ -1247,7 +1247,8 @@ init_stringtab (bfd *abfd, long offset) if (length == sizeof length) /* Empty table -- just the count */ return 0; - val = bfd_read (stringtab + sizeof lengthbuf, length - sizeof lengthbuf, 1, abfd); + val = bfd_bread (stringtab + sizeof lengthbuf, length - sizeof lengthbuf, + abfd); if (val != length - sizeof lengthbuf || stringtab[length - 1] != '\0') return -1; @@ -1346,7 +1347,7 @@ init_lineno (bfd *abfd, long offset, int /* Allocate the desired table, plus a sentinel */ linetab = (char *) xmalloc (size + local_linesz); - val = bfd_read (linetab, size, 1, abfd); + val = bfd_bread (linetab, size, abfd); if (val != size) return -1; Index: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.23 diff -u -p -r1.23 dbxread.c --- dbxread.c 2001/09/06 20:50:48 1.23 +++ dbxread.c 2001/09/18 10:22:53 @@ -700,7 +700,7 @@ dbx_symfile_init (struct objfile *objfil perror_with_name (name); memset ((PTR) size_temp, 0, sizeof (size_temp)); - val = bfd_read ((PTR) size_temp, sizeof (size_temp), 1, sym_bfd); + val = bfd_bread ((PTR) size_temp, sizeof (size_temp), sym_bfd); if (val < 0) { perror_with_name (name); @@ -739,8 +739,9 @@ dbx_symfile_init (struct objfile *objfil val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, SEEK_SET); if (val < 0) perror_with_name (name); - val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1, - sym_bfd); + val = bfd_bread (DBX_STRINGTAB (objfile), + DBX_STRINGTAB_SIZE (objfile), + sym_bfd); if (val != DBX_STRINGTAB_SIZE (objfile)) perror_with_name (name); } @@ -931,7 +932,7 @@ fill_symbuf (bfd *sym_bfd) count = sizeof (symbuf); } - nbytes = bfd_read ((PTR) symbuf, count, 1, sym_bfd); + nbytes = bfd_bread ((PTR) symbuf, count, sym_bfd); if (nbytes < 0) perror_with_name (bfd_get_filename (sym_bfd)); else if (nbytes == 0) @@ -2501,7 +2502,7 @@ coffstab_build_psymtabs (struct objfile val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET); if (val < 0) perror_with_name (name); - val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, 1, sym_bfd); + val = bfd_bread (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd); if (val != stabstrsize) perror_with_name (name); @@ -2597,7 +2598,7 @@ elfstab_build_psymtabs (struct objfile * val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET); if (val < 0) perror_with_name (name); - val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, 1, sym_bfd); + val = bfd_bread (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd); if (val != stabstrsize) perror_with_name (name); Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.31 diff -u -p -r1.31 dwarf2read.c --- dwarf2read.c 2001/09/05 02:13:11 1.31 +++ dwarf2read.c 2001/09/18 10:22:58 @@ -3030,7 +3030,7 @@ dwarf2_read_section (struct objfile *obj buf = (char *) obstack_alloc (&objfile->psymbol_obstack, size); if ((bfd_seek (abfd, offset, SEEK_SET) != 0) || - (bfd_read (buf, size, 1, abfd) != size)) + (bfd_bread (buf, size, abfd) != size)) { buf = NULL; error ("Dwarf Error: Can't read DWARF data from '%s'", Index: dwarfread.c =================================================================== RCS file: /cvs/src/src/gdb/dwarfread.c,v retrieving revision 1.8 diff -u -p -r1.8 dwarfread.c --- dwarfread.c 2001/09/05 02:13:11 1.8 +++ dwarfread.c 2001/09/18 10:23:01 @@ -695,7 +695,7 @@ dwarf_build_psymtabs (struct objfile *ob dbbase = xmalloc (dbsize); dbroff = 0; if ((bfd_seek (abfd, dbfoff, SEEK_SET) != 0) || - (bfd_read (dbbase, dbsize, 1, abfd) != dbsize)) + (bfd_bread (dbbase, dbsize, abfd) != dbsize)) { xfree (dbbase); error ("can't read DWARF data from '%s'", bfd_get_filename (abfd)); @@ -2269,7 +2269,7 @@ read_ofile_symtab (struct partial_symtab base_section_offsets = pst->section_offsets; baseaddr = ANOFFSET (pst->section_offsets, 0); if (bfd_seek (abfd, foffset, SEEK_SET) || - (bfd_read (dbbase, dbsize, 1, abfd) != dbsize)) + (bfd_bread (dbbase, dbsize, abfd) != dbsize)) { xfree (dbbase); error ("can't read DWARF data"); @@ -2285,8 +2285,8 @@ read_ofile_symtab (struct partial_symtab if (LNFOFF (pst)) { if (bfd_seek (abfd, LNFOFF (pst), SEEK_SET) || - (bfd_read ((PTR) lnsizedata, sizeof (lnsizedata), 1, abfd) != - sizeof (lnsizedata))) + (bfd_bread ((PTR) lnsizedata, sizeof (lnsizedata), abfd) + != sizeof (lnsizedata))) { error ("can't read DWARF line number table size"); } @@ -2294,7 +2294,7 @@ read_ofile_symtab (struct partial_symtab GET_UNSIGNED, pst->objfile); lnbase = xmalloc (lnsize); if (bfd_seek (abfd, LNFOFF (pst), SEEK_SET) || - (bfd_read (lnbase, lnsize, 1, abfd) != lnsize)) + (bfd_bread (lnbase, lnsize, abfd) != lnsize)) { xfree (lnbase); error ("can't read DWARF line numbers"); Index: somread.c =================================================================== RCS file: /cvs/src/src/gdb/somread.c,v retrieving revision 1.10 diff -u -p -r1.10 somread.c --- somread.c 2001/03/06 08:21:17 1.10 +++ somread.c 2001/09/18 10:23:02 @@ -101,13 +101,13 @@ som_symtab_read (bfd *abfd, struct objfi buf = alloca (symsize * number_of_symbols); bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET); - val = bfd_read (buf, symsize * number_of_symbols, 1, abfd); + val = bfd_bread (buf, symsize * number_of_symbols, abfd); if (val != symsize * number_of_symbols) error ("Couldn't read symbol dictionary!"); stringtab = alloca (obj_som_stringtab_size (abfd)); bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET); - val = bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd); + val = bfd_bread (stringtab, obj_som_stringtab_size (abfd), abfd); if (val != obj_som_stringtab_size (abfd)) error ("Can't read in HP string table."); Index: ultra3-nat.c =================================================================== RCS file: /cvs/src/src/gdb/ultra3-nat.c,v retrieving revision 1.8 diff -u -p -r1.8 ultra3-nat.c --- ultra3-nat.c 2001/05/04 04:15:28 1.8 +++ ultra3-nat.c 2001/09/18 10:23:02 @@ -273,7 +273,7 @@ /* OBSOLETE if (!CANNOT_FETCH_REGISTER (regno)) */ /* OBSOLETE { */ /* OBSOLETE val = bfd_seek (core_bfd, (file_ptr) register_addr (regno, 0), SEEK_SET); */ -/* OBSOLETE if (val < 0 || (val = bfd_read (buf, sizeof buf, 1, core_bfd)) < 0) */ +/* OBSOLETE if (val != 0 || (val = bfd_bread (buf, sizeof buf, core_bfd)) != sizeof buf) */ /* OBSOLETE { */ /* OBSOLETE char *buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) + 35); */ /* OBSOLETE strcpy (buffer, "Reading core register "); */ Index: xcoffread.c =================================================================== RCS file: /cvs/src/src/gdb/xcoffread.c,v retrieving revision 1.15 diff -u -p -r1.15 xcoffread.c --- xcoffread.c 2001/09/05 02:13:11 1.15 +++ xcoffread.c 2001/09/18 10:23:04 @@ -817,7 +817,7 @@ enter_line_range (struct subfile *subfil while (curoffset <= limit_offset) { bfd_seek (abfd, curoffset, SEEK_SET); - bfd_read (ext_lnno, linesz, 1, abfd); + bfd_bread (ext_lnno, linesz, abfd); bfd_coff_swap_lineno_in (abfd, ext_lnno, &int_lnno); /* Find the address this line represents. */ @@ -1923,7 +1923,7 @@ init_stringtab (bfd *abfd, file_ptr offs error ("cannot seek to string table in %s: %s", bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ())); - val = bfd_read ((char *) lengthbuf, 1, sizeof lengthbuf, abfd); + val = bfd_bread ((char *) lengthbuf, sizeof lengthbuf, abfd); length = bfd_h_get_32 (abfd, lengthbuf); /* If no string table is needed, then the file may end immediately @@ -1944,8 +1944,7 @@ init_stringtab (bfd *abfd, file_ptr offs if (length == sizeof lengthbuf) return; - val = bfd_read (strtbl + sizeof lengthbuf, 1, length - sizeof lengthbuf, - abfd); + val = bfd_bread (strtbl + sizeof lengthbuf, length - sizeof lengthbuf, abfd); if (val != length - sizeof lengthbuf) error ("cannot read string table from %s: %s", @@ -2677,8 +2676,8 @@ xcoff_initial_scan (struct objfile *objf ((struct coff_symfile_info *) objfile->sym_private)->symtbl_num_syms = num_symbols; - val = bfd_read (((struct coff_symfile_info *) objfile->sym_private)->symtbl, - size, 1, abfd); + val = bfd_bread (((struct coff_symfile_info *) objfile->sym_private)->symtbl, + size, abfd); if (val != size) perror_with_name ("reading symbol table");