* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
(bfd_openw_with_cleanup): Use gdb_bfd_openw. * corelow.c (core_open): Use gdb_bfd_fopen. * dsrec.c (load_srec): Use gdb_bfd_openr. * exec.c (exec_file_attach): Use gdb_bfd_fopen. * gcore.c (gcore_memory_sections): Use gdb_bfd_openw. * gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw) (gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file) (gdb_bfd_fdopenr): New functions. * gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw) (gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file) (gdb_bfd_fdopenr): Declare. * jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec. * m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr. * machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr, gdb_bfd_openr_next_archived_file. (macho_check_dsym): Use gdb_bfd_openr. (macho_add_oso_symfile): Don't call gdb_bfd_stash_filename. * procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr. * remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr. * remote-mips.c (mips_load_srec, pmon_load_fast): Use gdb_bfd_openr. * remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec. * rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr, gdb_bfd_openr_next_archived_file. * solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_openr. * solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_openr. * solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec. * solib.c (solib_bfd_fopen): Use gdb_bfd_fopen. * spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec. * symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr. (symfile_bfd_open): Use gdb_bfd_fopen. (generic_load): Use gdb_bfd_openr. * windows-nat.c (windows_make_so): Use gdb_bfd_openr.
This commit is contained in:
parent
520b0001c1
commit
64c311498e
@ -1,3 +1,42 @@
|
||||
2012-07-23 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
|
||||
(bfd_openw_with_cleanup): Use gdb_bfd_openw.
|
||||
* corelow.c (core_open): Use gdb_bfd_fopen.
|
||||
* dsrec.c (load_srec): Use gdb_bfd_openr.
|
||||
* exec.c (exec_file_attach): Use gdb_bfd_fopen.
|
||||
* gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
|
||||
* gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
|
||||
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
|
||||
(gdb_bfd_fdopenr): New functions.
|
||||
* gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
|
||||
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
|
||||
(gdb_bfd_fdopenr): Declare.
|
||||
* jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
|
||||
* m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
|
||||
* machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
|
||||
gdb_bfd_openr_next_archived_file.
|
||||
(macho_check_dsym): Use gdb_bfd_openr.
|
||||
(macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
|
||||
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
|
||||
* remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
|
||||
* remote-mips.c (mips_load_srec, pmon_load_fast): Use
|
||||
gdb_bfd_openr.
|
||||
* remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
|
||||
* rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
|
||||
gdb_bfd_openr_next_archived_file.
|
||||
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
|
||||
Use gdb_bfd_openr.
|
||||
* solib-pa64.c (pa64_solib_create_inferior_hook): Use
|
||||
gdb_bfd_openr.
|
||||
* solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
|
||||
* solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
|
||||
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
|
||||
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
|
||||
(symfile_bfd_open): Use gdb_bfd_fopen.
|
||||
(generic_load): Use gdb_bfd_openr.
|
||||
* windows-nat.c (windows_make_so): Use gdb_bfd_openr.
|
||||
|
||||
2012-07-23 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* bfd-target.c (target_bfd_reopen): Update.
|
||||
|
@ -112,8 +112,7 @@ bfd_openr_with_cleanup (const char *filename, const char *target)
|
||||
{
|
||||
bfd *ibfd;
|
||||
|
||||
ibfd = bfd_openr (filename, target);
|
||||
gdb_bfd_ref (ibfd);
|
||||
ibfd = gdb_bfd_openr (filename, target);
|
||||
if (ibfd == NULL)
|
||||
error (_("Failed to open %s: %s."), filename,
|
||||
bfd_errmsg (bfd_get_error ()));
|
||||
@ -133,8 +132,7 @@ bfd_openw_with_cleanup (const char *filename, const char *target,
|
||||
|
||||
if (*mode == 'w') /* Write: create new file */
|
||||
{
|
||||
obfd = bfd_openw (filename, target);
|
||||
gdb_bfd_ref (obfd);
|
||||
obfd = gdb_bfd_openw (filename, target);
|
||||
if (obfd == NULL)
|
||||
error (_("Failed to open %s: %s."), filename,
|
||||
bfd_errmsg (bfd_get_error ()));
|
||||
|
@ -318,15 +318,12 @@ core_open (char *filename, int from_tty)
|
||||
if (scratch_chan < 0)
|
||||
perror_with_name (filename);
|
||||
|
||||
temp_bfd = bfd_fopen (filename, gnutarget,
|
||||
write_files ? FOPEN_RUB : FOPEN_RB,
|
||||
scratch_chan);
|
||||
gdb_bfd_ref (temp_bfd);
|
||||
temp_bfd = gdb_bfd_fopen (filename, gnutarget,
|
||||
write_files ? FOPEN_RUB : FOPEN_RB,
|
||||
scratch_chan);
|
||||
if (temp_bfd == NULL)
|
||||
perror_with_name (filename);
|
||||
|
||||
gdb_bfd_stash_filename (temp_bfd);
|
||||
|
||||
if (!bfd_check_format (temp_bfd, bfd_core)
|
||||
&& !gdb_check_format (temp_bfd))
|
||||
{
|
||||
|
@ -61,8 +61,7 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset,
|
||||
|
||||
srec = (char *) alloca (maxrecsize + 1);
|
||||
|
||||
abfd = bfd_openr (file, 0);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (file, 0);
|
||||
if (!abfd)
|
||||
{
|
||||
printf_filtered (_("Unable to open file %s\n"), file);
|
||||
|
@ -233,10 +233,9 @@ exec_file_attach (char *filename, int from_tty)
|
||||
|
||||
if (scratch_chan < 0)
|
||||
perror_with_name (filename);
|
||||
exec_bfd = bfd_fopen (scratch_pathname, gnutarget,
|
||||
write_files ? FOPEN_RUB : FOPEN_RB,
|
||||
scratch_chan);
|
||||
gdb_bfd_ref (exec_bfd);
|
||||
exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget,
|
||||
write_files ? FOPEN_RUB : FOPEN_RB,
|
||||
scratch_chan);
|
||||
|
||||
if (!exec_bfd)
|
||||
{
|
||||
@ -254,8 +253,6 @@ exec_file_attach (char *filename, int from_tty)
|
||||
gdb_bfd_errmsg (bfd_get_error (), matching));
|
||||
}
|
||||
|
||||
gdb_bfd_stash_filename (exec_bfd);
|
||||
|
||||
/* FIXME - This should only be run for RS6000, but the ifdef is a poor
|
||||
way to accomplish. */
|
||||
#ifdef DEPRECATED_IBM6000_TARGET
|
||||
|
@ -51,12 +51,10 @@ static int gcore_memory_sections (bfd *);
|
||||
bfd *
|
||||
create_gcore_bfd (char *filename)
|
||||
{
|
||||
bfd *obfd = bfd_openw (filename, default_gcore_target ());
|
||||
bfd *obfd = gdb_bfd_openw (filename, default_gcore_target ());
|
||||
|
||||
gdb_bfd_ref (obfd);
|
||||
if (!obfd)
|
||||
error (_("Failed to open '%s' for output."), filename);
|
||||
gdb_bfd_stash_filename (obfd);
|
||||
bfd_set_format (obfd, bfd_core);
|
||||
bfd_set_arch_mach (obfd, default_gcore_arch (), default_gcore_mach ());
|
||||
return obfd;
|
||||
|
114
gdb/gdb_bfd.c
114
gdb/gdb_bfd.c
@ -481,3 +481,117 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
|
||||
*size = descriptor->size;
|
||||
return descriptor->data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_fopen (const char *filename, const char *target, const char *mode,
|
||||
int fd)
|
||||
{
|
||||
bfd *result = bfd_fopen (filename, target, mode, fd);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_stash_filename (result);
|
||||
gdb_bfd_ref (result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_openr (const char *filename, const char *target)
|
||||
{
|
||||
bfd *result = bfd_openr (filename, target);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_stash_filename (result);
|
||||
gdb_bfd_ref (result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_openw (const char *filename, const char *target)
|
||||
{
|
||||
bfd *result = bfd_openw (filename, target);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_stash_filename (result);
|
||||
gdb_bfd_ref (result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_openr_iovec (const char *filename, const char *target,
|
||||
void *(*open_func) (struct bfd *nbfd,
|
||||
void *open_closure),
|
||||
void *open_closure,
|
||||
file_ptr (*pread_func) (struct bfd *nbfd,
|
||||
void *stream,
|
||||
void *buf,
|
||||
file_ptr nbytes,
|
||||
file_ptr offset),
|
||||
int (*close_func) (struct bfd *nbfd,
|
||||
void *stream),
|
||||
int (*stat_func) (struct bfd *abfd,
|
||||
void *stream,
|
||||
struct stat *sb))
|
||||
{
|
||||
bfd *result = bfd_openr_iovec (filename, target,
|
||||
open_func, open_closure,
|
||||
pread_func, close_func, stat_func);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_ref (result);
|
||||
gdb_bfd_stash_filename (result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous)
|
||||
{
|
||||
bfd *result = bfd_openr_next_archived_file (archive, previous);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_ref (result);
|
||||
/* No need to stash the filename here. */
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
bfd *
|
||||
gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
|
||||
{
|
||||
bfd *result = bfd_fdopenr (filename, target, fd);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gdb_bfd_ref (result);
|
||||
gdb_bfd_stash_filename (result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -58,4 +58,49 @@ void gdb_bfd_unref (struct bfd *abfd);
|
||||
|
||||
const gdb_byte *gdb_bfd_map_section (asection *section, bfd_size_type *size);
|
||||
|
||||
|
||||
|
||||
/* A wrapper for bfd_fopen that initializes the gdb-specific reference
|
||||
count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_fopen (const char *, const char *, const char *, int);
|
||||
|
||||
/* A wrapper for bfd_openr that initializes the gdb-specific reference
|
||||
count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_openr (const char *, const char *);
|
||||
|
||||
/* A wrapper for bfd_openw that initializes the gdb-specific reference
|
||||
count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_openw (const char *, const char *);
|
||||
|
||||
/* A wrapper for bfd_openr_iovec that initializes the gdb-specific
|
||||
reference count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_openr_iovec (const char *filename, const char *target,
|
||||
void *(*open_func) (struct bfd *nbfd,
|
||||
void *open_closure),
|
||||
void *open_closure,
|
||||
file_ptr (*pread_func) (struct bfd *nbfd,
|
||||
void *stream,
|
||||
void *buf,
|
||||
file_ptr nbytes,
|
||||
file_ptr offset),
|
||||
int (*close_func) (struct bfd *nbfd,
|
||||
void *stream),
|
||||
int (*stat_func) (struct bfd *abfd,
|
||||
void *stream,
|
||||
struct stat *sb));
|
||||
|
||||
/* A wrapper for bfd_openr_next_archived_file that initializes the
|
||||
gdb-specific reference count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous);
|
||||
|
||||
/* A wrapper for bfd_fdopenr that initializes the gdb-specific
|
||||
reference count and calls gdb_bfd_stash_filename. */
|
||||
|
||||
bfd *gdb_bfd_fdopenr (const char *filename, const char *target, int fd);
|
||||
|
||||
#endif /* GDB_BFD_H */
|
||||
|
13
gdb/jit.c
13
gdb/jit.c
@ -137,12 +137,12 @@ bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, char *target)
|
||||
|
||||
buffer->base = addr;
|
||||
buffer->size = size;
|
||||
return bfd_openr_iovec ("<in-memory>", target,
|
||||
mem_bfd_iovec_open,
|
||||
buffer,
|
||||
mem_bfd_iovec_pread,
|
||||
mem_bfd_iovec_close,
|
||||
mem_bfd_iovec_stat);
|
||||
return gdb_bfd_openr_iovec ("<in-memory>", target,
|
||||
mem_bfd_iovec_open,
|
||||
buffer,
|
||||
mem_bfd_iovec_pread,
|
||||
mem_bfd_iovec_close,
|
||||
mem_bfd_iovec_stat);
|
||||
}
|
||||
|
||||
/* One reader that has been loaded successfully, and can potentially be used to
|
||||
@ -861,7 +861,6 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
|
||||
puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
|
||||
return;
|
||||
}
|
||||
gdb_bfd_ref (nbfd);
|
||||
|
||||
/* Check the format. NOTE: This initializes important data that GDB uses!
|
||||
We would segfault later without this line. */
|
||||
|
@ -130,8 +130,7 @@ m32r_load (char *filename, int from_tty)
|
||||
if (filename == NULL || filename[0] == 0)
|
||||
filename = get_exec_file (1);
|
||||
|
||||
abfd = bfd_openr (filename, 0);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (filename, 0);
|
||||
if (!abfd)
|
||||
error (_("Unable to open file %s."), filename);
|
||||
cleanup = make_cleanup_bfd_unref (abfd);
|
||||
@ -530,8 +529,7 @@ m32r_upload_command (char *args, int from_tty)
|
||||
printf_filtered (" -- Ethernet load complete.\n");
|
||||
|
||||
gettimeofday (&end_time, NULL);
|
||||
abfd = bfd_openr (args, 0);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (args, 0);
|
||||
cleanup = make_cleanup_bfd_unref (abfd);
|
||||
if (abfd != NULL)
|
||||
{ /* Download is done -- print section statistics. */
|
||||
|
@ -629,11 +629,6 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
|
||||
|
||||
bfd_hash_table_free (&table);
|
||||
|
||||
/* Make sure that the filename has the correct lifetime. The
|
||||
current filename comes either from an OSO symbol name or from an
|
||||
archive name. Memory for both is not managed by gdb. */
|
||||
gdb_bfd_stash_filename (abfd);
|
||||
|
||||
/* We need to clear SYMFILE_MAINLINE to avoid interractive question
|
||||
from symfile.c:symbol_file_add_with_addrs_or_offsets. */
|
||||
symbol_file_add_from_bfd
|
||||
@ -689,8 +684,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
|
||||
}
|
||||
|
||||
/* Open the archive and check the format. */
|
||||
archive_bfd = bfd_openr (archive_name, gnutarget);
|
||||
gdb_bfd_ref (archive_bfd);
|
||||
archive_bfd = gdb_bfd_openr (archive_name, gnutarget);
|
||||
if (archive_bfd == NULL)
|
||||
{
|
||||
warning (_("Could not open OSO archive file \"%s\""),
|
||||
@ -707,10 +701,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
gdb_bfd_stash_filename (archive_bfd);
|
||||
|
||||
member_bfd = bfd_openr_next_archived_file (archive_bfd, NULL);
|
||||
gdb_bfd_ref (member_bfd);
|
||||
member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd, NULL);
|
||||
|
||||
if (member_bfd == NULL)
|
||||
{
|
||||
@ -746,9 +737,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
|
||||
}
|
||||
|
||||
prev = member_bfd;
|
||||
member_bfd = bfd_openr_next_archived_file (archive_bfd,
|
||||
member_bfd);
|
||||
gdb_bfd_ref (member_bfd);
|
||||
member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd,
|
||||
member_bfd);
|
||||
|
||||
/* Free previous member if not referenced by an oso. */
|
||||
if (ix2 >= last_ix)
|
||||
@ -768,8 +758,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
|
||||
{
|
||||
bfd *abfd;
|
||||
|
||||
abfd = bfd_openr (oso->name, gnutarget);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (oso->name, gnutarget);
|
||||
if (!abfd)
|
||||
warning (_("`%s': can't open to read symbols: %s."), oso->name,
|
||||
bfd_errmsg (bfd_get_error ()));
|
||||
@ -819,14 +808,12 @@ macho_check_dsym (struct objfile *objfile)
|
||||
warning (_("can't find UUID in %s"), objfile->name);
|
||||
return NULL;
|
||||
}
|
||||
dsym_bfd = bfd_openr (dsym_filename, gnutarget);
|
||||
gdb_bfd_ref (dsym_bfd);
|
||||
dsym_bfd = gdb_bfd_openr (dsym_filename, gnutarget);
|
||||
if (dsym_bfd == NULL)
|
||||
{
|
||||
warning (_("can't open dsym file %s"), dsym_filename);
|
||||
return NULL;
|
||||
}
|
||||
gdb_bfd_stash_filename (dsym_filename);
|
||||
|
||||
if (!bfd_check_format (dsym_bfd, bfd_object))
|
||||
{
|
||||
|
@ -3486,8 +3486,7 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored)
|
||||
long storage_needed;
|
||||
CORE_ADDR sym_addr;
|
||||
|
||||
abfd = bfd_fdopenr ("unamed", 0, fd);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_fdopenr ("unamed", 0, fd);
|
||||
if (abfd == NULL)
|
||||
{
|
||||
warning (_("Failed to create a bfd: %s."), bfd_errmsg (bfd_get_error ()));
|
||||
|
@ -1258,8 +1258,7 @@ m32r_load (char *args, int from_tty)
|
||||
if (!filename)
|
||||
filename = get_exec_file (1);
|
||||
|
||||
pbfd = bfd_openr (filename, gnutarget);
|
||||
gdb_bfd_ref (pbfd);
|
||||
pbfd = gdb_bfd_openr (filename, gnutarget);
|
||||
if (pbfd == NULL)
|
||||
{
|
||||
perror_with_name (filename);
|
||||
|
@ -2789,8 +2789,7 @@ mips_load_srec (char *args)
|
||||
|
||||
buffer = alloca (srec_frame * 2 + 256);
|
||||
|
||||
abfd = bfd_openr (args, 0);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (args, 0);
|
||||
if (!abfd)
|
||||
{
|
||||
printf_filtered ("Unable to open file %s\n", args);
|
||||
@ -3377,8 +3376,7 @@ pmon_load_fast (char *file)
|
||||
buffer = (char *) xmalloc (MAXRECSIZE + 1);
|
||||
binbuf = (unsigned char *) xmalloc (BINCHUNK);
|
||||
|
||||
abfd = bfd_openr (file, 0);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (file, 0);
|
||||
if (!abfd)
|
||||
{
|
||||
printf_filtered ("Unable to open file %s\n", file);
|
||||
|
12
gdb/remote.c
12
gdb/remote.c
@ -9824,14 +9824,12 @@ remote_filename_p (const char *filename)
|
||||
bfd *
|
||||
remote_bfd_open (const char *remote_file, const char *target)
|
||||
{
|
||||
bfd *abfd = bfd_openr_iovec (remote_file, target,
|
||||
remote_bfd_iovec_open, NULL,
|
||||
remote_bfd_iovec_pread,
|
||||
remote_bfd_iovec_close,
|
||||
remote_bfd_iovec_stat);
|
||||
bfd *abfd = gdb_bfd_openr_iovec (remote_file, target,
|
||||
remote_bfd_iovec_open, NULL,
|
||||
remote_bfd_iovec_pread,
|
||||
remote_bfd_iovec_close,
|
||||
remote_bfd_iovec_stat);
|
||||
|
||||
if (abfd != NULL)
|
||||
gdb_bfd_stash_filename (abfd);
|
||||
return abfd;
|
||||
}
|
||||
|
||||
|
@ -748,17 +748,15 @@ add_vmap (LdInfo *ldi)
|
||||
if (fd < 0)
|
||||
/* Note that this opens it once for every member; a possible
|
||||
enhancement would be to only open it once for every object. */
|
||||
abfd = bfd_openr (filename, gnutarget);
|
||||
abfd = gdb_bfd_openr (filename, gnutarget);
|
||||
else
|
||||
abfd = bfd_fdopenr (filename, gnutarget, fd);
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_fdopenr (filename, gnutarget, fd);
|
||||
if (!abfd)
|
||||
{
|
||||
warning (_("Could not open `%s' as an executable file: %s"),
|
||||
filename, bfd_errmsg (bfd_get_error ()));
|
||||
return NULL;
|
||||
}
|
||||
gdb_bfd_stash_filename (abfd);
|
||||
|
||||
/* Make sure we have an object file. */
|
||||
|
||||
@ -769,9 +767,8 @@ add_vmap (LdInfo *ldi)
|
||||
{
|
||||
last = 0;
|
||||
/* FIXME??? am I tossing BFDs? bfd? */
|
||||
while ((last = bfd_openr_next_archived_file (abfd, last)))
|
||||
while ((last = gdb_bfd_openr_next_archived_file (abfd, last)))
|
||||
{
|
||||
gdb_bfd_ref (last);
|
||||
if (strcmp (mem, last->filename) == 0)
|
||||
break;
|
||||
}
|
||||
|
@ -371,8 +371,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
|
||||
cleanup = make_cleanup (null_cleanup, NULL);
|
||||
|
||||
/* Create a bfd for the interpreter. */
|
||||
dyld_bfd = bfd_openr (interp_name, gnutarget);
|
||||
gdb_bfd_ref (dyld_bfd);
|
||||
dyld_bfd = gdb_bfd_openr (interp_name, gnutarget);
|
||||
if (dyld_bfd)
|
||||
{
|
||||
bfd *sub;
|
||||
|
@ -362,8 +362,7 @@ manpage for methods to privately map shared library text."));
|
||||
to find any magic formula to find it for Solaris (appears to
|
||||
be trivial on GNU/Linux). Therefore, we have to try an alternate
|
||||
mechanism to find the dynamic linker's base address. */
|
||||
tmp_bfd = bfd_openr (buf, gnutarget);
|
||||
gdb_bfd_ref (tmp_bfd);
|
||||
tmp_bfd = gdb_bfd_openr (buf, gnutarget);
|
||||
if (tmp_bfd == NULL)
|
||||
return;
|
||||
|
||||
|
@ -326,11 +326,10 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
|
||||
CORE_ADDR *open_closure = xmalloc (sizeof (CORE_ADDR));
|
||||
*open_closure = addr;
|
||||
|
||||
nbfd = bfd_openr_iovec (name, "elf32-spu",
|
||||
spu_bfd_iovec_open, open_closure,
|
||||
spu_bfd_iovec_pread, spu_bfd_iovec_close,
|
||||
spu_bfd_iovec_stat);
|
||||
gdb_bfd_ref (nbfd);
|
||||
nbfd = gdb_bfd_openr_iovec (name, "elf32-spu",
|
||||
spu_bfd_iovec_open, open_closure,
|
||||
spu_bfd_iovec_pread, spu_bfd_iovec_close,
|
||||
spu_bfd_iovec_stat);
|
||||
if (!nbfd)
|
||||
return NULL;
|
||||
|
||||
@ -340,7 +339,6 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdb_bfd_stash_filename (nbfd);
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ solib_bfd_fopen (char *pathname, int fd)
|
||||
}
|
||||
else
|
||||
{
|
||||
abfd = bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
|
||||
abfd = gdb_bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
|
||||
|
||||
if (abfd)
|
||||
bfd_set_cacheable (abfd, 1);
|
||||
@ -390,10 +390,8 @@ solib_bfd_fopen (char *pathname, int fd)
|
||||
pathname, bfd_errmsg (bfd_get_error ()));
|
||||
}
|
||||
|
||||
gdb_bfd_stash_filename (abfd);
|
||||
xfree (pathname);
|
||||
|
||||
gdb_bfd_ref (abfd);
|
||||
return abfd;
|
||||
}
|
||||
|
||||
|
@ -315,13 +315,12 @@ spu_bfd_open (ULONGEST addr)
|
||||
ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
|
||||
*open_closure = addr;
|
||||
|
||||
nbfd = bfd_openr_iovec ("<in-memory>", "elf32-spu",
|
||||
spu_bfd_iovec_open, open_closure,
|
||||
spu_bfd_iovec_pread, spu_bfd_iovec_close,
|
||||
spu_bfd_iovec_stat);
|
||||
nbfd = gdb_bfd_openr_iovec ("<in-memory>", "elf32-spu",
|
||||
spu_bfd_iovec_open, open_closure,
|
||||
spu_bfd_iovec_pread, spu_bfd_iovec_close,
|
||||
spu_bfd_iovec_stat);
|
||||
if (!nbfd)
|
||||
return NULL;
|
||||
gdb_bfd_ref (nbfd);
|
||||
|
||||
if (!bfd_check_format (nbfd, bfd_object))
|
||||
{
|
||||
|
@ -1702,13 +1702,8 @@ bfd_open_maybe_remote (const char *name)
|
||||
if (remote_filename_p (name))
|
||||
result = remote_bfd_open (name, gnutarget);
|
||||
else
|
||||
{
|
||||
result = bfd_openr (name, gnutarget);
|
||||
if (result != NULL)
|
||||
gdb_bfd_stash_filename (result);
|
||||
}
|
||||
result = gdb_bfd_openr (name, gnutarget);
|
||||
|
||||
gdb_bfd_ref (result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1728,7 +1723,6 @@ symfile_bfd_open (char *name)
|
||||
if (remote_filename_p (name))
|
||||
{
|
||||
sym_bfd = remote_bfd_open (name, gnutarget);
|
||||
gdb_bfd_ref (sym_bfd);
|
||||
if (!sym_bfd)
|
||||
error (_("`%s': can't open to read symbols: %s."), name,
|
||||
bfd_errmsg (bfd_get_error ()));
|
||||
@ -1768,8 +1762,7 @@ symfile_bfd_open (char *name)
|
||||
name = absolute_name;
|
||||
make_cleanup (xfree, name);
|
||||
|
||||
sym_bfd = bfd_fopen (name, gnutarget, FOPEN_RB, desc);
|
||||
gdb_bfd_ref (sym_bfd);
|
||||
sym_bfd = gdb_bfd_fopen (name, gnutarget, FOPEN_RB, desc);
|
||||
if (!sym_bfd)
|
||||
{
|
||||
make_cleanup (xfree, name);
|
||||
@ -1785,8 +1778,6 @@ symfile_bfd_open (char *name)
|
||||
bfd_errmsg (bfd_get_error ()));
|
||||
}
|
||||
|
||||
gdb_bfd_stash_filename (sym_bfd);
|
||||
|
||||
return sym_bfd;
|
||||
}
|
||||
|
||||
@ -2111,8 +2102,7 @@ generic_load (char *args, int from_tty)
|
||||
}
|
||||
|
||||
/* Open the file for loading. */
|
||||
loadfile_bfd = bfd_openr (filename, gnutarget);
|
||||
gdb_bfd_ref (loadfile_bfd);
|
||||
loadfile_bfd = gdb_bfd_openr (filename, gnutarget);
|
||||
if (loadfile_bfd == NULL)
|
||||
{
|
||||
perror_with_name (filename);
|
||||
|
@ -752,8 +752,7 @@ windows_make_so (const char *name, LPVOID load_addr)
|
||||
asection *text = NULL;
|
||||
CORE_ADDR text_vma;
|
||||
|
||||
abfd = bfd_openr (so->so_name, "pei-i386");
|
||||
gdb_bfd_ref (abfd);
|
||||
abfd = gdb_bfd_openr (so->so_name, "pei-i386");
|
||||
|
||||
if (!abfd)
|
||||
return so;
|
||||
|
Loading…
Reference in New Issue
Block a user